예제 #1
0
    def testRunProvidesClocking(self):
        p2_pp = ('videotestsrc is-live=true ! '
                 'video/x-raw-rgb,framerate=(fraction)8/1,'
                 'width=32,height=24')
        p2 = pipeline_src(p2_pp)

        from flumotion.component.muxers.multipart import Multipart
        mux = ComponentWrapper('multipart-muxer', Multipart, name='mux')

        self.prod.feed(mux)
        p2.feed(mux)
        mux.feed(self.cnv1)

        self.clock_slave = p2

        def check_clocking(_):
            self.warning('check_clocking: %s %r' %
                         (self.clock_slave.name,
                          self.clock_slave.comp.pipeline.get_clock()))
            import gst
            pp = self.clock_slave.comp.pipeline
            # is there a better way to check if that component is
            # using an external clock source?
            self.failUnless(isinstance(pp.get_clock(), gst.NetClientClock),
                            "Didn't receive external clocking info.")
            return _
        task_d = defer.Deferred()
        task_d.addCallback(check_clocking)

        self.p.set_flow([self.prod, p2, mux, self.cnv1], auto_link=False)
        if self.prod is not self.p._master:
            # p2 (of [self.prod, p2]) seems to be the master this time
            self.clock_slave = self.prod
        d = self.p.run_flow(self.duration, tasks=[task_d])
        return d
예제 #2
0
    def testSimpleLink(self):
        pp = ComponentWrapper("pipeline-producer", None, name="pp")
        pc = ComponentWrapper("pipeline-converter", None)

        pp.feed(pc)
        self.assertEquals(pc.cfg["source"], ["pp:default"])
        self.assertEquals(pc.cfg["eater"], {"default": [("pp:default", "default")]})
예제 #3
0
    def testGstreamerError(self):
        pp = ComponentWrapper('pipeline-producer', Producer,
                              name='pp', props={'pipeline': 'fakesink'})

        d = pp.instantiate()
        # See the comment in test_setup_fail_gst_linking()
        return self.failUnlessFailure(d, ComponentSad)
예제 #4
0
    def testSimpleLink(self):
        pp = ComponentWrapper('pipeline-producer', None, name='pp')
        pc = ComponentWrapper('pipeline-converter', None)

        pp.feed(pc)
        self.assertEquals(pc.cfg['source'], ['pp:default'])
        self.assertEquals(pc.cfg['eater'], {'default':
                                            [('pp:default', 'default')]})
예제 #5
0
    def testSuccess(self):
        pp = ComponentWrapper('pipeline-producer', Producer,
                              name='pp', props={'pipeline':
                                                'audiotestsrc is-live=1'},
                              cfg={'clock-master': '/default/pp'})

        d = pp.instantiate()
        d.addCallback(lambda _: pp.wait_for_mood(moods.happy))
        d.addCallback(lambda _: pp.stop())
        return d
예제 #6
0
    def testInstantiateErrors(self):
        # this passes None as the class name for ComponentWrapper,
        # i.e. it tries to dynamically subclass None. Throws a "cannot
        # instantiate None" error
        pp = ComponentWrapper("pipeline-producer", None, name="pp")
        self.failUnlessRaises(TypeError, pp.instantiate)

        # missing mandatory pipeline property
        pp = ComponentWrapper("pipeline-producer", Producer, name="pp")
        d = pp.instantiate()
        # See the comment in test_setup_fail_gst_linking()
        return self.failUnlessFailure(d, ComponentSad)
예제 #7
0
    def testInstantiateErrors(self):
        # this passes None as the class name for ComponentWrapper,
        # i.e. it tries to dynamically subclass None. Throws a "cannot
        # instantiate None" error
        pp = ComponentWrapper('pipeline-producer', None, name='pp')
        self.failUnlessRaises(TypeError, pp.instantiate)

        # missing mandatory pipeline property
        pp = ComponentWrapper('pipeline-producer', Producer,
                              name='pp')
        d = pp.instantiate()
        # See the comment in test_setup_fail_gst_linking()
        return self.failUnlessFailure(d, ComponentSad)
예제 #8
0
    def testNonDefaultLink(self):
        fwp = ComponentWrapper("firewire-producer", None, name="fwp")
        pc = ComponentWrapper("pipeline-converter", None, name="pc")

        # this should raise an exception - firewire-producer doesn't
        # have a default feeder
        self.failUnlessRaises(comptest.ComponentTestException, fwp.feed, pc)

        fwp.feed(pc, [("video", "default")])
        fwp.feed(pc, [("audio", "default")])

        self.assertEquals(pc.cfg["source"], ["fwp:video", "fwp:audio"])
        self.assertEquals(pc.cfg["eater"], {"default": [("fwp:video", "default"), ("fwp:audio", "default-bis")]})
예제 #9
0
    def testSuccess(self):
        pp = ComponentWrapper(
            "pipeline-producer",
            Producer,
            name="pp",
            props={"pipeline": "audiotestsrc is-live=1"},
            cfg={"clock-master": "/default/pp"},
        )

        d = pp.instantiate()
        d.addCallback(lambda _: pp.wait_for_mood(moods.happy))
        d.addCallback(lambda _: pp.stop())
        return d
예제 #10
0
    def testNonDefaultLink(self):
        fwp = ComponentWrapper('firewire-producer', None, name='fwp')
        pc = ComponentWrapper('pipeline-converter', None, name='pc')

        # this should raise an exception - firewire-producer doesn't
        # have a default feeder
        self.failUnlessRaises(comptest.ComponentTestException, fwp.feed, pc)

        fwp.feed(pc, [('video', 'default')])
        fwp.feed(pc, [('audio', 'default')])

        self.assertEquals(pc.cfg['source'], ['fwp:video', 'fwp:audio'])
        self.assertEquals(pc.cfg['eater'],
                          {'default': [('fwp:video', 'default'),
                                       ('fwp:audio', 'default-bis')]})
예제 #11
0
 def testValidType(self):
     cw = ComponentWrapper('pipeline-producer', None, name='pp')
     self.assertEquals(cw.cfg,
                       {'feed': ['default'], 'name': 'pp',
                        'parent': 'default', 'clock-master': None,
                        'avatarId': '/default/pp', 'eater': {},
                        'source': [], 'plugs': {}, 'properties': {},
                        'type': 'pipeline-producer'})
예제 #12
0
            def instantiate(self, *a, **kw):
                d = ComponentWrapper.instantiate(self, *a, **kw)

                def delay_start(result):
                    dd = defer.Deferred()
                    reactor.callLater(start_delay_time, dd.callback, result)
                    return dd
                d.addCallback(delay_start)
                return d
예제 #13
0
            def stop(self, *a, **kw):
                d = ComponentWrapper.stop(self, *a, **kw)

                def delay_stop(result):
                    # breaking once should be enough
                    if self.do_break:
                        self.do_break = False
                        raise CustomStopException()
                d.addCallback(delay_stop)
                return d
예제 #14
0
            def stop(self, *a, **kw):
                d = ComponentWrapper.stop(self, *a, **kw)

                def delay_stop(result):
                    if self.do_delay:
                        self.do_delay = False
                        dd = defer.Deferred()
                        reactor.callLater(stop_delay_time, dd.callback, result)
                        return dd
                    return result
                d.addCallback(delay_stop)
                return d
예제 #15
0
 def testGetUniqueName(self):
     self.failIfEquals(ComponentWrapper.get_unique_name(),
                       ComponentWrapper.get_unique_name())
예제 #16
0
    def testGstreamerError(self):
        pp = ComponentWrapper("pipeline-producer", Producer, name="pp", props={"pipeline": "fakesink"})

        d = pp.instantiate()
        # See the comment in test_setup_fail_gst_linking()
        return self.failUnlessFailure(d, ComponentSad)