[Telepathy-commits] [telepathy-gabble/master] GabbleMediaStream: more stream direction handling fixes
Senko Rasic
senko.rasic at collabora.co.uk
Tue Dec 2 04:34:08 PST 2008
---
src/media-channel.c | 31 +++++++------------------------
src/media-stream.c | 41 +++++++++++++++++++++++++----------------
2 files changed, 32 insertions(+), 40 deletions(-)
diff --git a/src/media-channel.c b/src/media-channel.c
index 4f3114c..c58f515 100644
--- a/src/media-channel.c
+++ b/src/media-channel.c
@@ -1808,21 +1808,6 @@ session_state_changed_cb (GabbleJingleSession *session,
}
- if (state == JS_STATE_ACTIVE)
- {
- guint i;
-
- /* set all streams as playing */
- for (i = 0; i < priv->streams->len; i++)
- {
- GabbleMediaStream *stream = g_ptr_array_index (priv->streams, i);
-
- g_object_set (stream, "playing", TRUE, NULL);
- _gabble_media_stream_update_sending (stream, TRUE);
-
- }
- }
-
tp_intset_destroy (set);
}
@@ -2135,6 +2120,7 @@ create_stream_from_content (GabbleMediaChannel *chan, GabbleJingleContent *c)
GabbleMediaChannelPrivate *priv = GABBLE_MEDIA_CHANNEL_GET_PRIVATE (chan);
GabbleMediaStream *stream;
JingleMediaType type;
+ TpMediaStreamType mtype;
gchar *name;
guint id;
gchar *object_path;
@@ -2154,13 +2140,15 @@ create_stream_from_content (GabbleMediaChannel *chan, GabbleJingleContent *c)
object_path = g_strdup_printf ("%s/MediaStream%u",
priv->object_path, id);
+ mtype = (type == JINGLE_MEDIA_TYPE_AUDIO) ?
+ TP_MEDIA_STREAM_TYPE_AUDIO : TP_MEDIA_STREAM_TYPE_VIDEO;
+
stream = g_object_new (GABBLE_TYPE_MEDIA_STREAM,
"object-path", object_path,
"content", c,
"name", name,
"id", id,
- "media-type", type == JINGLE_MEDIA_TYPE_AUDIO ?
- TP_MEDIA_STREAM_TYPE_AUDIO : TP_MEDIA_STREAM_TYPE_VIDEO,
+ "media-type", mtype,
NULL);
DEBUG ("%p: created new MediaStream %p for content '%s'", chan, stream, name);
@@ -2186,9 +2174,7 @@ create_stream_from_content (GabbleMediaChannel *chan, GabbleJingleContent *c)
type == JINGLE_MEDIA_TYPE_AUDIO ? "audio" : "video");
tp_svc_channel_type_streamed_media_emit_stream_added (
- chan, id, priv->session->peer,
- type == JINGLE_MEDIA_TYPE_AUDIO ?
- TP_MEDIA_STREAM_TYPE_AUDIO : TP_MEDIA_STREAM_TYPE_VIDEO);
+ chan, id, priv->session->peer, mtype);
/* A stream being added might cause the "total" hold state to change */
stream_hold_state_changed (stream, NULL, chan);
@@ -2199,10 +2185,7 @@ create_stream_from_content (GabbleMediaChannel *chan, GabbleJingleContent *c)
* just in the signalling they change */
DEBUG ("emitting MediaSessionHandler:NewStreamHandler signal for stream %d", id);
tp_svc_media_session_handler_emit_new_stream_handler (chan,
- object_path, id,
- type == JINGLE_MEDIA_TYPE_AUDIO ?
- TP_MEDIA_STREAM_TYPE_AUDIO : TP_MEDIA_STREAM_TYPE_VIDEO,
- TP_MEDIA_STREAM_DIRECTION_BIDIRECTIONAL);
+ object_path, id, mtype, TP_MEDIA_STREAM_DIRECTION_BIDIRECTIONAL);
}
g_free (object_path);
diff --git a/src/media-stream.c b/src/media-stream.c
index f01c8e0..c3bbf41 100644
--- a/src/media-stream.c
+++ b/src/media-stream.c
@@ -137,6 +137,7 @@ static void content_senders_changed_cb (GabbleJingleContent *c,
GParamSpec *pspec, GabbleMediaStream *stream);
static void content_removed_cb (GabbleJingleContent *content,
GabbleMediaStream *stream);
+static void update_direction (GabbleMediaStream *stream, GabbleJingleContent *c);
static void
gabble_media_stream_init (GabbleMediaStream *self)
@@ -172,18 +173,36 @@ gabble_media_stream_constructor (GType type, guint n_props,
GObjectConstructParam *props)
{
GObject *obj;
+ GabbleMediaStream *stream;
GabbleMediaStreamPrivate *priv;
DBusGConnection *bus;
/* call base class constructor */
obj = G_OBJECT_CLASS (gabble_media_stream_parent_class)->
constructor (type, n_props, props);
- priv = GABBLE_MEDIA_STREAM_GET_PRIVATE (GABBLE_MEDIA_STREAM (obj));
+ stream = GABBLE_MEDIA_STREAM (obj);
+ priv = GABBLE_MEDIA_STREAM_GET_PRIVATE (stream);
/* go for the bus */
bus = tp_get_bus ();
dbus_g_connection_register_g_object (bus, priv->object_path, obj);
+ if (priv->content != NULL)
+ {
+ update_direction (stream, priv->content);
+
+ /* we can immediately get the codecs if we're responder */
+ new_remote_codecs_cb (priv->content,
+ gabble_jingle_media_rtp_get_remote_codecs (GABBLE_JINGLE_MEDIA_RTP (priv->content)),
+ stream);
+
+ /* if any candidates arrived before idle loop had the chance to excute
+ * us (e.g. specified in session-initiate/content-add), we don't want to
+ * miss them */
+ new_remote_candidates_cb (priv->content,
+ gabble_jingle_content_get_remote_candidates (priv->content), stream);
+ }
+
return obj;
}
@@ -239,8 +258,6 @@ gabble_media_stream_get_property (GObject *object,
}
}
-static void update_direction (GabbleMediaStream *stream, GabbleJingleContent *c);
-
static void
gabble_media_stream_set_property (GObject *object,
guint property_id,
@@ -312,18 +329,6 @@ gabble_media_stream_set_property (GObject *object,
priv->removed_id = g_signal_connect (priv->content, "removed",
(GCallback) content_removed_cb, stream);
-
- update_direction (stream, priv->content);
-
- /* we can immediately get the codecs if we're responder */
- new_remote_codecs_cb (priv->content,
- gabble_jingle_media_rtp_get_remote_codecs (GABBLE_JINGLE_MEDIA_RTP (priv->content)),
- stream);
-
- /* if any candidates arrived before idle loop had the chance to excute
- * us, we don't wan to miss them */
- new_remote_candidates_cb (priv->content,
- gabble_jingle_content_get_remote_candidates (priv->content), stream);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -1112,7 +1117,8 @@ new_remote_codecs_cb (GabbleJingleContent *content,
g_value_take_boxed (&codec,
dbus_g_type_specialized_construct (codec_struct_type));
- DEBUG ("new remote codec: %u '%s' %u %u %u",
+ DEBUG ("new remote %s codec: %u '%s' %u %u %u",
+ priv->media_type == TP_MEDIA_STREAM_TYPE_AUDIO ? "audio" : "video",
c->id, c->name, priv->media_type, c->clockrate, c->channels);
dbus_g_type_struct_set (&codec,
@@ -1238,6 +1244,7 @@ content_state_changed_cb (GabbleJingleContent *c,
/* connected stream means we can play, but sending is determined
* by content senders (in update_senders) */
stream->playing = TRUE;
+ _gabble_media_stream_update_sending (stream, TRUE);
push_playing (stream);
push_sending (stream);
break;
@@ -1338,6 +1345,8 @@ update_direction (GabbleMediaStream *stream, GabbleJingleContent *c)
JingleContentSenders senders;
gboolean local_initiator;
+ DEBUG ("called");
+
g_object_get (c, "senders", &senders, NULL);
g_object_get (c->session, "local-initiator", &local_initiator, NULL);
--
1.5.6.5
More information about the Telepathy-commits
mailing list