From c71d66dbdedb40193c2170ee04d332fe2ed48fbe Mon Sep 17 00:00:00 2001 From: "David I. Lehn" Date: Tue, 3 Feb 2004 09:45:42 +0000 Subject: [PATCH] gst/: Support GstPlay, bug fixes, updates. Original commit message from CVS: * gstinterfaces/.cvsignore: * gstinterfaces/0.7.defs: * gstinterfaces/Makefile.am: * gstinterfaces/common.defs: * gstinterfaces/common.override: * gstinterfaces/gstinterfacesmodule.c: (init_gstinterfaces): * gstplay/.cvsignore: * gstplay/0.7.c: * gstplay/0.7.defs: * gstplay/0.7.h: * gstplay/0.7.override: * gstplay/Makefile.am: * gstplay/__init__.py: * gstplay/arg-types.py: * gstplay/common.c: * gstplay/common.h: * gstplay/common.override: * gstplay/gstplaymodule.c: (init_gstplay): * gstreamer/Makefile.am: * gstreamer/__init__.py: * gstreamer/common.override: Support GstPlay, bug fixes, updates. * examples/gstplay/player.py: GstPlay example. * Makefile.am: Support GstPlay build. * configure.ac: Support GstPlay build, remove AC_SUBST() calls that PKG_CHECK_MODULES does automagically. --- ChangeLog | 32 ++++++++++ Makefile.am | 10 +++- common | 2 +- configure.ac | 16 ++++- examples/gstplay/player.py | 116 +++++++++++++++++++++++++++++++++++++ gst/Makefile.am | 24 ++++---- gst/__init__.py | 2 + gst/common.override | 4 +- gstreamer/Makefile.am | 24 ++++---- gstreamer/__init__.py | 2 + gstreamer/common.override | 4 +- 11 files changed, 202 insertions(+), 34 deletions(-) create mode 100755 examples/gstplay/player.py diff --git a/ChangeLog b/ChangeLog index 7d497b9b0a..02fd364f44 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,35 @@ +2004-02-03 David I. Lehn + + * gstinterfaces/.cvsignore: + * gstinterfaces/0.7.defs: + * gstinterfaces/Makefile.am: + * gstinterfaces/common.defs: + * gstinterfaces/common.override: + * gstinterfaces/gstinterfacesmodule.c: (init_gstinterfaces): + * gstplay/.cvsignore: + * gstplay/0.7.c: + * gstplay/0.7.defs: + * gstplay/0.7.h: + * gstplay/0.7.override: + * gstplay/Makefile.am: + * gstplay/__init__.py: + * gstplay/arg-types.py: + * gstplay/common.c: + * gstplay/common.h: + * gstplay/common.override: + * gstplay/gstplaymodule.c: (init_gstplay): + * gstreamer/Makefile.am: + * gstreamer/__init__.py: + * gstreamer/common.override: + Support GstPlay, bug fixes, updates. + * examples/gstplay/player.py: + GstPlay example. + * Makefile.am: + Support GstPlay build. + * configure.ac: + Support GstPlay build, remove AC_SUBST() calls that + PKG_CHECK_MODULES does automagically. + 2004-01-27 David I. Lehn * Makefile.am: add gstinterfaces dir diff --git a/Makefile.am b/Makefile.am index 5126195fb5..d7f2064e1d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -6,13 +6,19 @@ endif if GST_0_6 INTERFACESDIR = +PLAYDIR = else INTERFACESDIR = gstinterfaces +PLAYDIR = gstplay endif UNCONDDIRS = gstreamer pkgconfig examples testsuite -SUBDIRS = $(UNCONDDIRS) $(SUBDIRS_DOCS) $(INTERFACESDIR) -DIST_SUBDIRS = $(UNCONDDIRS) docs gstinterfaces +SUBDIRS = \ + $(UNCONDDIRS) \ + $(INTERFACESDIR) \ + $(PLAYDIR) \ + $(SUBDIRS_DOCS) +DIST_SUBDIRS = $(UNCONDDIRS) docs gstinterfaces gstplay EXTRA_DIST = \ gst-python.spec.in gst-python.spec README-docs diff --git a/common b/common index 0bcde34201..ab32709acc 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 0bcde342015b96d9a6ba3b9d9102e2a543399d96 +Subproject commit ab32709acc23a4a1b458823fd094327332408035 diff --git a/configure.ac b/configure.ac index ebc9d6ef1b..9d410e2cfd 100644 --- a/configure.ac +++ b/configure.ac @@ -58,15 +58,12 @@ if test "x$HAVE_GSTREAMER" = "xno"; then AC_MSG_ERROR(you need gstreamer development packages installed !) fi -AC_SUBST(GST_LIBS) -AC_SUBST(GST_CFLAGS) AC_SUBST(GST_MAJORMINOR) AM_CONDITIONAL(GST_0_6, test $GST_MAJORMINOR = 0.6) AM_CONDITIONAL(GST_0_7, test $GST_MAJORMINOR = 0.7) dnl check for pygtk PKG_CHECK_MODULES(PYGTK, pygtk-2.0 >= $PYGTK_REQ) -AC_SUBST(PYGTK_CFLAGS) AC_PATH_PROG(PYGTK_CODEGEN, pygtk-codegen-2.0, no) if test "x$PYGTK_CODEGEN" = xno; then AC_MSG_ERROR(could not find pygtk-codegen-2.0 script) @@ -98,6 +95,7 @@ AC_SUBST(GST_INCLUDEDIR) if test "x$GST_MAJORMINOR" != "x0.6"; then AC_MSG_CHECKING(for GStreamer interfaces include dir) + PKG_CHECK_MODULES(GST_INTERFACES, gstreamer-interfaces-$GST_MAJORMINOR) GST_INTERFACES_INCLUDEDIR=`$PKG_CONFIG --variable=includedir gstreamer-interfaces-$GST_MAJORMINOR` AC_MSG_RESULT($GST_INTERFACES_INCLUDEDIR) if test "x$GST_INTERFACES_INCLUDEDIR" = "x"; then @@ -106,6 +104,17 @@ if test "x$GST_MAJORMINOR" != "x0.6"; then AC_SUBST(GST_INTERFACES_INCLUDEDIR) fi +if test "x$GST_MAJORMINOR" != "x0.6"; then + AC_MSG_CHECKING(for GStreamer play include dir) + PKG_CHECK_MODULES(GST_PLAY, gstreamer-play-$GST_MAJORMINOR) + GST_PLAY_INCLUDEDIR=`$PKG_CONFIG --variable=includedir gstreamer-play-$GST_MAJORMINOR` + AC_MSG_RESULT($GST_PLAY_INCLUDEDIR) + if test "x$GST_PLAY_INCLUDEDIR" = "x"; then + AC_MSG_ERROR(no GStreamer play include dir found) + fi + AC_SUBST(GST_PLAY_INCLUDEDIR) +fi + AC_CHECK_PROG(HAVE_XMLTO, xmlto, true, false) AC_CHECK_PROG(HAVE_XMLCATALOG, xmlcatalog, true, false) @@ -153,6 +162,7 @@ AC_OUTPUT([ Makefile gstreamer/Makefile gstinterfaces/Makefile + gstplay/Makefile pkgconfig/Makefile pkgconfig/gst-python.pc pkgconfig/gst-python-uninstalled.pc diff --git a/examples/gstplay/player.py b/examples/gstplay/player.py new file mode 100755 index 0000000000..bf368fe48c --- /dev/null +++ b/examples/gstplay/player.py @@ -0,0 +1,116 @@ +#!/usr/bin/env python +# +# gst-python +# Copyright (C) 2004 David I. Lehn +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Library General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. +# +# Author: David I. Lehn +# + +# +# GstPlay wrapper demo +# + +import sys +import gobject +from gstreamer import * +from gstplay import Play + +#threads_init() + +def nano_time_string(nanos): + ts = nanos / 1000000000 + h = ts / 3600 + m = ts / 60 + s = ts % 60 + us = nanos % 1000000000 + return '%02d:%02d:%02d.%06d' % (h, m, s, us) + +def got_time_tick(sender, nanos): + print 'time tick %s (%d)' % (nano_time_string(nanos), nanos) + +def got_stream_length(sender, nanos): + print 'stream length %s (%d)' % (nano_time_string(nanos), nanos) + +def got_have_video_size(sender, w, h): + print 'video size %d %d' % (w, h) + +def got_found_tag(sender, src, tags, *args): + print 'found tag', src, tags, args + +def got_eos(sender, *args): + print 'eos', args + +def idle_iterate(sender): + #threads_enter() + return sender.iterate() + #threads_leave() + #return sender.get_state() == STATE_PLAYING + +def main(): + "Basic example to play a media stream with GstPlay" + #gst_debug_set_default_threshold(LEVEL_INFO) + + if len(sys.argv) != 2: + print 'usage: %s ' % (sys.argv[0]) + return -1 + + #threads_enter() + + loop = gobject.MainLoop() + + # the player + play = Play () + play.connect('time_tick', got_time_tick) + play.connect('stream_length', got_stream_length) + play.connect('have_video_size', got_have_video_size) + play.connect('found_tag', got_found_tag) + play.connect('eos', got_eos) + + data_src = Element ('gnomevfssrc', 'data_src') + #audio_sink = Element ('osssink', 'audio_sink') + audio_sink = Element ('fakesink', 'audio_sink') + video_sink = Element ('fakesink', 'video_sink') + #video_sink = Element ('aasink', 'video_sink') + #video_sink.set_property('driver', 4) + #vis_sink = Element ('fakesink', 'vis_sink') + + # setup the player + play.set_data_src(data_src) + play.set_audio_sink(audio_sink) + play.set_video_sink(video_sink) + #play.set_visualization(vis_sink) + play.set_location(sys.argv[1]) + + # start playing + play.set_state(STATE_PLAYING); + + #while play.iterate(): pass + #while play.iterate(): print '.' + gobject.idle_add(idle_iterate, play) + loop.run() + + #threads_leave() + + # stop the bin + play.set_state(STATE_NULL) + + return 0 + +if __name__ == '__main__': + ret = main() + sys.exit(ret) diff --git a/gst/Makefile.am b/gst/Makefile.am index 3f80aeea41..cfa25e1f65 100644 --- a/gst/Makefile.am +++ b/gst/Makefile.am @@ -1,10 +1,12 @@ +MODULE = gstreamer + INCLUDES = $(PYTHON_INCLUDES) $(PYGTK_CFLAGS) PYGTK_DEFSDIR = @PYGTK_DEFSDIR@ -pygstreamerdir = $(pythondir)/gstreamer +pygstreamerdir = $(pythondir)/$(MODULE) pygstreamer_PYTHON = __init__.py -pygstreamerexecdir = $(pyexecdir)/gstreamer +pygstreamerexecdir = $(pyexecdir)/$(MODULE) GST_OVERRIDES = common.override \ 0.6.override \ @@ -35,11 +37,9 @@ _gstreamermodule_la_LIBADD = $(GST_LIBS) _gstreamermodule_la_LDFLAGS = -module -avoid-version -export-symbols-regex init_gstreamer nodist__gstreamermodule_la_SOURCES = gstreamer.c -CLEANFILES = gstreamer.c core.defs gstreamer.defs gstreamer.override +CLEANFILES = $(MODULE).c h2def.defs $(MODULE).defs $(MODULE).override EXTRA_DIST = $(GST_OVERRIDES) $(GST_DEFS) $(GST_CODE) arg-types.py -gstreamer.c: gstreamer.defs gstreamer.override - GST_EXCLUDE_INCLUDES=\ $(GST_INCLUDEDIR)/gst/gstatomic_impl.h \ $(GST_INCLUDEDIR)/gst/gstcompat.h @@ -48,19 +48,19 @@ GST_INCLUDES=$(filter-out $(GST_EXCLUDE_INCLUDES),$(wildcard $(GST_INCLUDEDIR)/g gstreamer.override: common.override $(GST_MAJORMINOR).override cat $+ > $@ -core.defs: $(GST_INCLUDES) +h2def.defs: $(GST_INCLUDES) $(PYTHON) $(PYGTK_H2DEF) $(GST_INCLUDES) > $@ -gstreamer.defs: core.defs common.defs $(GST_MAJORMINOR).defs +gstreamer.defs: h2def.defs common.defs $(GST_MAJORMINOR).defs cat $+ > $@ -gstreamer.c: gstreamer.defs arg-types.py gstreamer.override +gstreamer.c: $(MODULE).defs arg-types.py $(MODULE).override $(PYGTK_CODEGEN) \ --load-types $(srcdir)/arg-types.py \ - --override $(srcdir)/gstreamer.override \ - --prefix pygstreamer gstreamer.defs > gen-gstreamer.c \ - && cp gen-gstreamer.c gstreamer.c \ - && rm -f gen-gstreamer.c + --override $(srcdir)/$(MODULE).override \ + --prefix py$(MODULE) $(MODULE).defs > gen-$(MODULE).c \ + && cp gen-$(MODULE).c $(MODULE).c \ + && rm -f gen-$(MODULE).c # --register $(PYGTK_DEFSDIR)/gtk-types.defs # --register $(top_srcdir)/blah/blah-types.defs diff --git a/gst/__init__.py b/gst/__init__.py index 358110ce7e..c735ec12cc 100644 --- a/gst/__init__.py +++ b/gst/__init__.py @@ -37,6 +37,8 @@ del devloc, sys, os from _gstreamer import * +#from gtk import threads_init, threads_enter, threads_leave + def threads_init(): import gtk gtk.threads_init() diff --git a/gst/common.override b/gst/common.override index bff4e89fa1..8dfb39dd9b 100644 --- a/gst/common.override +++ b/gst/common.override @@ -358,10 +358,10 @@ _wrap_gst_element_factory_make_element(PyGObject *self, PyObject *args, PyObject return 0; } %% -override gst_version +override gst_version noargs static PyObject * -_wrap_gst_version(PyGObject *self) +_wrap_gst_version(void) { guint major, minor, micro; diff --git a/gstreamer/Makefile.am b/gstreamer/Makefile.am index 3f80aeea41..cfa25e1f65 100644 --- a/gstreamer/Makefile.am +++ b/gstreamer/Makefile.am @@ -1,10 +1,12 @@ +MODULE = gstreamer + INCLUDES = $(PYTHON_INCLUDES) $(PYGTK_CFLAGS) PYGTK_DEFSDIR = @PYGTK_DEFSDIR@ -pygstreamerdir = $(pythondir)/gstreamer +pygstreamerdir = $(pythondir)/$(MODULE) pygstreamer_PYTHON = __init__.py -pygstreamerexecdir = $(pyexecdir)/gstreamer +pygstreamerexecdir = $(pyexecdir)/$(MODULE) GST_OVERRIDES = common.override \ 0.6.override \ @@ -35,11 +37,9 @@ _gstreamermodule_la_LIBADD = $(GST_LIBS) _gstreamermodule_la_LDFLAGS = -module -avoid-version -export-symbols-regex init_gstreamer nodist__gstreamermodule_la_SOURCES = gstreamer.c -CLEANFILES = gstreamer.c core.defs gstreamer.defs gstreamer.override +CLEANFILES = $(MODULE).c h2def.defs $(MODULE).defs $(MODULE).override EXTRA_DIST = $(GST_OVERRIDES) $(GST_DEFS) $(GST_CODE) arg-types.py -gstreamer.c: gstreamer.defs gstreamer.override - GST_EXCLUDE_INCLUDES=\ $(GST_INCLUDEDIR)/gst/gstatomic_impl.h \ $(GST_INCLUDEDIR)/gst/gstcompat.h @@ -48,19 +48,19 @@ GST_INCLUDES=$(filter-out $(GST_EXCLUDE_INCLUDES),$(wildcard $(GST_INCLUDEDIR)/g gstreamer.override: common.override $(GST_MAJORMINOR).override cat $+ > $@ -core.defs: $(GST_INCLUDES) +h2def.defs: $(GST_INCLUDES) $(PYTHON) $(PYGTK_H2DEF) $(GST_INCLUDES) > $@ -gstreamer.defs: core.defs common.defs $(GST_MAJORMINOR).defs +gstreamer.defs: h2def.defs common.defs $(GST_MAJORMINOR).defs cat $+ > $@ -gstreamer.c: gstreamer.defs arg-types.py gstreamer.override +gstreamer.c: $(MODULE).defs arg-types.py $(MODULE).override $(PYGTK_CODEGEN) \ --load-types $(srcdir)/arg-types.py \ - --override $(srcdir)/gstreamer.override \ - --prefix pygstreamer gstreamer.defs > gen-gstreamer.c \ - && cp gen-gstreamer.c gstreamer.c \ - && rm -f gen-gstreamer.c + --override $(srcdir)/$(MODULE).override \ + --prefix py$(MODULE) $(MODULE).defs > gen-$(MODULE).c \ + && cp gen-$(MODULE).c $(MODULE).c \ + && rm -f gen-$(MODULE).c # --register $(PYGTK_DEFSDIR)/gtk-types.defs # --register $(top_srcdir)/blah/blah-types.defs diff --git a/gstreamer/__init__.py b/gstreamer/__init__.py index 358110ce7e..c735ec12cc 100644 --- a/gstreamer/__init__.py +++ b/gstreamer/__init__.py @@ -37,6 +37,8 @@ del devloc, sys, os from _gstreamer import * +#from gtk import threads_init, threads_enter, threads_leave + def threads_init(): import gtk gtk.threads_init() diff --git a/gstreamer/common.override b/gstreamer/common.override index bff4e89fa1..8dfb39dd9b 100644 --- a/gstreamer/common.override +++ b/gstreamer/common.override @@ -358,10 +358,10 @@ _wrap_gst_element_factory_make_element(PyGObject *self, PyObject *args, PyObject return 0; } %% -override gst_version +override gst_version noargs static PyObject * -_wrap_gst_version(PyGObject *self) +_wrap_gst_version(void) { guint major, minor, micro;