コード例 #1
0
    def testSaveTimeline(self):
        video_stream = VideoStream(gst.Caps("video/x-raw-yuv"))
        audio_stream = AudioStream(gst.Caps("audio/x-raw-int"))
        source1 = VideoTestSourceFactory()
        source1.addOutputStream(video_stream)

        self.formatter._saveSource(source1)
        self.formatter._saveStream(video_stream)

        track_object = SourceTrackObject(source1, video_stream,
                start=10 * gst.SECOND, duration=20 * gst.SECOND,
                in_point=5 * gst.SECOND, media_duration=15 * gst.SECOND,
                priority=10)

        track = Track(video_stream)
        track.addTrackObject(track_object)

        self.formatter._saveTrackObject(track_object)

        timeline_object = TimelineObject(source1)
        timeline_object.addTrackObject(track_object)

        self.formatter._saveTimelineObject(timeline_object)

        timeline = Timeline()
        timeline.addTrack(track)

        element = self.formatter._saveTimeline(timeline)
        self.failUnlessEqual(element.tag, "timeline")
        tracks = element.find("tracks")
        self.failUnlessEqual(len(tracks), 1)
コード例 #2
0
    def testGetReleaseBinForFactoryStream(self):
        factory = VideoTestSourceFactory()
        stream = VideoStream(gst.Caps('video/x-raw-rgb; video/x-raw-yuv'),
                             'src0')
        factory.addOutputStream(stream)

        # try to get a cached instance
        self.failUnlessRaises(PipelineError,
                              self.pipeline.getBinForFactoryStream, factory,
                              stream, False)

        # create a bin
        bin1 = self.pipeline.getBinForFactoryStream(factory, stream, True)
        self.failUnless(isinstance(bin1, gst.Element))
        # return the cached instance
        bin2 = self.pipeline.getBinForFactoryStream(factory, stream, True)
        self.failUnlessEqual(id(bin1), id(bin2))

        self.pipeline.releaseBinForFactoryStream(factory, stream)
        self.pipeline.releaseBinForFactoryStream(factory, stream)

        # the bin has been destroyed at this point
        self.failUnlessRaises(PipelineError,
                              self.pipeline.releaseBinForFactoryStream,
                              factory, stream)

        # we should get a new instance
        bin2 = self.pipeline.getBinForFactoryStream(factory, stream, True)
        self.pipeline.releaseBinForFactoryStream(factory, stream)
コード例 #3
0
ファイル: test_etree_formatter.py プロジェクト: qlf/Pitivi
    def testSaveTimeline(self):
        video_stream = VideoStream(gst.Caps("video/x-raw-yuv"))
        audio_stream = AudioStream(gst.Caps("audio/x-raw-int"))
        source1 = VideoTestSourceFactory()
        source1.addOutputStream(video_stream)

        self.formatter._saveSource(source1)
        self.formatter._saveStream(video_stream)

        track_object = SourceTrackObject(source1,
                                         video_stream,
                                         start=10 * gst.SECOND,
                                         duration=20 * gst.SECOND,
                                         in_point=5 * gst.SECOND,
                                         media_duration=15 * gst.SECOND,
                                         priority=10)

        track = Track(video_stream)
        track.addTrackObject(track_object)

        self.formatter._saveTrackObject(track_object)

        timeline_object = TimelineObject(source1)
        timeline_object.addTrackObject(track_object)

        self.formatter._saveTimelineObject(timeline_object)

        timeline = Timeline()
        timeline.addTrack(track)

        element = self.formatter._saveTimeline(timeline)
        self.failUnlessEqual(element.tag, "timeline")
        tracks = element.find("tracks")
        self.failUnlessEqual(len(tracks), 1)
コード例 #4
0
ファイル: test_pipeline.py プロジェクト: bemasc/pitivi
    def testGetReleaseBinForFactoryStream(self):
        factory = VideoTestSourceFactory()
        stream = VideoStream(gst.Caps('video/x-raw-rgb; video/x-raw-yuv'),
                'src0')
        factory.addOutputStream(stream)

        # try to get a cached instance
        self.failUnlessRaises(PipelineError,
                self.pipeline.getBinForFactoryStream, factory, stream, False)

        # create a bin
        bin1 = self.pipeline.getBinForFactoryStream(factory, stream, True)
        self.failUnless(isinstance(bin1, gst.Element))
        # return the cached instance
        bin2 = self.pipeline.getBinForFactoryStream(factory, stream, True)
        self.failUnlessEqual(id(bin1), id(bin2))

        self.pipeline.releaseBinForFactoryStream(factory, stream)
        self.pipeline.releaseBinForFactoryStream(factory, stream)

        # the bin has been destroyed at this point
        self.failUnlessRaises(PipelineError,
                self.pipeline.releaseBinForFactoryStream, factory, stream)

        # we should get a new instance
        bin2 = self.pipeline.getBinForFactoryStream(factory, stream, True)
        self.pipeline.releaseBinForFactoryStream(factory, stream)
コード例 #5
0
ファイル: test_pipeline.py プロジェクト: bemasc/pitivi
    def testGetReleaseQueueForFactoryStream(self):
        factory = FakeSinkFactory()
        stream = VideoStream(gst.Caps('any'), 'sink')
        factory.addInputStream(stream)

        self.failUnlessRaises(PipelineError,
            self.pipeline.getQueueForFactoryStream, factory, stream, True)

        # getBinForFactoryStream(factory, stream) must be called before
        self.failUnlessRaises(PipelineError,
            self.pipeline.getQueueForFactoryStream, factory, stream, True)

        # create the bin
        bin1 = self.pipeline.getBinForFactoryStream(factory, stream, True)

        # try to get a cached queue
        self.failUnlessRaises(PipelineError,
            self.pipeline.getQueueForFactoryStream, factory, stream, False)

        # create queue
        queue1 = self.pipeline.getQueueForFactoryStream(factory, stream, True)
        self.failUnless(isinstance(queue1, gst.Element))

        gst.debug("pouet")

        # get the cached instance
        queue2 = self.pipeline.getQueueForFactoryStream(factory, stream, True)
        self.failUnlessEqual(id(queue1), id(queue2))

        # release
        self.pipeline.releaseQueueForFactoryStream(factory, stream)

        gst.debug("pouet")

        # there's still a queue alive, so we can't release the bin
        self.failUnlessRaises(PipelineError,
                self.pipeline.releaseBinForFactoryStream, factory, stream)

        self.pipeline.releaseQueueForFactoryStream(factory, stream)

        gst.debug("pouet2")
        self.failUnlessRaises(PipelineError,
                self.pipeline.releaseQueueForFactoryStream, factory, stream)

        # should always fail with a src bin
        factory2 = VideoTestSourceFactory()
        stream2 = VideoStream(gst.Caps('any'), 'src')
        factory2.addOutputStream(stream2)

        bin1 = self.pipeline.getBinForFactoryStream(factory, stream, True)
        self.failUnlessRaises(PipelineError,
            self.pipeline.getQueueForFactoryStream, factory2, stream2, True)
        self.pipeline.releaseBinForFactoryStream(factory, stream)

        self.pipeline.releaseBinForFactoryStream(factory, stream)
        self.assertEquals(factory.current_bins, 0)
コード例 #6
0
ファイル: test_etree_formatter.py プロジェクト: qlf/Pitivi
    def testLoadTimeline(self):
        # we need a project for this to work
        self.formatter.project = Project()

        # create fake document tree
        timeline_element = Element("timeline")

        tracks_element = SubElement(timeline_element, "tracks")
        track_element = SubElement(tracks_element, "track")
        stream_element = SubElement(track_element,
                                    "stream",
                                    id="1",
                                    type="pitivi.stream.VideoStream",
                                    caps="video/x-raw-rgb")
        track_objects_element = SubElement(track_element, "track-objects")
        track_object = SubElement(
            track_objects_element,
            "track-object",
            type="pitivi.timeline.track.SourceTrackObject",
            start=ts(1 * gst.SECOND),
            duration=ts(10 * gst.SECOND),
            in_point=ts(5 * gst.SECOND),
            media_duration=ts(15 * gst.SECOND),
            priority=ts(5),
            id="1")
        factory_ref = SubElement(track_object, "factory-ref", id="1")
        stream_ref = SubElement(track_object, "stream-ref", id="1")
        timeline_objects_element = SubElement(timeline_element,
                                              "timeline-objects")
        timeline_object_element = \
                SubElement(timeline_objects_element, "timeline-object")
        factory_ref = SubElement(timeline_object_element,
                                 "factory-ref",
                                 id="1")
        stream_ref = SubElement(timeline_object_element, "stream-ref", id="1")
        track_object_refs = SubElement(timeline_object_element,
                                       "track-object-refs")
        track_object_ref = SubElement(track_object_refs,
                                      "track-object-ref",
                                      id="1")

        # insert fake streams and factories into context
        factory = VideoTestSourceFactory()
        self.formatter._context.factories["1"] = factory
        stream = VideoStream(gst.Caps("video/x-raw-rgb"))
        self.formatter._context.streams["1"] = stream
        video_stream = VideoStream(gst.Caps("video/x-raw-yuv"))
        source1 = VideoTestSourceFactory()
        self.formatter._context.factories["2"] = source1
        self.formatter._context.track_objects["1"] = SourceTrackObject(
            source1, video_stream)

        # point gun at foot; pull trigger
        self.formatter._loadTimeline(timeline_element)
        self.failUnlessEqual(len(self.formatter.project.timeline.tracks), 1)
コード例 #7
0
    def testGetReleaseTeeForFactoryStream(self):
        factory = VideoTestSourceFactory()
        stream = VideoStream(gst.Caps('video/x-raw-rgb; video/x-raw-yuv'),
                             'src')
        factory.addOutputStream(stream)

        self.failUnlessRaises(PipelineError,
                              self.pipeline.getTeeForFactoryStream, factory,
                              stream, True)

        # getBinForFactoryStream(factory, stream) must be called before
        self.failUnlessRaises(PipelineError,
                              self.pipeline.getTeeForFactoryStream, factory,
                              stream, True)

        # create the bin
        bin1 = self.pipeline.getBinForFactoryStream(factory, stream, True)

        # try to get a cached tee
        self.failUnlessRaises(PipelineError,
                              self.pipeline.getTeeForFactoryStream, factory,
                              stream, False)

        # create tee
        tee1 = self.pipeline.getTeeForFactoryStream(factory, stream, True)
        self.failUnless(isinstance(tee1, gst.Element))

        # get the cached instance
        tee2 = self.pipeline.getTeeForFactoryStream(factory, stream, True)
        self.failUnlessEqual(id(tee1), id(tee2))

        # release
        self.pipeline.releaseTeeForFactoryStream(factory, stream)

        # there's still a tee alive, so we can't release the bin
        #self.failUnlessRaises(PipelineError,
        #        self.pipeline.releaseBinForFactoryStream, factory, stream)

        self.pipeline.releaseTeeForFactoryStream(factory, stream)
        self.failUnlessRaises(PipelineError,
                              self.pipeline.releaseTeeForFactoryStream,
                              factory, stream)

        # should always fail with a sink bin
        factory2 = FakeSinkFactory()
        stream2 = VideoStream(gst.Caps('video/x-raw-rgb; video/x-raw-yuv'),
                              'src')
        factory2.addInputStream(stream2)

        self.failUnlessRaises(PipelineError,
                              self.pipeline.getTeeForFactoryStream, factory2,
                              stream2, True)
        self.pipeline.releaseBinForFactoryStream(factory, stream)
コード例 #8
0
ファイル: test_pipeline.py プロジェクト: bemasc/pitivi
    def testGetReleaseTeeForFactoryStream(self):
        factory = VideoTestSourceFactory()
        stream = VideoStream(gst.Caps('video/x-raw-rgb; video/x-raw-yuv'),
                'src')
        factory.addOutputStream(stream)

        self.failUnlessRaises(PipelineError,
            self.pipeline.getTeeForFactoryStream, factory, stream, True)

        # getBinForFactoryStream(factory, stream) must be called before
        self.failUnlessRaises(PipelineError,
            self.pipeline.getTeeForFactoryStream, factory, stream, True)

        # create the bin
        bin1 = self.pipeline.getBinForFactoryStream(factory, stream, True)

        # try to get a cached tee
        self.failUnlessRaises(PipelineError,
            self.pipeline.getTeeForFactoryStream, factory, stream, False)

        # create tee
        tee1 = self.pipeline.getTeeForFactoryStream(factory, stream, True)
        self.failUnless(isinstance(tee1, gst.Element))

        # get the cached instance
        tee2 = self.pipeline.getTeeForFactoryStream(factory, stream, True)
        self.failUnlessEqual(id(tee1), id(tee2))

        # release
        self.pipeline.releaseTeeForFactoryStream(factory, stream)

        # there's still a tee alive, so we can't release the bin
        #self.failUnlessRaises(PipelineError,
        #        self.pipeline.releaseBinForFactoryStream, factory, stream)

        self.pipeline.releaseTeeForFactoryStream(factory, stream)
        self.failUnlessRaises(PipelineError,
                self.pipeline.releaseTeeForFactoryStream, factory, stream)

        # should always fail with a sink bin
        factory2 = FakeSinkFactory()
        stream2 = VideoStream(gst.Caps('video/x-raw-rgb; video/x-raw-yuv'),
                'src')
        factory2.addInputStream(stream2)

        self.failUnlessRaises(PipelineError,
            self.pipeline.getTeeForFactoryStream, factory2, stream2, True)
        self.pipeline.releaseBinForFactoryStream(factory, stream)
コード例 #9
0
ファイル: test_etree_formatter.py プロジェクト: qlf/Pitivi
    def testLoadTrack(self):
        # create fake document tree
        element = Element("track")
        stream_element = SubElement(element,
                                    "stream",
                                    id="1",
                                    type="pitivi.stream.VideoStream",
                                    caps="video/x-raw-rgb")

        track_objects_element = SubElement(element, "track-objects")
        track_object = SubElement(
            track_objects_element,
            "track-object",
            type="pitivi.timeline.track.SourceTrackObject",
            start=ts(1 * gst.SECOND),
            duration=ts(10 * gst.SECOND),
            in_point=ts(5 * gst.SECOND),
            media_duration=ts(15 * gst.SECOND),
            priority=ts(5),
            id="1")
        factory_ref = SubElement(track_object, "factory-ref", id="1")
        stream_ref = SubElement(track_object, "stream-ref", id="1")

        # insert fake factories and streams into current context
        factory = VideoTestSourceFactory()
        self.formatter._context.factories["1"] = factory
        stream = VideoStream(gst.Caps("video/x-raw-rgb"))
        self.formatter._context.streams["1"] = stream

        # point gun at foot; pull trigger
        track = self.formatter._loadTrack(element)

        self.failUnlessEqual(len(track.track_objects), 1)
        # FIXME: this is an hack
        self.failUnlessEqual(str(track.stream), str(stream))
コード例 #10
0
ファイル: test_etree_formatter.py プロジェクト: qlf/Pitivi
    def testSaveTrack(self):
        video_stream = VideoStream(gst.Caps("video/x-raw-yuv"))
        audio_stream = AudioStream(gst.Caps("audio/x-raw-int"))
        source1 = VideoTestSourceFactory()

        # these two calls are needed to populate the context for the -ref
        # elements
        self.formatter._saveSource(source1)
        self.formatter._saveStream(video_stream)

        track_object = SourceTrackObject(source1,
                                         video_stream,
                                         start=10 * gst.SECOND,
                                         duration=20 * gst.SECOND,
                                         in_point=5 * gst.SECOND,
                                         media_duration=15 * gst.SECOND,
                                         priority=10)

        track = Track(video_stream)
        track.addTrackObject(track_object)

        element = self.formatter._saveTrack(track)
        self.failUnlessEqual(element.tag, "track")
        track_objects_element = element.find("track-objects")
        self.failUnlessEqual(len(track_objects_element), 1)
コード例 #11
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()
コード例 #12
0
ファイル: test_timeline_factory.py プロジェクト: qlf/Pitivi
    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()
コード例 #13
0
ファイル: test_etree_formatter.py プロジェクト: qlf/Pitivi
    def testLoadProject(self):
        video_stream = VideoStream(gst.Caps("video/x-raw-yuv"))
        audio_stream = AudioStream(gst.Caps("audio/x-raw-int"))
        source1 = VideoTestSourceFactory()

        self.formatter._saveSource(source1)
        self.formatter._saveStream(video_stream)

        track_object = SourceTrackObject(source1,
                                         video_stream,
                                         start=10 * gst.SECOND,
                                         duration=20 * gst.SECOND,
                                         in_point=5 * gst.SECOND,
                                         media_duration=15 * gst.SECOND,
                                         priority=10)

        track = Track(video_stream)
        track.addTrackObject(track_object)

        self.formatter._saveTrackObject(track_object)

        timeline_object = TimelineObject(source1)
        timeline_object.addTrackObject(track_object)

        self.formatter._saveTimelineObject(timeline_object)

        timeline = Timeline()
        timeline.addTrack(track)

        self.formatter._saveTimeline(timeline)

        project = Project()
        project.timeline = timeline
        project.sources.addFactory(source1)

        element = self.formatter._serializeProject(project)

        self.failUnlessEqual(element.tag, "pitivi")
        self.failIfEqual(element.find("factories"), None)
        self.failIfEqual(element.find("timeline"), None)

        indent(element)
        f = file("/tmp/untitled.pptv", "w")
        f.write(tostring(element))
        f.close()
コード例 #14
0
ファイル: test_etree_formatter.py プロジェクト: qlf/Pitivi
    def testLoadTimelineObject(self):
        video_stream = VideoStream(gst.Caps("video/x-raw-yuv"))
        source1 = VideoTestSourceFactory()
        self.formatter._context.factories["1"] = source1
        self.formatter._context.track_objects["1"] = SourceTrackObject(
            source1, video_stream)

        element = Element("timeline-object")
        factory_ref = SubElement(element, "factory-ref", id="1")
        stream_ref = SubElement(element, "stream-ref", id="1")
        track_object_refs = SubElement(element, "track-object-refs")
        track_object_ref = SubElement(track_object_refs,
                                      "track-object-ref",
                                      id="1")

        timeline_object = \
                self.formatter._loadTimelineObject(element)

        self.failUnlessEqual(timeline_object.factory, source1)
        self.failUnlessEqual(len(timeline_object.track_objects), 1)
コード例 #15
0
ファイル: track.py プロジェクト: dparker18/Pitivi
    def _getDefaultVideoTrackObject(self, stream):
        factory = VideoTestSourceFactory(pattern='black')
        factory.setFilterCaps(stream.caps)
        track_object = SourceTrackObject(factory, stream)

        return track_object
コード例 #16
0
def make_track_object(stream):
    factory = VideoTestSourceFactory()
    factory.duration = 15 * gst.SECOND
    return SourceTrackObject(factory, stream)
コード例 #17
0
ファイル: test_timeline_factory.py プロジェクト: qlf/Pitivi
    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()
コード例 #18
0
def make_track_object(stream):
    factory = VideoTestSourceFactory()
    factory.duration = 15 * gst.SECOND
    return SourceTrackObject(factory, stream)
コード例 #19
0
def new_source_factory():
    return VideoTestSourceFactory()
コード例 #20
0
    def testPipelineAction(self):
        """Testing pipeline state interaction"""
        p = Pipeline()
        a = Action()
        src = VideoTestSourceFactory()
        sink = common.FakeSinkFactory()
        sink.addInputStream(MultimediaStream(gst.Caps("any"), pad_name="sink"))

        # set the Action on the Pipeline
        p.setAction(a)
        self.assertEquals(p.actions, [a])

        # set the Producer and Consumer
        a.addProducers(src)
        a.addConsumers(sink)

        a.setLink(src, sink)

        # activate the Action
        a.activate()

        self.failUnlessEqual(src.current_bins, 1)
        self.failUnlessEqual(sink.current_bins, 1)

        # call get*ForFactoryStream(..., automake=False). They will raise
        # exceptions if the action didn't create the elements.
        bin = p.getBinForFactoryStream(src, automake=False)
        p.releaseBinForFactoryStream(src)

        tee = p.getTeeForFactoryStream(src, automake=False)
        p.releaseTeeForFactoryStream(src)

        bin = p.getBinForFactoryStream(sink, automake=False)

        queue = p.getQueueForFactoryStream(sink, automake=False)

        self.failUnlessEqual(queue.get_pad('src').get_peer().get_parent(), bin)

        p.releaseBinForFactoryStream(sink)
        p.releaseQueueForFactoryStream(sink)

        # switch to PLAYING
        p.setState(STATE_PLAYING)

        # wait half a second

        # switch to READY
        p.setState(STATE_READY)

        # deactivate action
        a.deactivate()

        # since we're the last Action to be release, the tees
        # and queues should have gone
        self.failUnlessEqual(src.current_bins, 0)
        self.failUnlessEqual(sink.current_bins, 0)

        # remove the action from the pipeline
        p.removeAction(a)

        # the gst.Pipeline should be empty !
        self.assertEquals(list(p._pipeline.elements()), [])

        p.release()
コード例 #21
0
ファイル: test_still_image.py プロジェクト: dparker18/Pitivi
    def setUp(self):
        self.mainloop = gobject.MainLoop()

        samples = os.path.join(os.path.dirname(__file__), "samples")
        self.facs = []
        self.facs.append([
            PictureFileSourceFactory(
                'file://' + os.path.join(samples, "flat_colour1_640x480.png")),
            VideoStream(
                gst.Caps(
                    "video/x-raw-rgb,bpp=(int)24,depth=(int)24,endianness=(int)4321,red_mask=(int)16711680,green_mask=(int)65280,blue_mask=(int)255"
                ))
        ])
        self.facs.append([
            PictureFileSourceFactory(
                'file://' + os.path.join(samples, "flat_colour2_640x480.png")),
            VideoStream(
                gst.Caps(
                    "video/x-raw-rgb,bpp=(int)24,depth=(int)24,endianness=(int)4321,red_mask=(int)16711680,green_mask=(int)65280,blue_mask=(int)255"
                ))
        ])
        self.facs.append([
            PictureFileSourceFactory(
                'file://' + os.path.join(samples, "flat_colour3_320x180.png")),
            VideoStream(
                gst.Caps(
                    "video/x-raw-rgb,bpp=(int)24,depth=(int)24,endianness=(int)4321,red_mask=(int)16711680,green_mask=(int)65280,blue_mask=(int)255"
                ))
        ])
        # one video with a different resolution
        self.facs.append([
            VideoTestSourceFactory(),
            VideoStream(
                gst.Caps(
                    'video/x-raw-yuv,width=(int)640,height=(int)480,format=(fourcc)I420'
                ))
        ])

        # configure durations and add output streams to factories
        for fac in self.facs:
            factory = fac[0]
            stream = fac[1]
            factory.duration = self.clip_duration
            factory.addOutputStream(stream)
        self.track_objects = []
        self.track = Track(self.facs[0][1])
        self.timeline = Timeline()
        self.timeline.addTrack(self.track)

        vsettings = StreamEncodeSettings(encoder="theoraenc")
        rsettings = RenderSettings(settings=[vsettings], muxer="oggmux")
        self.fakesink = common.FakeSinkFactory()
        rendersink = RenderSinkFactory(RenderFactory(settings=rsettings),
                                       self.fakesink)
        self.render = RenderAction()
        self.pipeline = Pipeline()
        self.pipeline.connect("eos", self._renderEOSCb)
        self.pipeline.connect("error", self._renderErrorCb)
        self.pipeline.addAction(self.render)
        self.render.addConsumers(rendersink)
        timeline_factory = TimelineSourceFactory(self.timeline)
        self.render.addProducers(timeline_factory)
コード例 #22
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()
コード例 #23
0
    def testGetReleaseQueueForFactoryStream(self):
        factory = FakeSinkFactory()
        stream = VideoStream(gst.Caps('any'), 'sink')
        factory.addInputStream(stream)

        self.failUnlessRaises(PipelineError,
                              self.pipeline.getQueueForFactoryStream, factory,
                              stream, True)

        # getBinForFactoryStream(factory, stream) must be called before
        self.failUnlessRaises(PipelineError,
                              self.pipeline.getQueueForFactoryStream, factory,
                              stream, True)

        # create the bin
        bin1 = self.pipeline.getBinForFactoryStream(factory, stream, True)

        # try to get a cached queue
        self.failUnlessRaises(PipelineError,
                              self.pipeline.getQueueForFactoryStream, factory,
                              stream, False)

        # create queue
        queue1 = self.pipeline.getQueueForFactoryStream(factory, stream, True)
        self.failUnless(isinstance(queue1, gst.Element))

        gst.debug("pouet")

        # get the cached instance
        queue2 = self.pipeline.getQueueForFactoryStream(factory, stream, True)
        self.failUnlessEqual(id(queue1), id(queue2))

        # release
        self.pipeline.releaseQueueForFactoryStream(factory, stream)

        gst.debug("pouet")

        # there's still a queue alive, so we can't release the bin
        self.failUnlessRaises(PipelineError,
                              self.pipeline.releaseBinForFactoryStream,
                              factory, stream)

        self.pipeline.releaseQueueForFactoryStream(factory, stream)

        gst.debug("pouet2")
        self.failUnlessRaises(PipelineError,
                              self.pipeline.releaseQueueForFactoryStream,
                              factory, stream)

        # should always fail with a src bin
        factory2 = VideoTestSourceFactory()
        stream2 = VideoStream(gst.Caps('any'), 'src')
        factory2.addOutputStream(stream2)

        bin1 = self.pipeline.getBinForFactoryStream(factory, stream, True)
        self.failUnlessRaises(PipelineError,
                              self.pipeline.getQueueForFactoryStream, factory2,
                              stream2, True)
        self.pipeline.releaseBinForFactoryStream(factory, stream)

        self.pipeline.releaseBinForFactoryStream(factory, stream)
        self.assertEquals(factory.current_bins, 0)
コード例 #24
0
ファイル: track.py プロジェクト: bemasc/pitivi
    def _getDefaultVideoTrackObject(self, stream):
        factory = VideoTestSourceFactory(pattern='black')
        factory.setFilterCaps(stream.caps)
        track_object = SourceTrackObject(factory, stream)

        return track_object