[farsight2/master] Add set_local_codecs_config to the python bindings

Olivier Crête olivier.crete at collabora.co.uk
Tue Dec 23 15:22:22 PST 2008


---
 python/pyfarsight.defs     |   10 ++++++++
 python/pyfarsight.override |   53 ++++++++++++++++++++++++++++++++++++++++++++
 tests/gui/fs2-gui.py       |    4 +-
 3 files changed, 65 insertions(+), 2 deletions(-)

diff --git a/python/pyfarsight.defs b/python/pyfarsight.defs
index 73bd017..dfb2724 100644
--- a/python/pyfarsight.defs
+++ b/python/pyfarsight.defs
@@ -372,6 +372,16 @@
   )
 )
 
+(define-method set_local_codecs_config
+  (of-object "FsSession")
+  (c-name "fs_session_set_local_codecs_config")
+  (return-type "gboolean")
+  (parameters
+    '("GList*" "local_codecs_config")
+    '("GError**" "error")
+  )
+)
+
 (define-method emit_error
   (of-object "FsSession")
   (c-name "fs_session_emit_error")
diff --git a/python/pyfarsight.override b/python/pyfarsight.override
index 680f7aa..fd451c1 100644
--- a/python/pyfarsight.override
+++ b/python/pyfarsight.override
@@ -624,3 +624,56 @@ _wrap_fs_stream_set_remote_codecs (PyGObject *self, PyObject *arg)
   return PyBool_FromLong (ret);
 }
 %%
+override fs_session_set_local_codecs_config onearg
+static PyObject *
+_wrap_fs_session_set_local_codecs_config (PyGObject *self, PyObject *arg)
+{
+  gboolean ret = FALSE;
+  GError *error = NULL;
+  GList *codecs = NULL;
+  int i;
+
+  if (arg == Py_None)
+    goto none;
+
+  if (!PySequence_Check (arg))
+  {
+    PyErr_SetString (PyExc_TypeError,
+        "The parameter must be a List of FsCodec or None");
+    return NULL;
+  }
+
+  for (i = 0; i < PySequence_Size (arg); i++)
+  {
+    PyObject *item = PySequence_GetItem (arg, i);
+
+    if (!pyg_boxed_check (item, FS_TYPE_CODEC))
+    {
+      PyErr_SetString(PyExc_TypeError,
+          "The parameter must be a List of FsCodec");
+      return NULL;
+    }
+  }
+
+  for (i = 0; i < PySequence_Size (arg); i++)
+  {
+    PyObject *item = PySequence_GetItem (arg, i);
+
+    codecs = g_list_append (codecs, pyg_boxed_get (item, FsCodec));
+  }
+
+none:
+
+  Py_BEGIN_ALLOW_THREADS
+  ret = fs_session_set_local_codecs_config (FS_SESSION(self->obj), codecs,
+      &error);
+  Py_END_ALLOW_THREADS
+
+  g_list_free (codecs);
+
+  if (pyg_error_check(&error))
+    return NULL;
+
+  return PyBool_FromLong (ret);
+}
+%%
diff --git a/tests/gui/fs2-gui.py b/tests/gui/fs2-gui.py
index f86ed09..7709266 100644
--- a/tests/gui/fs2-gui.py
+++ b/tests/gui/fs2-gui.py
@@ -327,7 +327,7 @@ class FsUISession:
             # We don't know if the others do work
             # We know H264 doesn't work for now or anything else
             # that needs to send config data
-            self.fssession.set_property("local-codecs-config",
+            self.fssession.set_local_codecs_config(
                                         [farsight.Codec(farsight.CODEC_ID_ANY,
                                                       "H264",
                                                       farsight.MEDIA_TYPE_VIDEO,
@@ -341,7 +341,7 @@ class FsUISession:
                                                      farsight.MEDIA_TYPE_VIDEO,
                                                      0)])
         elif source.get_type() == farsight.MEDIA_TYPE_AUDIO:
-            self.fssession.set_property("local-codecs-config",
+            self.fssession.set_local_codecs_config(
                                       [farsight.Codec(farsight.CODEC_ID_ANY,
                                                       "PCMA",
                                                       farsight.MEDIA_TYPE_AUDIO,
-- 
1.5.6.5




More information about the farsight-commits mailing list