[gst-devel] Reusing a pipeline

Jeffrey Barish jeff_barish at earthlink.net
Tue Feb 5 03:38:04 CET 2008

I created a class for ripping to a file.  It works fine once, but if I try
to use the same instance a second time, query_position or query_duration
returns a bogus value (I compute a ratio, so I'm not sure which is wrong). 
I presume that something needs to be reinitialized before I use the
instance again, but I don't see my mistake.  Clues?  It works to create a
new instance each time.  Is it good GStreamer practice to re-create the
pipeline each time despite the inefficiency?

class Ripper(gst.Pipeline):
    def __init__(self):
        gst.Pipeline.__init__(self, 'ripper_pipeline')
        self.prop_dict = {}

        cd_src = gst.element_factory_make('cdparanoiasrc', 'cd_src')
        self._register_property(cd_src, 'track')

        converter = gst.element_factory_make('audioconvert', 'converter')

        encoder = gst.element_factory_make('vorbisenc', 'encoder')

        oggmux = gst.element_factory_make('oggmux', 'oggmux')

        file_sink = gst.element_factory_make('filesink', 'file_sink')
        self._register_property(file_sink, 'location')

        gst.element_link_many(cd_src, converter, encoder, oggmux, file_sink)

    def _register_property(self, element, prop):
        # Direct set_property calls to the right element.
        self.prop_dict[prop] = element

    def set_property(self, prop, val):
        element = self.prop_dict[prop]
        element.set_property(prop, val)
Jeffrey Barish

More information about the gstreamer-devel mailing list