diff options
author | David Woodhouse <dwmw2@infradead.org> | 2018-04-18 09:02:50 +0100 |
---|---|---|
committer | David Woodhouse <dwmw2@infradead.org> | 2018-04-18 09:02:50 +0100 |
commit | 611a906efaaaba3aef2f984c0327eebff1636e3e (patch) | |
tree | 0b1b3fc1ae1aced09adc74f83a51f700b08134dc | |
parent | 58b6da5cfc28d292c369ea9f29f056050ed35224 (diff) | |
download | pidgin-611a906efaaaba3aef2f984c0327eebff1636e3e.tar.gz |
media: allow per-stream src/sink elements to be set
Instead of only using the default registered elements for a given media
stream type, allow a different PurpleMediaElementInfo to be passed in by
attaching it to the PurpleMedia before calling purple_media_add_stream().
This means that PURPLE_MEDIA_SEND_VIDEO streams which are actually a
screen share, for example, can use ximagesrc instead of the camera.
For screen share, we'll actually want the UI to have a method for
choosing which monitor/window to share, and providing the appropriate
PurpleMediaElementInfo according to the user's choice (and the platform).
For now I'm doing it in my PRPL.
-rw-r--r-- | libpurple/media/enum-types.h | 6 | ||||
-rw-r--r-- | libpurple/mediamanager.c | 31 |
2 files changed, 24 insertions, 13 deletions
diff --git a/libpurple/media/enum-types.h b/libpurple/media/enum-types.h index f61d66cb00..9f35222421 100644 --- a/libpurple/media/enum-types.h +++ b/libpurple/media/enum-types.h @@ -99,7 +99,11 @@ typedef enum { PURPLE_MEDIA_AUDIO = PURPLE_MEDIA_RECV_AUDIO | PURPLE_MEDIA_SEND_AUDIO, PURPLE_MEDIA_VIDEO = PURPLE_MEDIA_RECV_VIDEO | PURPLE_MEDIA_SEND_VIDEO, PURPLE_MEDIA_APPLICATION = PURPLE_MEDIA_RECV_APPLICATION | - PURPLE_MEDIA_SEND_APPLICATION + PURPLE_MEDIA_SEND_APPLICATION, + PURPLE_MEDIA_SEND = PURPLE_MEDIA_SEND_AUDIO | PURPLE_MEDIA_SEND_VIDEO | + PURPLE_MEDIA_SEND_APPLICATION, + PURPLE_MEDIA_RECV = PURPLE_MEDIA_RECV_AUDIO | PURPLE_MEDIA_RECV_VIDEO | + PURPLE_MEDIA_RECV_APPLICATION } PurpleMediaSessionType; /** Media state-changed types */ diff --git a/libpurple/mediamanager.c b/libpurple/mediamanager.c index 49bb9dc5e2..605b7dc1b9 100644 --- a/libpurple/mediamanager.c +++ b/libpurple/mediamanager.c @@ -1191,18 +1191,25 @@ purple_media_manager_get_element(PurpleMediaManager *manager, PurpleMediaElementInfo *info = NULL; PurpleMediaElementType element_type; - if (type & PURPLE_MEDIA_SEND_AUDIO) - info = manager->priv->audio_src; - else if (type & PURPLE_MEDIA_RECV_AUDIO) - info = manager->priv->audio_sink; - else if (type & PURPLE_MEDIA_SEND_VIDEO) - info = manager->priv->video_src; - else if (type & PURPLE_MEDIA_RECV_VIDEO) - info = manager->priv->video_sink; - else if (type & PURPLE_MEDIA_SEND_APPLICATION) - info = get_send_application_element_info (); - else if (type & PURPLE_MEDIA_RECV_APPLICATION) - info = get_recv_application_element_info (); + if (type & PURPLE_MEDIA_SEND) + info = g_object_get_data(G_OBJECT(media), "src-element"); + else + info = g_object_get_data(G_OBJECT(media), "sink-element"); + + if (info == NULL) { + if (type & PURPLE_MEDIA_SEND_AUDIO) + info = manager->priv->audio_src; + else if (type & PURPLE_MEDIA_RECV_AUDIO) + info = manager->priv->audio_sink; + else if (type & PURPLE_MEDIA_SEND_VIDEO) + info = manager->priv->video_src; + else if (type & PURPLE_MEDIA_RECV_VIDEO) + info = manager->priv->video_sink; + else if (type & PURPLE_MEDIA_SEND_APPLICATION) + info = get_send_application_element_info (); + else if (type & PURPLE_MEDIA_RECV_APPLICATION) + info = get_recv_application_element_info (); + } if (info == NULL) return NULL; |