summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2012-02-17 11:56:35 +0000
committerWill Thompson <will.thompson@collabora.co.uk>2012-02-23 12:46:24 +0000
commit51ec259c494d42c30adfb982646eda2805b2ec3d (patch)
tree5ca383b0c92e503c1bb64f3055d01c59bbb6feac
parent729d3f4f06eba69e499805b004383aba521c7a35 (diff)
JingleMediaRtp: drop use of TP_ERRORS
Depending on whether an illegal codec update comes from the network or from the local system, we end up wanting either a WOCKY_XMPP_ERROR or a TP_ERROR (to throw back over the wire or in a D-Bus method error, respectively). Previously, this choice was made inside JingleMediaRtp; this patch moves the conversion out to GabbleMediaStream. (The Call codepaths all pass NULL for the GError **... great.)
-rw-r--r--src/jingle-media-rtp.c27
-rw-r--r--src/media-stream.c11
2 files changed, 28 insertions, 10 deletions
diff --git a/src/jingle-media-rtp.c b/src/jingle-media-rtp.c
index bb586b0fa..20e83a3d1 100644
--- a/src/jingle-media-rtp.c
+++ b/src/jingle-media-rtp.c
@@ -591,10 +591,11 @@ parse_rtp_header_extension (WockyNode *node)
static gboolean
codec_update_coherent (const JingleCodec *old_c,
const JingleCodec *new_c,
- GQuark domain,
- gint code,
GError **e)
{
+ const GQuark domain = WOCKY_XMPP_ERROR;
+ const gint code = WOCKY_XMPP_ERROR_BAD_REQUEST;
+
if (old_c == NULL)
{
g_set_error (e, domain, code, "Codec with id %u ('%s') unknown",
@@ -658,8 +659,7 @@ update_remote_media_description (GabbleJingleMediaRtp *self,
new_c = l->data;
old_c = g_hash_table_lookup (rc, GUINT_TO_POINTER ((guint) new_c->id));
- if (!codec_update_coherent (old_c, new_c, WOCKY_XMPP_ERROR,
- WOCKY_XMPP_ERROR_BAD_REQUEST, &e))
+ if (!codec_update_coherent (old_c, new_c, &e))
goto out;
}
@@ -1174,8 +1174,7 @@ jingle_media_rtp_compare_codecs (GList *old,
old_c = g_hash_table_lookup (old_table, GUINT_TO_POINTER (
(guint) new_c->id));
- if (!codec_update_coherent (old_c, new_c, TP_ERRORS,
- TP_ERROR_INVALID_ARGUMENT, e))
+ if (!codec_update_coherent (old_c, new_c, e))
goto out;
if (!string_string_maps_equal (old_c->params, new_c->params))
@@ -1195,8 +1194,20 @@ out:
return ret;
}
-/* Takes in a list of slice-allocated JingleCodec structs. Ready indicated
- * whether the codecs can regarded as ready to sent from now on */
+/*
+ * @self: a content in an RTP session
+ * @md: (transfer full): new media description for this content
+ * @ready: whether the codecs can regarded as ready to sent from now on
+ * @error: used to return a %WOCKY_XMPP_ERROR if the codec update is illegal.
+ *
+ * Sets or updates the media description (codecs, feedback messages, etc) for
+ * @self.
+ *
+ * Returns: %TRUE if no description was previously set, or if the update is
+ * compatible with the existing description; %FALSE if the update is illegal
+ * (due to adding previously-unknown codecs or renaming an existing codec, for
+ * example)
+ */
gboolean
jingle_media_rtp_set_local_media_description (GabbleJingleMediaRtp *self,
JingleMediaDescription *md,
diff --git a/src/media-stream.c b/src/media-stream.c
index c2b9f9b6d..75c9ea38f 100644
--- a/src/media-stream.c
+++ b/src/media-stream.c
@@ -1046,6 +1046,7 @@ pass_local_codecs (GabbleMediaStream *stream,
JingleMediaDescription *md;
const GPtrArray *hdrexts;
GHashTable *fbs;
+ GError *wocky_error = NULL;
DEBUG ("putting list of %d supported codecs from stream-engine into cache",
codecs->len);
@@ -1193,8 +1194,14 @@ pass_local_codecs (GabbleMediaStream *stream,
jingle_media_description_simplify (md);
- return jingle_media_rtp_set_local_media_description (
- GABBLE_JINGLE_MEDIA_RTP (priv->content), md, ready, error);
+ if (jingle_media_rtp_set_local_media_description (
+ GABBLE_JINGLE_MEDIA_RTP (priv->content), md, ready, &wocky_error))
+ return TRUE;
+
+ g_set_error_literal (error, TP_ERRORS, TP_ERROR_INVALID_ARGUMENT,
+ wocky_error->message);
+ g_clear_error (&wocky_error);
+ return FALSE;
}
/**