[telepathy-gabble/master] Only send codec information and description updates if we're really ready
Sjoerd Simons
sjoerd.simons at collabora.co.uk
Mon May 11 10:16:47 PDT 2009
---
src/jingle-content.c | 18 ++++++++----------
src/jingle-content.h | 2 ++
src/jingle-media-rtp.c | 25 +++++++++++++++----------
src/jingle-media-rtp.h | 2 +-
src/media-stream.c | 17 +++++++++++++----
5 files changed, 39 insertions(+), 25 deletions(-)
diff --git a/src/jingle-content.c b/src/jingle-content.c
index 99ba6dd..19aec46 100644
--- a/src/jingle-content.c
+++ b/src/jingle-content.c
@@ -871,13 +871,18 @@ _maybe_ready (GabbleJingleContent *self)
}
}
-
-static void
-send_description_info (GabbleJingleContent *self)
+void
+gabble_jingle_content_maybe_send_description (GabbleJingleContent *self)
{
+ GabbleJingleContentPrivate *priv = self->priv;
LmMessage *msg;
LmMessageNode *sess_node;
+ /* If we didn't send the content yet there is no reason to send a
+ * description-info to update it */
+ if (priv->state < JINGLE_CONTENT_STATE_SENT)
+ return;
+
msg = gabble_jingle_session_new_message (self->session,
JINGLE_ACTION_DESCRIPTION_INFO, &sess_node);
gabble_jingle_content_produce_node (self, sess_node, TRUE);
@@ -900,13 +905,6 @@ _gabble_jingle_content_set_media_ready (GabbleJingleContent *self)
{
GabbleJingleContentPrivate *priv = self->priv;
- /* 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;
diff --git a/src/jingle-content.h b/src/jingle-content.h
index f422bd9..73f9a5d 100644
--- a/src/jingle-content.h
+++ b/src/jingle-content.h
@@ -129,6 +129,8 @@ gboolean gabble_jingle_content_is_created_by_us (GabbleJingleContent *c);
const gchar *gabble_jingle_content_get_name (GabbleJingleContent *self);
+void gabble_jingle_content_maybe_send_description (GabbleJingleContent *self);
+
gboolean gabble_jingle_content_handle_info (GabbleJingleContent *self,
LmMessageNode *session_info_payload,
gboolean *handled,
diff --git a/src/jingle-media-rtp.c b/src/jingle-media-rtp.c
index 1873a5f..b24c915 100644
--- a/src/jingle-media-rtp.c
+++ b/src/jingle-media-rtp.c
@@ -650,10 +650,6 @@ produce_description (GabbleJingleContent *obj, LmMessageNode *content_node)
for (; li != NULL; li = li->next)
produce_payload_type (desc_node, li->data, dialect);
-
- /* If we were updating, then we're done with the diff. */
- g_list_free (priv->local_codec_updates);
- priv->local_codec_updates = NULL;
}
/**
@@ -735,10 +731,12 @@ out:
return ret;
}
-/* Takes in a list of slice-allocated JingleCodec structs */
+/* Takes in a list of slice-allocated JingleCodec structs. Ready indicated
+ * whether the codecs can regarded as ready to sent from now on */
gboolean
jingle_media_rtp_set_local_codecs (GabbleJingleMediaRtp *self,
GList *codecs,
+ gboolean ready,
GError **error)
{
GabbleJingleMediaRtpPrivate *priv = self->priv;
@@ -750,9 +748,6 @@ jingle_media_rtp_set_local_codecs (GabbleJingleMediaRtp *self,
GList *changed = NULL;
GError *err = NULL;
- /* Calling _gabble_jingle_content_set_media_ready () should use and unset
- * these right after we set them.
- */
g_assert (priv->local_codec_updates == NULL);
if (!compare_codecs (priv->local_codecs, codecs, &changed, &err))
@@ -766,7 +761,7 @@ jingle_media_rtp_set_local_codecs (GabbleJingleMediaRtp *self,
{
DEBUG ("codec update changed nothing!");
jingle_media_rtp_free_codecs (codecs);
- return TRUE;
+ goto out;
}
DEBUG ("%u codecs changed", g_list_length (changed));
@@ -777,7 +772,17 @@ jingle_media_rtp_set_local_codecs (GabbleJingleMediaRtp *self,
priv->local_codecs = codecs;
- _gabble_jingle_content_set_media_ready (GABBLE_JINGLE_CONTENT (self));
+ /* Codecs have changed, sending a fresh description might be necessary */
+ gabble_jingle_content_maybe_send_description (GABBLE_JINGLE_CONTENT (self));
+
+ /* Update done if any, free the changed codecs if any */
+ g_list_free (priv->local_codec_updates);
+ priv->local_codec_updates = NULL;
+
+out:
+ if (ready)
+ _gabble_jingle_content_set_media_ready (GABBLE_JINGLE_CONTENT (self));
+
return TRUE;
}
diff --git a/src/jingle-media-rtp.h b/src/jingle-media-rtp.h
index f29dc3c..0c21c22 100644
--- a/src/jingle-media-rtp.h
+++ b/src/jingle-media-rtp.h
@@ -79,7 +79,7 @@ const gchar *gabble_jingle_media_rtp_parse (GabbleJingleMediaRtp *sess,
LmMessage *message, GError **error);
void jingle_media_rtp_register (GabbleJingleFactory *factory);
gboolean jingle_media_rtp_set_local_codecs (GabbleJingleMediaRtp *self,
- GList *codecs, GError **error);
+ GList *codecs, gboolean ready, GError **error);
GList *gabble_jingle_media_rtp_get_remote_codecs (GabbleJingleMediaRtp *self);
JingleCodec * jingle_media_rtp_codec_new (guint id, const gchar *name,
diff --git a/src/media-stream.c b/src/media-stream.c
index 2ea0ac9..2ed1c6c 100644
--- a/src/media-stream.c
+++ b/src/media-stream.c
@@ -1049,6 +1049,7 @@ gabble_media_stream_ready (TpSvcMediaStreamHandler *iface,
static gboolean
pass_local_codecs (GabbleMediaStream *stream,
const GPtrArray *codecs,
+ gboolean ready,
GError **error)
{
GabbleMediaStreamPrivate *priv = stream->priv;
@@ -1089,7 +1090,7 @@ pass_local_codecs (GabbleMediaStream *stream,
}
return jingle_media_rtp_set_local_codecs (
- GABBLE_JINGLE_MEDIA_RTP (priv->content), li, error);
+ GABBLE_JINGLE_MEDIA_RTP (priv->content), li, ready, error);
}
/**
@@ -1110,7 +1111,8 @@ gabble_media_stream_set_local_codecs (TpSvcMediaStreamHandler *iface,
if (gabble_jingle_content_is_created_by_us (self->priv->content))
{
- if (!pass_local_codecs (self, codecs, &error))
+ if (!pass_local_codecs (self, codecs, self->priv->created_locally,
+ &error))
{
DEBUG ("failed: %s", error->message);
@@ -1184,7 +1186,7 @@ gabble_media_stream_supported_codecs (TpSvcMediaStreamHandler *iface,
if (priv->awaiting_intersection)
{
- if (!pass_local_codecs (self, codecs, &error))
+ if (!pass_local_codecs (self, codecs, TRUE, &error))
{
DEBUG ("failed: %s", error->message);
@@ -1236,7 +1238,14 @@ gabble_media_stream_codecs_updated (TpSvcMediaStreamHandler *iface,
return;
}
- if (pass_local_codecs (self, codecs, &error))
+ if (self->priv->awaiting_intersection)
+ {
+ /* If we're awaiting the intersection ignore codecs updated */
+ tp_svc_media_stream_handler_return_from_codecs_updated (context);
+ return;
+ }
+
+ if (pass_local_codecs (self, codecs, self->priv->created_locally, &error))
{
tp_svc_media_stream_handler_return_from_codecs_updated (context);
}
--
1.5.6.5
More information about the telepathy-commits
mailing list