Beispiel #1
0
    def __init__(self, name, player, audiovis=False):
        ObGstPipeline.__init__(self, name)
        self.player = player
        self.start_time = 0
        self.audiosink = None
        self.videosink = None

        self.pipeline = Gst.Pipeline()

        self.decodebin = Gst.ElementFactory.make('uridecodebin')
        self.pipeline.add(self.decodebin)
        self.decodebin.connect("pad-added", self.on_decoder_pad_added)

        #if audiovis is True:
        #    self.audiovis = Gst.ElementFactory.make('libvisual_jess')
        #    self.pipeline.set_property('flags', self.pipeline.get_property('flags') | 0x00000008)
        #    self.pipeline.set_property('vis-plugin', self.audiovis)

        self.fakesinks = {}
        for output in self.player.outputs.keys() + ['audio', 'visual']:
            self.fakesinks[output] = Gst.ElementFactory.make('fakesink')

        self.set_property('audio-sink', self.fakesinks['audio'])
        self.set_property('video-sink', self.fakesinks['visual'])

        self.register_signals()
Beispiel #2
0
 def patch(self, mode):
     self.wait_state(Gst.State.NULL)
     if 'audio' in mode:
         self.set_property('audio-sink', self.player.outputs['audio'].get_bin())
     ObGstPipeline.patch(self, mode)
     self.wait_state(Gst.State.PLAYING)
     if obplayer.Config.setting('gst_init_callback'):
         os.system(obplayer.Config.setting('gst_init_callback'))
Beispiel #3
0
 def unpatch(self, mode):
     self.wait_state(Gst.State.NULL)
     if 'audio' in mode:
         self.set_property('audio-sink', self.fakesink)
     ObGstPipeline.unpatch(self, mode)
     if len(self.mode) > 0:
         self.wait_state(Gst.State.PLAYING)
         if obplayer.Config.setting('gst_init_callback'):
             os.system(obplayer.Config.setting('gst_init_callback'))
Beispiel #4
0
    def __init__(self, name, player):
        ObGstPipeline.__init__(self, name)
        self.player = player

        self.pipeline = Gst.Pipeline()
        self.elements = [ ]

        self.filesrc = Gst.ElementFactory.make('filesrc')
        self.pipeline.add(self.filesrc)

        self.sdpdemux = Gst.ElementFactory.make('sdpdemux')
        #self.sdpdemux.set_property('debug', True)
        self.pipeline.add(self.sdpdemux)
        self.filesrc.link(self.sdpdemux)

        def sdpdemux_pad_added(obj, pad):
            #print("Pad added " + str(pad))
            #caps = pad.get_current_caps()
            pad.link(self.decodebin.get_static_pad('sink'))
        self.sdpdemux.connect('pad-added', sdpdemux_pad_added)

        self.decodebin = Gst.ElementFactory.make('decodebin')
        self.pipeline.add(self.decodebin)

        def decodebin_pad_added(obj, pad):
            caps = pad.get_current_caps().to_string()
            #print(caps, pad.is_linked())

            if caps.startswith('audio'):
                pad.link(self.audioconvert.get_static_pad('sink'))
            else:
                print("Fake sink thing that we don't want")
                fakesink = Gst.ElementFactory.make('fakesink')
                self.pipeline.add(fakesink)
                pad.link(fakesink.get_static_pad('sink'))

            #for p in self.decodebin.iterate_pads():
            #    print("Pad: ", p, p.is_linked())
        self.decodebin.connect('pad-added', decodebin_pad_added)

        self.audioconvert = Gst.ElementFactory.make('audioconvert')
        self.pipeline.add(self.audioconvert)

        self.queue = Gst.ElementFactory.make('queue2')
        self.pipeline.add(self.queue)
        self.audioconvert.link(self.queue)


        self.audiosink = None
        self.fakesink = Gst.ElementFactory.make('fakesink')
        self.set_property('audio-sink', self.fakesink)

        self.register_signals()
Beispiel #5
0
    def __init__(self, name, player):
        ObGstPipeline.__init__(self, name)
        self.player = player

        self.pipeline = Gst.Pipeline()

        audio_input = obplayer.Config.setting('audio_in_mode')
        if audio_input == 'alsa':
            self.audiosrc = Gst.ElementFactory.make('alsasrc', 'audiosrc')
            alsa_device = obplayer.Config.setting('audio_in_alsa_device')
            if alsa_device != '':
                self.audiosrc.set_property('device', alsa_device)

        elif audio_input == 'jack':
            self.audiosrc = Gst.ElementFactory.make('jackaudiosrc', 'audiosrc')
            self.audiosrc.set_property('connect',
                                       0)  # don't autoconnect ports.
            name = obplayer.Config.setting('audio_in_jack_name')
            self.audiosrc.set_property('client-name',
                                       name if name else 'obplayer')

        elif audio_input == 'oss':
            self.audiosrc = Gst.ElementFactory.make('osssrc', 'audiosrc')

        elif audio_input == 'pulse':
            self.audiosrc = Gst.ElementFactory.make('pulsesrc', 'audiosrc')
            self.audiosrc.set_property('client-name', 'obplayer-pipe: line-in')

        elif audio_input == 'test':
            self.audiosrc = Gst.ElementFactory.make('fakesrc', 'audiosrc')

        else:
            self.audiosrc = Gst.ElementFactory.make('autoaudiosrc', 'audiosrc')

        self.pipeline.add(self.audiosrc)

        self.queue = Gst.ElementFactory.make('queue2')
        self.pipeline.add(self.queue)
        self.audiosrc.link(self.queue)

        self.audioconvert = Gst.ElementFactory.make('audioconvert')
        self.pipeline.add(self.audioconvert)
        self.queue.link(self.audioconvert)

        self.audiosink = None
        self.fakesink = Gst.ElementFactory.make('fakesink')
        self.set_property('audio-src', self.fakesink)

        self.register_signals()
Beispiel #6
0
    def __init__(self, name, player):
        ObGstPipeline.__init__(self, name)
        self.player = player

        self.pipeline = Gst.Pipeline()
        self.audiotestsrc = Gst.ElementFactory.make('audiotestsrc')
        self.pipeline.add(self.audiotestsrc)
        self.audiosink = None

        self.fakesink = Gst.ElementFactory.make('fakesink')

        self.set_property('audio-sink', self.fakesink)
        self.audiotestsrc.set_property('wave', 4)       # silence
        self.audiotestsrc.set_property('is-live', True)

        self.register_signals()
Beispiel #7
0
    def __init__(self, name, player):
        ObGstPipeline.__init__(self, name)
        self.player = player

        self.pipeline = Gst.Pipeline()
        self.audiotestsrc = Gst.ElementFactory.make('audiotestsrc')
        self.pipeline.add(self.audiotestsrc)
        self.videotestsrc = Gst.ElementFactory.make('videotestsrc')
        self.pipeline.add(self.videotestsrc)
        self.audiosink = None
        self.videosink = None

        self.fakesinks = {}
        for output in list(self.player.outputs.keys()) + ['audio', 'visual']:
            self.fakesinks[output] = Gst.ElementFactory.make('fakesink')

        self.set_property('audio-sink', self.fakesinks['audio'])
        self.set_property('video-sink', self.fakesinks['visual'])

        self.audiotestsrc.set_property('volume', 0.2)
        self.audiotestsrc.set_property('is-live', True)
        self.videotestsrc.set_property('is-live', True)
        self.register_signals()
Beispiel #8
0
    def __init__(self, name, player, audiovis=False):
        ObGstPipeline.__init__(self, name)
        self.player = player
        self.start_time = 0
        self.pipeline = Gst.ElementFactory.make('playbin')
        # TODO this is false for testing
        #self.pipeline.set_property('force-aspect-ratio', False)
        self.pipeline.set_property('force-aspect-ratio', True)

        if audiovis is True:
            self.audiovis = Gst.ElementFactory.make('libvisual_jess')
            self.pipeline.set_property(
                'flags',
                self.pipeline.get_property('flags') | 0x00000008)
            self.pipeline.set_property('vis-plugin', self.audiovis)

        self.fakesinks = {}
        for output in list(self.player.outputs.keys()) + ['audio', 'visual']:
            self.fakesinks[output] = Gst.ElementFactory.make('fakesink')

        self.pipeline.set_property('audio-sink', self.fakesinks['audio'])
        self.pipeline.set_property('video-sink', self.fakesinks['visual'])

        self.register_signals()
Beispiel #9
0
    def __init__(self, name, player):
        ObGstPipeline.__init__(self, name)
        self.player = player

        self.pipeline = Gst.Pipeline()
        self.elements = []

        self.prequeue = Gst.ElementFactory.make('queue2')
        self.elements.append(self.prequeue)

        self.rtpdepay = Gst.ElementFactory.make('rtpopusdepay')
        self.elements.append(self.rtpdepay)

        self.decoder = Gst.ElementFactory.make('opusdec')
        self.decoder.set_property('plc', True)  # Packet loss concealment
        self.decoder.set_property('use-inband-fec', True)  # FEC
        self.elements.append(self.decoder)

        self.audioconvert = Gst.ElementFactory.make('audioconvert')
        self.elements.append(self.audioconvert)
        self.audioresample = Gst.ElementFactory.make('audioresample')
        self.audioresample.set_property('quality', 6)
        self.elements.append(self.audioresample)

        self.postqueue = Gst.ElementFactory.make('queue2')
        self.elements.append(self.postqueue)

        self.build_pipeline(self.elements)

        ## Hook up RTPBin
        self.udpsrc_rtp = Gst.ElementFactory.make('udpsrc')
        self.udpsrc_rtp.set_property('port', 5004)
        #self.udpsrc_rtp.set_property('caps', Gst.Caps.from_string("application/x-rtp"))
        self.udpsrc_rtp.set_property(
            'caps',
            Gst.Caps.from_string(
                "application/x-rtp,payload=96,media=audio,clock-rate=48000,encoding-name=OPUS"
            ))
        #self.udpsrc_rtp.set_property('caps', Gst.Caps.from_string("application/x-rtp,media=audio,channels=1,clock-rate=44100,encoding-name=L16"))
        #self.udpsrc_rtp.set_property('timeout', 3000000)
        #self.elements.append(self.udpsrc_rtp)
        self.pipeline.add(self.udpsrc_rtp)

        self.udpsrc_rtcp = Gst.ElementFactory.make('udpsrc')
        self.udpsrc_rtcp.set_property('port', 5004 + 1)
        self.pipeline.add(self.udpsrc_rtcp)

        self.rtpbin = Gst.ElementFactory.make('rtpbin')
        #self.rtpbin.set_property('latency', 2000)
        #self.rtpbin.set_property('autoremove', True)
        #self.rtpbin.set_property('do-lost', True)
        #self.rtpbin.set_property('buffer-mode', 1)
        self.rtpbin.set_property('drop-on-latency', True)
        #self.elements.append(self.rtpbin)
        self.pipeline.add(self.rtpbin)

        self.udpsrc_rtp.link_pads('src', self.rtpbin, 'recv_rtp_sink_0')
        self.udpsrc_rtcp.link_pads('src', self.rtpbin, 'recv_rtcp_sink_0')

        def rtpbin_pad_added(obj, pad):
            self.rtpbin.unlink(self.elements[0])
            self.rtpbin.link(self.elements[0])

        self.rtpbin.connect('pad-added', rtpbin_pad_added)

        self.audiosink = None
        self.fakesink = Gst.ElementFactory.make('fakesink')
        self.set_property('audio-src', self.fakesink)

        self.register_signals()
Beispiel #10
0
    def __init__(self, name, player, audiovis=False):
        ObGstPipeline.__init__(self, name)
        self.player = player
        self.request = None
        self.videosink = None

        self.images_transitions_enable = obplayer.Config.setting('images_transitions_enable')
        self.images_width = obplayer.Config.setting('images_width')
        self.images_height = obplayer.Config.setting('images_height')
        self.images_framerate = obplayer.Config.setting('images_framerate')

        self.pipeline = Gst.Pipeline()

        #self.imagebin = Gst.parse_launch('uridecodebin uri="file:///home/trans/Downloads/kitty.jpg" ! imagefreeze ! videoconvert ! videoscale ! video/x-raw, height=1920, width=1080 ! autovideosink')

        self.decodebin = Gst.ElementFactory.make('uridecodebin', 'uridecodebin')
        self.pipeline.add(self.decodebin)
        self.decodebin.connect("pad-added", self.on_decoder_pad_added)

        self.elements = [ ]
        self.elements.append(Gst.ElementFactory.make('imagefreeze', 'imagefreeze'))

        ## create basic filter elements
        self.elements.append(Gst.ElementFactory.make("videoscale", "image_scale"))
        #self.elements[-1].set_property('add-borders', False)
        self.elements.append(Gst.ElementFactory.make("videoconvert", "image_convert"))
        self.elements.append(Gst.ElementFactory.make("videorate", "image_rate"))

        ## create caps filter element to set the output video parameters
        caps = Gst.ElementFactory.make('capsfilter', "image_capsfilter")
        #caps.set_property('caps', Gst.Caps.from_string("video/x-raw,width=" + str(self.video_width) + ",height=" + str(self.video_height)))
        #caps.set_property('caps', Gst.Caps.from_string("video/x-raw,width=640,height=480,framerate=15/1"))
        caps.set_property('caps', Gst.Caps.from_string("video/x-raw,width=%d,height=%d,framerate=%d/1" % (self.images_width, self.images_height, self.images_framerate)))
        self.elements.append(caps)

        #self.videobalance = Gst.ElementFactory.make('videobalance', 'videobalance')
        #self.videobalance.set_property('videobalance', 0.0)
        #self.elements.append(self.videobalance)

        self.control_source = GstController.InterpolationControlSource.new()
        self.control_source.props.mode = GstController.InterpolationMode.LINEAR

        #binding = GstController.DirectControlBinding.new(self.videobalance, 'contrast', self.control_source)
        #self.videobalance.add_control_binding(binding)

        if self.images_transitions_enable:
            self.elements.append(Gst.ElementFactory.make('alpha', 'alpha'))
            #self.elements[-1].set_property('method', 1)
            binding = GstController.DirectControlBinding.new(self.elements[-1], 'alpha', self.control_source)
            self.elements[-1].add_control_binding(binding)

            self.elements.append(Gst.ElementFactory.make('videomixer', 'videomixer'))
            self.elements[-1].set_property('background', 1)

        """
        self.elements.append(Gst.ElementFactory.make('videorate', 'videorate'))

        ## create caps filter element to set the output video parameters
        caps_filter = Gst.ElementFactory.make('capsfilter', "capsfilter3")
        caps_filter.set_property('caps', Gst.Caps.from_string("video/x-raw,framerate=5/1"))
        self.elements.append(caps_filter)
        """

        self.build_pipeline(self.elements)

        self.register_signals()
Beispiel #11
0
    def __init__(self, name, player):
        ObGstPipeline.__init__(self, name)
        self.player = player

        self.pipeline = Gst.Pipeline()
        self.elements = [ ]


        self.rtspsrc = Gst.ElementFactory.make('rtspsrc')
        #self.rtspsrc.set_property('location', "rtsp://172.16.0.15/by-id/2")
        self.pipeline.add(self.rtspsrc)
        self.rtspsrc.connect('on-sdp', self.rtspsrc_on_sdp)

        def rtspsrc_pad_added(obj, pad):
            print("Pad added " + str(pad))

            caps = pad.get_current_caps().to_string()
            #print(caps)

            if 'media=(string)audio' in caps:
                pad.link(self.decodebin.get_static_pad('sink'))
            else:
                pad.link(Gst.ElementFactory.make('fakesink').get_static_pad('sink'))
        self.rtspsrc.connect('pad-added', rtspsrc_pad_added)

        self.decodebin = Gst.ElementFactory.make('decodebin')
        self.pipeline.add(self.decodebin)
        #self.rtspsrc.link(self.decodebin)

        self.queue = Gst.ElementFactory.make('queue2')
        self.pipeline.add(self.queue)

        self.audioconvert = Gst.ElementFactory.make('audioconvert')
        self.pipeline.add(self.audioconvert)
        self.queue.link(self.audioconvert)

        #self.foo = Gst.ElementFactory.make('autoaudiosink')
        #self.pipeline.add(self.foo)
        #self.queue.link(self.foo)

        def decodebin_pad_added(obj, pad):
            print("Decode pad added " + str(pad))

            caps = pad.get_current_caps().to_string()
            print(caps, pad.is_linked())

            if caps.startswith('audio'):
                pad.link(self.queue.get_static_pad('sink'))
            else:
                print("Fake sink thing that we don't want")
                fakesink = Gst.ElementFactory.make('fakesink')
                self.pipeline.add(fakesink)
                pad.link(fakesink.get_static_pad('sink'))

            #for p in self.decodebin.iterate_pads():
            #    print("Pad: ", p, p.is_linked())

        self.decodebin.connect('pad-added', decodebin_pad_added)


        self.audiosink = None
        self.fakesink = Gst.ElementFactory.make('fakesink')
        self.set_property('audio-src', self.fakesink)

        self.register_signals()