[Telepathy-commits] [telepathy-gabble/master] On CodecsUpdated, send the update to peer in description-info
Senko Rasic
senko.rasic at collabora.co.uk
Thu Mar 12 13:09:47 PDT 2009
---
src/jingle-content.c | 22 ++++++++++++++++++++++
src/jingle-factory.h | 3 ++-
src/jingle-media-rtp.c | 5 +++--
src/jingle-session.c | 4 ++++
src/media-stream.c | 26 ++++++++++++++++++++++++++
5 files changed, 57 insertions(+), 3 deletions(-)
diff --git a/src/jingle-content.c b/src/jingle-content.c
index b04ad15..e4e1849 100644
--- a/src/jingle-content.c
+++ b/src/jingle-content.c
@@ -851,6 +851,20 @@ _maybe_ready (GabbleJingleContent *self)
}
}
+
+static void
+send_description_info (GabbleJingleContent *self)
+{
+ LmMessage *msg;
+ LmMessageNode *sess_node;
+
+ msg = gabble_jingle_session_new_message (self->session,
+ JINGLE_ACTION_DESCRIPTION_INFO, &sess_node);
+ gabble_jingle_content_produce_node (self, sess_node, TRUE);
+ gabble_jingle_session_send (self->session, msg, NULL, NULL);
+}
+
+
/* Used when session-initiate is sent (so all initial contents transmit their
* candidates), and when we detect gtalk3 after we've transmitted some
* candidates. */
@@ -866,6 +880,14 @@ _gabble_jingle_content_set_media_ready (GabbleJingleContent *self)
{
GabbleJingleContentPrivate *priv = GABBLE_JINGLE_CONTENT_GET_PRIVATE (self);
+ /* If media was already ready, media info was changed and we need to
+ * push description-info action to the peer. */
+ if (priv->media_ready == TRUE)
+ {
+ send_description_info (self);
+ return;
+ }
+
priv->media_ready = TRUE;
_maybe_ready (self);
diff --git a/src/jingle-factory.h b/src/jingle-factory.h
index e37e2e2..447d10b 100644
--- a/src/jingle-factory.h
+++ b/src/jingle-factory.h
@@ -65,7 +65,8 @@ typedef enum {
JINGLE_ACTION_SESSION_INITIATE,
JINGLE_ACTION_SESSION_TERMINATE,
JINGLE_ACTION_TRANSPORT_INFO,
- JINGLE_ACTION_TRANSPORT_ACCEPT
+ JINGLE_ACTION_TRANSPORT_ACCEPT,
+ JINGLE_ACTION_DESCRIPTION_INFO
} JingleAction;
typedef enum {
diff --git a/src/jingle-media-rtp.c b/src/jingle-media-rtp.c
index dc09675..be78ee4 100644
--- a/src/jingle-media-rtp.c
+++ b/src/jingle-media-rtp.c
@@ -484,9 +484,10 @@ jingle_media_rtp_set_local_codecs (GabbleJingleMediaRtp *self, GList *codecs)
{
GabbleJingleMediaRtpPrivate *priv = self->priv;
- DEBUG ("adding new local codecs");
+ DEBUG ("setting new local codecs");
- priv->local_codecs = g_list_concat (priv->local_codecs, codecs);
+ jingle_media_rtp_free_codecs (priv->local_codecs);
+ priv->local_codecs = codecs;
_gabble_jingle_content_set_media_ready (GABBLE_JINGLE_CONTENT (self));
}
diff --git a/src/jingle-session.c b/src/jingle-session.c
index 47328c4..4105228 100644
--- a/src/jingle-session.c
+++ b/src/jingle-session.c
@@ -417,6 +417,8 @@ parse_action (const gchar *txt)
return JINGLE_ACTION_SESSION_INFO;
else if (!tp_strdiff (txt, "transport-accept"))
return JINGLE_ACTION_TRANSPORT_ACCEPT;
+ else if (!tp_strdiff (txt, "description-info"))
+ return JINGLE_ACTION_DESCRIPTION_INFO;
return JINGLE_ACTION_UNKNOWN;
}
@@ -453,6 +455,8 @@ produce_action (JingleAction action, JingleDialect dialect)
return "session-info";
case JINGLE_ACTION_TRANSPORT_ACCEPT:
return "transport-accept";
+ case JINGLE_ACTION_DESCRIPTION_INFO:
+ return "description-info";
default:
DEBUG ("unknown action %u", action);
g_assert_not_reached ();
diff --git a/src/media-stream.c b/src/media-stream.c
index e8a95dc..fe7d8b0 100644
--- a/src/media-stream.c
+++ b/src/media-stream.c
@@ -1200,6 +1200,31 @@ gabble_media_stream_supported_codecs (TpSvcMediaStreamHandler *iface,
tp_svc_media_stream_handler_return_from_supported_codecs (context);
}
+/**
+ * gabble_media_stream_codecs_updated
+ *
+ * Implements D-Bus method CodecsUpdated
+ * on interface org.freedesktop.Telepathy.Media.StreamHandler
+ */
+static void
+gabble_media_stream_codecs_updated (TpSvcMediaStreamHandler *iface,
+ const GPtrArray *codecs,
+ DBusGMethodInvocation *context)
+{
+ GabbleMediaStream *self = GABBLE_MEDIA_STREAM (iface);
+ GabbleMediaStreamPrivate *priv = GABBLE_MEDIA_STREAM_GET_PRIVATE (self);
+
+ /* FIXME: we assume codecs have already been set (by set_local_codecs
+ * or supported_codecs(), depending on who's stream creator. */
+
+ /* trick pass_local_codecs() into always pushing the codecs, no matter
+ * whether we're creator or not. */
+ pass_local_codecs (self, codecs,
+ !gabble_jingle_content_is_created_by_us (priv->content));
+
+ tp_svc_media_stream_handler_return_from_codecs_updated (context);
+}
+
void
_gabble_media_stream_close (GabbleMediaStream *stream)
{
@@ -1677,6 +1702,7 @@ stream_handler_iface_init (gpointer g_iface, gpointer iface_data)
IMPLEMENT(stream_state,);
IMPLEMENT(supported_codecs,);
IMPLEMENT(unhold_failure,);
+ IMPLEMENT(codecs_updated,);
#undef IMPLEMENT
}
--
1.5.6.5
More information about the telepathy-commits
mailing list