Commit d178fff2 authored by Johan Dahlin's avatar Johan Dahlin

gstreamer/gstreamer.defs (element_link_many): This is function and not a...

gstreamer/gstreamer.defs (element_link_many): This is function and not a method, despite popular belief

Original commit message from CVS:
* gstreamer/gstreamer.defs (element_link_many): This is function
and not a method, despite popular belief
(gst_element_factory_make): Make it the constructor of GstElement,
so we can avoid dirty hacks.

* gstreamer/gstreamer.override (_wrap_gst_element_link_many): Wrap
(_wrap_gst_element_link_many): Wrap

* gstreamer/common.defs:
* gstreamer/common.override:
* gstreamer/Makefile.am: Beginning of reorganization, to include
gstreamer.defs and override (eg, not auto generate them)

* examples/gstreamer/cp.py: Prettify and pythonify. Will do the
other examples later

* gstreamer/gstreamer.py: Backwards compatibility module

* gstreamer/gstreamermodule.c:
* gstreamer/Makefile.am: Rename the module to gst
parent ade405ce
2004-02-23 Johan Dahlin <johan@gnome.org>
* gstreamer/gstreamer.defs (element_link_many): This is function
and not a method, despite popular belief
(gst_element_factory_make): Make it the constructor of GstElement,
so we can avoid dirty hacks.
* gstreamer/gstreamer.override (_wrap_gst_element_link_many): Wrap
(_wrap_gst_element_link_many): Wrap
* gstreamer/common.defs:
* gstreamer/common.override:
* gstreamer/Makefile.am: Beginning of reorganization, to include
gstreamer.defs and override (eg, not auto generate them)
* examples/gstreamer/cp.py: Prettify and pythonify. Will do the
other examples later
* gstreamer/gstreamer.py: Backwards compatibility module
* gstreamer/gstreamermodule.c:
......
#!/usr/bin/env python
#
# gst-python
# Copyright (C) 2002 David I. Lehn
# Copyright (C) 2002 David I. Lehn <dlehn@users.sourceforge.net>
# 2004 Johan Dahlin <johan@gnome.org>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
......@@ -22,63 +23,45 @@
#
import sys
from gstreamer import *
from gobject import GObject
import gst
def update(sender, *args):
print sender.get_name(), args
def filter(filters):
def filter(input, output):
"A GStreamer copy pipeline which can add arbitrary filters"
if len(sys.argv) != 3:
print 'usage: %s source dest' % (sys.argv[0])
return -1
# create a new bin to hold the elements
bin = Pipeline('pipeline')
bin = gst.Pipeline('pipeline')
filesrc = Element('filesrc', 'source');
filesrc.set_property('location', sys.argv[1])
filesrc = gst.Element('filesrc', 'source');
filesrc.set_property('location', input)
filesink = Element('filesink', 'sink')
filesink.set_property('location', sys.argv[2])
stats = gst.Element('statistics', 'stats');
stats.set_property('silent', False)
stats.set_property('buffer_update_freq', True)
stats.set_property('update_on_eos', True)
filesink = gst.Element('filesink', 'sink')
filesink.set_property('location', output)
elements = [filesrc] + filters + [filesink]
# add objects to the main pipeline
for e in elements:
bin.add(e)
# link the elements
previous = None
for e in elements:
if previous:
previous.link(e)
previous = e
bin.add_many(filesrc, stats, filesink)
gst.element_link_many(filesrc, stats, filesink)
# start playing
bin.set_state(STATE_PLAYING);
bin.set_state(gst.STATE_PLAYING);
while bin.iterate(): pass
while bin.iterate():
pass
# stop the bin
bin.set_state(STATE_NULL)
return 0
bin.set_state(gst.STATE_NULL)
def main():
def main(args):
"A GStreamer based cp(1) with stats"
#gst_info_set_categories(-1)
#gst_debug_set_categories(-1)
stats = Element ('statistics', 'stats');
stats.set_property('silent', 0)
stats.set_property('buffer_update_freq', 1)
stats.set_property('update_on_eos', 1)
#stats.connect('update', update)
if len(args) != 3:
print 'usage: %s source dest' % (sys.argv[0])
return -1
return filter([stats])
return filter(args[1], args[2])
if __name__ == '__main__':
ret = main()
sys.exit (ret)
sys.exit(main(sys.argv))
#!/usr/bin/env python
#
# gst-python
# Copyright (C) 2002 David I. Lehn
# Copyright (C) 2002 David I. Lehn <dlehn@users.sourceforge.net>
# 2004 Johan Dahlin <johan@gnome.org>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
......@@ -22,63 +23,45 @@
#
import sys
from gstreamer import *
from gobject import GObject
import gst
def update(sender, *args):
print sender.get_name(), args
def filter(filters):
def filter(input, output):
"A GStreamer copy pipeline which can add arbitrary filters"
if len(sys.argv) != 3:
print 'usage: %s source dest' % (sys.argv[0])
return -1
# create a new bin to hold the elements
bin = Pipeline('pipeline')
bin = gst.Pipeline('pipeline')
filesrc = Element('filesrc', 'source');
filesrc.set_property('location', sys.argv[1])
filesrc = gst.Element('filesrc', 'source');
filesrc.set_property('location', input)
filesink = Element('filesink', 'sink')
filesink.set_property('location', sys.argv[2])
stats = gst.Element('statistics', 'stats');
stats.set_property('silent', False)
stats.set_property('buffer_update_freq', True)
stats.set_property('update_on_eos', True)
filesink = gst.Element('filesink', 'sink')
filesink.set_property('location', output)
elements = [filesrc] + filters + [filesink]
# add objects to the main pipeline
for e in elements:
bin.add(e)
# link the elements
previous = None
for e in elements:
if previous:
previous.link(e)
previous = e
bin.add_many(filesrc, stats, filesink)
gst.element_link_many(filesrc, stats, filesink)
# start playing
bin.set_state(STATE_PLAYING);
bin.set_state(gst.STATE_PLAYING);
while bin.iterate(): pass
while bin.iterate():
pass
# stop the bin
bin.set_state(STATE_NULL)
return 0
bin.set_state(gst.STATE_NULL)
def main():
def main(args):
"A GStreamer based cp(1) with stats"
#gst_info_set_categories(-1)
#gst_debug_set_categories(-1)
stats = Element ('statistics', 'stats');
stats.set_property('silent', 0)
stats.set_property('buffer_update_freq', 1)
stats.set_property('update_on_eos', 1)
#stats.connect('update', update)
if len(args) != 3:
print 'usage: %s source dest' % (sys.argv[0])
return -1
return filter([stats])
return filter(args[1], args[2])
if __name__ == '__main__':
ret = main()
sys.exit (ret)
sys.exit(main(sys.argv))
......@@ -42,26 +42,17 @@ _gstmodule_la_SOURCES = \
_gstmodule_la_CFLAGS = $(GST_CFLAGS) -fno-strict-aliasing
_gstmodule_la_LIBADD = $(GST_LIBS)
_gstmodule_la_LDFLAGS = -module -avoid-version -export-symbols-regex init_gst
nodist__gstmodule_la_SOURCES = gstreamer.c
nodist__gstmodule_la_SOURCES = $(MODULE).c
CLEANFILES = $(MODULE).c h2def.defs $(MODULE).defs $(MODULE).override
EXTRA_DIST = $(GST_OVERRIDES) $(GST_DEFS) $(GST_CODE) arg-types.py
CLEANFILES = $(MODULE).c
EXTRA_DIST = $(MODULE).defs $(GST_OVERRIDES) $(GST_DEFS) $(GST_CODE) arg-types.py
GST_EXCLUDE_INCLUDES=\
$(GST_INCLUDEDIR)/gst/gstatomic_impl.h \
$(GST_INCLUDEDIR)/gst/gstcompat.h
GST_INCLUDES=$(filter-out $(GST_EXCLUDE_INCLUDES),$(wildcard $(GST_INCLUDEDIR)/gst/*.h))
gstreamer.override: common.override $(GST_MAJORMINOR).override
cat $+ > $@
h2def.defs: $(GST_INCLUDES)
$(PYTHON) $(PYGTK_H2DEF) $(GST_INCLUDES) > $@
gstreamer.defs: h2def.defs common.defs $(GST_MAJORMINOR).defs
cat $+ > $@
gstreamer.c: $(MODULE).defs arg-types.py $(MODULE).override
gstreamer.c: $(srcdir)/$(MODULE).defs $(srcdir)/arg-types.py $(srcdir)/$(MODULE).override
$(PYGTK_CODEGEN) \
--load-types $(srcdir)/arg-types.py \
--override $(srcdir)/$(MODULE).override \
......
;; -*- scheme -*-
;;
;; Boxed types
;;
......@@ -67,17 +68,4 @@
)
)
;;
;; Element constructor override; uses a nonexistant make_element
;; which is defined in gstreamer.overrides
;;
(define-function gst_element_factory_make_element
(is-constructor-of "GstElement")
(c-name "gst_element_factory_make_element")
(return-type "GstElement*")
(parameters
'("const-gchar*" "elementname")
'("const-gchar*" "name")
)
)
......@@ -369,3 +369,39 @@ _wrap_gst_version(void)
return Py_BuildValue("(iii)", major, minor, micro);
}
%%
override gst_bin_add_many args
static PyObject *
_wrap_gst_bin_add_many(PyGObject *self, PyObject *args, PyObject *kwargs)
{
PyGObject *element;
int i;
int len;
len = PyList_Size(args);
if (len == 0)
{
PyErr_SetString(PyExc_TypeError, "GstBin.add requires at least one argument");
return NULL;
}
for (i = 0; i < len; i++)
{
element = (PyGObject*)PyList_GetItem(args, i);
if (!pygobject_check(element, &PyGstElement_Type))
{
PyErr_SetString(PyExc_TypeError, "argument must be a GstElement");
return NULL;
}
}
for (i = 0; i < len; i++)
{
element = (PyGObject*)PyList_GetItem(args, i);
gst_bin_add(GST_BIN(self->obj), GST_ELEMENT(element->obj));
}
Py_INCREF(Py_None);
return Py_None;
}
This diff is collapsed.
This diff is collapsed.
......@@ -42,26 +42,17 @@ _gstmodule_la_SOURCES = \
_gstmodule_la_CFLAGS = $(GST_CFLAGS) -fno-strict-aliasing
_gstmodule_la_LIBADD = $(GST_LIBS)
_gstmodule_la_LDFLAGS = -module -avoid-version -export-symbols-regex init_gst
nodist__gstmodule_la_SOURCES = gstreamer.c
nodist__gstmodule_la_SOURCES = $(MODULE).c
CLEANFILES = $(MODULE).c h2def.defs $(MODULE).defs $(MODULE).override
EXTRA_DIST = $(GST_OVERRIDES) $(GST_DEFS) $(GST_CODE) arg-types.py
CLEANFILES = $(MODULE).c
EXTRA_DIST = $(MODULE).defs $(GST_OVERRIDES) $(GST_DEFS) $(GST_CODE) arg-types.py
GST_EXCLUDE_INCLUDES=\
$(GST_INCLUDEDIR)/gst/gstatomic_impl.h \
$(GST_INCLUDEDIR)/gst/gstcompat.h
GST_INCLUDES=$(filter-out $(GST_EXCLUDE_INCLUDES),$(wildcard $(GST_INCLUDEDIR)/gst/*.h))
gstreamer.override: common.override $(GST_MAJORMINOR).override
cat $+ > $@
h2def.defs: $(GST_INCLUDES)
$(PYTHON) $(PYGTK_H2DEF) $(GST_INCLUDES) > $@
gstreamer.defs: h2def.defs common.defs $(GST_MAJORMINOR).defs
cat $+ > $@
gstreamer.c: $(MODULE).defs arg-types.py $(MODULE).override
gstreamer.c: $(srcdir)/$(MODULE).defs $(srcdir)/arg-types.py $(srcdir)/$(MODULE).override
$(PYGTK_CODEGEN) \
--load-types $(srcdir)/arg-types.py \
--override $(srcdir)/$(MODULE).override \
......
;; -*- scheme -*-
;;
;; Boxed types
;;
......@@ -67,17 +68,4 @@
)
)
;;
;; Element constructor override; uses a nonexistant make_element
;; which is defined in gstreamer.overrides
;;
(define-function gst_element_factory_make_element
(is-constructor-of "GstElement")
(c-name "gst_element_factory_make_element")
(return-type "GstElement*")
(parameters
'("const-gchar*" "elementname")
'("const-gchar*" "name")
)
)
......@@ -369,3 +369,39 @@ _wrap_gst_version(void)
return Py_BuildValue("(iii)", major, minor, micro);
}
%%
override gst_bin_add_many args
static PyObject *
_wrap_gst_bin_add_many(PyGObject *self, PyObject *args, PyObject *kwargs)
{
PyGObject *element;
int i;
int len;
len = PyList_Size(args);
if (len == 0)
{
PyErr_SetString(PyExc_TypeError, "GstBin.add requires at least one argument");
return NULL;
}
for (i = 0; i < len; i++)
{
element = (PyGObject*)PyList_GetItem(args, i);
if (!pygobject_check(element, &PyGstElement_Type))
{
PyErr_SetString(PyExc_TypeError, "argument must be a GstElement");
return NULL;
}
}
for (i = 0; i < len; i++)
{
element = (PyGObject*)PyList_GetItem(args, i);
gst_bin_add(GST_BIN(self->obj), GST_ELEMENT(element->obj));
}
Py_INCREF(Py_None);
return Py_None;
}
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment