soc.2008.vv: 2f754c3c: Added some utility functions to convert ...
maiku at soc.pidgin.im
maiku at soc.pidgin.im
Fri Jun 6 15:10:45 EDT 2008
-----------------------------------------------------------------
Revision: 2f754c3c40f236bff732f267635518c25bd82726
Ancestor: 918fc8001ddbd9310a439b02fce437ba82d058ac
Author: maiku at soc.pidgin.im
Date: 2008-06-06T19:08:04
Branch: im.pidgin.soc.2008.vv
URL: http://d.pidgin.im/viewmtn/revision/info/2f754c3c40f236bff732f267635518c25bd82726
Modified files:
libpurple/media.c libpurple/media.h
libpurple/protocols/jabber/jingle.c pidgin/gtkmedia.c
ChangeLog:
Added some utility functions to convert PurpleMediaStreamType
to and from FsMediaType and FsStreamDirection.
-------------- next part --------------
============================================================
--- libpurple/media.c 71590385ed72de68140055bf22cb003071dc009d
+++ libpurple/media.c db407d6341e58704292fbfc319db7269d0c7e652
@@ -46,7 +46,7 @@ struct _PurpleMediaSession
GstElement *sink;
FsSession *session;
GHashTable *streams; /* FsStream list map to participant's name */
- FsMediaType type;
+ PurpleMediaStreamType type;
GHashTable *local_candidates; /* map to participant's name? */
FsCandidate *local_candidate;
FsCandidate *remote_candidate;
@@ -276,6 +276,51 @@ purple_media_get_property (GObject *obje
}
+FsMediaType
+purple_media_to_fs_media_type(PurpleMediaStreamType type)
+{
+ if (type & PURPLE_MEDIA_AUDIO)
+ return FS_MEDIA_TYPE_AUDIO;
+ else if (type & PURPLE_MEDIA_VIDEO)
+ return FS_MEDIA_TYPE_VIDEO;
+ else
+ return FS_MEDIA_TYPE_APPLICATION;
+}
+
+FsStreamDirection
+purple_media_to_fs_stream_direction(PurpleMediaStreamType type)
+{
+ if ((type & PURPLE_MEDIA_AUDIO) == PURPLE_MEDIA_AUDIO ||
+ (type & PURPLE_MEDIA_VIDEO) == PURPLE_MEDIA_VIDEO)
+ return FS_DIRECTION_BOTH;
+ else if ((type & PURPLE_MEDIA_SEND_AUDIO) ||
+ (type & PURPLE_MEDIA_SEND_VIDEO))
+ return FS_DIRECTION_SEND;
+ else if ((type & PURPLE_MEDIA_RECV_AUDIO) ||
+ (type & PURPLE_MEDIA_RECV_VIDEO))
+ return FS_DIRECTION_RECV;
+ else
+ return FS_DIRECTION_NONE;
+}
+
+PurpleMediaStreamType
+purple_media_from_fs(FsMediaType type, FsStreamDirection direction)
+{
+ PurpleMediaStreamType result = PURPLE_MEDIA_NONE;
+ if (type == FS_MEDIA_TYPE_AUDIO) {
+ if (direction & FS_DIRECTION_SEND)
+ result |= PURPLE_MEDIA_SEND_AUDIO;
+ if (direction & FS_DIRECTION_RECV)
+ result |= PURPLE_MEDIA_RECV_AUDIO;
+ } else if (type == FS_MEDIA_TYPE_VIDEO) {
+ if (direction & FS_DIRECTION_SEND)
+ result |= PURPLE_MEDIA_SEND_VIDEO;
+ if (direction & FS_DIRECTION_RECV)
+ result |= PURPLE_MEDIA_RECV_VIDEO;
+ }
+ return result;
+}
+
static PurpleMediaSession*
purple_media_get_session(PurpleMedia *media, const gchar *sess_id)
{
@@ -824,7 +869,7 @@ purple_media_add_stream_internal(PurpleM
session->id = g_strdup(sess_id);
session->media = media;
- session->type = type;
+ session->type = purple_media_from_fs(type, type_direction);
purple_media_add_session(media, session);
}
@@ -867,14 +912,7 @@ purple_media_add_stream(PurpleMedia *med
FsStreamDirection type_direction;
if (type & PURPLE_MEDIA_AUDIO) {
- if (type & PURPLE_MEDIA_SEND_AUDIO && type & PURPLE_MEDIA_RECV_AUDIO)
- type_direction = FS_DIRECTION_BOTH;
- else if (type & PURPLE_MEDIA_SEND_AUDIO)
- type_direction = FS_DIRECTION_SEND;
- else if (type & PURPLE_MEDIA_RECV_AUDIO)
- type_direction = FS_DIRECTION_RECV;
- else
- type_direction = FS_DIRECTION_NONE;
+ type_direction = purple_media_to_fs_stream_direction(type & PURPLE_MEDIA_AUDIO);
if (!purple_media_add_stream_internal(media, sess_id, who,
FS_MEDIA_TYPE_AUDIO, type_direction,
@@ -883,14 +921,7 @@ purple_media_add_stream(PurpleMedia *med
}
}
if (type & PURPLE_MEDIA_VIDEO) {
- if (type & PURPLE_MEDIA_SEND_VIDEO && type & PURPLE_MEDIA_RECV_VIDEO)
- type_direction = FS_DIRECTION_BOTH;
- else if (type & PURPLE_MEDIA_SEND_VIDEO)
- type_direction = FS_DIRECTION_SEND;
- else if (type & PURPLE_MEDIA_RECV_VIDEO)
- type_direction = FS_DIRECTION_RECV;
- else
- type_direction = FS_DIRECTION_NONE;
+ type_direction = purple_media_to_fs_stream_direction(type & PURPLE_MEDIA_VIDEO);
if (!purple_media_add_stream_internal(media, sess_id, who,
FS_MEDIA_TYPE_VIDEO, type_direction,
============================================================
--- libpurple/media.h 147731438eade59e0c49313feb546be10ffc9b0e
+++ libpurple/media.h ae45e1b93d1ecdfedf36bf9cfa106f5ff1c788c5
@@ -51,6 +51,7 @@ typedef enum {
typedef struct _PurpleMediaSession PurpleMediaSession;
typedef enum {
+ PURPLE_MEDIA_NONE = 0,
PURPLE_MEDIA_RECV_AUDIO = 1 << 0,
PURPLE_MEDIA_SEND_AUDIO = 1 << 1,
PURPLE_MEDIA_RECV_VIDEO = 1 << 2,
@@ -72,6 +73,10 @@ GType purple_media_get_type(void);
GType purple_media_get_type(void);
+FsMediaType purple_media_to_fs_media_type(PurpleMediaStreamType type);
+FsStreamDirection purple_media_to_fs_stream_direction(PurpleMediaStreamType type);
+PurpleMediaStreamType purple_media_from_fs(FsMediaType type, FsStreamDirection direction);
+
GList *purple_media_get_session_names(PurpleMedia *media);
void purple_media_get_elements(PurpleMedia *media, GstElement **audio_src, GstElement **audio_sink,
============================================================
--- libpurple/protocols/jabber/jingle.c a04c20218596e0f5824b88c6efce7b6e98348922
+++ libpurple/protocols/jabber/jingle.c 36390d9a7e95417560bb394e7ac7de5d6f199188
@@ -1340,3 +1340,4 @@ jabber_jingle_session_handle_transport_i
}
#endif /* USE_VV */
+
============================================================
--- pidgin/gtkmedia.c 169a4b38a8e634eb113d3b4a0ba2b210a23e59c8
+++ pidgin/gtkmedia.c 6a7d9cdc48a71155bae1d82c6e484470ccb885c7
@@ -272,10 +272,10 @@ pidgin_media_ready_cb(PurpleMedia *media
purple_media_video_init_recv(&videorecvbin);
for (; sessions; sessions = sessions->next) {
- if (purple_media_get_session_type(media, sessions->data) == FS_MEDIA_TYPE_AUDIO) {
+ if (purple_media_get_session_type(media, sessions->data) & PURPLE_MEDIA_AUDIO) {
purple_media_set_src(media, sessions->data, audiosendbin);
purple_media_set_sink(media, sessions->data, audiorecvbin);
- } else if (purple_media_get_session_type(media, sessions->data) == FS_MEDIA_TYPE_VIDEO) {
+ } else if (purple_media_get_session_type(media, sessions->data) & PURPLE_MEDIA_VIDEO) {
purple_media_set_src(media, sessions->data, videosendbin);
purple_media_set_sink(media, sessions->data, videorecvbin);
}
More information about the Commits
mailing list