Esempio n. 1
0
def parse_create():
    pipe = Gst.parse_launchv([
        'audiotestsrc','name=source','!',
        'audiobin','name=testbin','caps=audio/x-raw,channels=2','!',
        'autoaudiosink','name=sink',
    ])
    return pipe
Esempio n. 2
0
def test_main():
    """Manually setup a pipeline with direct element creation"""
    logging.basicConfig(level=logging.DEBUG)

    bin = retrybin.UDPFailoverBin([
        {
            'address': '224.1.1.2',
            'port': 8000,
            'multicast-iface': 'lo'
        },
        {
            'address': '224.1.1.3',
            'port': 8000,
            'multicast-iface': 'lo'
        },
    ])
    pipe = Gst.parse_launchv([
        'queue',
        'name=input',
        '!',
        'decodebin',
        'name=decoder',
        '!',
        'autovideosink',
    ])
    pipe.add(bin)
    bin.link(pipe.get_by_name('input'))

    pipe.set_state(Gst.State.PLAYING)
    LOOP = GObject.MainLoop()
    LOOP.run()
Esempio n. 3
0
 def run(self):
     try:
         self.pipeline = Gst.parse_launchv(self.pipeline_command)
     except GLib.Error as err:
         log.error("Failed to parse the pipeline: %s", err)
         log.info(" gst-launch --gst-debug=3 %s",
                  " ".join(self.pipeline_command))
         raise
     bus = self.pipeline.get_bus()
     bus.add_signal_watch()
     bus.connect("message", self.message)
     self.pipeline.set_state(Gst.State.PLAYING)
Esempio n. 4
0
    def start_transmission(self) -> None:
        """Start video transmission"""

        width, height, fps = self.parameters()
        sys.stdout.buffer.write(struct.pack('=HHH', width, height, fps))
        sys.stdout.buffer.flush()
        Gst.init()
        element = self._element = Gst.parse_launchv(
            self.pipeline(width, height, fps))
        bus = element.get_bus()
        bus.add_signal_watch()
        bus.connect('message', self.msg_handler)
        element.set_state(Gst.State.PLAYING)
Esempio n. 5
0
def test_main():
    """Manually setup a pipeline with direct element creation"""
    logging.basicConfig(level=logging.INFO)
    log.info("Running on Gstreamer %s", Gst.version_string())
    caps = 'video/x-raw,width=720,height=480,rate=60'

    def source_constructor(*args, **named):
        """Callback that re-creates source when called"""
        patterns = [0, 1, 7, 8, 9, 10, 13, 18, 23, 24]
        pattern = patterns[named['retry_count'] % len(patterns)]
        return utils.EasyBin('source', [
            utils.create_element(
                'videotestsrc',
                pattern=pattern,
                is_live=True,
                name='primary',
                num_buffers=100,
            ),
            utils.create_element(
                'capsfilter', name='filter', caps=Gst.Caps.from_string(caps)),
        ])

    def default_build(*args, **named):
        return utils.EasyBin('source', [
            utils.create_element(
                'videotestsrc', is_live=True, name='primary', pattern=2),
            utils.create_element(
                'capsfilter', name='filter', caps=Gst.Caps.from_string(caps)),
        ])

    bin = retrybin.RetryBin(build_callback=source_constructor,
                            default_build=default_build)
    pipe = Gst.parse_launchv([
        'queue',
        'name=input',
        '!',
        'decodebin',
        'name=decoder',
        '!',
        'autovideosink',
    ])
    pipe.add(bin)
    bin.link(pipe.get_by_name('input'))

    pipe.set_state(Gst.State.PLAYING)
    LOOP = GObject.MainLoop()
    LOOP.run()
Esempio n. 6
0
def test_main():
    """Manually setup a pipeline with direct element creation"""
    logging.basicConfig(level=logging.DEBUG)

    pipe = Gst.parse_launchv([
        'videotestsrc',
        'pattern=6',
        '!',
        'video/x-raw,width=720,height=480,fps=10',
        '!',
        'x264enc',
        '!',
        'mpegtsmux',
        '!',
        'udpsink',
        'host=224.1.1.2',
        'multicast-iface=lo',
        'bind-address=127.0.0.1',
    ])
    pipe.set_state(Gst.State.PLAYING)
    LOOP = GObject.MainLoop()
    LOOP.run()