def _create_decoder_pipeline(self, filename, file): if file is None: # Hooray, can just use filename src = gst.gst_element_factory_make('filesrc', 'src') gobject.g_object_set(src, 'location', filename, None) else: # Boo, use PythonFileObjectSrc src = gst.gst_element_factory_make('pyfileobjectsrc', 'src') pysrc = PythonFileObjectSrc.get_instance(src) pysrc.init(file) # Don't GC the source self._file_source = pysrc # Create pipeline to manage pause/play state. pipeline = gst.gst_pipeline_new('pipeline') # Create decodebin to find audio and video streams in file decoder = gst.gst_element_factory_make('decodebin', 'decoder') self._new_decoded_pad_func = DecodebinNewDecodedPad( self._new_decoded_pad) self._no_more_pads_func = DecodebinNoMorePads(self._no_more_pads) gobject.g_signal_connect_data(decoder, 'new-decoded-pad', self._new_decoded_pad_func, None, None, 0) gobject.g_signal_connect_data(decoder, 'no-more-pads', self._no_more_pads_func, None, None, 0) gst.gst_bin_add_many(pipeline, src, decoder, None) gst.gst_element_link(src, decoder) # Create audioconvert self.convert = gst.gst_element_factory_make('audioconvert', 'convert') gst.gst_bin_add(pipeline, self.convert) return pipeline
def __init__(self, filename, file): super(GstreamerOpenALStreamingSound, self).__init__() self._pipeline = self._create_decoder_pipeline(filename, file) self.sink = gst.gst_element_factory_make('openalstreamingsink', 'sink') gst.gst_bin_add(self._pipeline, self.sink) gst.gst_element_link(self.convert, self.sink) gst.gst_element_set_state(self._pipeline, gstreamer.GST_STATE_PAUSED)
def __init__(self, filename, file=None): super(GstreamerOpenALStaticMedium, self).__init__() self._pipeline = self._create_decoder_pipeline(filename, file) self._sink = gst.gst_element_factory_make('openalstaticsink', 'sink') gst.gst_bin_add(self._pipeline, self._sink) gst.gst_element_link(self.convert, self._sink) self._element = OpenALStaticSinkElement.get_instance(self._sink) self._element.init() gst.gst_element_set_state(self._pipeline, gstreamer.GST_STATE_PLAYING)
def __init__(self, filename, file): super(GstreamerOpenALStreamingVideo, self).__init__() # Block frame format until width/height arrives self._frame_format_semaphore = threading.Semaphore(0) self._pipeline = self._create_decoder_pipeline(filename, file) self.sink = gst.gst_element_factory_make('openalstreamingsink', 'sink') gst.gst_bin_add(self._pipeline, self.sink) gst.gst_element_link(self.convert, self.sink) self.videoconvert = \ gst.gst_element_factory_make('ffmpegcolorspace', 'videoconvert') gst.gst_bin_add(self._pipeline, self.videoconvert) gst.gst_element_link(self.videoconvert, self.sink) gst.gst_element_set_state(self._pipeline, gstreamer.GST_STATE_PAUSED) self._frames = [] # queued upcoming video frames self._last_frame_timestamp = 0.