gst/gst.*: add another registry method
authorThomas Vander Stichele <thomas@apestaart.org>
Fri, 23 Sep 2005 15:37:40 +0000 (15:37 +0000)
committerThomas Vander Stichele <thomas@apestaart.org>
Fri, 23 Sep 2005 15:37:40 +0000 (15:37 +0000)
Original commit message from CVS:

* gst/gst.defs:
* gst/gst.override:
add another registry method
* testsuite/Makefile.am:
add check-verbose
* testsuite/runtests.py:
check for VERBOSE env var
* testsuite/test_pad.py:
refactor a test and add one more for probes

ChangeLog
common
gst/gst.defs
gst/gst.override
testsuite/Makefile.am
testsuite/runtests.py
testsuite/test_pad.py

index a5cae52..0a57b5e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2005-09-23  Thomas Vander Stichele  <thomas at apestaart dot org>
+
+       * gst/gst.defs:
+       * gst/gst.override:
+         add another registry method
+       * testsuite/Makefile.am:
+         add check-verbose
+       * testsuite/runtests.py:
+         check for VERBOSE env var
+       * testsuite/test_pad.py:
+         refactor a test and add one more for probes
+
 2005-09-22  Jan Schmidt  <thaytan@mad.scientist.com>
 
        * gst/gstbuffer.override:
diff --git a/common b/common
index cd4da6a..345fd98 160000 (submodule)
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit cd4da6a319d9f92d28f7b8a3b412577e6de50b64
+Subproject commit 345fd9851051274dd758a19bbe33dbb561b4d303
index d5b2cbf..ba31ed6 100644 (file)
   )
 )
 
+(define-method get_feature_list_by_plugin
+  (of-object "GstRegistry")
+  (c-name "gst_registry_get_feature_list_by_plugin")
+  (return-type "GList*")
+  (parameters
+    '("const gchar*" "name")
+  )
+)
 (define-method add_feature
   (of-object "GstRegistry")
   (c-name "gst_registry_add_feature")
index 733928c..901a68f 100644 (file)
@@ -748,6 +748,37 @@ _wrap_gst_registry_get_feature_list (PyGObject *self, PyObject *args, PyObject *
 }
 
 %%
+override gst_registry_get_feature_list_by_plugin kwargs
+static PyObject *
+_wrap_gst_registry_get_feature_list_by_plugin (PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+    static char *kwlist[] = { "name", NULL };
+    gchar * name = NULL;
+
+    GstRegistry *registry;
+    GList *l, *features;
+    PyObject *list;
+       
+
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+            "s:GstRegistry.get_feature_list_by_plugin", kwlist, &name))
+        return NULL;
+
+    registry = GST_REGISTRY (self->obj);
+
+    features = gst_registry_get_feature_list_by_plugin (registry, name);
+
+    list = PyList_New (0);
+    for (l = features; l; l = l->next) {
+        GstPluginFeature *feature = (GstPluginFeature *) l->data;
+        PyList_Append (list, pygobject_new (G_OBJECT (feature)));
+    }
+    g_list_free (features);
+       
+    return list;
+}
+
+%%
 override gst_xml_new noargs
 
 extern PyObject * libxml_xmlDocPtrWrap(xmlDocPtr doc);
index 6fe4a08..70a9f37 100644 (file)
@@ -34,5 +34,9 @@ check-local: testhelper.la
        @G_DEBUG=fatal_warnings GST_DEBUG=*:0 PYTHONPATH=$(top_builddir):$(top_builddir)/gst/.libs:`pwd`:$(top_srcdir):$(PYTHONPATH) $(PYTHON) $(srcdir)/runtests.py
        @rm -fr *.pyc
 
+check-verbose: testhelper.la
+       @VERBOSE=yes G_DEBUG=fatal_warnings GST_DEBUG=*:0 PYTHONPATH=$(top_builddir):$(top_builddir)/gst/.libs:`pwd`:$(top_srcdir):$(PYTHONPATH) $(PYTHON) $(srcdir)/runtests.py
+       @rm -fr *.pyc
+
 EXTRA_DIST = $(tests) common.py runtests.py test-object.h
 
index 139ba97..3d3b95b 100644 (file)
@@ -41,7 +41,14 @@ loader = unittest.TestLoader()
 for name in gettestnames():
     suite.addTest(loader.loadTestsFromName(name))
     
-testRunner = unittest.TextTestRunner()
+descriptions = 1
+verbosity = 1
+if os.environ.has_key('VERBOSE'):
+    descriptions = 2
+    verbosity = 2
+
+testRunner = unittest.TextTestRunner(descriptions=descriptions,
+    verbosity=verbosity)
 result = testRunner.run(suite)
 if result.failures or result.errors:
     sys.exit(1)
index 773426c..c39ba8c 100644 (file)
@@ -55,31 +55,45 @@ class PadPipelineTest(unittest.TestCase):
 #        assert self.srcpad.query(gst.QUERY_POSITION, gst.FORMAT_TIME) == 0
 
 class PadProbeTest(unittest.TestCase):
-    def testFakeSrcProbe(self):
-        pipeline = gst.Pipeline()
-        fakesrc = gst.element_factory_make('fakesrc')
-        fakesrc.set_property('num-buffers', 1)
-        fakesink = gst.element_factory_make('fakesink')
-
-        pipeline.add_many(fakesrc, fakesink)
-        fakesrc.link(fakesink)
-        pad = fakesrc.get_pad('src')
+    def setUp(self):
+        self.pipeline = gst.Pipeline()
+        self.fakesrc = gst.element_factory_make('fakesrc')
+        self.fakesink = gst.element_factory_make('fakesink')
+        self.pipeline.add_many(self.fakesrc, self.fakesink)
+        self.fakesrc.link(self.fakesink)
+
+    def testFakeSrcProbeOnce(self):
+        self.fakesrc.set_property('num-buffers', 1)
+
+        pad = self.fakesrc.get_pad('src')
         pad.add_buffer_probe(self._probe_callback_fakesrc)
-        self._got_fakesrc_buffer = False
-        pipeline.set_state(gst.STATE_PLAYING)
+        self._got_fakesrc_buffer = 0
+        self.pipeline.set_state(gst.STATE_PLAYING)
         while not self._got_fakesrc_buffer:
             pass
 
+        self.pipeline.set_state(gst.STATE_NULL)
+
+    def testFakeSrcProbeMany(self):
+        self.fakesrc.set_property('num-buffers', 1000)
+
+        pad = self.fakesrc.get_pad('src')
+        pad.add_buffer_probe(self._probe_callback_fakesrc)
+        self._got_fakesrc_buffer = 0
+        self.pipeline.set_state(gst.STATE_PLAYING)
+        while not self._got_fakesrc_buffer == 1000:
+            pass
+
+        self.pipeline.set_state(gst.STATE_NULL)
+
+
     def _probe_callback_fakesrc(self, pad, buffer):
         self.failUnless(isinstance(pad, gst.Pad))
         self.failUnless(isinstance(buffer, gst.Buffer))
-        self._got_fakesrc_buffer = True
+        self._got_fakesrc_buffer += 1
 
     def testRemovingProbe(self):
-        pipeline = gst.Pipeline()
-        fakesrc = gst.element_factory_make('fakesrc')
-        fakesrc.set_property('num-buffers', 10)
-        fakesink = gst.element_factory_make('fakesink')
+        self.fakesrc.set_property('num-buffers', 10)
 
         handle = None
         self._num_times_called = 0
@@ -88,15 +102,13 @@ class PadProbeTest(unittest.TestCase):
             pad.remove_buffer_probe(handle)
             return True
 
-        pipeline.add_many(fakesrc, fakesink)
-        fakesrc.link(fakesink)
-        pad = fakesrc.get_pad('src')
+        pad = self.fakesrc.get_pad('src')
         handle = pad.add_buffer_probe(buffer_probe)
-        self._got_fakesrc_buffer = False
-        pipeline.set_state(gst.STATE_PLAYING)
-        m = pipeline.get_bus().poll(gst.MESSAGE_EOS, -1)
+        self.pipeline.set_state(gst.STATE_PLAYING)
+        m = self.pipeline.get_bus().poll(gst.MESSAGE_EOS, -1)
         assert m
         assert self._num_times_called == 1
+        self.pipeline.set_state(gst.STATE_NULL)
 
 
 if __name__ == "__main__":