From: <wi...@fr...> - 2005-07-13 10:03:26
|
CVS Root: /cvs/gstreamer Module: gst-python Changes by: wingo Date: Wed Jul 13 2005 03:03:16 PDT Log message: 2005-07-13 Andy Wingo <wi...@po...> * examples/pipeline-tester: Tweaks, show messages. Modified files: . : ChangeLog examples : pipeline-tester Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-python/ChangeLog.diff?r1=1.179&r2=1.180 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-python/examples/pipeline-tester.diff?r1=1.1&r2=1.2 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gst-python/ChangeLog,v retrieving revision 1.179 retrieving revision 1.180 diff -u -d -r1.179 -r1.180 --- ChangeLog 12 Jul 2005 16:37:31 -0000 1.179 +++ ChangeLog 13 Jul 2005 10:03:04 -0000 1.180 @@ -1,3 +1,7 @@ +2005-07-13 Andy Wingo <wi...@po...> + + * examples/pipeline-tester: Tweaks, show messages. 2005-07-12 Edward Hervey <ed...@fl...> * gst/gst.override: Index: pipeline-tester RCS file: /cvs/gstreamer/gst-python/examples/pipeline-tester,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- pipeline-tester 12 Jul 2005 15:23:22 -0000 1.1 +++ pipeline-tester 13 Jul 2005 10:03:04 -0000 1.2 @@ -29,6 +29,7 @@ import gtk import gtk.gdk import pango +import gobject import pygst pygst.require('0.9') @@ -40,11 +41,16 @@ ' ! video/x-raw-yuv,format=(fourcc)I420 \n' ' ! videorate \n' ' ! xvimagesink'), + ('Video capture via V4L, fixed frame rate', + 'v4lsrc name=source autoprobe=false autoprobe-fps=false \n' + ' ! video/x-raw-yuv,format=(fourcc)I420,framerate=(double)7.5 \n' + ' ! videorate \n' + ' ! xvimagesink'), ('Sound capture via ALSA', 'alsasrc\n' ' ! audio/x-raw-int,rate=22050,depth=16,channels=1,width=16,signed=(boolean)TRUE,endianness=1234\n' ' ! level signal=true\n' - ' ! alsasink')) + ' ! fakesink')) def escape(s, chars, escaper='\\'): @@ -92,6 +98,7 @@ sw.show() b.pack_start(sw, True, True, 6) tv = gtk.TreeView(make_model()) + tv.set_property('can-default', False) r = gtk.CellRendererText() r.set_property('xalign', 0.5) c = gtk.TreeViewColumn('System', r, text=0) @@ -108,9 +115,11 @@ bb.show() b.pack_start(bb, False, False, 0) bu = gtk.Button(stock=gtk.STOCK_MEDIA_PLAY) + bu.set_property('can-default', True) bu.set_focus_on_click(False) bu.show() bb.pack_start(bu, True, False, 0) + bu.set_property('has-default', True) def on_changed(s): m, i = s.get_selected() @@ -123,21 +132,55 @@ l.set_markup('') tv.get_selection().connect('changed', on_changed) + tv.connect('row-activated', lambda *x: self.play_toggled(bu)) bu.connect('clicked', self.play_toggled) + def error(self, message, secondary=None): + m = gtk.MessageDialog(self, + gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, + gtk.MESSAGE_ERROR, + gtk.BUTTONS_OK, + message) + if secondary: + m.format_secondary_text(secondary) + m.run() + + def on_message(self, bus, message): + t = message.type + if t == gst.MESSAGE_STATE_CHANGED: + pass + else: + print '%s: %s:' % (message.src.get_path_string(), + message.type.value_nicks[1]) + print ' %s' % message.structure.to_string() + return True def play(self): pipestr = self.selected_pipe - pipeline = gst.parse_launch(pipestr) + try: + self.set_sensitive(False) + pipeline = gst.parse_launch(pipestr) + self.set_sensitive(True) + except gobject.GError, e: + self.error('Could not create pipeline', e.__str__) + return False + watch_id = pipeline.get_bus().add_watch(self.on_message) if pipeline.set_state(gst.STATE_PLAYING) != gst.STATE_SUCCESS: - print 'state change failed' + pipeline.set_state(gst.STATE_NULL) + gobject.source_remove(watch_id) return False else: self.pipeline = pipeline + self.watch_id = watch_id return True def stop(self): self.pipeline.set_state(gst.STATE_NULL) self.pipeline = None + gobject.source_remove(self.watch_id) + del self.watch_id def play_toggled(self, button): if self.playing: |