[gst-devel] gst-python: how to use BaseSink.set_sync()
Edward Hervey
bilboed at gmail.com
Fri Oct 20 12:11:55 CEST 2006
Hi,
On 10/20/06, Antoine Pitrou <antoine.pitrou at wengo.fr> wrote:
>
> Hi,
>
> I'm trying to write a sink that needs to receive buffers lazily (for
> streaming purposes), not all at once. For that it seems that the
> set_sync() method in gst.BaseSink is the right one. I've noticed that
> it's how fakesink works (by reading gstfakesink.c).
>
> However, I can't manage to reproduce this behaviour in Python. Although
> I call set_sync(True), when linking a source like audiotestsrc or mad to
> this sink, it still sends buffers greedily (while it does not if use
> fakesink sync=true).
The sync property is to synchronize the call to render(), it has
nothing to do with the *speed* at which buffers arrive in the sync.
>
> I also tried to define get_times() and render() methods but they never
> get called.
Those are virtual methods. To implement virtual methods with
pygobject (and therefore gst-python), you need to implement a
do_<virtualmethod name>.
If you implement do_render() it will be called.
>
> Here is the current code for my sink. I use gst-python 0.10.4 (as
> shipped with Ubuntu Dapper).
>
>
> class MySink(gst.BaseSink):
> __gsttemplates__ = (
> gst.PadTemplate("sink",
> gst.PAD_SINK,
> gst.PAD_ALWAYS,
> gst.caps_new_any()),
> )
>
> sink_pad = property(lambda self: self.get_pad("sink"))
>
> def __init__(self):
> self.__gobject_init__()
> logging.info('setting chain/event functions')
> sink_pad = self.sink_pad
> sink_pad.set_chain_function(self.sink_chain)
> sink_pad.set_event_function(self.sink_event)
> self.num_bytes = 0
> self.set_sync(True)
>
> def sink_chain(self, pad, buf):
> size = buf.size
> self.num_bytes += size
> logging.debug("%s timestamp:%d size:%d(%d)",
> pad, buf.timestamp, size, len(buf.data))
> return gst.FLOW_OK
>
> def sink_event(self, pad, event):
> logging.info("%s event:%r" % (pad, event.type))
> return True
>
> gobject.type_register(MySink)
>
>
>
> Thanks
>
> Antoine.
>
>
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>
--
Edward Hervey
Multimedia editing developer / Fluendo S.A.
http://www.pitivi.org/
More information about the gstreamer-devel
mailing list