[Telepathy-commits] [telepathy-glib/master] ExampleCallableMediaChannel: comply with telepathy-spec 0.17.22

Simon McVittie simon.mcvittie at collabora.co.uk
Tue Mar 24 13:33:31 PDT 2009


If the initial direction isn't what the spec says, catch up by emitting
a signal.
---
 examples/cm/callable/media-channel.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/examples/cm/callable/media-channel.c b/examples/cm/callable/media-channel.c
index d6d693d..c3372d4 100644
--- a/examples/cm/callable/media-channel.c
+++ b/examples/cm/callable/media-channel.c
@@ -1023,6 +1023,7 @@ example_callable_media_channel_add_stream (ExampleCallableMediaChannel *self,
 {
   ExampleCallableMediaStream *stream;
   guint id = self->priv->next_stream_id++;
+  guint state, direction, pending_send;
 
   if (locally_requested)
     {
@@ -1042,6 +1043,27 @@ example_callable_media_channel_add_stream (ExampleCallableMediaChannel *self,
   tp_svc_channel_type_streamed_media_emit_stream_added (self, id,
       self->priv->handle, media_type);
 
+  g_object_get (stream,
+      "state", &state,
+      "direction", &direction,
+      "pending-send", &pending_send,
+      NULL);
+
+  /* this is the "implicit" initial state mandated by telepathy-spec */
+  if (state != TP_MEDIA_STREAM_STATE_DISCONNECTED)
+    {
+      tp_svc_channel_type_streamed_media_emit_stream_state_changed (self, id,
+          state);
+    }
+
+  /* this is the "implicit" initial direction mandated by telepathy-spec */
+  if (direction != TP_MEDIA_STREAM_DIRECTION_RECEIVE ||
+      pending_send != TP_MEDIA_STREAM_PENDING_LOCAL_SEND)
+    {
+      tp_svc_channel_type_streamed_media_emit_stream_direction_changed (self,
+          id, direction, pending_send);
+    }
+
   g_signal_connect (stream, "removed", G_CALLBACK (stream_removed_cb),
       self);
   g_signal_connect (stream, "notify::state",
-- 
1.5.6.5




More information about the telepathy-commits mailing list