[snappy] engine_seek can be accurate or use keyframes



commit 857b56ff80451982ed92d948850015a97ecd87d8
Author: Luis de Bethencourt <luis debethencourt com>
Date:   Fri May 4 09:38:14 2012 +0100

    engine_seek can be accurate or use keyframes

 src/dlna.c           |    2 +-
 src/gst_engine.c     |   17 ++++++++++++-----
 src/gst_engine.h     |    2 +-
 src/user_interface.c |    4 ++--
 4 files changed, 16 insertions(+), 9 deletions(-)
---
diff --git a/src/dlna.c b/src/dlna.c
index 59b5062..33e9ba3 100644
--- a/src/dlna.c
+++ b/src/dlna.c
@@ -230,7 +230,7 @@ handle_method_call (GDBusConnection * connection,
     relative = offset / 100000000.0;
     position = myobj->engine->media_duration * relative;
     // g_print ("offset: %ld    relative: %f", offset, relative);
-    engine_seek (myobj->engine, position);
+    engine_seek (myobj->engine, position, FALSE);
 
     handle_result (invocation, ret, error);
 
diff --git a/src/gst_engine.c b/src/gst_engine.c
index 8bfbf86..183d396 100644
--- a/src/gst_engine.c
+++ b/src/gst_engine.c
@@ -403,7 +403,7 @@ bus_call (GstBus * bus, GstMessage * msg, gpointer data)
       remove_uri_unfinished_playback (engine, engine->uri);
 
       if (engine->loop) {
-        engine_seek (engine, 0);
+        engine_seek (engine, 0, TRUE);
       } else {
         interface_play_next (ui);
       }
@@ -442,7 +442,7 @@ bus_call (GstBus * bus, GstMessage * msg, gpointer data)
           /* Check if URI was left unfinished, if so seek to last position */
           position = is_uri_unfinished_playback (engine, engine->uri);
           if (position != -1) {
-            engine_seek (engine, position);
+            engine_seek (engine, position, TRUE);
           }
 
           if (!engine->secret)
@@ -467,7 +467,7 @@ bus_call (GstBus * bus, GstMessage * msg, gpointer data)
     case GST_MESSAGE_SEGMENT_DONE:
     {
       if (engine->loop)
-        engine_seek (engine, 0);
+        engine_seek (engine, 0, TRUE);
       break;
     }
 
@@ -669,13 +669,20 @@ engine_play (GstEngine * engine)
 
 /*            Seek engine to position            */
 gboolean
-engine_seek (GstEngine * engine, gint64 position)
+engine_seek (GstEngine * engine, gint64 position, gboolean accurate)
 {
   gboolean ok;
   GstFormat fmt = GST_FORMAT_TIME;
+  GstSeekFlags flags;
+
+  if (accurate) {
+    flags = GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT | GST_SEEK_FLAG_ACCURATE;
+  } else {
+    flags = GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT | GST_SEEK_FLAG_KEY_UNIT;
+  }
 
   ok = gst_element_seek_simple (engine->player, fmt,
-      GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT | GST_SEEK_FLAG_ACCURATE,
+      GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT | GST_SEEK_FLAG_KEY_UNIT,
       position);
 
   engine->queries_blocked = TRUE;
diff --git a/src/gst_engine.h b/src/gst_engine.h
index e517f92..2021d0b 100644
--- a/src/gst_engine.h
+++ b/src/gst_engine.h
@@ -60,7 +60,7 @@ gboolean engine_init (GstEngine * engine, GstElement * sink);
 void engine_load_uri (GstEngine * engine, gchar * uri);
 void engine_open_uri (GstEngine * engine, gchar * uri);
 gboolean engine_play (GstEngine * engine);
-gboolean engine_seek (GstEngine * engine, gint64 position);
+gboolean engine_seek (GstEngine * engine, gint64 position, gboolean accurate);
 gboolean engine_stop (GstEngine * engine);
 void engine_volume (GstEngine * engine, gdouble level);
 gboolean frame_stepping (GstEngine * engine, gboolean foward);
diff --git a/src/user_interface.c b/src/user_interface.c
index 99fe12d..f31ce68 100644
--- a/src/user_interface.c
+++ b/src/user_interface.c
@@ -194,7 +194,7 @@ event_cb (ClutterStage * stage, ClutterEvent * event, UserInterface * ui)
 
           /* clamp the timestamp to be within the media */
           pos = CLAMP (pos, 0, ui->engine->media_duration);
-          engine_seek (ui->engine, pos);
+          engine_seek (ui->engine, pos, FALSE);
 
           handled = TRUE;
           break;
@@ -309,7 +309,7 @@ event_cb (ClutterStage * stage, ClutterEvent * event, UserInterface * ui)
           }
 
           progress = ui->engine->media_duration * (dist / ui->seek_width);
-          engine_seek (ui->engine, progress);
+          engine_seek (ui->engine, progress, FALSE);
           clutter_actor_set_size (ui->control_seekbar, dist, ui->seek_height);
 
         } else if (actor == ui->vol_int || actor == ui->vol_int_bg) {



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