[Telepathy-commits] [telepathy-gabble/master] properly pass extra codec params between jingle and telepathy
Senko Rasic
senko at phyrexia.lan
Tue Dec 2 04:34:04 PST 2008
---
src/jingle-media-rtp.c | 38 +++++++++++++++++++------
src/jingle-media-rtp.h | 8 +++++
src/media-stream.c | 73 +----------------------------------------------
3 files changed, 39 insertions(+), 80 deletions(-)
diff --git a/src/jingle-media-rtp.c b/src/jingle-media-rtp.c
index 2fcd2bc..21a6431 100644
--- a/src/jingle-media-rtp.c
+++ b/src/jingle-media-rtp.c
@@ -64,13 +64,6 @@ typedef enum {
JINGLE_MEDIA_PROFILE_RTP_AVP,
} JingleMediaProfile;
-typedef struct {
- guchar id;
- gchar *name;
- guint clockrate;
- guint channels;
-} JingleCodec;
-
struct _GabbleJingleMediaRtpPrivate
{
GList *local_codecs;
@@ -98,6 +91,9 @@ _free_codecs (GList *codecs)
{
JingleCodec *p = (JingleCodec *) codecs->data;
+ if (p->params != NULL)
+ g_hash_table_destroy (p->params);
+
g_free (p->name);
g_slice_free (JingleCodec, p);
@@ -206,6 +202,10 @@ gabble_jingle_media_rtp_class_init (GabbleJingleMediaRtpClass *cls)
#define SET_OUT_ORDER(txt...) g_set_error (error, GABBLE_XMPP_ERROR, XMPP_ERROR_JINGLE_OUT_OF_ORDER, txt)
#define SET_CONFLICT(txt...) g_set_error (error, GABBLE_XMPP_ERROR, XMPP_ERROR_CONFLICT, txt)
+static const gchar *video_codec_params[] = {
+ "x", "y", "width", "height", "layer", "transparent", NULL,
+};
+
static void
parse_description (GabbleJingleContent *content,
LmMessageNode *desc_node, GError **error)
@@ -272,6 +272,7 @@ parse_description (GabbleJingleContent *content,
guchar id;
const gchar *name;
guint clockrate, channels;
+ guint i;
if (tp_strdiff (node->name, "payload-type"))
continue;
@@ -311,13 +312,20 @@ parse_description (GabbleJingleContent *content,
channels = 1;
}
- /* FIXME: do we need "bitrate" param? never seen it in use */
-
p = g_slice_new0 (JingleCodec);
p->id = id;
p->name = g_strdup (name);
p->clockrate = clockrate;
p->channels = channels;
+ p->params = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free);
+
+ for (i = 0; video_codec_params[i] != NULL; i++)
+ {
+ txt = lm_message_node_get_attribute (node, video_codec_params[i]);
+ if (txt != NULL)
+ g_hash_table_insert (p->params, (gpointer) video_codec_params[i],
+ g_strdup (txt));
+ }
DEBUG ("new remote codec: id = %u, name = %s, clockrate = %u, channels = %u",
p->id, p->name, p->clockrate, p->channels);
@@ -343,6 +351,13 @@ parse_description (GabbleJingleContent *content,
}
static void
+_produce_extra_param (gpointer key, gpointer value, gpointer user_data)
+{
+ lm_message_node_set_attribute ((LmMessageNode *) user_data,
+ (gchar *) key, (gchar *) value);
+}
+
+static void
produce_description (GabbleJingleContent *obj, LmMessageNode *content_node)
{
GabbleJingleMediaRtp *desc =
@@ -426,6 +441,11 @@ produce_description (GabbleJingleContent *obj, LmMessageNode *content_node)
sprintf (buf, "%u", p->channels);
lm_message_node_set_attribute (pt_node, "channels", buf);
}
+
+ if (p->params != NULL)
+ {
+ g_hash_table_foreach (p->params, _produce_extra_param, pt_node);
+ }
}
}
diff --git a/src/jingle-media-rtp.h b/src/jingle-media-rtp.h
index 4a9dc5a..970e2a2 100644
--- a/src/jingle-media-rtp.h
+++ b/src/jingle-media-rtp.h
@@ -60,6 +60,14 @@ struct _GabbleJingleMediaRtp {
GabbleJingleMediaRtpPrivate *priv;
};
+typedef struct {
+ guchar id;
+ gchar *name;
+ guint clockrate;
+ guint channels;
+ GHashTable *params;
+} JingleCodec;
+
const gchar *gabble_jingle_media_rtp_parse (GabbleJingleMediaRtp *sess,
LmMessage *message, GError **error);
void jingle_media_rtp_register (GabbleJingleFactory *factory);
diff --git a/src/media-stream.c b/src/media-stream.c
index 8f6fe94..209175c 100644
--- a/src/media-stream.c
+++ b/src/media-stream.c
@@ -570,13 +570,6 @@ gabble_media_stream_finalize (GObject *object)
G_OBJECT_CLASS (gabble_media_stream_parent_class)->finalize (object);
}
-typedef struct {
- guchar id;
- gchar *name;
- guint clockrate;
- guint channels;
-} JingleCodec;
-
/**
* gabble_media_stream_codec_choice
*
@@ -953,6 +946,7 @@ gabble_media_stream_set_local_codecs (TpSvcMediaStreamHandler *iface,
c->name = g_strdup (name);
c->clockrate = clock_rate;
c->channels = channels;
+ c->params = params;
DEBUG ("adding codec %s (%u %u %u)", c->name, c->id, c->clockrate, c->channels);
li = g_list_append (li, c);
@@ -1069,9 +1063,7 @@ new_remote_codecs_cb (GabbleJingleContent *content,
2, priv->media_type,
3, c->clockrate,
4, c->channels,
- /* FIXME: valgrind shows leak in g_hash_table_new_full - doesn't
- * dbus-glib free that? */
- 5, g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free),
+ 5, c->params,
G_MAXUINT);
g_ptr_array_add (codecs, g_value_get_boxed (&codec));
@@ -1277,67 +1269,6 @@ push_sending (GabbleMediaStream *stream)
stream, priv->sending);
}
-/*
- * oh sweet g_hash_table_foreach how beautiful thou be'st
- *
- * _\ / ^/
- * \/ \// 7_ __
- * ( 7 ) (__) (__)
- * ^\\ |/__/___/
- * \\/_/ | <-- TP-cable kindly provided by Mika N.
- * \ / O
- * || /|\
- * || / \
- * ||
- * ____||_____________
- */
-
-typedef struct {
- GabbleMediaStreamPrivate *priv;
- LmMessageNode *pt_node;
-} CodecParamsFromTpContext;
-
-#if 0
-static const gchar *video_codec_params[] = {
- "x", "y", "width", "height", "layer", "transparent",
-};
-
-// FIXME - we need to have extended params for video stream
-static void
-codec_params_from_tp_foreach (gpointer key, gpointer value, gpointer user_data)
-{
- CodecParamsFromTpContext *ctx = user_data;
- GabbleMediaStreamPrivate *priv = ctx->priv;
- const gchar *pname = key, *pvalue = value;
-
- if (priv->media_type == TP_MEDIA_STREAM_TYPE_AUDIO)
- {
- if (priv->mode == MODE_GOOGLE && strcmp (pname, "bitrate") == 0)
- {
- lm_message_node_set_attribute (ctx->pt_node, pname, pvalue);
- return;
- }
- }
- else if (priv->mode == MODE_JINGLE)
- {
- gint i;
-
- for (i = 0; video_codec_params[i] != NULL; i++)
- {
- if (strcmp (pname, video_codec_params[i]) == 0)
- {
- lm_message_node_set_attribute (ctx->pt_node, pname, pvalue);
- return;
- }
- }
- }
-
- DEBUG ("ignoring %s=%s for %s %s stream", pname, pvalue,
- (priv->mode == MODE_JINGLE) ? "jingle" : "google",
- (priv->media_type == TP_MEDIA_STREAM_TYPE_AUDIO) ? "audio" : "video");
-}
-#endif
-
static void
content_senders_changed_cb (GabbleJingleContent *c,
GParamSpec *pspec,
--
1.5.6.5
More information about the Telepathy-commits
mailing list