[Telepathy-commits] [telepathy-gabble/master] Jingle: handle incoming description-info
Senko Rasic
senko.rasic at collabora.co.uk
Thu Mar 12 13:09:47 PDT 2009
---
src/jingle-content.c | 16 ++++++++++++++++
src/jingle-content.h | 2 ++
src/jingle-media-rtp.c | 5 +++--
src/jingle-session.c | 24 +++++++++++++++++++++++-
src/media-stream.c | 48 +++++++++++++++++++++++++++++++++++++++++++++---
5 files changed, 89 insertions(+), 6 deletions(-)
diff --git a/src/jingle-content.c b/src/jingle-content.c
index e4e1849..7ebfba0 100644
--- a/src/jingle-content.c
+++ b/src/jingle-content.c
@@ -650,6 +650,22 @@ gabble_jingle_content_parse_accept (GabbleJingleContent *c,
}
void
+gabble_jingle_content_parse_description_info (GabbleJingleContent *c,
+ LmMessageNode *content_node, GError **error)
+{
+ LmMessageNode *desc_node;
+ desc_node = lm_message_node_get_child_any_ns (content_node, "description");
+ if (desc_node == NULL)
+ {
+ SET_BAD_REQ ("invalid description-info action");
+ return;
+ }
+
+ parse_description (c, desc_node, error);
+}
+
+
+void
gabble_jingle_content_produce_node (GabbleJingleContent *c,
LmMessageNode *parent, gboolean full)
{
diff --git a/src/jingle-content.h b/src/jingle-content.h
index 9271419..1bc8a87 100644
--- a/src/jingle-content.h
+++ b/src/jingle-content.h
@@ -106,6 +106,8 @@ void gabble_jingle_content_parse_accept (GabbleJingleContent *c,
void gabble_jingle_content_parse_transport_info (GabbleJingleContent *self,
LmMessageNode *trans_node, GError **error);
+void gabble_jingle_content_parse_description_info (GabbleJingleContent *self,
+ LmMessageNode *trans_node, GError **error);
void gabble_jingle_content_add_candidates (GabbleJingleContent *self, GList *li);
void _gabble_jingle_content_set_media_ready (GabbleJingleContent *self);
gboolean gabble_jingle_content_is_ready (GabbleJingleContent *self);
diff --git a/src/jingle-media-rtp.c b/src/jingle-media-rtp.c
index be78ee4..a0f2aab 100644
--- a/src/jingle-media-rtp.c
+++ b/src/jingle-media-rtp.c
@@ -370,8 +370,9 @@ parse_description (GabbleJingleContent *content,
DEBUG ("emitting remote-codecs signal");
g_signal_emit (self, signals[REMOTE_CODECS], 0, codecs);
- /* append them to the known remote codecs */
- priv->remote_codecs = g_list_concat (priv->remote_codecs, codecs);
+ /* set them as the known remote codecs */
+ jingle_media_rtp_free_codecs (priv->remote_codecs);
+ priv->remote_codecs = codecs;
}
static void
diff --git a/src/jingle-session.c b/src/jingle-session.c
index 4105228..4b3c0b3 100644
--- a/src/jingle-session.c
+++ b/src/jingle-session.c
@@ -762,6 +762,20 @@ _each_content_accept (GabbleJingleSession *sess, GabbleJingleContent *c,
}
static void
+_each_description_info (GabbleJingleSession *sess, GabbleJingleContent *c,
+ LmMessageNode *content_node, GError **error)
+{
+ if (c == NULL)
+ {
+ const gchar *name = lm_message_node_get_attribute (content_node, "name");
+ SET_BAD_REQ ("content called \"%s\" doesn't exist", name);
+ return;
+ }
+
+ gabble_jingle_content_parse_description_info (c, content_node, error);
+}
+
+static void
on_session_initiate (GabbleJingleSession *sess, LmMessageNode *node,
GError **error)
{
@@ -951,6 +965,13 @@ on_transport_accept (GabbleJingleSession *sess, LmMessageNode *node,
DEBUG ("Ignoring 'transport-accept' action from peer");
}
+static void
+on_description_info (GabbleJingleSession *sess, LmMessageNode *node,
+ GError **error)
+{
+ _foreach_content (sess, node, _each_description_info, error);
+}
+
static HandlerFunc handlers[] = {
NULL, /* for unknown action */
@@ -965,7 +986,8 @@ static HandlerFunc handlers[] = {
on_session_initiate,
on_session_terminate, /* jingle_on_session_terminate */
on_transport_info, /* jingle_on_transport_info */
- on_transport_accept
+ on_transport_accept,
+ on_description_info
};
static void
diff --git a/src/media-stream.c b/src/media-stream.c
index fe7d8b0..0293b9e 100644
--- a/src/media-stream.c
+++ b/src/media-stream.c
@@ -108,6 +108,11 @@ struct _GabbleMediaStreamPrivate
GValue native_codecs; /* intersected codec list */
GValue native_candidates;
+ /* Whether we're in the process of updating the remote
+ * codecs. Changes our behaviour on SupportedCodecs/Error
+ * (turns it into ACK/NAK for description-info from peer). */
+ gboolean updating_remote_codecs;
+
GValue remote_codecs;
GValue remote_candidates;
@@ -205,6 +210,8 @@ gabble_media_stream_init (GabbleMediaStream *self)
dbus_g_type_specialized_construct (candidate_list_type));
priv->stun_servers = g_ptr_array_sized_new (1);
+
+ priv->updating_remote_codecs = FALSE;
}
static gboolean
@@ -754,8 +761,20 @@ gabble_media_stream_error_async (TpSvcMediaStreamHandler *iface,
DBusGMethodInvocation *context)
{
GabbleMediaStream *self = GABBLE_MEDIA_STREAM (iface);
+ GabbleMediaStreamPrivate *priv = GABBLE_MEDIA_STREAM_GET_PRIVATE (self);
GError *error = NULL;
+ if (priv->updating_remote_codecs)
+ {
+ /* FIXME: description-info is purely advisory, and jingle-factory
+ * automatically acks stanzas that don't cause errors when they're
+ * interpreted, so we just never send error to the peer.
+ gabble_jingle_content_ack_description_info (priv->content, FALSE);
+ */
+ priv->updating_remote_codecs = FALSE;
+ return;
+ }
+
if (gabble_media_stream_error (self, errno, message, &error))
{
tp_svc_media_stream_handler_return_from_error (context);
@@ -1194,9 +1213,22 @@ gabble_media_stream_supported_codecs (TpSvcMediaStreamHandler *iface,
DBusGMethodInvocation *context)
{
GabbleMediaStream *self = GABBLE_MEDIA_STREAM (iface);
+ GabbleMediaStreamPrivate *priv = GABBLE_MEDIA_STREAM_GET_PRIVATE (self);
+
+ if (priv->updating_remote_codecs)
+ {
+ /* FIXME: jingle-factory already ack'd, so we don't do it now (see
+ * comment for _error() implementation).
+ gabble_jingle_content_ack_description_info (priv->content, TRUE);
+ */
+ priv->updating_remote_codecs = FALSE;
+ }
+ else
+ {
+ pass_local_codecs (self, codecs, TRUE);
+ g_signal_emit (self, signals[SUPPORTED_CODECS], 0, codecs);
+ }
- pass_local_codecs (self, codecs, TRUE);
- g_signal_emit (self, signals[SUPPORTED_CODECS], 0, codecs);
tp_svc_media_stream_handler_return_from_supported_codecs (context);
}
@@ -1258,7 +1290,17 @@ new_remote_codecs_cb (GabbleJingleContent *content,
codecs = g_value_get_boxed (&priv->remote_codecs);
- g_assert (codecs->len == 0);
+ /* If the codecs have already been set, this means the
+ * peer is updating their parameters. We set a flag so
+ * when CM calls SupportedCodecs or Error, we can
+ * turn that into ack/nak for description-info from
+ * peer. */
+ if (codecs->len != 0)
+ {
+ priv->updating_remote_codecs = TRUE;
+ g_value_reset (&priv->remote_codecs);
+ priv->updating_remote_codecs = TRUE;
+ }
for (li = clist; li; li = li->next)
{
--
1.5.6.5
More information about the telepathy-commits
mailing list