Esempio n. 1
0
    def testPads(self):
        timeline = Timeline()
        stream1 = VideoStream(gst.Caps('video/x-raw-rgb'), 'src0')
        stream2 = AudioStream(gst.Caps('audio/x-raw-int'), 'src1')
        track1 = Track(stream1)
        track2 = Track(stream2)

        timeline.addTrack(track1)
        timeline.addTrack(track2)

        factory = TimelineSourceFactory(timeline)
        bin = factory.makeBin()

        self.failUnlessEqual(len(list(bin.src_pads())), 0)

        pad1 = gst.Pad('src0', gst.PAD_SRC)
        pad1.set_caps(gst.Caps('asd'))
        pad1.set_active(True)
        track1.composition.add_pad(pad1)

        pad2 = gst.Pad('src0', gst.PAD_SRC)
        pad2.set_caps(gst.Caps('asd'))
        pad2.set_active(True)
        track2.composition.add_pad(pad2)

        self.failUnlessEqual(len(list(bin.src_pads())), 2)
        track1.composition.remove_pad(pad1)
        self.failUnlessEqual(len(list(bin.src_pads())), 1)
        track2.composition.remove_pad(pad2)
        self.failUnlessEqual(len(list(bin.src_pads())), 0)

        factory.clean()
    def testPads(self):
        timeline = Timeline()
        stream1 = VideoStream(gst.Caps('video/x-raw-rgb'), 'src0')
        stream2 = AudioStream(gst.Caps('audio/x-raw-int'), 'src1')
        track1 = Track(stream1)
        track2 = Track(stream2)

        timeline.addTrack(track1)
        timeline.addTrack(track2)

        factory = TimelineSourceFactory(timeline)
        bin = factory.makeBin()

        self.failUnlessEqual(len(list(bin.src_pads())), 0)

        pad1 = gst.Pad('src0', gst.PAD_SRC)
        pad1.set_caps(gst.Caps('asd'))
        pad1.set_active(True)
        track1.composition.add_pad(pad1)

        pad2 = gst.Pad('src0', gst.PAD_SRC)
        pad2.set_caps(gst.Caps('asd'))
        pad2.set_active(True)
        track2.composition.add_pad(pad2)

        self.failUnlessEqual(len(list(bin.src_pads())), 2)
        track1.composition.remove_pad(pad1)
        self.failUnlessEqual(len(list(bin.src_pads())), 1)
        track2.composition.remove_pad(pad2)
        self.failUnlessEqual(len(list(bin.src_pads())), 0)

        factory.clean()
Esempio n. 3
0
    def testTracks(self):
        timeline = Timeline()
        stream1 = VideoStream(gst.Caps('video/x-raw-rgb'), 'src0')
        stream2 = AudioStream(gst.Caps('audio/x-raw-int'), 'src1')
        track1 = Track(stream1)
        track2 = Track(stream2)

        # start with 2 tracks
        timeline.addTrack(track1)
        timeline.addTrack(track2)

        factory = TimelineSourceFactory(timeline)
        bin = factory.makeBin()
        self.failUnlessEqual(len(list(bin)), 2)
        self.failUnlessEqual(set(factory.getOutputStreams()),
                             set([stream1, stream2]))

        # add a new track
        stream3 = AudioStream(gst.Caps('audio/x-raw-int'), 'src2')
        track3 = Track(stream3)
        timeline.addTrack(track3)
        self.failUnlessEqual(len(list(bin)), 3)
        self.failUnlessEqual(set(factory.getOutputStreams()),
                             set([stream1, stream2, stream3]))

        # remove a track
        timeline.removeTrack(track3)
        self.failUnlessEqual(len(list(bin)), 2)
        self.failUnlessEqual(set(factory.getOutputStreams()),
                             set([stream1, stream2]))

        factory.clean()
    def testTracks(self):
        timeline = Timeline()
        stream1 = VideoStream(gst.Caps('video/x-raw-rgb'), 'src0')
        stream2 = AudioStream(gst.Caps('audio/x-raw-int'), 'src1')
        track1 = Track(stream1)
        track2 = Track(stream2)

        # start with 2 tracks
        timeline.addTrack(track1)
        timeline.addTrack(track2)

        factory = TimelineSourceFactory(timeline)
        bin = factory.makeBin()
        self.failUnlessEqual(len(list(bin)), 2)
        self.failUnlessEqual(set(factory.getOutputStreams()),
                set([stream1, stream2]))

        # add a new track
        stream3 = AudioStream(gst.Caps('audio/x-raw-int'), 'src2')
        track3 = Track(stream3)
        timeline.addTrack(track3)
        self.failUnlessEqual(len(list(bin)), 3)
        self.failUnlessEqual(set(factory.getOutputStreams()),
                set([stream1, stream2, stream3]))

        # remove a track
        timeline.removeTrack(track3)
        self.failUnlessEqual(len(list(bin)), 2)
        self.failUnlessEqual(set(factory.getOutputStreams()),
                set([stream1, stream2]))

        factory.clean()
Esempio n. 5
0
    def testEmpty(self):
        timeline = Timeline()
        factory = TimelineSourceFactory(timeline)
        bin = factory.makeBin()
        self.failUnlessRaises(ObjectFactoryError, factory.makeBin)

        self.failUnlessEqual(len(list(bin)), 0)

        factory.clean()
    def testEmpty(self):
        timeline = Timeline()
        factory = TimelineSourceFactory(timeline)
        bin = factory.makeBin()
        self.failUnlessRaises(ObjectFactoryError, factory.makeBin)

        self.failUnlessEqual(len(list(bin)), 0)

        factory.clean()
Esempio n. 7
0
    def testAudioOnly(self):
        audio_factory1 = AudioTestSourceFactory(3)
        audio_factory1.duration = 10 * gst.SECOND
        stream = AudioStream(gst.Caps('audio/x-raw-int'), 'src0')
        audio_factory1.addOutputStream(stream)

        timeline = Timeline()
        track = Track(stream)
        track_object1 = SourceTrackObject(audio_factory1, stream)
        track_object1.start = 2 * gst.SECOND
        track.addTrackObject(track_object1)
        timeline.addTrack(track)

        factory = TimelineSourceFactory(timeline)
        bin = factory.makeBin()
        self.failUnlessEqual(len(list(bin)), 1)
        self.failUnlessEqual(factory.duration, 12 * gst.SECOND)

        fakesink = gst.element_factory_make('fakesink')

        def bin_pad_added_cb(bin, pad):
            pad.link(fakesink.get_pad('sink'))

        bin.connect('pad-added', bin_pad_added_cb)

        def error_cb(bus, message):
            gerror, debug = message.parse_error()
            self.fail('%s: %s' % (gerror.message, debug))

        def eos_cb(bus, message):
            self.loop.quit()

        pipeline = gst.Pipeline()
        bus = pipeline.get_bus()
        bus.add_signal_watch()
        bus.connect('message::error', error_cb)
        bus.connect('message::eos', eos_cb)

        pipeline.add(bin)
        pipeline.add(fakesink)

        pipeline.set_state(gst.STATE_PLAYING)
        self.loop.run()
        pipeline.set_state(gst.STATE_NULL)

        factory.clean()
    def testAudioOnly(self):
        audio_factory1 = AudioTestSourceFactory(3)
        audio_factory1.duration = 10 * gst.SECOND
        stream = AudioStream(gst.Caps('audio/x-raw-int'), 'src0')
        audio_factory1.addOutputStream(stream)

        timeline = Timeline()
        track = Track(stream)
        track_object1 = SourceTrackObject(audio_factory1, stream)
        track_object1.start = 2 * gst.SECOND
        track.addTrackObject(track_object1)
        timeline.addTrack(track)

        factory = TimelineSourceFactory(timeline)
        bin = factory.makeBin()
        self.failUnlessEqual(len(list(bin)), 1)
        self.failUnlessEqual(factory.duration, 12 * gst.SECOND)

        fakesink = gst.element_factory_make('fakesink')

        def bin_pad_added_cb(bin, pad):
            pad.link(fakesink.get_pad('sink'))

        bin.connect('pad-added', bin_pad_added_cb)

        def error_cb(bus, message):
            gerror, debug = message.parse_error()
            self.fail('%s: %s' % (gerror.message, debug))

        def eos_cb(bus, message):
            self.loop.quit()

        pipeline = gst.Pipeline()
        bus = pipeline.get_bus()
        bus.add_signal_watch()
        bus.connect('message::error', error_cb)
        bus.connect('message::eos', eos_cb)

        pipeline.add(bin)
        pipeline.add(fakesink)

        pipeline.set_state(gst.STATE_PLAYING)
        self.loop.run()
        pipeline.set_state(gst.STATE_NULL)

        factory.clean()