[Telepathy-commits] [telepathy-glib/master] ExampleCallableMediaChannel: attempt to simulate stream directions
Simon McVittie
simon.mcvittie at collabora.co.uk
Mon Mar 16 08:52:40 PDT 2009
---
examples/cm/callable/media-channel.c | 10 ++++++++--
examples/cm/callable/media-stream.c | 20 +++++++++++++++-----
examples/cm/callable/media-stream.h | 5 +++++
3 files changed, 28 insertions(+), 7 deletions(-)
diff --git a/examples/cm/callable/media-channel.c b/examples/cm/callable/media-channel.c
index 10b70fb..1adf73d 100644
--- a/examples/cm/callable/media-channel.c
+++ b/examples/cm/callable/media-channel.c
@@ -854,6 +854,9 @@ simulate_contact_answered_cb (gpointer p)
while (g_hash_table_iter_next (&iter, NULL, &v))
{
+ /* remote contact accepts our proposed stream direction... */
+ example_callable_media_stream_simulate_contact_agreed_to_send (v);
+ /* ... and the stream tries to connect */
example_callable_media_stream_connect (v);
}
@@ -951,8 +954,6 @@ media_request_streams (TpSvcChannelTypeStreamedMedia *iface,
"handle", self->priv->handle,
"type", media_type,
NULL);
- /* FIXME: what direction should the stream have, and why? Answers on
- * a postcard. */
g_hash_table_insert (self->priv->streams, GUINT_TO_POINTER (id), stream);
@@ -966,6 +967,11 @@ media_request_streams (TpSvcChannelTypeStreamedMedia *iface,
g_signal_connect (stream, "direction-changed",
G_CALLBACK (stream_direction_changed_cb), self);
+ /* newly requested streams start off in a "we want to be bidirectional"
+ * state */
+ example_callable_media_stream_change_direction (stream,
+ TP_MEDIA_STREAM_DIRECTION_BIDIRECTIONAL, NULL);
+
if (self->priv->progress == PROGRESS_ACTIVE)
{
example_callable_media_stream_connect (stream);
diff --git a/examples/cm/callable/media-stream.c b/examples/cm/callable/media-stream.c
index 0c207cc..a2373ec 100644
--- a/examples/cm/callable/media-stream.c
+++ b/examples/cm/callable/media-stream.c
@@ -80,6 +80,11 @@ example_callable_media_stream_init (ExampleCallableMediaStream *self)
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
EXAMPLE_TYPE_CALLABLE_MEDIA_STREAM,
ExampleCallableMediaStreamPrivate);
+
+ /* FIXME: no particular "implicit" direction is currently mandated by
+ * telepathy-spec */
+ self->priv->direction = TP_MEDIA_STREAM_DIRECTION_NONE;
+ self->priv->pending_send = 0;
}
static void
@@ -346,11 +351,10 @@ example_callable_media_stream_close (ExampleCallableMediaStream *self)
}
}
-static gboolean
-simulate_contact_agreed_to_send_cb (gpointer p)
+void
+example_callable_media_stream_simulate_contact_agreed_to_send (
+ ExampleCallableMediaStream *self)
{
- ExampleCallableMediaStream *self = p;
-
if (self->priv->removed ||
!(self->priv->pending_send & TP_MEDIA_STREAM_PENDING_REMOTE_SEND))
return;
@@ -364,6 +368,13 @@ simulate_contact_agreed_to_send_cb (gpointer p)
g_signal_emit (self, signals[SIGNAL_DIRECTION_CHANGED], 0);
}
+static gboolean
+simulate_contact_agreed_to_send_cb (gpointer p)
+{
+ example_callable_media_stream_simulate_contact_agreed_to_send (p);
+ return FALSE;
+}
+
gboolean
example_callable_media_stream_change_direction (
ExampleCallableMediaStream *self,
@@ -467,7 +478,6 @@ simulate_stream_connected_cb (gpointer p)
void
example_callable_media_stream_connect (ExampleCallableMediaStream *self)
{
-
/* if already trying to connect, do nothing */
if (self->priv->connected_event_id != 0)
return;
diff --git a/examples/cm/callable/media-stream.h b/examples/cm/callable/media-stream.h
index 09d1a8e..5f5d916 100644
--- a/examples/cm/callable/media-stream.h
+++ b/examples/cm/callable/media-stream.h
@@ -73,6 +73,11 @@ gboolean example_callable_media_stream_change_direction (
GError **error);
void example_callable_media_stream_connect (ExampleCallableMediaStream *self);
+/* This controls receiving emulated network events, so it wouldn't exist in
+ * a real connection manager */
+void example_callable_media_stream_simulate_contact_agreed_to_send (
+ ExampleCallableMediaStream *self);
+
G_END_DECLS
#endif
--
1.5.6.5
More information about the telepathy-commits
mailing list