[gst-devel] gst-python: how to use BaseSink.set_sync()

Antoine Pitrou antoine.pitrou at wengo.fr
Fri Oct 20 11:38:13 CEST 2006


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).

I also tried to define get_times() and render() methods but they never
get 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.






More information about the gstreamer-devel mailing list