[Telepathy-commits] [telepathy-gabble/master] Factor extract_media_type out of parse_description
Will Thompson
will.thompson at collabora.co.uk
Thu Feb 26 09:43:51 PST 2009
---
src/jingle-media-rtp.c | 82 +++++++++++++++++++++++++-----------------------
1 files changed, 43 insertions(+), 39 deletions(-)
diff --git a/src/jingle-media-rtp.c b/src/jingle-media-rtp.c
index d98d5e8..98739c8 100644
--- a/src/jingle-media-rtp.c
+++ b/src/jingle-media-rtp.c
@@ -224,18 +224,10 @@ gabble_jingle_media_rtp_class_init (GabbleJingleMediaRtpClass *cls)
#define SET_CONFLICT(txt...) g_set_error (error, GABBLE_XMPP_ERROR, XMPP_ERROR_CONFLICT, txt)
-static void
-parse_description (GabbleJingleContent *content,
- LmMessageNode *desc_node, GError **error)
+static JingleMediaType
+extract_media_type (LmMessageNode *desc_node,
+ GError **error)
{
- GabbleJingleMediaRtp *self = GABBLE_JINGLE_MEDIA_RTP (content);
- GabbleJingleMediaRtpPrivate *priv = self->priv;
- JingleMediaType mtype = JINGLE_MEDIA_TYPE_NONE;
- GList *codecs = NULL;
- LmMessageNode *node;
-
- DEBUG ("node: %s", desc_node->name);
-
if (lm_message_node_has_namespace (desc_node, NS_JINGLE_RTP, NULL))
{
const gchar *type = lm_message_node_get_attribute (desc_node, "media");
@@ -243,41 +235,53 @@ parse_description (GabbleJingleContent *content,
if (type == NULL)
{
SET_BAD_REQ("missing required media type attribute");
- return;
+ return JINGLE_MEDIA_TYPE_NONE;
}
if (!tp_strdiff (type, "audio"))
- mtype = JINGLE_MEDIA_TYPE_AUDIO;
- else if (!tp_strdiff (type, "video"))
- mtype = JINGLE_MEDIA_TYPE_VIDEO;
- else
- {
- SET_BAD_REQ("unknown media type %s", type);
- return;
- }
+ return JINGLE_MEDIA_TYPE_AUDIO;
+
+ if (!tp_strdiff (type, "video"))
+ return JINGLE_MEDIA_TYPE_VIDEO;
+
+ SET_BAD_REQ("unknown media type %s", type);
+ return JINGLE_MEDIA_TYPE_NONE;
}
- else if (lm_message_node_has_namespace (desc_node,
+
+ if (lm_message_node_has_namespace (desc_node,
NS_JINGLE_DESCRIPTION_AUDIO, NULL))
- {
- mtype = JINGLE_MEDIA_TYPE_AUDIO;
- }
- else if (lm_message_node_has_namespace (desc_node,
+ return JINGLE_MEDIA_TYPE_AUDIO;
+
+ if (lm_message_node_has_namespace (desc_node,
NS_JINGLE_DESCRIPTION_VIDEO, NULL))
- {
- mtype = JINGLE_MEDIA_TYPE_VIDEO;
- }
- else if (lm_message_node_has_namespace (desc_node,
+ return JINGLE_MEDIA_TYPE_VIDEO;
+
+ if (lm_message_node_has_namespace (desc_node,
NS_GOOGLE_SESSION_PHONE, NULL))
- {
- mtype = JINGLE_MEDIA_TYPE_AUDIO;
- }
- else
- {
- /* If we get here, namespace in use is not one of
- * namespaces we signed up with, so obviously a bug
- * somewhere. */
- g_assert_not_reached ();
- }
+ return JINGLE_MEDIA_TYPE_AUDIO;
+
+ /* If we get here, namespace in use is not one of namespaces we signed up
+ * with, so obviously a bug somewhere.
+ */
+ g_assert_not_reached ();
+}
+
+static void
+parse_description (GabbleJingleContent *content,
+ LmMessageNode *desc_node, GError **error)
+{
+ GabbleJingleMediaRtp *self = GABBLE_JINGLE_MEDIA_RTP (content);
+ GabbleJingleMediaRtpPrivate *priv = self->priv;
+ JingleMediaType mtype = JINGLE_MEDIA_TYPE_NONE;
+ GList *codecs = NULL;
+ LmMessageNode *node;
+
+ DEBUG ("node: %s", desc_node->name);
+
+ mtype = extract_media_type (desc_node, error);
+
+ if (mtype == JINGLE_MEDIA_TYPE_NONE)
+ return;
DEBUG ("detected media type %u", mtype);
--
1.5.6.5
More information about the telepathy-commits
mailing list