[pitivi] Serialize seek actions and fix state change action serialization
- From: Thibault Saunier <tsaunier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] Serialize seek actions and fix state change action serialization
- Date: Sat, 15 Nov 2014 10:32:23 +0000 (UTC)
commit d74c0e8d4d497d35d26e991beb437e8ac33bf484
Author: Thibault Saunier <tsaunier gnome org>
Date: Thu Sep 25 12:17:12 2014 +0200
Serialize seek actions and fix state change action serialization
https://bugzilla.gnome.org/show_bug.cgi?id=739251
pitivi/utils/pipeline.py | 20 +++++++++++++++++---
pitivi/viewer.py | 15 ++++++++-------
2 files changed, 25 insertions(+), 10 deletions(-)
---
diff --git a/pitivi/utils/pipeline.py b/pitivi/utils/pipeline.py
index 9b57bfa..7592fe1 100644
--- a/pitivi/utils/pipeline.py
+++ b/pitivi/utils/pipeline.py
@@ -39,7 +39,7 @@ from pitivi.utils.misc import format_ns
MAX_RECOVERIES = 5
PIPELINE_SIGNALS = {
- "state-change": (GObject.SignalFlags.RUN_LAST, None, (GObject.TYPE_INT,)),
+ "state-change": (GObject.SignalFlags.RUN_LAST, None, (GObject.TYPE_INT, GObject.TYPE_INT)),
"position": (GObject.SignalFlags.RUN_LAST, None, (GObject.TYPE_UINT64,)),
"duration-changed": (GObject.SignalFlags.RUN_LAST, None, (GObject.TYPE_UINT64,)),
"eos": (GObject.SignalFlags.RUN_LAST, None, ()),
@@ -437,7 +437,7 @@ class SimplePipeline(GObject.Object, Loggable):
self._listenToPosition(False)
if emit_state_change:
- self.emit('state-change', new)
+ self.emit('state-change', new, prev)
elif message.type == Gst.MessageType.ERROR:
error, detail = message.parse_error()
@@ -526,10 +526,12 @@ class Pipeline(GES.Pipeline, SimplePipeline):
__gsignals__ = PIPELINE_SIGNALS
- def __init__(self, pipeline=None):
+ def __init__(self, app, pipeline=None):
GES.Pipeline.__init__(self)
SimplePipeline.__init__(self, self)
+ self.app = app
+
self._timeline = None
self._seeker = Seeker()
self._seeker.connect("seek", self._seekCb)
@@ -589,3 +591,15 @@ class Pipeline(GES.Pipeline, SimplePipeline):
end of the timeline.
"""
self.simple_seek(position)
+
+ def simple_seek(self, position):
+ st = Gst.Structure.new_empty("seek")
+
+ if self.getState() == Gst.State.PLAYING:
+ st.set_value("playback_time", float(self.getPosition()) / Gst.SECOND)
+
+ st.set_value("start", float(position / Gst.SECOND))
+ st.set_value("flags", "accurate+flush")
+ self.app.write_action(st)
+
+ SimplePipeline.simple_seek(self, position)
diff --git a/pitivi/viewer.py b/pitivi/viewer.py
index 250a68c..fdcbf1a 100644
--- a/pitivi/viewer.py
+++ b/pitivi/viewer.py
@@ -444,7 +444,7 @@ class ViewerContainer(Gtk.VBox, Loggable):
self.setPipeline(self.app.project_manager.current_project.pipeline, self._oldTimelinePos)
self.debug("Back to the project's pipeline")
- def _pipelineStateChangedCb(self, unused_pipeline, state):
+ def _pipelineStateChangedCb(self, unused_pipeline, state, old_state):
"""
When playback starts/stops, update the viewer widget,
play/pause button and (un)inhibit the screensaver.
@@ -453,16 +453,17 @@ class ViewerContainer(Gtk.VBox, Loggable):
"""
if int(state) == int(Gst.State.PLAYING):
st = Gst.Structure.new_empty("play")
- st.set_value("playback_time", float(self.pipeline.getPosition())
- / Gst.SECOND)
self.app.write_action(st)
self.playpause_button.setPause()
self.system.inhibitScreensaver(self.INHIBIT_REASON)
elif int(state) == int(Gst.State.PAUSED):
- st = Gst.Structure.new_empty("pause")
- st.set_value("playback_time", float(self.pipeline.getPosition()) /
- Gst.SECOND)
- self.app.write_action(st)
+ if old_state != int(Gst.State.PAUSED):
+ st = Gst.Structure.new_empty("pause")
+ if old_state == int(Gst.State.PLAYING):
+ st.set_value("playback_time", float(self.pipeline.getPosition()) /
+ Gst.SECOND)
+ self.app.write_action(st)
+
self.playpause_button.setPlay()
self.system.uninhibitScreensaver(self.INHIBIT_REASON)
else:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]