Ejemplo n.º 1
0
    def create_interaudiosrc_and_connections(self):
        '''
        The audio equivalent of create_intervideosrc_and_connections
        '''

        mixer = self.session().mixers[0]

        source = mixer.sources.get_for_input_or_mixer(self)
        if not source:
            raise Exception('Cannot find source for input %d with mixer %d' %
                            (self.id, mixer.id))

        # Create the receiving 'inter' elements to accept the AV into the main pipeline
        interaudiosrc = source.add_element('interaudiosrc')
        self.interaudiosrc_src_pad = interaudiosrc.get_static_pad('src')

        # Blocks the src pad to stop incomplete messages.
        # Note, this has caused issues in the past.
        self._block_interaudiosrc_src_pad()

        # Give the 'inter' elements a channel name. It doesn't matter what, so long as they're unique.
        channel_name = create_intersink_channel_name()
        self.interaudiosink.set_property('channel', channel_name)
        interaudiosrc.set_property('channel', channel_name)

        self.audio_pad_to_connect_to_mix = interaudiosrc.get_static_pad('src')
Ejemplo n.º 2
0
    def _create_inter_elements(self, audio_or_video):
        '''
        Creates intervideosrc and intervideosink (or the equivalent audio ones)
        '''
        intersrc = self._create_intersrc(audio_or_video)
        intersink = self._create_intersink(audio_or_video)

        # Give the 'inter' elements a channel name. It doesn't matter what, so long as they're unique.
        channel_name = create_intersink_channel_name()
        intersink.set_property('channel', channel_name)
        intersrc.set_property('channel', channel_name)
        return intersrc, intersink
Ejemplo n.º 3
0
    def create_interaudiosink_and_connections(self):
        '''
        interaudiosink/interaudiosrc are used to connect the master pipeline
        with the local pipeline for this output.
        '''
        self.interaudiosink = self.source.add_element('interaudiosink', self)
        self.audio_element_multiqueue_should_connect_to = self.interaudiosink

        channel_name = create_intersink_channel_name()
        self.interaudiosrc.set_property('channel', channel_name)
        self.interaudiosink.set_property('channel', channel_name)

        # We block the source (output) pad of this interaudiosrc until we're sure audio is being sent.
        # Otherwise we can get a partial message, which causes an error.
        # We don't need to do this if the other one is playing.
        if self.source.get_state() not in [Gst.State.PLAYING, Gst.State.PAUSED]:
            block_pad(self, 'interaudiosrc_src_pad')
Ejemplo n.º 4
0
    def create_intervideosrc_and_connections(self):
        '''
        Create the 'intervideosrc' element, which accepts the video input that's come from a separate pipeline.
        Then connects intervideosrc to the convert/scale/queue elements, ready for mixing.
        '''

        mixer = self.session().mixers[0]

        source = mixer.sources.get_for_input_or_mixer(self)
        if not source:
            raise Exception('Cannot find source for input %d with mixer %d' %
                            (self.id, mixer.id))

        # Create the receiving 'inter' element to accept the AV into the main pipeline
        intervideosrc = source.add_element('intervideosrc')
        self.intervideosrc_src_pad = intervideosrc.get_static_pad('src')

        # We ask the src to hold the frame for 24 hours (basically, a very long time)
        # This is optional, but prevents it from going black when it's better to show the last frame.
        intervideosrc.set_property('timeout', Gst.SECOND * 60 * 60 * 24)

        # We block the source (output) pad of this intervideosrc until we're sure video is being sent.
        # Otherwise we can get a partial message, which causes an error.
        self._block_intervideosrc_src_pad()

        # Give the 'inter' elements a channel name. It doesn't matter what, so long as they're unique.
        channel_name = create_intersink_channel_name()
        self.intervideosink.set_property('channel', channel_name)
        intervideosrc.set_property('channel', channel_name)

        videoscale = source.add_element('videoscale')
        intervideosrc.link(videoscale)

        # Decent scaling options:
        videoscale.set_property('method', 3)
        videoscale.set_property('dither', True)

        self.capsfilter_after_intervideosrc = source.add_element('capsfilter')
        videoscale.link(self.capsfilter_after_intervideosrc)

        queue = source.add_element('queue', name='video_queue')
        self.capsfilter_after_intervideosrc.link(queue)

        self.video_pad_to_connect_to_mix = queue.get_static_pad('src')
Ejemplo n.º 5
0
    def create_intervideosink_and_connections(self):
        '''
        intervideosink/intervidesrc are used to connect the master pipeline
        with the local pipeline for this output.
        '''
        self.intervideosink = self.source.add_element('intervideosink', self)
        self.video_element_multiqueue_should_connect_to = self.intervideosink

        channel_name = create_intersink_channel_name()
        self.intervideosrc.set_property('channel', channel_name)
        self.intervideosink.set_property('channel', channel_name)

        # We block the source (output) pad of this intervideosrc until we're sure video is being sent.
        # Otherwise the output pipeline will have a 'not negotiated' error if it starts before the other one.
        # We don't need to do this if the other one is playing.
        # Note: without this things work *most* of the time.
        # 'test_image_input' is an example that fails without it.
        if self.source.get_state() not in [Gst.State.PLAYING, Gst.State.PAUSED]:
            block_pad(self, 'intervideosrc_src_pad')