mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-02 12:32:29 +00:00
gst/: deprecate add_many/remove_many, fold into add/remove
Original commit message from CVS: * gst/gst.defs: * gst/gst.override: * gst/gstbin.override: deprecate add_many/remove_many, fold into add/remove * gst/gstmodule.c: (init_gst): add AddError and RemoveError * testsuite/Makefile.am: remove fatal warnings, until we can wrap log handlers and catch our expected add/remove errors * testsuite/test_bin.py: add tests for new add/remove semantics * testsuite/test_pad.py: * testsuite/test_pipeline.py: fix up
This commit is contained in:
parent
e6a5b6d2df
commit
58c3c18b93
9 changed files with 124 additions and 25 deletions
17
ChangeLog
17
ChangeLog
|
@ -1,3 +1,20 @@
|
||||||
|
2005-09-30 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||||
|
|
||||||
|
* gst/gst.defs:
|
||||||
|
* gst/gst.override:
|
||||||
|
* gst/gstbin.override:
|
||||||
|
deprecate add_many/remove_many, fold into add/remove
|
||||||
|
* gst/gstmodule.c: (init_gst):
|
||||||
|
add AddError and RemoveError
|
||||||
|
* testsuite/Makefile.am:
|
||||||
|
remove fatal warnings, until we can wrap log handlers
|
||||||
|
and catch our expected add/remove errors
|
||||||
|
* testsuite/test_bin.py:
|
||||||
|
add tests for new add/remove semantics
|
||||||
|
* testsuite/test_pad.py:
|
||||||
|
* testsuite/test_pipeline.py:
|
||||||
|
fix up
|
||||||
|
|
||||||
2005-09-29 Johan Dahlin <johan@gnome.org>
|
2005-09-29 Johan Dahlin <johan@gnome.org>
|
||||||
|
|
||||||
* gst/gstelement.override (_wrap_gst_element_get_state): return an
|
* gst/gstelement.override (_wrap_gst_element_get_state): return an
|
||||||
|
|
37
gst/gst.defs
37
gst/gst.defs
|
@ -70,10 +70,21 @@
|
||||||
(define-method add
|
(define-method add
|
||||||
(of-object "GstBin")
|
(of-object "GstBin")
|
||||||
(c-name "gst_bin_add")
|
(c-name "gst_bin_add")
|
||||||
(return-type "gboolean")
|
(return-type "none")
|
||||||
(parameters
|
(parameters
|
||||||
'("GstElement*" "element")
|
'("GstElement*" "element_1")
|
||||||
)
|
)
|
||||||
|
(varargs #t)
|
||||||
|
)
|
||||||
|
|
||||||
|
(define-method add_many
|
||||||
|
(of-object "GstBin")
|
||||||
|
(c-name "gst_bin_add_many")
|
||||||
|
(return-type "none")
|
||||||
|
(parameters
|
||||||
|
'("GstElement*" "element_1")
|
||||||
|
)
|
||||||
|
(varargs #t)
|
||||||
)
|
)
|
||||||
|
|
||||||
(define-method remove
|
(define-method remove
|
||||||
|
@ -81,10 +92,20 @@
|
||||||
(c-name "gst_bin_remove")
|
(c-name "gst_bin_remove")
|
||||||
(return-type "gboolean")
|
(return-type "gboolean")
|
||||||
(parameters
|
(parameters
|
||||||
'("GstElement*" "element")
|
'("GstElement*" "element_1")
|
||||||
)
|
)
|
||||||
|
(varargs #t)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
(define-method remove_many
|
||||||
|
(of-object "GstBin")
|
||||||
|
(c-name "gst_bin_remove_many")
|
||||||
|
(return-type "gboolean")
|
||||||
|
(parameters
|
||||||
|
'("GstElement*" "element_1")
|
||||||
|
)
|
||||||
|
(varargs #t)
|
||||||
|
)
|
||||||
(define-method get_by_name
|
(define-method get_by_name
|
||||||
(of-object "GstBin")
|
(of-object "GstBin")
|
||||||
(c-name "gst_bin_get_by_name")
|
(c-name "gst_bin_get_by_name")
|
||||||
|
@ -5917,16 +5938,6 @@
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
(define-method add_many
|
|
||||||
(of-object "GstBin")
|
|
||||||
(c-name "gst_bin_add_many")
|
|
||||||
(return-type "none")
|
|
||||||
(parameters
|
|
||||||
'("GstElement*" "element_1")
|
|
||||||
)
|
|
||||||
(varargs #t)
|
|
||||||
)
|
|
||||||
|
|
||||||
(define-method remove_many
|
(define-method remove_many
|
||||||
(of-object "GstBin")
|
(of-object "GstBin")
|
||||||
(c-name "gst_bin_remove_many")
|
(c-name "gst_bin_remove_many")
|
||||||
|
|
|
@ -51,6 +51,8 @@ headers
|
||||||
#include <frameobject.h>
|
#include <frameobject.h>
|
||||||
|
|
||||||
PyObject *PyGstExc_LinkError = NULL;
|
PyObject *PyGstExc_LinkError = NULL;
|
||||||
|
PyObject *PyGstExc_AddError = NULL;
|
||||||
|
PyObject *PyGstExc_RemoveError = NULL;
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_EXTERN (python_debug);
|
GST_DEBUG_CATEGORY_EXTERN (python_debug);
|
||||||
#define GST_CAT_DEFAULT python_debug
|
#define GST_CAT_DEFAULT python_debug
|
||||||
|
|
|
@ -24,9 +24,9 @@
|
||||||
ignore
|
ignore
|
||||||
gst_bin_get_by_name_recurse_up
|
gst_bin_get_by_name_recurse_up
|
||||||
%%
|
%%
|
||||||
override gst_bin_add_many args
|
override gst_bin_add args
|
||||||
static PyObject *
|
static PyObject *
|
||||||
_wrap_gst_bin_add_many(PyGObject *self, PyObject *args)
|
_wrap_gst_bin_add(PyGObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
PyGObject *element;
|
PyGObject *element;
|
||||||
int i, len;
|
int i, len;
|
||||||
|
@ -49,16 +49,30 @@ _wrap_gst_bin_add_many(PyGObject *self, PyObject *args)
|
||||||
|
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
element = (PyGObject*)PyTuple_GetItem(args, i);
|
element = (PyGObject*)PyTuple_GetItem(args, i);
|
||||||
gst_bin_add(GST_BIN(self->obj), GST_ELEMENT(element->obj));
|
if (!gst_bin_add(GST_BIN(self->obj), GST_ELEMENT(element->obj))) {
|
||||||
|
PyErr_Format(PyGstExc_AddError, "Could not add element '%s'", GST_OBJECT_NAME(element->obj));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
%%
|
%%
|
||||||
override gst_bin_remove_many args
|
override gst_bin_add_many kwargs
|
||||||
static PyObject *
|
static PyObject *
|
||||||
_wrap_gst_bin_remove_many(PyGObject *self, PyObject *args)
|
_wrap_gst_bin_add_many(PyGObject *self, PyObject *args)
|
||||||
|
{
|
||||||
|
if (PyErr_Warn(PyExc_DeprecationWarning, "gst.Bin.add_many() is deprecated, use gst.Bin.add()") < 0)
|
||||||
|
return NULL;
|
||||||
|
return _wrap_gst_bin_add (self, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
%%
|
||||||
|
override gst_bin_remove args
|
||||||
|
static PyObject *
|
||||||
|
_wrap_gst_bin_remove(PyGObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
PyGObject *element;
|
PyGObject *element;
|
||||||
int i, len;
|
int i, len;
|
||||||
|
@ -81,12 +95,27 @@ _wrap_gst_bin_remove_many(PyGObject *self, PyObject *args)
|
||||||
|
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
element = (PyGObject*)PyTuple_GetItem(args, i);
|
element = (PyGObject*)PyTuple_GetItem(args, i);
|
||||||
gst_bin_remove(GST_BIN(self->obj), GST_ELEMENT(element->obj));
|
if (!gst_bin_remove(GST_BIN(self->obj), GST_ELEMENT(element->obj))) {
|
||||||
|
PyErr_Format(PyGstExc_RemoveError, "Could not remove element '%s'", GST_OBJECT_NAME(element->obj));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
%%
|
||||||
|
override gst_bin_remove_many kwargs
|
||||||
|
static PyObject *
|
||||||
|
_wrap_gst_bin_remove_many(PyGObject *self, PyObject *args)
|
||||||
|
{
|
||||||
|
if (PyErr_Warn(PyExc_DeprecationWarning, "gst.Bin.remove_many() is deprecated, use gst.Bin.remove()") < 0)
|
||||||
|
return NULL;
|
||||||
|
return _wrap_gst_bin_remove (self, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
%%
|
%%
|
||||||
override gst_bin_get_by_name kwargs
|
override gst_bin_get_by_name kwargs
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
|
|
@ -41,6 +41,8 @@ extern PyMethodDef pygst_functions[];
|
||||||
extern GSList *mainloops;
|
extern GSList *mainloops;
|
||||||
extern void _pygst_main_quit(void);
|
extern void _pygst_main_quit(void);
|
||||||
extern PyObject *PyGstExc_LinkError;
|
extern PyObject *PyGstExc_LinkError;
|
||||||
|
extern PyObject *PyGstExc_AddError;
|
||||||
|
extern PyObject *PyGstExc_RemoveError;
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY (pygst_debug); /* for bindings code */
|
GST_DEBUG_CATEGORY (pygst_debug); /* for bindings code */
|
||||||
GST_DEBUG_CATEGORY (python_debug); /* for python code */
|
GST_DEBUG_CATEGORY (python_debug); /* for python code */
|
||||||
|
@ -171,12 +173,23 @@ init_gst (void)
|
||||||
|
|
||||||
PyModule_AddObject(m, "CLOCK_TIME_NONE", PyLong_FromUnsignedLongLong(GST_CLOCK_TIME_NONE));
|
PyModule_AddObject(m, "CLOCK_TIME_NONE", PyLong_FromUnsignedLongLong(GST_CLOCK_TIME_NONE));
|
||||||
|
|
||||||
/* LinkError exception */
|
/* exceptions */
|
||||||
PyGstExc_LinkError = PyErr_NewException("gst.LinkError",
|
PyGstExc_LinkError = PyErr_NewException("gst.LinkError",
|
||||||
PyExc_RuntimeError,
|
PyExc_RuntimeError,
|
||||||
NULL);
|
NULL);
|
||||||
PyDict_SetItemString(d, "LinkError", PyGstExc_LinkError);
|
PyDict_SetItemString(d, "LinkError", PyGstExc_LinkError);
|
||||||
|
|
||||||
|
PyGstExc_AddError = PyErr_NewException("gst.AddError",
|
||||||
|
PyExc_RuntimeError,
|
||||||
|
NULL);
|
||||||
|
PyDict_SetItemString(d, "AddError", PyGstExc_AddError);
|
||||||
|
|
||||||
|
PyGstExc_RemoveError = PyErr_NewException("gst.RemoveError",
|
||||||
|
PyExc_RuntimeError,
|
||||||
|
NULL);
|
||||||
|
PyDict_SetItemString(d, "RemoveError", PyGstExc_RemoveError);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pygstminiobject_register_class(d, "GstMiniObject", GST_TYPE_MINI_OBJECT,
|
pygstminiobject_register_class(d, "GstMiniObject", GST_TYPE_MINI_OBJECT,
|
||||||
&PyGstMiniObject_Type, NULL);
|
&PyGstMiniObject_Type, NULL);
|
||||||
|
|
|
@ -31,11 +31,11 @@ tests = \
|
||||||
test_xml.py
|
test_xml.py
|
||||||
|
|
||||||
check-local: testhelper.la
|
check-local: testhelper.la
|
||||||
@G_DEBUG=fatal_warnings PYTHONPATH=$(top_builddir):$(top_builddir)/gst/.libs:`pwd`:$(top_srcdir):$(PYTHONPATH) $(PYTHON) $(srcdir)/runtests.py
|
@PYTHONPATH=$(top_builddir):$(top_builddir)/gst/.libs:`pwd`:$(top_srcdir):$(PYTHONPATH) $(PYTHON) $(srcdir)/runtests.py
|
||||||
@rm -fr *.pyc
|
@rm -fr *.pyc
|
||||||
|
|
||||||
check-verbose: testhelper.la
|
check-verbose: testhelper.la
|
||||||
@VERBOSE=yes G_DEBUG=fatal_warnings PYTHONPATH=$(top_builddir):$(top_builddir)/gst/.libs:`pwd`:$(top_srcdir):$(PYTHONPATH) $(PYTHON) $(srcdir)/runtests.py
|
@VERBOSE=yes PYTHONPATH=$(top_builddir):$(top_builddir)/gst/.libs:`pwd`:$(top_srcdir):$(PYTHONPATH) $(PYTHON) $(srcdir)/runtests.py
|
||||||
@rm -fr *.pyc
|
@rm -fr *.pyc
|
||||||
|
|
||||||
EXTRA_DIST = $(tests) common.py runtests.py test-object.h
|
EXTRA_DIST = $(tests) common.py runtests.py test-object.h
|
||||||
|
|
|
@ -95,5 +95,32 @@ class BinSubclassTest(TestCase):
|
||||||
# back to NULL
|
# back to NULL
|
||||||
bin.set_state(gst.STATE_NULL)
|
bin.set_state(gst.STATE_NULL)
|
||||||
|
|
||||||
|
class BinAddRemove(TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
TestCase.setUp(self)
|
||||||
|
self.bin = gst.Bin('bin')
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
del self.bin
|
||||||
|
TestCase.tearDown(self)
|
||||||
|
|
||||||
|
def testError(self):
|
||||||
|
src = gst.element_factory_make('fakesrc', 'name')
|
||||||
|
sink = gst.element_factory_make('fakesink', 'name')
|
||||||
|
self.bin.add(src)
|
||||||
|
self.assertRaises(gst.AddError, self.bin.add, sink)
|
||||||
|
self.assertRaises(gst.AddError, self.bin.add, src)
|
||||||
|
self.assertRaises(gst.RemoveError, self.bin.remove, sink)
|
||||||
|
self.bin.remove(src)
|
||||||
|
self.assertRaises(gst.RemoveError, self.bin.remove, src)
|
||||||
|
|
||||||
|
def testMany(self):
|
||||||
|
src = gst.element_factory_make('fakesrc')
|
||||||
|
sink = gst.element_factory_make('fakesink')
|
||||||
|
self.bin.add(src, sink)
|
||||||
|
self.assertRaises(gst.AddError, self.bin.add, src, sink)
|
||||||
|
self.bin.remove(src, sink)
|
||||||
|
self.assertRaises(gst.RemoveError, self.bin.remove, src, sink)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
@ -98,7 +98,7 @@ class PadProbeTest(TestCase):
|
||||||
self.assertEquals(self.fakesrc.__gstrefcount__, 1)
|
self.assertEquals(self.fakesrc.__gstrefcount__, 1)
|
||||||
self.assertEquals(sys.getrefcount(self.fakesrc), 3)
|
self.assertEquals(sys.getrefcount(self.fakesrc), 3)
|
||||||
|
|
||||||
self.pipeline.add_many(self.fakesrc, self.fakesink)
|
self.pipeline.add(self.fakesrc, self.fakesink)
|
||||||
self.assertEquals(self.fakesrc.__gstrefcount__, 2) # added
|
self.assertEquals(self.fakesrc.__gstrefcount__, 2) # added
|
||||||
self.assertEquals(sys.getrefcount(self.fakesrc), 3)
|
self.assertEquals(sys.getrefcount(self.fakesrc), 3)
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ class Pipeline(TestCase):
|
||||||
source = gst.element_factory_make('fakesrc', 'source')
|
source = gst.element_factory_make('fakesrc', 'source')
|
||||||
source.set_property('num-buffers', 5)
|
source.set_property('num-buffers', 5)
|
||||||
sink = gst.element_factory_make('fakesink', 'sink')
|
sink = gst.element_factory_make('fakesink', 'sink')
|
||||||
self.pipeline.add_many(source, sink)
|
self.pipeline.add(source, sink)
|
||||||
gst.element_link_many(source, sink)
|
gst.element_link_many(source, sink)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
|
@ -93,7 +93,7 @@ class PipelineAndBus(TestCase):
|
||||||
self.pipeline.set_property('play-timeout', 0L)
|
self.pipeline.set_property('play-timeout', 0L)
|
||||||
source = gst.element_factory_make('fakesrc', 'source')
|
source = gst.element_factory_make('fakesrc', 'source')
|
||||||
sink = gst.element_factory_make('fakesink', 'sink')
|
sink = gst.element_factory_make('fakesink', 'sink')
|
||||||
self.pipeline.add_many(source, sink)
|
self.pipeline.add(source, sink)
|
||||||
gst.element_link_many(source, sink)
|
gst.element_link_many(source, sink)
|
||||||
|
|
||||||
self.bus = self.pipeline.get_bus()
|
self.bus = self.pipeline.get_bus()
|
||||||
|
|
Loading…
Reference in a new issue