[telepathy-gabble/master] Implement and announce InitialAudio/Video props

Will Thompson will.thompson at collabora.co.uk
Thu Apr 9 09:20:26 PDT 2009


---
 src/media-channel-internal.h                |    3 ++
 src/media-channel.c                         |   44 +++++++++++++++++++++++++++
 tests/twisted/jingle/initial-audio-video.py |   31 ++++++++++++++++++-
 3 files changed, 77 insertions(+), 1 deletions(-)

diff --git a/src/media-channel-internal.h b/src/media-channel-internal.h
index d78f7a5..c517706 100644
--- a/src/media-channel-internal.h
+++ b/src/media-channel-internal.h
@@ -62,6 +62,9 @@ struct _GabbleMediaChannelPrivate
 
   GPtrArray *delayed_request_streams;
 
+  gboolean initial_audio;
+  gboolean initial_video;
+
   /* These are really booleans, but gboolean is signed. Thanks, GLib */
   unsigned ready:1;
   unsigned closed:1;
diff --git a/src/media-channel.c b/src/media-channel.c
index 1d966e1..416f3bd 100644
--- a/src/media-channel.c
+++ b/src/media-channel.c
@@ -36,6 +36,8 @@
 
 #define DEBUG_FLAG GABBLE_DEBUG_MEDIA
 
+#include "extensions/extensions.h"
+
 #include "connection.h"
 #include "debug.h"
 #include "jingle-content.h"
@@ -69,6 +71,8 @@ G_DEFINE_TYPE_WITH_CODE (GabbleMediaChannel, gabble_media_channel,
       media_signalling_iface_init);
     G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_TYPE_STREAMED_MEDIA,
       streamed_media_iface_init);
+    G_IMPLEMENT_INTERFACE (GABBLE_TYPE_SVC_CHANNEL_TYPE_STREAMED_MEDIA_FUTURE,
+      NULL);
     G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_PROPERTIES_INTERFACE,
       tp_properties_mixin_iface_init);
     G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_DBUS_PROPERTIES,
@@ -106,6 +110,8 @@ enum
   PROP_INTERFACES,
   PROP_CHANNEL_DESTROYED,
   PROP_CHANNEL_PROPERTIES,
+  PROP_INITIAL_AUDIO,
+  PROP_INITIAL_VIDEO,
   /* TP properties (see also below) */
   PROP_NAT_TRAVERSAL,
   PROP_STUN_SERVER,
@@ -454,11 +460,19 @@ gabble_media_channel_get_property (GObject    *object,
               TP_IFACE_CHANNEL, "InitiatorID",
               TP_IFACE_CHANNEL, "Requested",
               TP_IFACE_CHANNEL, "Interfaces",
+              GABBLE_IFACE_CHANNEL_TYPE_STREAMED_MEDIA_FUTURE, "InitialAudio",
+              GABBLE_IFACE_CHANNEL_TYPE_STREAMED_MEDIA_FUTURE, "InitialVideo",
               NULL));
       break;
     case PROP_SESSION:
       g_value_set_object (value, priv->session);
       break;
+    case PROP_INITIAL_AUDIO:
+      g_value_set_boolean (value, priv->initial_audio);
+      break;
+    case PROP_INITIAL_VIDEO:
+      g_value_set_boolean (value, priv->initial_video);
+      break;
     default:
       param_name = g_param_spec_get_name (pspec);
 
@@ -531,6 +545,12 @@ gabble_media_channel_set_property (GObject     *object,
 
         }
       break;
+    case PROP_INITIAL_AUDIO:
+      priv->initial_audio = g_value_get_boolean (value);
+      break;
+    case PROP_INITIAL_VIDEO:
+      priv->initial_video = g_value_get_boolean (value);
+      break;
     default:
       param_name = g_param_spec_get_name (pspec);
 
@@ -575,12 +595,22 @@ gabble_media_channel_class_init (GabbleMediaChannelClass *gabble_media_channel_c
       { "InitiatorID", "creator-id", NULL },
       { NULL }
   };
+  static TpDBusPropertiesMixinPropImpl streamed_media_props[] = {
+      { "InitialAudio", "initial-audio", NULL },
+      { "InitialVideo", "initial-video", NULL },
+      { NULL }
+  };
   static TpDBusPropertiesMixinIfaceImpl prop_interfaces[] = {
       { TP_IFACE_CHANNEL,
         tp_dbus_properties_mixin_getter_gobject_properties,
         NULL,
         channel_props,
       },
+      { GABBLE_IFACE_CHANNEL_TYPE_STREAMED_MEDIA_FUTURE,
+        tp_dbus_properties_mixin_getter_gobject_properties,
+        NULL,
+        streamed_media_props,
+      },
       { NULL }
   };
   GObjectClass *object_class = G_OBJECT_CLASS (gabble_media_channel_class);
@@ -705,6 +735,20 @@ gabble_media_channel_class_init (GabbleMediaChannelClass *gabble_media_channel_c
       G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB);
   g_object_class_install_property (object_class, PROP_SESSION, param_spec);
 
+  param_spec = g_param_spec_boolean ("initial-audio", "InitialAudio",
+      "Whether the channel initially contained an audio stream",
+      FALSE,
+      G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+  g_object_class_install_property (object_class, PROP_INITIAL_AUDIO,
+      param_spec);
+
+  param_spec = g_param_spec_boolean ("initial-video", "InitialVideo",
+      "Whether the channel initially contained an video stream",
+      FALSE,
+      G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+  g_object_class_install_property (object_class, PROP_INITIAL_VIDEO,
+      param_spec);
+
   tp_properties_mixin_class_init (object_class,
       G_STRUCT_OFFSET (GabbleMediaChannelClass, properties_class),
       channel_property_signatures, NUM_CHAN_PROPS, NULL);
diff --git a/tests/twisted/jingle/initial-audio-video.py b/tests/twisted/jingle/initial-audio-video.py
index 99f8036..3e9ecfd 100644
--- a/tests/twisted/jingle/initial-audio-video.py
+++ b/tests/twisted/jingle/initial-audio-video.py
@@ -2,7 +2,8 @@
 Tests outgoing calls created with InitialAudio and/or InitialVideo.
 """
 
-from servicetest import assertContains
+from servicetest import assertContains, wrap_channel, EventPattern
+from gabbletest import sync_stream
 
 from jingletest2 import JingleTest2, test_all_dialects
 
@@ -13,6 +14,9 @@ def test(jp, q, bus, conn, stream):
     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]
+
     rccs = conn.Properties.Get(cs.CONN_IFACE_REQUESTS, 'RequestableChannelClasses')
     cclass = ({ cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_STREAMED_MEDIA,
                 cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT,
@@ -23,5 +27,30 @@ def test(jp, q, bus, conn, stream):
              )
     assertContains(cclass, rccs)
 
+    # Make a channel without specifying InitialAudio or InitialVideo; check
+    # that it's announced with both False, and that they're both present and
+    # false in GetAll(). Also, make sure that nothing's sent to the peer.
+    si = EventPattern('stream-iq', predicate=lambda e:
+        jp.match_jingle_action(e.query, 'session-initiate'))
+    q.forbid_events([si])
+
+    path, props = conn.Requests.CreateChannel({
+        cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_STREAMED_MEDIA,
+        cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT,
+        cs.TARGET_HANDLE: remote_handle})
+    assertContains((cs.INITIAL_AUDIO, False), props.items())
+    assertContains((cs.INITIAL_VIDEO, False), props.items())
+
+    chan = wrap_channel(bus.get_object(conn.bus_name, path), cs.CHANNEL_TYPE_STREAMED_MEDIA)
+    props = chan.Properties.GetAll(cs.CHANNEL_TYPE_STREAMED_MEDIA + '.FUTURE')
+    assertContains(('InitialAudio', False), props.items())
+    assertContains(('InitialVideo', False), props.items())
+
+    # Get rid of this channel.
+    chan.Close()
+
+    sync_stream(q, stream)
+    q.unforbid_events([si])
+
 if __name__ == '__main__':
     test_all_dialects(test)
-- 
1.5.6.5




More information about the telepathy-commits mailing list