[telepathy-gabble/telepathy-gabble-0.8] Implement StreamedMedia.ImmutableStreams property

Will Thompson will.thompson at collabora.co.uk
Mon Oct 5 02:48:38 PDT 2009


---
 src/media-channel-internal.h |    1 +
 src/media-channel.c          |   49 +++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 49 insertions(+), 1 deletions(-)

diff --git a/src/media-channel-internal.h b/src/media-channel-internal.h
index 8e4003b..1743f68 100644
--- a/src/media-channel-internal.h
+++ b/src/media-channel-internal.h
@@ -61,6 +61,7 @@ struct _GabbleMediaChannelPrivate
 
   gboolean initial_audio;
   gboolean initial_video;
+  gboolean immutable_streams;
 
   /* These are really booleans, but gboolean is signed. Thanks, GLib */
   unsigned ready:1;
diff --git a/src/media-channel.c b/src/media-channel.c
index eecf729..760c2d2 100644
--- a/src/media-channel.c
+++ b/src/media-channel.c
@@ -112,6 +112,7 @@ enum
   PROP_CHANNEL_PROPERTIES,
   PROP_INITIAL_AUDIO,
   PROP_INITIAL_VIDEO,
+  PROP_IMMUTABLE_STREAMS,
   /* TP properties (see also below) */
   PROP_NAT_TRAVERSAL,
   PROP_STUN_SERVER,
@@ -415,6 +416,32 @@ gabble_media_channel_constructor (GType type, guint n_props,
         }
     }
 
+  /* If this is a Google session, let's set ImmutableStreams */
+  if (priv->session != NULL)
+    {
+      JingleDialect d = gabble_jingle_session_get_dialect (priv->session);
+
+      priv->immutable_streams = JINGLE_IS_GOOGLE_DIALECT (d);
+    }
+  /* If there's no session yet, but we know who the peer will be, and we have
+   * presence for them, we can set ImmutableStreams using the same algorithm as
+   * for old-style capabilities.  If we don't know who the peer will be, then
+   * the client is using an old calling convention and doesn't need to know
+   * this.
+   */
+  else if (priv->initial_peer != 0)
+    {
+      GabblePresence *presence = gabble_presence_cache_get (
+          priv->conn->presence_cache, priv->initial_peer);
+      TpChannelMediaCapabilities flags = 0;
+
+      if (presence != NULL)
+          _gabble_media_channel_caps_to_typeflags (presence->caps);
+
+      if (flags & TP_CHANNEL_MEDIA_CAPABILITY_IMMUTABLE_STREAMS)
+        priv->immutable_streams = TRUE;
+    }
+
   return obj;
 }
 
@@ -519,6 +546,7 @@ gabble_media_channel_get_property (GObject    *object,
               TP_IFACE_CHANNEL, "InitiatorID",
               TP_IFACE_CHANNEL, "Requested",
               TP_IFACE_CHANNEL, "Interfaces",
+              TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA, "ImmutableStreams",
               GABBLE_IFACE_CHANNEL_TYPE_STREAMED_MEDIA_FUTURE, "InitialAudio",
               GABBLE_IFACE_CHANNEL_TYPE_STREAMED_MEDIA_FUTURE, "InitialVideo",
               NULL));
@@ -532,6 +560,9 @@ gabble_media_channel_get_property (GObject    *object,
     case PROP_INITIAL_VIDEO:
       g_value_set_boolean (value, priv->initial_video);
       break;
+    case PROP_IMMUTABLE_STREAMS:
+      g_value_set_boolean (value, priv->immutable_streams);
+      break;
     default:
       param_name = g_param_spec_get_name (pspec);
 
@@ -654,6 +685,10 @@ gabble_media_channel_class_init (GabbleMediaChannelClass *gabble_media_channel_c
       { NULL }
   };
   static TpDBusPropertiesMixinPropImpl streamed_media_props[] = {
+      { "ImmutableStreams", "immutable-streams", NULL },
+      { NULL }
+  };
+  static TpDBusPropertiesMixinPropImpl streamed_media_future_props[] = {
       { "InitialAudio", "initial-audio", NULL },
       { "InitialVideo", "initial-video", NULL },
       { NULL }
@@ -664,11 +699,16 @@ gabble_media_channel_class_init (GabbleMediaChannelClass *gabble_media_channel_c
         NULL,
         channel_props,
       },
-      { GABBLE_IFACE_CHANNEL_TYPE_STREAMED_MEDIA_FUTURE,
+      { TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA,
         tp_dbus_properties_mixin_getter_gobject_properties,
         NULL,
         streamed_media_props,
       },
+      { GABBLE_IFACE_CHANNEL_TYPE_STREAMED_MEDIA_FUTURE,
+        tp_dbus_properties_mixin_getter_gobject_properties,
+        NULL,
+        streamed_media_future_props,
+      },
       { NULL }
   };
   GObjectClass *object_class = G_OBJECT_CLASS (gabble_media_channel_class);
@@ -807,6 +847,13 @@ gabble_media_channel_class_init (GabbleMediaChannelClass *gabble_media_channel_c
   g_object_class_install_property (object_class, PROP_INITIAL_VIDEO,
       param_spec);
 
+  param_spec = g_param_spec_boolean ("immutable-streams", "ImmutableStreams",
+      "Whether the set of streams on this channel are fixed once requested",
+      FALSE,
+      G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+  g_object_class_install_property (object_class, PROP_IMMUTABLE_STREAMS,
+      param_spec);
+
   tp_properties_mixin_class_init (object_class,
       G_STRUCT_OFFSET (GabbleMediaChannelClass, properties_class),
       channel_property_signatures, NUM_CHAN_PROPS, NULL);
-- 
1.5.6.5




More information about the telepathy-commits mailing list