[pitivi/T3404-intermediary_format: 2/4] validate: Use the pitivi code paths when seeking



commit c44f1aca7a2cc533599b92ab1a2f35d1eab024dd
Author: Thibault Saunier <tsaunier gnome org>
Date:   Wed Dec 2 14:24:27 2015 +0100

    validate: Use the pitivi code paths when seeking

 pitivi/utils/validate.py |   38 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/pitivi/utils/validate.py b/pitivi/utils/validate.py
index 997b190..68641c7 100644
--- a/pitivi/utils/validate.py
+++ b/pitivi/utils/validate.py
@@ -71,6 +71,8 @@ if GstValidate:
 
             if GstValidate:
                 try:
+                    import gi
+                    gi.require_version('Wnck', '3.0')
                     from gi.repository import Wnck
                     Wnck.Screen.get_default().connect("window-opened", self._windowOpenedCb)
                 except ImportError:
@@ -139,6 +141,37 @@ def stop(scenario, action):
     return 1
 
 
+def positionChangedCb(pipeline, position, scenario, action,
+                      wanted_position):
+    if pipeline._waiting_for_async_done:
+        return
+
+    if pipeline._next_seek:
+        return
+
+    print(str(wanted_position), str(position))
+    if wanted_position != position:
+        scenario.report_simple(GLib.quark_from_string(
+            "scenario::execution-error"),
+            "Position after seek (%s) does not match wanted "
+            "one %s" % (Gst.TIME_ARGS(position),
+                        Gst.TIME_ARGS(wanted_position)))
+
+    pipeline.disconnect_by_func(positionChangedCb)
+    action.set_done()
+
+
+def seek(scenario, action):
+    from pitivi.utils.pipeline import Seeker
+    res, wanted_position = GstValidate.utils_get_clocktime(action.structure,
+                                                      "start")
+    Seeker().seek(action.structure["start"])
+    scenario.pipeline.connect("position", positionChangedCb, scenario,
+                              action, wanted_position)
+
+    return GstValidate.ActionReturn.ASYNC
+
+
 def set_state(scenario, action):
     wanted_state = action.structure["state"]
     if wanted_state is None:
@@ -475,6 +508,11 @@ def init():
                                          "Pitivi override for the stop action",
                                          GstValidate.ActionTypeFlags.NONE)
 
+        GstValidate.register_action_type("seek", "pitivi",
+                                         seek, None,
+                                         "Pitivi override for the seek action",
+                                         GstValidate.ActionTypeFlags.NONE)
+
         GstValidate.register_action_type("pause", "pitivi",
                                          set_state, None,
                                          "Pitivi override for the pause action",


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]