[gstreamer-bugs] [Bug 581546] Elements do_query function is broken

GStreamer (bugzilla.gnome.org) bugzilla-daemon at bugzilla.gnome.org
Tue May 5 20:04:55 PDT 2009


If you have any questions why you received this email, please see the text at
the end of this email. Replies to this email are NOT read, please see the text
at the end of this email. You can add comments to this bug at:
  http://bugzilla.gnome.org/show_bug.cgi?id=581546

  GStreamer | gst-python | Ver: 0.10.22




------- Comment #1 from A2K  2009-05-06 03:04 UTC -------
Example code:

class Source(gst.BaseSrc):
    __gsttemplates__ = (
        gst.PadTemplate("src",
                        gst.PAD_SRC,
                        gst.PAD_ALWAYS,
                        gst.caps_new_any()),
                       )
    blocksize = 4096
    def __init__(self, name, config, track):
        self.__gobject_init__()
        self.set_name(name)
        self.buf = Buffer(track, config=config) #my class that downloads file
    def do_create(self, offset, size):
        if self.buf.length and offset > self.buf.length:
            return gst.FLOW_UNEXPECTED, None
        while self.buf.pos < offset+size and not self.buf.finished:
            sleep(0.1) # i don't know should i use this here
        self.buf.file.seek(offset)
        data = self.buf.file.read(size)
        return gst.FLOW_OK, gst.Buffer(data)
    def do_query (self, query):
        if query.type == gst.QUERY_DURATION:
            while not self.buf.track.length:
                sleep(0.01)
            if query.parse_duration()[0] == gst.FORMAT_TIME:
                lent = self.buf.track.length*gst.SECOND
                query.set_duration(gst.FORMAT_TIME, lent)
                query.stucture = gst.Query
                return True
            elif query.parse_duration()[0] == gst.FORMAT_BYTES:
                query.set_duration(format=gst.FORMAT_BYTES,
duration=self.buf.length/self.blocksize)
                return True
            else:
                return False
            return False
        elif query.type == gst.QUERY_LATENCY:
            query.set_latency(min_latency=0, live=False, max_latency=-1)
            return True
        else:
            print 'UNHANDLED QUERY:', query.type
            return False

#use this as a source for pipeline:
player = gst.Pipeline("pipeline")
source = Source("bufsrc", config, track)
decoder = gst.element_factory_make("mad", "mp3-decoder")
conv = gst.element_factory_make("audioconvert", "converter")
sink = gst.element_factory_make("autoaudiosink", "alsa-output")
player.add(source, decoder, conv, sink)
gst.element_link_many(source, decoder, conv, sink)


-- 
See http://bugzilla.gnome.org/page.cgi?id=email.html for more info about why you received
this email, why you can't respond via email, how to stop receiving
emails (or reduce the number you receive), and how to contact someone
if you are having problems with the system.

You can add comments to this bug at http://bugzilla.gnome.org/show_bug.cgi?id=581546.




More information about the Gstreamer-bugs mailing list