当前位置: 首页>>代码示例>>Python>>正文


Python Pipeline.getQueueForFactoryStream方法代码示例

本文整理汇总了Python中pitivi.pipeline.Pipeline.getQueueForFactoryStream方法的典型用法代码示例。如果您正苦于以下问题:Python Pipeline.getQueueForFactoryStream方法的具体用法?Python Pipeline.getQueueForFactoryStream怎么用?Python Pipeline.getQueueForFactoryStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pitivi.pipeline.Pipeline的用法示例。


在下文中一共展示了Pipeline.getQueueForFactoryStream方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestPipeline

# 需要导入模块: from pitivi.pipeline import Pipeline [as 别名]
# 或者: from pitivi.pipeline.Pipeline import getQueueForFactoryStream [as 别名]

#.........这里部分代码省略.........

        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)

    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)
开发者ID:bemasc,项目名称:pitivi,代码行数:104,代码来源:test_pipeline.py

示例2: testPipelineAction

# 需要导入模块: from pitivi.pipeline import Pipeline [as 别名]
# 或者: from pitivi.pipeline.Pipeline import getQueueForFactoryStream [as 别名]
    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()
开发者ID:Mathieu69,项目名称:Pitivi_Gargamel,代码行数:66,代码来源:test_pipeline_action.py


注:本文中的pitivi.pipeline.Pipeline.getQueueForFactoryStream方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。