Beispiel #1
0
    def testVideoOnly(self):
        video_factory1 = VideoTestSourceFactory(3)
        video_factory1.duration = 3 * gst.SECOND
        stream = VideoStream(gst.Caps('video/x-raw-rgb'), 'src0')
        video_factory1.addOutputStream(stream)

        timeline = Timeline()
        track = Track(stream)
        track_object1 = SourceTrackObject(video_factory1, stream)
        track_object1.start = 1 * 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, 4 * 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 testVideoOnly(self):
        video_factory1 = VideoTestSourceFactory(3)
        video_factory1.duration = 3 * gst.SECOND
        stream = VideoStream(gst.Caps('video/x-raw-rgb'), 'src0')
        video_factory1.addOutputStream(stream)

        timeline = Timeline()
        track = Track(stream)
        track_object1 = SourceTrackObject(video_factory1, stream)
        track_object1.start = 1 * 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, 4 * 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()
Beispiel #3
0
def make_track_object(stream):
    factory = VideoTestSourceFactory()
    factory.duration = 15 * gst.SECOND
    return SourceTrackObject(factory, stream)
Beispiel #4
0
    def testAudioVideo(self):
        audio_factory1 = AudioTestSourceFactory(3)
        audio_factory1.duration = 10 * gst.SECOND
        audio_stream = AudioStream(gst.Caps('audio/x-raw-int'), 'src0')
        audio_factory1.addOutputStream(audio_stream)

        video_factory1 = VideoTestSourceFactory(3)
        video_factory1.duration = 3 * gst.SECOND
        video_stream = VideoStream(gst.Caps('video/x-raw-rgb'), 'src1')
        video_factory1.addOutputStream(video_stream)

        timeline = Timeline()
        video_track = Track(video_stream)
        audio_track = Track(audio_stream)

        track_object1 = SourceTrackObject(audio_factory1, audio_stream)
        track_object1.start = 2 * gst.SECOND
        audio_track.addTrackObject(track_object1)
        timeline.addTrack(audio_track)

        track_object2 = SourceTrackObject(video_factory1, video_stream)
        track_object2.start = 2 * gst.SECOND
        video_track.addTrackObject(track_object2)
        timeline.addTrack(video_track)

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

        fakesink1 = gst.element_factory_make('fakesink')
        fakesink2 = gst.element_factory_make('fakesink')
        fakesinks = [fakesink1, fakesink2]

        def bin_pad_added_cb(bin, pad):
            pad.link(fakesinks.pop(0).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(fakesink1)
        pipeline.add(fakesink2)

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

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

        video_factory1 = VideoTestSourceFactory(3)
        video_factory1.duration = 3 * gst.SECOND
        video_stream = VideoStream(gst.Caps('video/x-raw-rgb'), 'src1')
        video_factory1.addOutputStream(video_stream)

        timeline = Timeline()
        video_track = Track(video_stream)
        audio_track = Track(audio_stream)

        track_object1 = SourceTrackObject(audio_factory1, audio_stream)
        track_object1.start = 2 * gst.SECOND
        audio_track.addTrackObject(track_object1)
        timeline.addTrack(audio_track)

        track_object2 = SourceTrackObject(video_factory1, video_stream)
        track_object2.start = 2 * gst.SECOND
        video_track.addTrackObject(track_object2)
        timeline.addTrack(video_track)

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

        fakesink1 = gst.element_factory_make('fakesink')
        fakesink2 = gst.element_factory_make('fakesink')
        fakesinks = [fakesink1, fakesink2]

        def bin_pad_added_cb(bin, pad):
            pad.link(fakesinks.pop(0).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(fakesink1)
        pipeline.add(fakesink2)

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

        factory.clean()
def make_track_object(stream):
    factory = VideoTestSourceFactory()
    factory.duration = 15 * gst.SECOND
    return SourceTrackObject(factory, stream)