summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier CrĂȘte <olivier.crete@collabora.com>2012-02-20 18:22:15 (GMT)
committerOlivier CrĂȘte <olivier.crete@collabora.com>2012-02-20 18:22:15 (GMT)
commitb355218252fc5a5cf7d7ef954e91e3225ad354b0 (patch)
tree6aeb936d16c2f3686d9207e82e73b0b829bb0bfe
parent2ff161461abfefe2370d70c22ed86126d9225531 (diff)
downloadfarstream-b355218252fc5a5cf7d7ef954e91e3225ad354b0.tar.gz
farstream-b355218252fc5a5cf7d7ef954e91e3225ad354b0.tar.xz
Add override for fs_stream_set_transmitter
-rw-r--r--python/example.py3
-rw-r--r--python/pyfarstream.override109
2 files changed, 111 insertions, 1 deletions
diff --git a/python/example.py b/python/example.py
index a8a94da..9960409 100644
--- a/python/example.py
+++ b/python/example.py
@@ -11,7 +11,8 @@ pipeline.add (conference)
session = conference.new_session (farstream.MEDIA_TYPE_VIDEO)
participant = conference.new_participant ()
-stream = session.new_stream (participant, farstream.DIRECTION_BOTH, "multicast")
+stream = session.new_stream (participant, farstream.DIRECTION_BOTH)
+stream.set_transmitter("multicast")
stream.set_remote_codecs([farstream.Codec(96, "H263-1998",
farstream.MEDIA_TYPE_VIDEO,
diff --git a/python/pyfarstream.override b/python/pyfarstream.override
index 8a3d7fc..e3bd291 100644
--- a/python/pyfarstream.override
+++ b/python/pyfarstream.override
@@ -862,3 +862,112 @@ _wrap_fs_stream_force_remote_candidates (PyGObject *self, PyObject *arg)
return PyBool_FromLong (ret);
}
%%
+override fs_stream_set_transmitter kwargs
+static PyObject *
+_wrap_fs_stream_set_transmitter(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ static char *kwlist[] = {"transmitter", "transmitter_parameters", NULL};
+ const gchar *transmitter_name = NULL;
+ PyObject *st_params = NULL;
+ Py_ssize_t pos = 0, i = 0;
+ PyObject *key, *value;
+ GObjectClass *st_class = NULL;
+ GError *error = NULL;
+ FsSession *session = NULL;
+ guint n_parameters = 0;
+ GParameter *parameters = NULL;
+ gboolean ret = FALSE;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "z|O!:FsStream.set_transmitter",
+ kwlist,
+ &transmitter_name,
+ &PyDict_Type, &st_params))
+ return NULL;
+
+ if (!transmitter_name)
+ return NULL;
+
+ if (st_params)
+ {
+ GType st_type = 0;
+
+ Py_BEGIN_ALLOW_THREADS
+ g_object_get (pygobject_get (self), "session", &session, NULL);
+ st_type = fs_session_get_stream_transmitter_type (
+ FS_SESSION (pygobject_get (self)), transmitter_name);
+ g_object_unref (session);
+ Py_END_ALLOW_THREADS
+
+ if (!st_type)
+ goto error;
+
+ st_class = g_type_class_ref (st_type);
+
+ n_parameters = PyDict_Size (st_params);
+ parameters = g_new0 (GParameter, n_parameters);
+ while (PyDict_Next(st_params, &pos, &key, &value))
+ {
+ GParamSpec *spec;
+
+ if (!PyString_Check (key))
+ {
+ PyErr_SetString (PyExc_TypeError,
+ "Expected Stream Parameter key to be a string");
+ goto error;
+ }
+
+ spec = g_object_class_find_property (st_class, PyString_AsString (key));
+
+ if (!spec)
+ {
+ PyErr_Format (PyExc_TypeError, "Received unknown key %s",
+ PyString_AsString (key));
+ goto error;
+ }
+
+ g_value_init (&parameters[i].value, G_PARAM_SPEC_VALUE_TYPE(spec));
+
+ parameters[i].name = PyString_AsString (key);
+
+ if (pyg_value_from_pyobject (&parameters[i].value , value) < 0)
+ {
+ PyErr_Format (PyExc_TypeError, "Expected parameter %s to be a %s",
+ PyString_AsString (key),
+ g_type_name (G_PARAM_SPEC_VALUE_TYPE(spec)));
+ goto error;
+ }
+
+ i++;
+ }
+ }
+
+ Py_BEGIN_ALLOW_THREADS
+ ret = fs_stream_set_transmitter (FS_STREAM (pygobject_get (self)),
+ transmitter_name, parameters, n_parameters, &error);
+ Py_END_ALLOW_THREADS
+
+ if (!ret)
+ goto error;
+
+ if (parameters)
+ {
+ g_type_class_unref (st_class);
+ g_free (parameters);
+ }
+
+ return PyBool_FromLong (ret);
+
+ error:
+ if (error)
+ pyg_error_check (&error);
+
+ if (st_class)
+ g_type_class_unref (st_class);
+ if (parameters)
+ g_free (parameters);
+
+ return PyBool_FromLong (ret);
+}
+%%