summaryrefslogtreecommitdiff
path: root/farstream
diff options
context:
space:
mode:
authorOlivier CrĂȘte <olivier.crete@collabora.com>2013-01-11 19:47:42 -0500
committerOlivier CrĂȘte <olivier.crete@collabora.com>2013-03-26 14:50:24 -0400
commit2c19591ca948fc302508b2afbdd232b219d92e2a (patch)
treeff9c2db12bd5c535c6d4f7871881175474f4c9f3 /farstream
parent77df96b6b6fad5aac69dc73c06816d050f60a735 (diff)
downloadfarstream-2c19591ca948fc302508b2afbdd232b219d92e2a.tar.gz
session: Add API to set the transmitter parameters as a GHashTable
Diffstat (limited to 'farstream')
-rw-r--r--farstream/fs-stream.c99
-rw-r--r--farstream/fs-stream.h5
2 files changed, 104 insertions, 0 deletions
diff --git a/farstream/fs-stream.c b/farstream/fs-stream.c
index cde69c25..c81e8788 100644
--- a/farstream/fs-stream.c
+++ b/farstream/fs-stream.c
@@ -648,6 +648,105 @@ fs_stream_set_transmitter (FsStream *stream,
}
/**
+ * fs_stream_set_transmitter_ht:
+ * @stream: a #FsStream
+ * @transmitter: Name of the type of transmitter to use for this stream
+ * @stream_transmitter_parameters: (element-type utf8 GValue) (allow-none):
+ * A #GHashTable of <String->GValue) containing the parameters.
+ * @error: location of a #GError, or %NULL if no error occured
+ *
+ * Set the transmitter to use for this stream. This function will only succeed
+ * once.
+ *
+ * The parameters correspond to the varios GObject properties of the
+ * selected stream transmitter.
+ *
+ * This is the same as fs_stream_set_transmitter() except that the parameters
+ * are passed in a #GHashTable to make it more friendly to GObject introspection
+ *
+ * Returns: %TRUE if the transmitter could be set, %FALSE otherwise
+ */
+gboolean fs_stream_set_transmitter_ht (FsStream *stream,
+ const gchar *transmitter,
+ GHashTable *stream_transmitter_parameters,
+ GError **error)
+{
+ GParameter *params = NULL;
+ gboolean ret = FALSE;
+ guint n_params = 0;
+ guint i = 0;
+
+ if (stream_transmitter_parameters &&
+ g_hash_table_size (stream_transmitter_parameters) != 0)
+ {
+ FsSession *session = NULL;
+ GType st_type;
+ GObjectClass *st_class = NULL;
+ GHashTableIter iter;
+ gpointer key, value;
+
+ n_params = g_hash_table_size (stream_transmitter_parameters);
+
+ g_object_get (stream, "session", &session, NULL);
+
+ if (!session) {
+ g_set_error_literal (error, FS_ERROR, FS_ERROR_DISPOSED,
+ "Stream has already been disposed");
+ return FALSE;
+ }
+
+ st_type = fs_session_get_stream_transmitter_type (session,
+ transmitter);
+ g_object_unref (session);
+
+ if (st_type == 0) {
+ g_set_error (error, FS_ERROR, FS_ERROR_INVALID_ARGUMENTS,
+ "Unknown transmitter: %s", transmitter);
+ return FALSE;
+ }
+
+ params = g_new0 (GParameter, n_params);
+ st_class = g_type_class_ref (st_type);
+
+ g_hash_table_iter_init (&iter, stream_transmitter_parameters);
+ while (g_hash_table_iter_next (&iter, &key, &value)) {
+ GParamSpec *spec;
+ gchar *name = key;
+ const GValue *v = value;
+
+ spec = g_object_class_find_property (st_class, name);
+
+ if (!spec) {
+ g_set_error (error, FS_ERROR, FS_ERROR_INVALID_ARGUMENTS,
+ "Unknown argument %s for transmitter %s", name, transmitter);
+ goto end;
+ }
+
+ params[i].name = name;
+ g_value_init (&params[i].value, G_PARAM_SPEC_VALUE_TYPE(spec));
+ if (!g_value_transform (v, &params[i].value)) {
+ g_set_error (error, FS_ERROR, FS_ERROR_INVALID_ARGUMENTS,
+ "Invalid type of argument %s for transmitter %s",
+ name, transmitter);
+ goto end;
+ }
+ i++;
+ }
+ }
+
+ ret = fs_stream_set_transmitter (stream, transmitter, params, n_params,
+ error);
+
+end:
+
+ for (i = 0; i < n_params; i++)
+ g_value_unset (&params[i].value);
+ g_free (params);
+
+ return ret;
+}
+
+/**
* fs_stream_destroy:
* @stream: a #FsStream
*
diff --git a/farstream/fs-stream.h b/farstream/fs-stream.h
index a3c82158..5239fddf 100644
--- a/farstream/fs-stream.h
+++ b/farstream/fs-stream.h
@@ -185,6 +185,11 @@ gboolean fs_stream_set_transmitter (FsStream *stream,
guint stream_transmitter_n_parameters,
GError **error);
+gboolean fs_stream_set_transmitter_ht (FsStream *stream,
+ const gchar *transmitter,
+ GHashTable *stream_transmitter_parameters,
+ GError **error);
+
void fs_stream_destroy (FsStream *stream);
gboolean fs_stream_parse_new_local_candidate (FsStream *stream,