[pitivi: 7/27] Removed Actioner.actioner
- From: Thibault Saunier <tsaunier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi: 7/27] Removed Actioner.actioner
- Date: Wed, 11 May 2011 14:05:46 +0000 (UTC)
commit d2e50f89a76e97bdbcaf23fbded9c11686da7446
Author: Alex BÄ?luÈ? <alexandru balut gmail com>
Date: Mon Mar 7 12:55:58 2011 +0100
Removed Actioner.actioner
pitivi/action.py | 23 +------
pitivi/actioner.py | 195 +++++++++++++++++++++++++++++++---------------------
2 files changed, 118 insertions(+), 100 deletions(-)
---
diff --git a/pitivi/action.py b/pitivi/action.py
index e93bf6b..d77e133 100644
--- a/pitivi/action.py
+++ b/pitivi/action.py
@@ -30,7 +30,7 @@ states = (STATE_NOT_ACTIVE,
from pitivi.signalinterface import Signallable
from pitivi.factories.base import SourceFactory, SinkFactory
-from pitivi.encode import RenderSinkFactory, RenderFactory
+from pitivi.encode import RenderSinkFactory
from pitivi.log.loggable import Loggable
# TODO : Create a convenience class for Links
@@ -747,24 +747,3 @@ class RenderAction(Action):
compatible_consumers = [RenderSinkFactory]
# Use a queue of 5s to allow for big interleave
queue_size = 5
-
-def render_action_for_uri(uri, settings, *factories):
- """Creates a L{RenderAction}.
-
- @param uri: The destination uri
- @type uri: C{URI}
- @param settings: The settings
- @type settings: L{RenderSettings}
- @param factories: The source factories
- @type factories: L{SourceFactory}
- @returns: The action
- @rtype: L{RenderAction}
- """
- from pitivi.factories.file import URISinkFactory
- sf = RenderSinkFactory(RenderFactory(settings=settings),
- URISinkFactory(uri=uri))
- a = RenderAction()
- a.addProducers(*factories)
- a.addConsumers(sf)
-
- return a
diff --git a/pitivi/actioner.py b/pitivi/actioner.py
index 7a3aaeb..b7c8882 100644
--- a/pitivi/actioner.py
+++ b/pitivi/actioner.py
@@ -1,6 +1,6 @@
# PiTiVi , Non-linear video editor
#
-# render.py
+# pitivi/actioner.py
#
# Copyright (c) 2005, Edward Hervey <bilboed bilboed com>
# Copyright (c) 2010, Robert Swain <rob opendot cl>
@@ -27,13 +27,15 @@ Rendering helpers
import time
import gst
-from pitivi.signalinterface import Signallable
-from pitivi.log.loggable import Loggable
-from pitivi.action import render_action_for_uri, ViewAction
+from pitivi.action import RenderAction, ViewAction
+from pitivi.encode import RenderFactory, RenderSinkFactory
from pitivi.factories.base import SourceFactory
+from pitivi.factories.file import URISinkFactory
from pitivi.factories.timeline import TimelineSourceFactory
+from pitivi.log.loggable import Loggable
from pitivi.settings import export_settings_to_render_settings
-from pitivi.stream import VideoStream, AudioStream
+from pitivi.signalinterface import Signallable
+from pitivi.stream import AudioStream, VideoStream
from pitivi.utils import beautify_length
class Actioner(Loggable, Signallable):
@@ -44,9 +46,6 @@ class Actioner(Loggable, Signallable):
"error" : None
}
- RENDERER = 0
- PREVIEWER = 1
-
def __init__(self, project, pipeline=None):
Loggable.__init__(self)
# grab the Pipeline and settings
@@ -61,8 +60,6 @@ class Actioner(Loggable, Signallable):
def _eosCb(self, unused_pipeline):
self.debug("eos !")
- if self.actioner != self.PREVIEWER:
- self.shutdown()
self.emit("eos")
def shutdown(self):
@@ -90,77 +87,87 @@ class Actioner(Loggable, Signallable):
def addAction(self):
self.debug("action %r", self.action)
- if self.action == None:
- if self.actioner == self.RENDERER:
- self.pipeline.connect('position', self._positionCb)
- self.pipeline.connect('eos', self._eosCb)
- self.pipeline.connect('error', self._errorCb)
- self.debug("Setting pipeline to STOP")
- self.pipeline.stop()
- self.debug("Creating action")
- if len(self.pipeline.factories) == 0:
- sources = [self.project.factory]
- else:
- sources = [factory for factory in self.pipeline.factories
- if isinstance(factory, SourceFactory)]
- if self.actioner == self.PREVIEWER:
- self.action = ViewAction()
- self.action.addProducers(*sources)
- self.ui.setAction(self.action)
- self.ui.setPipeline(self.pipeline)
- elif self.actioner == self.RENDERER:
- settings = export_settings_to_render_settings(self.settings,
- self.have_video, self.have_audio)
- self.action = render_action_for_uri(self.outfile,
- settings, *sources)
- #else:
- # BIG FAT ERROR HERE
-
- self.debug("setting action on pipeline")
- self.pipeline.addAction(self.action)
- self.debug("Activating action")
- self.action.activate()
- if self.actioner == self.RENDERER:
- self.debug("Setting all active ViewAction to sync=False")
- for ac in self.pipeline.actions:
- if isinstance(ac, ViewAction) and ac.isActive():
- ac.setSync(False)
- self.debug("Updating all sources to render settings")
- self._changeSourceSettings(self.settings)
- self.debug("setting pipeline to PAUSE")
- self.pipeline.pause()
- self.debug("done")
+ if self.action:
+ return
+ self._connectFunctions()
+ self.debug("Setting pipeline to STOP")
+ self.pipeline.stop()
+ self.debug("Creating action")
+ sources = self._getSources()
+ self.action = self._createAction(sources)
+
+ self.debug("Setting action on pipeline")
+ self.pipeline.addAction(self.action)
+ self.debug("Activating action")
+ self._activateAction()
+ self.debug("Updating all sources to render settings")
+ self._changeSourceSettings(self.settings)
+ self.debug("Setting pipeline to PAUSE")
+ self.pipeline.pause()
+ self.debug("Done")
+ def _getSources(self):
+ if not self.pipeline.factories:
+ return [self.project.factory]
+ return [factory
+ for factory in self.pipeline.factories
+ if isinstance(factory, SourceFactory)]
+
+ def _connectFunctions(self):
+ self.pipeline.connect('eos', self._eosCb)
+ self.pipeline.connect('error', self._errorCb)
+
+ def _disconnectFunctions(self):
+ self.pipeline.disconnect_by_function(self._eosCb)
+ self.pipeline.disconnect_by_function(self._errorCb)
+
+ def _activateAction(self):
+ self.action.activate()
def removeAction(self):
self.debug("action %r", self.action)
- if self.action:
- self.pipeline.stop()
- self.action.deactivate()
- self.pipeline.removeAction(self.action)
- self.debug("putting all active ViewActions back to sync=True")
- for ac in self.pipeline.actions:
- if isinstance(ac, ViewAction) and ac.isActive():
- ac.setSync(True)
- self._changeSourceSettings(self.project.getSettings())
- self.pipeline.pause()
- if self.actioner == self.RENDERER:
- self.pipeline.disconnect_by_function(self._positionCb)
- self.pipeline.disconnect_by_function(self._eosCb)
- self.pipeline.disconnect_by_function(self._errorCb)
- self.action = None
-
- def _startAction(self):
+ if not self.action:
+ return
+ self.pipeline.stop()
+ self.action.deactivate()
+ self.pipeline.removeAction(self.action)
+ self.debug("putting all active ViewActions back to sync=True")
+ for ac in self.pipeline.actions:
+ if isinstance(ac, ViewAction) and ac.isActive():
+ ac.setSync(True)
+ self._changeSourceSettings(self.project.getSettings())
+ self.pipeline.pause()
+ self._disconnectFunctions()
+ self.action = None
+
+ def startAction(self):
+ if not self._isReady():
+ return
self.addAction()
self.pipeline.play()
self.timestarted = time.time()
self.acting = True
+ def _isReady(self):
+ """ Whether the @action can be started """
+ raise NotImplementedError()
+
+ def _createAction(self, sources):
+ """ Create the @action for this Actioner
+
+ @param sources: The source factories
+ @type sources: L{SourceFactory}
+ """
+ raise NotImplementedError()
+
class Renderer(Actioner):
""" Rendering helper methods """
def __init__(self, project, pipeline=None, outfile=None):
- self.actioner = self.RENDERER
+ """
+ @param outfile: The destination URI
+ @type outfile: C{URI}
+ """
Actioner.__init__(self, project, pipeline)
self.detectStreamTypes()
self.outfile = outfile
@@ -187,7 +194,6 @@ class Renderer(Actioner):
def _positionCb(self, unused_pipeline, position):
self.debug("%r %r", unused_pipeline, position)
- fraction = None
text = None
timediff = time.time() - self.timestarted
length = self.project.timeline.duration
@@ -202,20 +208,53 @@ class Renderer(Actioner):
def updatePosition(self, fraction, text):
pass
- def startAction(self):
- self.debug("Rendering")
- if not self.acting and self.outfile:
- self._startAction()
+ def _isReady(self):
+ return bool(not self.acting and self.outfile)
+
+ def _eosCb(self, unused_pipeline):
+ self.shutdown()
+ Actioner._eosCb(self, unused_pipeline)
+
+ def _createAction(self, sources):
+ """Creates a L{RenderAction}."""
+ settings = export_settings_to_render_settings(self.settings,
+ self.have_video, self.have_audio)
+ sf = RenderSinkFactory(RenderFactory(settings=settings),
+ URISinkFactory(uri=self.outfile))
+ a = RenderAction()
+ a.addProducers(*sources)
+ a.addConsumers(sf)
+
+ return a
+
+ def _connectFunctions(self):
+ self.pipeline.connect('position', self._positionCb)
+ Actioner._connectFunctions(self)
+
+ def _disconnectFunctions(self):
+ self.pipeline.disconnect_by_function(self._positionCb)
+ Actioner._disconnectFunctions(self)
+
+ def _activateAction(self):
+ Actioner._activateAction(self)
+ self.debug("Setting all active ViewAction to sync=False")
+ for action in self.pipeline.actions:
+ if isinstance(action, ViewAction) and action.isActive():
+ action.setSync(False)
class Previewer(Actioner):
""" Previewing helper methods """
def __init__(self, project, pipeline=None, ui=None):
- self.actioner = self.PREVIEWER
Actioner.__init__(self, project, pipeline)
self.ui = ui
- def startAction(self):
- self.debug("Previewing")
- if not self.acting and self.ui:
- self._startAction()
+ def _isReady(self):
+ return bool(not self.acting and self.ui)
+
+ def _createAction(self, sources):
+ action = ViewAction()
+ action.addProducers(*sources)
+ self.ui.setAction(action)
+ self.ui.setPipeline(self.pipeline)
+ return action
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]