gst/gst.defs: add gst.ghost_pad_new_notarget

Original commit message from CVS:

* gst/gst.defs:
add gst.ghost_pad_new_notarget
* gst/gstpad.override:
change wrap_gst_pad_new a little and add logging
* testsuite/test_pad.py:
add tests for constructors of gst.Pad
This commit is contained in:
Thomas Vander Stichele 2005-09-08 13:34:29 +00:00
parent 9e2af8b0b4
commit 4babdda09c
5 changed files with 395 additions and 352 deletions

View file

@ -1,3 +1,12 @@
2005-09-08 Thomas Vander Stichele <thomas at apestaart dot org>
* gst/gst.defs:
add gst.ghost_pad_new_notarget
* gst/gstpad.override:
change wrap_gst_pad_new a little and add logging
* testsuite/test_pad.py:
add tests for constructors of gst.Pad
2005-09-05 Andy Wingo <wingo@pobox.com> 2005-09-05 Andy Wingo <wingo@pobox.com>
* examples/pipeline-tester: Update pipelines. The fixed-rate v4l * examples/pipeline-tester: Update pipelines. The fixed-rate v4l

2
common

@ -1 +1 @@
Subproject commit 54886902497be267fe1f1a3f9c4dc0245bc46175 Subproject commit 00cc4f5af95a15be55b8c1b3eed09f4738412f91

View file

@ -1780,7 +1780,7 @@
) )
) )
(define-function gst_ghost_pad_new_notarget (define-function ghost_pad_new_notarget
(c-name "gst_ghost_pad_new_notarget") (c-name "gst_ghost_pad_new_notarget")
(return-type "GstPad*") (return-type "GstPad*")
(parameters (parameters

View file

@ -1,5 +1,7 @@
/* -*- Mode: C; c-basic-offset: 4 -*- */ /* -*- Mode: C; c-basic-offset: 4 -*- */
/* gst-python * vi:si:et:sw=4:sts=4:ts=4
*
* gst-python
* Copyright (C) 2004 Johan Dahlin * Copyright (C) 2004 Johan Dahlin
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
@ -552,23 +554,36 @@ _wrap_gst_pad_new(PyGObject *self, PyObject *args, PyObject *kwargs)
PyObject *py_direction = NULL; PyObject *py_direction = NULL;
GstPadDirection direction; GstPadDirection direction;
if (PyArg_ParseTupleAndKeywords(args, kwargs, "sO:GstPad.__init__", kwlist, &name, &py_direction)) { if (PyArg_ParseTupleAndKeywords (args, kwargs, "zO:GstPad.__init__",
if (pyg_enum_get_value(GST_TYPE_PAD_DIRECTION, py_direction, (gint *)&direction)) kwlist, &name, &py_direction)) {
GST_LOG ("gst.Pad.__init__: using gst_pad_new");
if (pyg_enum_get_value (GST_TYPE_PAD_DIRECTION, py_direction,
(gint *) &direction)) {
GST_LOG ("gst.Pad.__init__: direction is not valid");
return -1; return -1;
self->obj = (GObject *)gst_pad_new(name, direction); }
self->obj = (GObject *) gst_pad_new (name, direction);
} else { } else {
PyErr_Clear (); PyErr_Clear ();
if (PyArg_ParseTupleAndKeywords(args, kwargs, "O!|s:GstPad.__init__", kwlist2, &PyGstPadTemplate_Type, &templ, &name)) {
GST_LOG ("gst.Pad.__init__: using gst_pad_new_from_template");
if (PyArg_ParseTupleAndKeywords (args, kwargs, "O!|s:GstPad.__init__",
kwlist2, &PyGstPadTemplate_Type,
&templ, &name)) {
if (name == NULL) if (name == NULL)
name = GST_PAD_TEMPLATE_NAME_TEMPLATE (GST_PAD_TEMPLATE(templ->obj)); name = GST_PAD_TEMPLATE_NAME_TEMPLATE (GST_PAD_TEMPLATE (
self->obj = (GObject *)gst_pad_new_from_template(GST_PAD_TEMPLATE(templ->obj), name); templ->obj));
self->obj = (GObject *) gst_pad_new_from_template (
GST_PAD_TEMPLATE (templ->obj), name);
} }
} }
if (!self->obj) { if (!self->obj) {
PyErr_SetString(PyExc_RuntimeError, "could not create GstPad object"); PyErr_SetString (PyExc_RuntimeError, "could not create GstPad object");
return -1; return -1;
} }
pygobject_register_wrapper((PyObject *)self); pygobject_register_wrapper ((PyObject *)self);
return 0; return 0;
} }
%% %%

View file

@ -22,7 +22,26 @@
from common import gst, unittest from common import gst, unittest
class PadTemplateTest(unittest.TestCase):
def testConstructor(self):
self.failUnless(gst.PadTemplate("template", gst.PAD_SINK,
gst.PAD_ALWAYS, gst.caps_from_string("audio/x-raw-int")))
class PadTest(unittest.TestCase): class PadTest(unittest.TestCase):
def testConstructor(self):
# first style uses gst_pad_new
gst.debug('creating pad with name src')
self.failUnless(gst.Pad("src", gst.PAD_SRC))
gst.debug('creating pad with no name')
self.failUnless(gst.Pad(None, gst.PAD_SRC))
self.failUnless(gst.Pad(name=None, direction=gst.PAD_SRC))
self.failUnless(gst.Pad(direction=gst.PAD_SRC, name=None))
self.failUnless(gst.Pad(direction=gst.PAD_SRC, name="src"))
# second uses gst_pad_new_from_template
#template = gst.PadTemplate()
class PadPipelineTest(unittest.TestCase):
def setUp(self): def setUp(self):
self.pipeline = gst.parse_launch('fakesrc name=source ! fakesink') self.pipeline = gst.parse_launch('fakesrc name=source ! fakesink')
src = self.pipeline.get_by_name('source') src = self.pipeline.get_by_name('source')