diff options
author | Olivier CrĂȘte <olivier.crete@collabora.com> | 2011-05-30 13:53:31 +0300 |
---|---|---|
committer | Olivier CrĂȘte <olivier.crete@collabora.com> | 2011-05-30 13:53:31 +0300 |
commit | 09b9df6b46424815b083d7c62360106e1b5cb304 (patch) | |
tree | 03919b1146ebd6dbcd1c016b983fe4646205e31a | |
parent | 45b613e8ed8037c3e24dabb067dddb08f3d6f5af (diff) |
Add a block-ready property to TfStream
This allows the application to block the calling of the Ready() dbus method
until some pre-condition as been accomplished. If this property is set to
TRUE during the "stream-created" signal, then Ready() will not be called
before it is unset.
-rw-r--r-- | telepathy-farsight/stream.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/telepathy-farsight/stream.c b/telepathy-farsight/stream.c index f925147..6730be8 100644 --- a/telepathy-farsight/stream.c +++ b/telepathy-farsight/stream.c @@ -104,12 +104,15 @@ struct _TfStreamPrivate gboolean send_local_codecs; gboolean send_supported_codecs; + gboolean ready_called; guint tos; GHashTable *feedback_messages; GPtrArray *header_extensions; + gboolean block_ready; + GStaticMutex mutex; guint idle_connected_id; /* Protected by mutex */ gboolean disposed; /* Protected by mutex */ @@ -151,7 +154,8 @@ enum PROP_SINK_PAD, PROP_LOCAL_PREFERENCES, PROP_TOS, - PROP_RESOURCES + PROP_RESOURCES, + PROP_BLOCK_READY }; static void get_all_properties_cb (TpProxy *proxy, @@ -313,6 +317,9 @@ tf_stream_get_property (GObject *object, case PROP_RESOURCES: g_value_set_uint (value, self->priv->has_resource); break; + case PROP_BLOCK_READY: + g_value_set_boolean (value, self->priv->block_ready); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -365,6 +372,20 @@ tf_stream_set_property (GObject *object, if (self->priv->fs_session) g_object_set_property (G_OBJECT (self->priv->fs_session), "tos", value); break; + case PROP_BLOCK_READY: + if (self->priv->ready_called) + { + WARNING (self, + "Trying to block the Ready() call after it has happenned"); + } + else + { + gboolean old_block_ready = self->priv->block_ready; + self->priv->block_ready = g_value_get_boolean (value); + if (old_block_ready && !self->priv->block_ready) + _tf_stream_try_sending_codecs (self); + } + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -624,6 +645,13 @@ tf_stream_class_init (TfStreamClass *klass) TP_MEDIA_STREAM_DIRECTION_NONE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (object_class, PROP_BLOCK_READY, + g_param_spec_boolean ("block-ready", + "Blocks calling Ready on the StreamHandler", + "Blocks calling Ready on the StreamHandler", + FALSE, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + /** * TfStream::closed: * @stream: the stream that has been closed @@ -2839,6 +2867,9 @@ _tf_stream_try_sending_codecs (TfStream *stream) GHashTable *feedback_messages = NULL; GPtrArray *header_extensions = NULL; + if (stream->priv->block_ready) + return; + DEBUG (stream, "called (send_local:%d send_supported:%d)", stream->priv->send_local_codecs, stream->priv->send_supported_codecs); @@ -2882,6 +2913,7 @@ _tf_stream_try_sending_codecs (TfStream *stream) -1, tpcodecs, async_method_callback, "Media.StreamHandler::Ready", NULL, (GObject *) stream); stream->priv->send_local_codecs = FALSE; + stream->priv->ready_called = TRUE; goto out; } |