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


Python Pipeline.stop方法代码示例

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


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

示例1: testMultiple

# 需要导入模块: from pitivi.pipeline import Pipeline [as 别名]
# 或者: from pitivi.pipeline.Pipeline import stop [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 stop [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: Project

# 需要导入模块: from pitivi.pipeline import Pipeline [as 别名]
# 或者: from pitivi.pipeline.Pipeline import stop [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

示例4: TestPipeline

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

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

        # playing
        self.pipeline.setState(STATE_PLAYING)
        loop.run()
        self.failUnlessEqual(bag["last_state"], STATE_PLAYING)
        self.failUnlessEqual(self.pipeline.getState(), STATE_PLAYING)
        self.assertEquals(self.monitor.state_changed_count, 1)

        # playing again
        self.pipeline.setState(STATE_PLAYING)
        self.assertEquals(self.monitor.state_changed_count, 1)

        # ready
        self.pipeline.setState(STATE_READY)
        loop.run()
        self.failUnlessEqual(bag["last_state"], STATE_READY)
        self.failUnlessEqual(self.pipeline.getState(), STATE_READY)
        self.assertEquals(self.monitor.state_changed_count, 2)

        # PLAYING
        self.pipeline.play()
        loop.run()
        self.failUnlessEqual(bag["last_state"], STATE_PLAYING)
        self.failUnlessEqual(self.pipeline.getState(), STATE_PLAYING)
        self.assertEquals(self.monitor.state_changed_count, 3)

        # PAUSE
        self.pipeline.pause()
        loop.run()
        self.failUnlessEqual(bag["last_state"], STATE_PAUSED)
        self.failUnlessEqual(self.pipeline.getState(), STATE_PAUSED)
        self.assertEquals(self.monitor.state_changed_count, 4)

        self.pipeline.stop()
        loop.run()
        self.failUnlessEqual(bag["last_state"], STATE_READY)
        self.failUnlessEqual(self.pipeline.getState(), STATE_READY)
        self.assertEquals(self.monitor.state_changed_count, 5)

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

示例5: Project

# 需要导入模块: from pitivi.pipeline import Pipeline [as 别名]
# 或者: from pitivi.pipeline.Pipeline import stop [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.stop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。