[python]nettimeprovider and playbin2
riccardo cagnasso
riccardo at phascode.org
Mon Oct 3 06:25:10 PDT 2011
Hello, i have a problem in a python-gstreamer program. My script
should create a playbin2, load a video, then take the clock from the
playbin2 and use it to create a NetTimeProvider.
The code (that is ugly because it's just a test) is this
import site
import sys, os
import pygtk, gtk, gobject
import pygst
pygst.require("0.10")
import gst
class GTK_Main:
def __init__(self):
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.set_title("Audio-Player")
window.set_default_size(300, -1)
window.connect("destroy", gtk.main_quit, "WM destroy")
self.movie_window=gtk.DrawingArea()
window.add(self.movie_window)
window.show_all()
self.player = gst.element_factory_make("playbin2", "player")
self.player.set_property("uri", "file:///home/phas/Downloads/bbb.ogg")
bus = self.player.get_bus()
bus.connect("sync-message::element",
self.create_moviewindow_on_sync_message(self.movie_window))
bus.add_signal_watch()
bus.connect("message", self.on_message)
clock = self.player.get_clock()
self.player.use_clock(clock)
clock_provider = gst.NetTimeProvider(clock, None, 20000)
base_time = clock.get_time()
self.player.set_new_stream_time(gst.CLOCK_TIME_NONE)
self.player.set_base_time(base_time)
self.start_stop()
def start_stop(self):
self.player.set_state(gst.STATE_PLAYING)
def on_message(self, bus, message):
t = message.type
if t == gst.MESSAGE_EOS:
self.player.set_state(gst.STATE_NULL)
elif t == gst.MESSAGE_ERROR:
self.player.set_state(gst.STATE_NULL)
err, debug = message.parse_error()
print "Error: %s" % err, debug
def create_moviewindow_on_sync_message(self, movie_window):
def on_sync_message(bus, message):
if message.structure is None:
return
message_name = message.structure.get_name()
if message_name == "prepare-xwindow-id":
imagesink = message.src
imagesink.set_property('synchronous', True)
gtk.gdk.threads_enter()
imagesink.set_xwindow_id(movie_window.window.xid)
gtk.gdk.threads_leave()
return on_sync_message
GTK_Main()
gtk.gdk.threads_init()
gtk.main()
and the problem is that when i run the script with
export GST_DEBUG=net*:5
i get this output
** Message: pygobject_register_sinkfunc is deprecated (GstObject)
0:00:00.025237534 7005 0x1c50810 DEBUG nettime
gstnettimeprovider.c:382:gst_net_time_provider_start:<nettimeprovider0>
binding on port 20000
0:00:00.025309644 7005 0x1c50810 DEBUG nettime
gstnettimeprovider.c:395:gst_net_time_provider_start:<nettimeprovider0>
bound, on port 20000
0:00:00.025436305 7005 0x2484e90 LOG nettime
gstnettimeprovider.c:228:gst_net_time_provider_thread:<nettimeprovider0>
doing select
0:00:00.034776029 7005 0x2484e90 LOG nettime
gstnettimeprovider.c:230:gst_net_time_provider_thread:<nettimeprovider0>
select returned -1
0:00:00.034814397 7005 0x2484e90 LOG nettime
gstnettimeprovider.c:234:gst_net_time_provider_thread:<nettimeprovider0>
stop
0:00:00.034822627 7005 0x2484e90 DEBUG nettime
gstnettimeprovider.c:275:gst_net_time_provider_thread:<nettimeprovider0>
shutting down
and basically that nettimeprovider doesn't work
More information about the gstreamer-devel
mailing list