[pitivi/ges] Handle everything pipeline related in the pipeline class
- From: Thibault Saunier <tsaunier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi/ges] Handle everything pipeline related in the pipeline class
- Date: Sat, 5 May 2012 20:18:54 +0000 (UTC)
commit 27de1708f2eb9674a3c4e026ef65a46699f5d062
Author: Thibault Saunier <thibault saunier collabora com>
Date: Tue May 1 22:18:25 2012 -0400
Handle everything pipeline related in the pipeline class
pitivi/mainwindow.py | 42 ------------------------------------------
pitivi/timeline/timeline.py | 3 +--
pitivi/utils/pipeline.py | 11 ++++-------
pitivi/viewer.py | 28 ++++++++--------------------
4 files changed, 13 insertions(+), 71 deletions(-)
---
diff --git a/pitivi/mainwindow.py b/pitivi/mainwindow.py
index b2456e0..a10b1e0 100644
--- a/pitivi/mainwindow.py
+++ b/pitivi/mainwindow.py
@@ -722,7 +722,6 @@ class PitiviMainWindow(gtk.Window, Loggable):
"""
self.log("A new project is loaded, wait for clips")
self._connectToProjectSources(self.app.current.medialibrary)
- self.setProjectPipeline(project.pipeline)
self.app.current.timeline.connect("notify::duration",
self._timelineDurationChangedCb)
@@ -1080,23 +1079,6 @@ class PitiviMainWindow(gtk.Window, Loggable):
res = self._installPlugins(details, missingPluginsCallback)
return res
-## Current Project Pipeline
-# We handle the pipeline here
-
- def setProjectPipeline(self, pipeline):
- self._project_pipeline = pipeline
- if self._project_pipeline:
- bus = self._project_pipeline.get_bus()
- bus.add_signal_watch()
- bus.connect('message', self._busMessageCb)
-
- def getProjectPipeline(self):
- return self._project_pipeline
-
- project_pipeline = property(getProjectPipeline, setProjectPipeline, None, "The Gst.Pipeline of the project")
-
-## Project Timeline (not to be confused with UI timeline)
-
def _timelineDurationChangedCb(self, timeline, unused_duration):
self.debug("Timeline duration changed to %d", timeline.props.duration)
if timeline.props.duration > 0:
@@ -1111,30 +1093,6 @@ class PitiviMainWindow(gtk.Window, Loggable):
sensitive = False
self.render_button.set_sensitive(sensitive)
-#Pipeline messages
-
- def _busMessageCb(self, unused_bus, message):
- """
- The pipeline has sent us a message. It could be that it reached the end
- of the stream or that the pipeline state changed (ex: playback started
- or stopped).
-
- In that case, tell the timeline UI and viewer about the new state.
- """
- if message.type == gst.MESSAGE_EOS:
- # Playback reached the end of the timeline. Pause the pipeline
- # to prevent playback from resuming when the user seeks somewhere.
- self.app.current.pipeline.set_state(gst.STATE_PAUSED)
- self.viewer.pipelineStateChanged(gst.STATE_PAUSED)
- elif message.type == gst.MESSAGE_STATE_CHANGED:
- prev, new, pending = message.parse_state_changed()
- if message.src == self._project_pipeline:
- self.info("Pipeline state changed. Prev:%r, new:%r, pending:%r", prev, new, pending)
- state_really_changed = pending == gst.STATE_VOID_PENDING
- if state_really_changed:
- self.viewer.pipelineStateChanged(new)
- self.timeline_ui.pipeline_state = new
-
## other
def _showExportDialog(self, project):
self.log("Export requested")
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index 634f8ac..667d807 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -588,7 +588,6 @@ class Timeline(gtk.Table, Loggable, Zoomable):
self._factories = None
self._finish_drag = False
self._position = 0
- self.pipeline_state = gst.STATE_NULL
self._createUI()
self.rate = gst.Fraction(1, 1)
self._timeline = None
@@ -1135,7 +1134,7 @@ class Timeline(gtk.Table, Loggable, Zoomable):
self._position = position
self.ruler.timelinePositionChanged(position)
self._canvas.timelinePositionChanged(position)
- if self.pipeline_state == gst.STATE_PLAYING:
+ if self.app.current.pipeline.getState() == gst.STATE_PLAYING:
self.scrollToPlayhead()
def scrollToPlayhead(self):
diff --git a/pitivi/utils/pipeline.py b/pitivi/utils/pipeline.py
index 8b3e7c2..33d97f5 100644
--- a/pitivi/utils/pipeline.py
+++ b/pitivi/utils/pipeline.py
@@ -130,9 +130,6 @@ class Seeker(Signallable, Loggable):
return False
return False
- def setPosition(self, position):
- self.emit("position-changed", position)
-
#-----------------------------------------------------------------------------#
# Pipeline utils #
@@ -208,7 +205,7 @@ class Pipeline(ges.TimelinePipeline, Loggable):
@postcondition: The L{Pipeline} will no longer be usable.
"""
- self._listenToPosition(False)
+ self.deactivatePositionListener()
self._bus.disconnect_by_func(self._busMessageCb)
self._bus.remove_signal_watch()
self._bus.set_sync_handler(None)
@@ -412,7 +409,7 @@ class Pipeline(ges.TimelinePipeline, Loggable):
# clamp between [0, duration]
if format == gst.FORMAT_TIME:
- position = max(0, min(position, self.getDuration()))
+ position = max(0, min(position, self.getDuration()) - 1)
res = self.seek(1.0, format, gst.SEEK_FLAG_FLUSH,
gst.SEEK_TYPE_SET, position,
@@ -453,9 +450,9 @@ class Pipeline(ges.TimelinePipeline, Loggable):
# no sinks??
pass
elif prev == gst.STATE_PAUSED and new == gst.STATE_PLAYING:
- self._listenToPosition(True)
+ self.activatePositionListener(True)
elif prev == gst.STATE_PLAYING and new == gst.STATE_PAUSED:
- self._listenToPosition(False)
+ self.activatePositionListener(False)
if emit_state_change:
self.emit('state-changed', new)
diff --git a/pitivi/viewer.py b/pitivi/viewer.py
index f48f794..abd7ebd 100644
--- a/pitivi/viewer.py
+++ b/pitivi/viewer.py
@@ -129,6 +129,8 @@ class PitiviViewer(gtk.VBox, Loggable):
if self.pipeline:
self.pipeline.set_state(gst.STATE_NULL)
+ self.pipeline.disconnect_by_func(self._pipelineStateChangedCb)
+ self.pipeline.disconnect_by_func(self._positionCb)
self.pipeline = pipeline
if self.pipeline:
@@ -147,6 +149,9 @@ class PitiviViewer(gtk.VBox, Loggable):
self.pipeline.get_state(-1)
self.pipeline.seek_simple(gst.FORMAT_TIME, gst.SEEK_FLAG_FLUSH, position)
+ self.pipeline.connect("state-changed", self._pipelineStateChangedCb)
+ self.pipeline.connect("position", self._positionCb)
+
self._setUiActive()
self.seeker = Seeker()
@@ -466,30 +471,14 @@ class PitiviViewer(gtk.VBox, Loggable):
else:
self.dock()
- def positionCheck(self):
+ def _positionCb(self, unused_pipeline, position):
"""
If the timeline position changed, update the viewer UI widgets.
This is meant to be called either by the gobject timer when playing,
or by mainwindow's _timelineSeekCb when the timer is disabled.
"""
- try:
- self.current_time = self.pipeline.query_position(gst.FORMAT_TIME)[0]
- if self.current_time != self.previous_time:
- self.debug("value:%s", gst.TIME_ARGS(self.current_time))
- self.timecode_entry.setWidgetValue(self.current_time, False)
- self.seeker.setPosition(self.current_time)
- self.previous_time = self.current_time
- except:
- self.info("Could not check timeline position for the viewer")
-
- def _positionCheckTimerCb(self):
- """
- Every 300 ms, request to check if the timeline position changed.
- If the pipeline is paused, this returns False to stop the gobject timer.
- """
- self.positionCheck()
- return self.currentState != gst.STATE_PAUSED
+ self.timecode_entry.setWidgetValue(self.current_time, False)
def clipTrimPreview(self, tl_obj, position):
"""
@@ -526,7 +515,7 @@ class PitiviViewer(gtk.VBox, Loggable):
self.setPipeline(self.app.current.pipeline, self._oldTimelinePos)
self.debug("Back to old pipeline")
- def pipelineStateChanged(self, state):
+ def _pipelineStateChangedCb(self, pipeline, state):
"""
When playback starts/stops, update the viewer widget,
play/pause button and (un)inhibit the screensaver.
@@ -537,7 +526,6 @@ class PitiviViewer(gtk.VBox, Loggable):
if int(state) == int(gst.STATE_PLAYING):
self.playpause_button.setPause()
self.system.inhibitScreensaver(self.INHIBIT_REASON)
- gobject.timeout_add(300, self._positionCheckTimerCb)
elif int(state) == int(gst.STATE_PAUSED):
self.playpause_button.setPlay()
self.system.uninhibitScreensaver(self.INHIBIT_REASON)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]