[telepathy-gabble/master] Extract InitialAudio/Video from initial streams
Will Thompson
will.thompson at collabora.co.uk
Wed Apr 15 07:29:57 PDT 2009
---
src/media-channel.c | 38 ++++++++++++++++++++++++---
src/media-factory.c | 1 -
tests/twisted/jingle/initial-audio-video.py | 37 ++++++++++++++++++++++++--
3 files changed, 68 insertions(+), 8 deletions(-)
diff --git a/src/media-channel.c b/src/media-channel.c
index c2b5f9f..5c6a120 100644
--- a/src/media-channel.c
+++ b/src/media-channel.c
@@ -182,17 +182,45 @@ static gboolean contact_is_media_capable (GabbleMediaChannel *chan, TpHandle pee
static void stream_creation_data_cancel (gpointer p, gpointer unused);
static void
-_create_streams (GabbleMediaChannel *chan)
+create_initial_streams (GabbleMediaChannel *chan)
{
GabbleMediaChannelPrivate *priv = chan->priv;
GList *contents, *li;
contents = gabble_jingle_session_get_contents (priv->session);
+
for (li = contents; li; li = li->next)
{
- create_stream_from_content (chan, GABBLE_JINGLE_CONTENT (li->data));
+ GabbleJingleContent *c = li->data;
+
+ /* I'm so sorry. */
+ if (G_OBJECT_TYPE (c) == GABBLE_TYPE_JINGLE_MEDIA_RTP)
+ {
+ guint media_type;
+
+ g_object_get (c, "media-type", &media_type, NULL);
+
+ switch (media_type)
+ {
+ case JINGLE_MEDIA_TYPE_AUDIO:
+ priv->initial_audio = TRUE;
+ break;
+ case JINGLE_MEDIA_TYPE_VIDEO:
+ priv->initial_video = TRUE;
+ break;
+ default:
+ /* smell? */
+ DEBUG ("unknown rtp media type %u", media_type);
+ }
+ }
+
+ create_stream_from_content (chan, c);
}
+ DEBUG ("initial_audio: %s, initial_video: %s",
+ priv->initial_audio ? "true" : "false",
+ priv->initial_video ? "true" : "false");
+
g_list_free (contents);
}
@@ -319,9 +347,11 @@ gabble_media_channel_constructor (GType type, guint n_props,
priv->session->peer, TP_CHANNEL_GROUP_CHANGE_REASON_INVITED);
tp_intset_destroy (set);
- /* Set up signal callbacks, emit session handler, initialize streams */
+ /* Set up signal callbacks, emit session handler, initialize streams,
+ * figure out InitialAudio and InitialVideo
+ */
_latch_to_session (GABBLE_MEDIA_CHANNEL (obj));
- _create_streams (GABBLE_MEDIA_CHANNEL (obj));
+ create_initial_streams (GABBLE_MEDIA_CHANNEL (obj));
}
else
{
diff --git a/src/media-factory.c b/src/media-factory.c
index ed3c70a..85485eb 100644
--- a/src/media-factory.c
+++ b/src/media-factory.c
@@ -330,7 +330,6 @@ new_jingle_session_cb (GabbleJingleFactory *jf, GabbleJingleSession *sess, gpoin
if (gabble_jingle_session_get_content_type (sess) ==
GABBLE_TYPE_JINGLE_MEDIA_RTP)
{
- /* FIXME: set initial_audio and initial_video */
GabbleMediaChannel *chan = new_media_channel (self, sess, sess->peer,
FALSE, FALSE, FALSE);
tp_channel_manager_emit_new_channel (self,
diff --git a/tests/twisted/jingle/initial-audio-video.py b/tests/twisted/jingle/initial-audio-video.py
index 537c090..31e8b36 100644
--- a/tests/twisted/jingle/initial-audio-video.py
+++ b/tests/twisted/jingle/initial-audio-video.py
@@ -1,5 +1,7 @@
"""
-Tests outgoing calls created with InitialAudio and/or InitialVideo.
+Tests outgoing calls created with InitialAudio and/or InitialVideo, and
+exposing the initial contents of incoming calls as values of InitialAudio and
+InitialVideo
"""
from servicetest import (
@@ -11,7 +13,7 @@ from jingletest2 import JingleTest2, test_all_dialects
import constants as cs
-def test(jp, q, bus, conn, stream):
+def outgoing(jp, q, bus, conn, stream):
remote_jid = 'flames at cold.mountain/beyond'
jt = JingleTest2(jp, conn, q, stream, 'test at localhost', remote_jid)
jt.prepare()
@@ -128,5 +130,34 @@ def check_iav(jt, q, conn, bus, stream, remote_handle, initial_audio,
chan.Close()
+def incoming(jp, q, bus, conn, stream):
+ remote_jid = 'skinny.fists at heaven/antennas'
+ jt = JingleTest2(jp, conn, q, stream, 'test at localhost', remote_jid)
+ jt.prepare()
+
+ self_handle = conn.GetSelfHandle()
+ remote_handle = conn.RequestHandles(cs.HT_CONTACT, [remote_jid])[0]
+
+ for a, v in [(True, False), (False, True), (True, True)]:
+ if v and jp.is_gtalk():
+ continue
+
+ jt.incoming_call(audio=a, video=v)
+ e = q.expect('dbus-signal', signal='NewChannels')
+ chans = e.args[0]
+ assertLength(1, chans)
+
+ path, props = chans[0]
+
+ assertEquals(cs.CHANNEL_TYPE_STREAMED_MEDIA, props[cs.CHANNEL_TYPE])
+ assertEquals(a, props[cs.INITIAL_AUDIO])
+ assertEquals(v, props[cs.INITIAL_VIDEO])
+
+ chan = wrap_channel(bus.get_object(conn.bus_name, path),
+ cs.CHANNEL_TYPE_STREAMED_MEDIA)
+ chan.Close()
+
+
if __name__ == '__main__':
- test_all_dialects(test)
+ test_all_dialects(outgoing)
+ test_all_dialects(incoming)
--
1.5.6.5
More information about the telepathy-commits
mailing list