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


Python Pipeline.getState方法代码示例

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


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

示例1: testMultiple

# 需要导入模块: from pitivi.pipeline import Pipeline [as 别名]
# 或者: from pitivi.pipeline.Pipeline import getState [as 别名]
    def testMultiple(self):
        """Test a dual stream encoding with separates sources"""
        settings = RenderSettings(settings=[self.asettings, self.vsettings],
                                  muxer="oggmux")
        sf = RenderSinkFactory(RenderFactory(settings=settings),
                               common.FakeSinkFactory())
        a = RenderAction()
        a.addConsumers(sf)
        a.addProducers(self.vsrc, self.asrc)

        p = Pipeline()
        a.setPipeline(p)

        a.activate()
        self.assertEquals(len(a._links), 2)

        p.play()
        time.sleep(3)
        p.getState()
        p.stop()
        a.deactivate()

        a.unsetPipeline()

        p.release()
开发者ID:bemasc,项目名称:pitivi,代码行数:27,代码来源:test_action.py

示例2: testSimpleStreams

# 需要导入模块: from pitivi.pipeline import Pipeline [as 别名]
# 或者: from pitivi.pipeline.Pipeline import getState [as 别名]
    def testSimpleStreams(self):
        """Test a RenderSettings with exact stream settings"""
        # let's force the video to some unusual size
        outs = VideoStream(gst.Caps("video/x-raw-yuv,width=624,height=230,framerate=10/1"))
        fset = StreamEncodeSettings(encoder="theoraenc", input_stream=outs)
        settings = RenderSettings(settings=[fset], muxer="oggmux")
        sf = RenderSinkFactory(RenderFactory(settings=settings),
                               common.FakeSinkFactory())

        a = RenderAction()
        a.addConsumers(sf)
        a.addProducers(self.vsrc)

        p = Pipeline()
        a.setPipeline(p)

        a.activate()
        self.assertEquals(len(a._links), 1)

        p.play()
        time.sleep(3)
        p.getState()
        p.stop()
        a.deactivate()

        p.release()
开发者ID:bemasc,项目名称:pitivi,代码行数:28,代码来源:test_action.py

示例3: testDynamicLink

# 需要导入模块: from pitivi.pipeline import Pipeline [as 别名]
# 或者: from pitivi.pipeline.Pipeline import getState [as 别名]
    def testDynamicLink(self):
        a = DynamicAction()
        p = Pipeline()
        src = common.FakeGnlFactory()
        src.addOutputStream(VideoStream(gst.Caps("video/x-raw-yuv"),
                                        pad_name="src"))

        # the link will be added dynamically
        self.assertEquals(a._links, [])

        p.setAction(a)
        a.addProducers(src)

        self.assertEquals(len(list(p._pipeline.elements())), 0)

        a.activate()
        # theoretically... there shouldn't only be the source, since
        # the pad for the source hasn't been created yet (and therefore not
        # requiring a consumer
        self.assertEquals(len(list(p._pipeline.elements())), 1)

        p.setState(STATE_PLAYING)
        time.sleep(1)
        p.getState()

        # and make sure that all other elements were created (4)
        self.assertEquals(len(list(p._pipeline.elements())), 4)

        p.setState(STATE_READY)
        time.sleep(1)
        a.deactivate()

        self.assertEquals(len(list(p._pipeline.elements())), 0)
        p.setState(STATE_NULL)

        p.release()
开发者ID:Mathieu69,项目名称:Pitivi_Gargamel,代码行数:38,代码来源:test_pipeline_action.py

示例4: TestPipeline

# 需要导入模块: from pitivi.pipeline import Pipeline [as 别名]
# 或者: from pitivi.pipeline.Pipeline import getState [as 别名]
class TestPipeline(TestCase):

    def setUp(self):
        TestCase.setUp(self)
        gst.debug("start")
        self.pipeline = Pipeline()
        self.monitor = SignalMonitor(self.pipeline, 'action-added',
                                     'action-removed', 'factory-added',
                                     'factory-removed', 'state-changed')
        self.assertEquals(self.monitor.action_added_count, 0)
        self.assertEquals(self.monitor.action_added_collect, [])

    def tearDown(self):
        self.pipeline.setState(STATE_NULL)
        self.pipeline.release()
        self.monitor.disconnectFromObj(self.pipeline)
        del self.pipeline
        del self.monitor
        TestCase.tearDown(self)

    def testAddRemoveActionSimple(self):
        """ Simple add/remove of Actions """
        ac1 = BogusAction()

        # add the action to the pipeline
        res = self.pipeline.addAction(ac1)
        # the returned value should be the given action
        self.assertEquals(res, ac1)
        # it should now be in the list of actions...
        self.failUnlessEqual(self.pipeline.actions, [ac1])
        # ... and the action should be set to that pipeline
        self.failUnlessEqual(ac1.pipeline, self.pipeline)
        # the 'action-added' signal should be triggered once
        self.assertEquals(self.monitor.action_added_count, 1)
        # And it contained our action
        self.assertEquals(self.monitor.action_added_collect, [(ac1, )])

        # if we try to add that action again, it should be silently ignored
        res = self.pipeline.addAction(ac1)
        self.assertEquals(res, ac1)
        # the list of actions shouldn't have changed
        self.failUnlessEqual(self.pipeline.actions, [ac1])
        # it shouldn't have changed the pipeline set on action
        self.failUnlessEqual(ac1.pipeline, self.pipeline)
        # the 'action-added' signal should NOT have been triggered again
        self.assertEquals(self.monitor.action_added_count, 1)

        # And now to remove it
        self.pipeline.removeAction(ac1)
        # the 'action-removed' signal should have been triggered once..
        self.assertEquals(self.monitor.action_removed_count, 1)
        # .. with the action as an argument
        self.assertEquals(self.monitor.action_removed_collect, [(ac1, )])
        # And there should be no actions left on the pipeline
        self.assertEquals(self.pipeline.actions, [])

    def testAddRemoveActionAdvanced(self):
        """ Advanced add/remove of Actions """
        ac1 = BogusAction()
        ac2 = BogusAction()
        p2 = Pipeline()

        res = self.pipeline.addAction(ac1)
        self.assertEquals(self.pipeline.actions, [ac1])

        # we can't add an action to two pipelines at the same time
        self.failUnlessRaises(PipelineError, p2.addAction, ac1)

        self.pipeline.removeAction(ac1)
        self.assertEquals(self.pipeline.actions, [])

        res = self.pipeline.setAction(ac1)
        self.assertEquals(res, ac1)
        self.assertEquals(self.pipeline.actions, [ac1])
        # calling setAction while a similar action is already set should
        # return the existing action and not change anything else
        res = self.pipeline.setAction(ac2)
        self.assertEquals(res, ac1)
        self.assertEquals(self.pipeline.actions, [ac1])

        # we can't remove active actions while in PAUSED/PLAYING
        self.pipeline.setState(STATE_PAUSED)
        ac1.state = STATE_ACTIVE
        self.assertEquals(self.pipeline.getState(), STATE_PAUSED)
        self.failUnlessRaises(PipelineError, self.pipeline.removeAction, ac1)

        # but we can remove deactivated actions while in PAUSED/PLAYING
        self.pipeline.setState(STATE_PAUSED)
        ac1.state = STATE_NOT_ACTIVE
        self.assertEquals(self.pipeline.getState(), STATE_PAUSED)
        self.pipeline.removeAction(ac1)

        # we can add actions while in PAUSED/PLAYING
        res = self.pipeline.addAction(ac2)
        self.assertEquals(res, ac2)
        self.assertEquals(self.pipeline.actions, [ac2])

        self.pipeline.removeAction(ac2)
        p2.release()

#.........这里部分代码省略.........
开发者ID:bemasc,项目名称:pitivi,代码行数:103,代码来源:test_pipeline.py

示例5: Project

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

#.........这里部分代码省略.........
    @type factory: L{TimelineSourceFactory}
    @ivar format: The format under which the project is currently stored.
    @type format: L{FormatterClass}
    @ivar loaded: Whether the project is fully loaded or not.
    @type loaded: C{bool}

    Signals:
     - C{loaded} : The project is now fully loaded.
    """

    __signals__ = {
        "settings-changed" : ['old', 'new'],
        "project-changed" : [],
        }

    def __init__(self, name="", uri=None, **kwargs):
        """
        @param name: the name of the project
        @param uri: the uri of the project
        """
        Loggable.__init__(self)
        self.log("name:%s, uri:%s", name, uri)
        self.name = name
        self.settings = None
        self.description = ""
        self.uri = uri
        self.urichanged = False
        self.format = None
        self.sources = SourceList()
        self.sources.connect("source-added", self._sourceAddedCb)
        self.sources.connect("source-removed", self._sourceRemovedCb)

        self._dirty = False

        self.timeline = Timeline()

        self.factory = TimelineSourceFactory(self.timeline)
        self.pipeline = Pipeline()
        self.view_action = ViewAction()
        self.view_action.addProducers(self.factory)
        self.seeker = Seeker(80)

        self.settings = ExportSettings()
        self._videocaps = self.settings.getVideoCaps()

    def release(self):
        self.pipeline.release()
        self.pipeline = None

    #{ Settings methods

    def getSettings(self):
        """
        return the currently configured settings.
        """
        self.debug("self.settings %s", self.settings)
        return self.settings

    def setSettings(self, settings):
        """
        Sets the given settings as the project's settings.
        @param settings: The new settings for the project.
        @type settings: ExportSettings
        """
        assert settings
        self.log("Setting %s as the project's settings", settings)
        oldsettings = self.settings
        self.settings = settings
        self._projectSettingsChanged()
        self.emit('settings-changed', oldsettings, settings)

    #}

    #{ Save and Load features

    def setModificationState(self, state):
        self._dirty = state
        if state:
            self.emit('project-changed')

    def hasUnsavedModifications(self):
        return self._dirty

    def _projectSettingsChanged(self):
        settings = self.getSettings()
        self._videocaps = settings.getVideoCaps()
        if self.timeline:
            self.timeline.updateVideoCaps(self._videocaps)

        for fact in self.sources.getSources():
            fact.setFilterCaps(self._videocaps)
        if self.pipeline.getState() != gst.STATE_NULL:
            self.pipeline.stop()
            self.pipeline.pause()

    def _sourceAddedCb(self, sourcelist, factory):
        factory.setFilterCaps(self._videocaps)

    def _sourceRemovedCb(self, sourclist, uri, factory):
        self.timeline.removeFactory(factory)
开发者ID:bemasc,项目名称:pitivi,代码行数:104,代码来源:project.py

示例6: Project

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

#.........这里部分代码省略.........
        """
        return the currently configured settings.
        If no setting have been explicitely set, some smart settings will be
        chosen.
        """
        self.debug("self.settings %s", self.settings)
        return self.settings or self.getAutoSettings()

    def setSettings(self, settings):
        """
        Sets the given settings as the project's settings.
        If settings is None, the current settings will be unset
        """
        self.log("Setting %s as the project's settings", settings)
        oldsettings = self.settings
        self.settings = settings
        self._projectSettingsChanged()
        self.emit('settings-changed', oldsettings, settings)

    def unsetSettings(self, unused_settings):
        """ Remove the currently configured settings."""
        self.setSettings(None)

    def getAutoSettings(self):
        """
        Computes and returns smart settings for the project.
        If the project only has one source, it will be that source's settings.
        If it has more than one, it will return the largest setting that suits
        all contained sources.
        """
        settings = ExportSettings()
        if not self.timeline:
            self.warning("project doesn't have a timeline, returning default settings")
            return settings

        # FIXME: this is ugly, but rendering for now assumes at most one audio
        # and one video tracks
        have_audio = have_video = False
        for track in self.timeline.tracks:
            if isinstance(track.stream, VideoStream) and track.duration != 0:
                have_video = True
            elif isinstance(track.stream, AudioStream) and track.duration != 0:
                have_audio = True

        if not have_audio:
            settings.aencoder = None

        if not have_video:
            settings.vencoder = None

        return settings

    #}

    #{ Save and Load features

    def save(self, location=None, overwrite=False):
        """
        Save the project to the given location.

        @param location: The location to write to. If not specified, the
        current project location will be used (if set).
        @type location: C{URI}
        @param overwrite: Whether to overwrite existing location.
        @type overwrite: C{bool}
        """
        # import here to break circular import
        from pitivi.formatters.format import save_project
        from pitivi.formatters.base import FormatterError

        self.log("saving...")
        location = location or self.uri

        if location == None:
            raise FormatterError("Location unknown")

        save_project(self, location or self.uri, self.format,
                     overwrite)

        self.uri = location

    def setModificationState(self, state):
        self._dirty = state

    def hasUnsavedModifications(self):
        return self._dirty

    def _projectSettingsChanged(self):
        self.getCapsFromSettings()
        for fact in self.sources.getSources():
            fact.setFilterCaps(self._videocaps)
        if self.pipeline.getState() != gst.STATE_NULL:
            self.pipeline.stop()
            self.pipeline.pause()

    def _sourceAddedCb(self, sourcelist, factory):
        factory.setFilterCaps(self._videocaps)

    def _sourceRemovedCb(self, sourclist, uri, factory):
        self.timeline.removeFactory(factory)
开发者ID:ironss,项目名称:pitivi-tweaking,代码行数:104,代码来源:project.py


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