Seeking support
authorMikko Rasa <mikko.rasa@movial.fi>
Mon, 3 Nov 2008 12:32:04 +0000 (14:32 +0200)
committerMikko Rasa <mikko.rasa@movial.fi>
Mon, 3 Nov 2008 12:32:04 +0000 (14:32 +0200)
src/octopus-backend-gst.c
src/octopus-backend.c
src/octopus-backend.h
src/octopus-dbus.xml
src/octopus-route.c
src/octopus-route.h
src/octopus-server.c
src/octopus-server.h

index 1e71c9b..a8da44b 100644 (file)
@@ -72,6 +72,10 @@ static gboolean
 set_route_volume(OctopusBackend *backend,
                  OctopusRoute   *route,
                  gdouble        volume);
+static gboolean
+seek_route(OctopusBackend *backend,
+           OctopusRoute   *route,
+           guint          seconds);
 
 static void
 route_mapping_changed(OctopusRoute *route,
@@ -123,6 +127,7 @@ octopus_backend_gst_class_init(OctopusBackendGstClass *klass)
   backend->stop_route = stop_route;
   backend->set_route_muted = set_route_muted;
   backend->set_route_volume = set_route_volume;
+  backend->seek_route = seek_route;
 
   hooks[HOOK_INIT] = 
     g_signal_new ("hook-init",
@@ -490,6 +495,21 @@ set_route_volume(OctopusBackend *backend,
   return ret;
 }
 
+static gboolean
+seek_route(OctopusBackend *backend,
+           OctopusRoute   *route,
+           guint          seconds)
+{
+  RouteDataGst *data;
+
+  data = (RouteDataGst *)g_object_get_data(G_OBJECT(route), "data");
+
+  return gst_element_seek_simple(data->pipeline,
+                                 GST_FORMAT_TIME,
+                                 GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT,
+                                 (gint64)seconds*GST_SECOND);
+}
+
 /*
  * Private functions
  */
index e91e7f6..9c626c2 100644 (file)
@@ -427,4 +427,13 @@ octopus_backend_set_route_volume(OctopusBackend *backend,
   return OCTOPUS_BACKEND_GET_CLASS(backend)->set_route_volume(backend, route, volume);
 }
 
+gboolean
+octopus_backend_seek_route(OctopusBackend *backend,
+                           OctopusRoute   *route,
+                           guint          seconds)
+{
+  g_assert(OCTOPUS_IS_BACKEND(backend));
+  return OCTOPUS_BACKEND_GET_CLASS(backend)->seek_route(backend, route, seconds);
+}
+
 // vim: filetype=c:expandtab:shiftwidth=2:tabstop=2:softtabstop=2
index d1cc317..87f6c4f 100644 (file)
@@ -86,6 +86,9 @@ struct _OctopusBackendClass {
   gboolean     (*set_route_volume)   (OctopusBackend *,
                                       OctopusRoute *,
                                       gdouble);
+  gboolean     (*seek_route)         (OctopusBackend *,
+                                      OctopusRoute *,
+                                      guint);
 };
 
 struct _OctopusParameter {
@@ -153,6 +156,10 @@ gboolean
 octopus_backend_set_route_volume         (OctopusBackend *backend,
                                           OctopusRoute   *route,
                                           gdouble        volume);
+gboolean
+octopus_backend_seek_route               (OctopusBackend *backend,
+                                          OctopusRoute   *route,
+                                          guint          seconds);
 
 #endif
 
index 097099c..3488ce6 100644 (file)
       <arg type="d" name="volume" direction="in" />
     </method>
 
+    <!-- Seek the pipeline (seconds from the beginning) -->
+    <method name="SeekTo">
+      <arg type="u" name="id" direction="in" />
+      <arg type="u" name="seconds" direction="in" />
+    </method>
+
     <!-- Playback signals -->
 
     <!-- Emitted when the playback fails  -->
index 0b0ecc9..896fde5 100644 (file)
@@ -394,6 +394,13 @@ octopus_route_set_volume(OctopusRoute *route,
   return octopus_backend_set_route_volume(route->priv->backend, route, volume);
 }
 
+gboolean
+octopus_route_seek_to(OctopusRoute *route,
+                      guint        seconds)
+{
+  return octopus_backend_seek_route(route->priv->backend, route, seconds);
+}
+
 void
 octopus_route_playback_error(OctopusRoute *route,
                              const gchar  *error)
index 694f219..18aabd7 100644 (file)
@@ -101,6 +101,9 @@ octopus_route_set_muted                (OctopusRoute *route,
 gboolean
 octopus_route_set_volume               (OctopusRoute *route,
                                         gdouble      volume);
+gboolean
+octopus_route_seek_to                  (OctopusRoute *route,
+                                        guint        seconds);
 
 void
 octopus_route_playback_error           (OctopusRoute *route,
index e096c17..3b2d760 100644 (file)
@@ -546,6 +546,27 @@ octopus_server_set_volume(OctopusServer  *server,
   return TRUE;
 }
 
+gboolean
+octopus_server_seek_to         (OctopusServer  *server,
+                                guint32        id,
+                                guint          seconds,
+                                GError         **error)
+{
+  OctopusRoute *route;
+
+  g_assert(OCTOPUS_IS_SERVER(server));
+
+  if(!(route = get_route_by_id(server, id, error)))
+    return FALSE;
+
+  if(!octopus_route_seek_to(route, seconds)) {
+    g_set_error(error, OCTOPUS_SERVER_ERROR, OCTOPUS_SERVER_ERROR_FAILED, "Could not seek route");
+    return FALSE;
+  }
+
+  return TRUE;
+}
+
 /*
  * D-Bus API signals
  */
index d4adbaf..5d04eca 100644 (file)
@@ -153,6 +153,11 @@ octopus_server_set_volume      (OctopusServer  *server,
                                 guint32        id,
                                 gdouble        volume,
                                 GError         **error);
+gboolean
+octopus_server_seek_to         (OctopusServer  *server,
+                                guint32        id,
+                                guint          seconds,
+                                GError         **error);
 
 G_END_DECLS