Пример #1
0
    def change_mixer(self, has_alpha):
        # When we change from having an alpha channel to not having one,
        # we need to change the videomixer to avoid Not Negotiated Errors (since
        # we are actually changing the caps format in this case).
        # This is Hacky, but needed for the alpha passthrough optimization to be
        # usable since if fixes bugs such as #632414, #637522 (and perhaps others)
        # More infos at:
        #   http://jeff.ecchi.ca/blog/2011/04/24/negotiating-performance/
        for pad_name in self.inputs:
            values = self.inputs.get(pad_name)
            values[3].send_event(gst.event_new_flush_start())
            values[3].send_event(gst.event_new_flush_stop())
            if not values[3].is_blocked():
                values[3].set_blocked_async(True, self._pad_blockedCb)

        new_videomixer = gst.element_factory_make("videomixer",
                                                  "real-videomixer")
        new_videomixer.props.background = 1

        self.videomixer.set_state(gst.STATE_NULL)
        #We change the mixer
        self.remove(self.videomixer)
        self.add(new_videomixer)

        #And relink everything in the new one
        for pad_name in self.inputs:
            values = self.inputs.get(pad_name)
            videomixerpad = new_videomixer.get_request_pad(pad_name)
            values[2].get_pad("src").unlink(values[3])
            values[2].get_pad("src").link_full(videomixerpad,
                                               gst.PAD_LINK_CHECK_NOTHING)
            self.inputs[pad_name] = (values[0], values[1], values[2],
                                     videomixerpad)

        csp_sink = self.colorspace.get_pad("sink")
        self.videomixer.get_pad("src").unlink(csp_sink)
        self.videomixer = new_videomixer
        self.videomixer.link_pads_full("src", self.colorspace, "sink",
                                       gst.PAD_LINK_CHECK_NOTHING)

        for pad_name in self.inputs:
            values = self.inputs.get(pad_name)
            values[3].send_event(gst.event_new_flush_start())
            values[3].send_event(gst.event_new_flush_stop())
            if values[3].is_blocked():
                values[3].set_blocked_async(False, self._pad_blockedCb)

        self.sync_state_with_parent()
Пример #2
0
    def _src_event(self, unused_pad, event):
        # for the moment we just push it upstream
        self.debug("event %r" % event)
        if event.type == gst.EVENT_SEEK:
            flags = event.parse_seek()[2]
            self.debug("Handling seek event %r" % flags)
            if flags & gst.SEEK_FLAG_FLUSH:
                self.debug("sending flush_start event")
                self.srcpad.push_event(gst.event_new_flush_start())
            self._segment.set_seek(*event.parse_seek())
            self.debug("_segment start:%s stop:%s" % (gst.TIME_ARGS(self._segment.start),
                                                     gst.TIME_ARGS(self._segment.stop)))
            # create a new initial seek
            self.debug("pausing task")
            self.srcpad.pause_task()
            self.debug("task paused")

            self._needsegment = True
            self.debug("Sending FLUS_STOP event")
            if flags & gst.SEEK_FLAG_FLUSH:
                self.srcpad.push_event(gst.event_new_flush_stop())
            self.debug("Restarting our task")
            self.srcpad.start_task(self._our_task)
            self.debug("Returning True")
            return True

        return self.sinkpad.push_event(event)
Пример #3
0
    def _src_event(self, unused_pad, event):
        # for the moment we just push it upstream
        self.debug("event %r" % event)
        if event.type == gst.EVENT_SEEK:
            flags = event.parse_seek()[2]
            self.debug("Handling seek event %r" % flags)
            if flags & gst.SEEK_FLAG_FLUSH:
                self.debug("sending flush_start event")
                self.srcpad.push_event(gst.event_new_flush_start())
            self._segment.set_seek(*event.parse_seek())
            self.debug("_segment start:%s stop:%s" % (gst.TIME_ARGS(
                self._segment.start), gst.TIME_ARGS(self._segment.stop)))
            # create a new initial seek
            self.debug("pausing task")
            self.srcpad.pause_task()
            self.debug("task paused")

            self._needsegment = True
            self.debug("Sending FLUS_STOP event")
            if flags & gst.SEEK_FLAG_FLUSH:
                self.srcpad.push_event(gst.event_new_flush_stop())
            self.debug("Restarting our task")
            self.srcpad.start_task(self._our_task)
            self.debug("Returning True")
            return True

        return self.sinkpad.push_event(event)
Пример #4
0
    def change_mixer(self, has_alpha):
        # When we change from having an alpha channel to not having one,
        # we need to change the videomixer to avoid Not Negotiated Errors (since
        # we are actually changing the caps format in this case).
        # This is Hacky, but needed for the alpha passthrough optimization to be
        # usable since if fixes bugs such as #632414, #637522 (and perhaps others)
        # More infos at:
        #   http://jeff.ecchi.ca/blog/2011/04/24/negotiating-performance/
        for pad_name in self.inputs:
            values = self.inputs.get(pad_name)
            values[3].send_event(gst.event_new_flush_start())
            values[3].send_event(gst.event_new_flush_stop())
            if not values[3].is_blocked():
                values[3].set_blocked_async(True, self._pad_blockedCb)

        new_videomixer = gst.element_factory_make("videomixer", "real-videomixer")
        new_videomixer.props.background = 1

        self.videomixer.set_state(gst.STATE_NULL)
        #We change the mixer
        self.remove(self.videomixer)
        self.add(new_videomixer)

        #And relink everything in the new one
        for pad_name in self.inputs:
            values = self.inputs.get(pad_name)
            videomixerpad = new_videomixer.get_request_pad(pad_name)
            values[2].get_pad("src").unlink(values[3])
            values[2].get_pad("src").link_full(videomixerpad, gst.PAD_LINK_CHECK_NOTHING)
            self.inputs[pad_name] = (values[0], values[1], values[2], videomixerpad)

        csp_sink = self.colorspace.get_pad("sink")
        self.videomixer.get_pad("src").unlink(csp_sink)
        self.videomixer = new_videomixer
        self.videomixer.link_pads_full("src", self.colorspace, "sink", gst.PAD_LINK_CHECK_NOTHING)

        for pad_name in self.inputs:
            values = self.inputs.get(pad_name)
            values[3].send_event(gst.event_new_flush_start())
            values[3].send_event(gst.event_new_flush_stop())
            if values[3].is_blocked():
                values[3].set_blocked_async(False, self._pad_blockedCb)

        self.sync_state_with_parent()
Пример #5
0
 def stop_sound_device(self):
     '''Stop grabbing data from capture device'''
     gst.event_new_flush_stop()
     self.pipeline.set_state(gst.STATE_NULL)
Пример #6
0
 def stop_sound_device(self):
     '''Stop grabbing data from capture device'''
     gst.event_new_flush_stop()
     self.pipeline.set_state(gst.STATE_NULL)
Пример #7
0
 def API_seek(self, mseconds):
     print "Seek simple to " + mseconds + " useconds"
      # FIXME: this *1000-hack only works for Spotify?
     self.pipeline.seek_simple (gst.FORMAT_TIME, gst.SEEK_FLAG_NONE, int(mseconds) * 1000);
     self.src.get_pad("src").push_event(gst.event_new_flush_start())
     self.src.get_pad("src").push_event(gst.event_new_flush_stop())