changeset 31517:a4ba3b194ce3

media: Allow setting SDES properties of RTP conferences. Fixes #12981. committer: John Bailey <rekkanoryo@rekkanoryo.org>
author jakub.adam@ktknet.cz
date Mon, 02 May 2011 03:23:23 +0000
parents 28144269b283
children 76595d4edf86
files libpurple/media.c libpurple/media.h libpurple/media/backend-fs2.c libpurple/media/backend-iface.c libpurple/media/backend-iface.h
diffstat 5 files changed, 180 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/media.c	Mon May 02 03:14:29 2011 +0000
+++ b/libpurple/media.c	Mon May 02 03:23:23 2011 +0000
@@ -916,6 +916,47 @@
 #endif
 }
 
+void
+purple_media_set_params(PurpleMedia *media,
+		guint num_params, GParameter *params)
+{
+#ifdef USE_VV
+	g_return_if_fail(PURPLE_IS_MEDIA(media));
+
+	purple_media_backend_set_params(media->priv->backend, num_params, params);
+#endif
+}
+
+const gchar **
+purple_media_get_available_params(PurpleMedia *media)
+{
+	static const gchar *NULL_ARRAY[] = { NULL };
+#ifdef USE_VV
+	g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL_ARRAY);
+
+	return purple_media_backend_get_available_params(media->priv->backend);
+#else
+	return NULL_ARRAY;
+#endif
+}
+
+gboolean
+purple_media_param_is_supported(PurpleMedia *media, const gchar *param)
+{
+#ifdef USE_VV
+	const gchar **params;
+
+	g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE);
+	g_return_val_if_fail(param != NULL, FALSE);
+
+	params = purple_media_backend_get_available_params(media->priv->backend);
+	for (; *params != NULL; ++params)
+		if (!strcmp(*params, param))
+			return TRUE;
+#endif
+	return FALSE;
+}
+
 #ifdef USE_VV
 static void
 purple_media_new_local_candidate_cb(PurpleMediaBackend *backend,
--- a/libpurple/media.h	Mon May 02 03:14:29 2011 +0000
+++ b/libpurple/media.h	Mon May 02 03:23:23 2011 +0000
@@ -144,6 +144,52 @@
 		gboolean local);
 
 /**
+ * Sets various optional parameters of the media call.
+ *
+ * Currently supported are:
+ *   - "sdes-cname"    : The CNAME for the RTP sessions
+ *   - "sdes-name"     : Real name used to describe the source in SDES messages
+ *   - "sdes-tool"     : The TOOL to put in SDES messages
+ *   - "sdes-email"    : Email address to put in SDES messages
+ *   - "sdes-location" : The LOCATION to put in SDES messages
+ *   - "sdes-note"     : The NOTE to put in SDES messages
+ *   - "sdes-phone"    : The PHONE to put in SDES messages
+ *
+ * @param media The media object to set the parameters on.
+ * @param num_params The number of parameters to pass
+ * @param params Array of @c GParameter to pass
+ *
+ * @since 2.8.0
+ */
+void purple_media_set_params(PurpleMedia *media,
+		guint num_params, GParameter *params);
+
+/**
+ * Gets the list of optional parameters supported by the media backend.
+ *
+ * The list is owned by the @c PurpleMedia internals and should NOT be freed.
+ *
+ * @param media The media object
+ *
+ * @return NULL-terminated array of names of supported parameters.
+ *
+ * @since 2.8.0
+ */
+const gchar **purple_media_get_available_params(PurpleMedia *media);
+
+/**
+ * Checks if given optional parameter is supported by the media backend.
+ *
+ * @param media The media object
+ * @param param name of parameter
+ *
+ * @return @c TRUE if backend recognizes the parameter, @c FALSE otherwise.
+ *
+ * @since 2.8.0
+ */
+gboolean purple_media_param_is_supported(PurpleMedia *media, const gchar *param);
+
+/**
  * Adds a stream to a session.
  *
  * It only adds a stream to one audio session or video session as
--- a/libpurple/media/backend-fs2.c	Mon May 02 03:14:29 2011 +0000
+++ b/libpurple/media/backend-fs2.c	Mon May 02 03:23:23 2011 +0000
@@ -85,6 +85,9 @@
 static gboolean purple_media_backend_fs2_set_send_codec(
 		PurpleMediaBackend *self, const gchar *sess_id,
 		PurpleMediaCodec *codec);
+static void purple_media_backend_fs2_set_params(PurpleMediaBackend *self,
+		guint num_params, GParameter *params);
+static const gchar **purple_media_backend_fs2_get_available_params(void);
 
 static void free_stream(PurpleMediaBackendFs2Stream *stream);
 static void free_session(PurpleMediaBackendFs2Session *session);
@@ -413,6 +416,8 @@
 			purple_media_backend_fs2_get_local_candidates;
 	iface->set_remote_codecs = purple_media_backend_fs2_set_remote_codecs;
 	iface->set_send_codec = purple_media_backend_fs2_set_send_codec;
+	iface->set_params = purple_media_backend_fs2_set_params;
+	iface->get_available_params = purple_media_backend_fs2_get_available_params;
 }
 
 static FsMediaType
@@ -2126,6 +2131,49 @@
 
 	return TRUE;
 }
+
+static void
+purple_media_backend_fs2_set_params(PurpleMediaBackend *self,
+		guint num_params, GParameter *params)
+{
+	PurpleMediaBackendFs2Private *priv;
+	const gchar **supported = purple_media_backend_fs2_get_available_params();
+	const gchar **p;
+	guint i;
+
+	g_return_if_fail(PURPLE_IS_MEDIA_BACKEND_FS2(self));
+
+	priv = PURPLE_MEDIA_BACKEND_FS2_GET_PRIVATE(self);
+
+	if (priv->conference == NULL &&
+		!init_conference(PURPLE_MEDIA_BACKEND_FS2(self))) {
+		purple_debug_error("backend-fs2",
+				"Error initializing the conference.\n");
+		return;
+	}
+
+	for (i = 0; i != num_params; ++i) {
+		for (p = supported; *p != NULL; ++p) {
+			if (!strcmp(params[i].name, *p)) {
+				g_object_set(priv->conference,
+						params[i].name, g_value_get_string(&params[i].value),
+						NULL);
+				break;
+			}
+		}
+	}
+}
+
+static const gchar **
+purple_media_backend_fs2_get_available_params(void)
+{
+	static const gchar *supported_params[] = {
+		"sdes-cname", "sdes-email", "sdes-location", "sdes-name", "sdes-note",
+		"sdes-phone", "sdes-tool", NULL
+	};
+
+	return supported_params;
+}
 #else
 GType
 purple_media_backend_fs2_get_type(void)
--- a/libpurple/media/backend-iface.c	Mon May 02 03:14:29 2011 +0000
+++ b/libpurple/media/backend-iface.c	Mon May 02 03:23:23 2011 +0000
@@ -192,3 +192,20 @@
 	return PURPLE_MEDIA_BACKEND_GET_INTERFACE(self)->set_send_codec(self,
 			sess_id, codec);
 }
+
+void
+purple_media_backend_set_params(PurpleMediaBackend *self,
+		guint num_params, GParameter *params)
+{
+	g_return_if_fail(PURPLE_IS_MEDIA_BACKEND(self));
+	PURPLE_MEDIA_BACKEND_GET_INTERFACE(self)->set_params(self, num_params, params);
+}
+
+const gchar **
+purple_media_backend_get_available_params(PurpleMediaBackend *self)
+{
+	static const gchar *NULL_ARRAY[] = { NULL };
+
+	g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND(self), NULL_ARRAY);
+	return PURPLE_MEDIA_BACKEND_GET_INTERFACE(self)->get_available_params();
+}
--- a/libpurple/media/backend-iface.h	Mon May 02 03:14:29 2011 +0000
+++ b/libpurple/media/backend-iface.h	Mon May 02 03:23:23 2011 +0000
@@ -68,6 +68,9 @@
 		GList *codecs);
 	gboolean (*set_send_codec) (PurpleMediaBackend *self,
 		const gchar *sess_id, PurpleMediaCodec *codec);
+	void (*set_params) (PurpleMediaBackend *self,
+		guint num_params, GParameter *params);
+	const gchar **(*get_available_params) (void);
 };
 
 /**
@@ -191,6 +194,31 @@
 gboolean purple_media_backend_set_send_codec(PurpleMediaBackend *self,
 		const gchar *sess_id, PurpleMediaCodec *codec);
 
+/**
+ * Sets various optional parameters of the media backend.
+ *
+ * @param self The media backend to set the parameters on.
+ * @param num_params The number of parameters to pass to backend
+ * @param params Array of @c GParameter to pass to backend
+ *
+ * @since 2.8.0
+ */
+void purple_media_backend_set_params(PurpleMediaBackend *self,
+		guint num_params, GParameter *params);
+
+/**
+ * Gets the list of optional parameters supported by the media backend.
+ *
+ * The list should NOT be freed.
+ *
+ * @param self The media backend
+ *
+ * @return NULL-terminated array of names of supported parameters.
+ *
+ * @since 2.8.0
+ */
+const gchar **purple_media_backend_get_available_params(PurpleMediaBackend *self);
+
 G_END_DECLS
 
 #endif /* _MEDIA_BACKEND_IFACE_H_ */