Implement an end-of-stream signal
authorMikko Rasa <mikko.rasa@movial.fi>
Wed, 10 Dec 2008 07:29:00 +0000 (09:29 +0200)
committerMikko Rasa <mikko.rasa@movial.fi>
Wed, 10 Dec 2008 07:29:00 +0000 (09:29 +0200)
src/octopus-backend-gst.c
src/octopus-dbus.xml
src/octopus-route.c
src/octopus-route.h
src/octopus-server.c

index d5c577c..1dd7ea0 100644 (file)
@@ -1031,6 +1031,7 @@ bus_watch(GstBus     *bus,
 
   case GST_MESSAGE_EOS:
     g_debug("GST EOS");
+    octopus_route_end_of_stream(route);
     stop_route(backend, route);
     break;
 
index 3488ce6..5ed36ab 100644 (file)
       <arg type="u" name="length" direction="out"/>
     </signal>
 
+    <!-- Emitted when a stream reaches its end -->
+    <signal name="EndOfStream">
+      <arg type="u" name="id" direction="out"/>
+    </signal>
+
     <!-- Stream state changed
          TBD: Define the state values (stopped, playing, paused, etc)
       -->
index c3571f4..994b1ca 100644 (file)
@@ -37,6 +37,7 @@ enum
   SIGNAL_PLAYBACK_ERROR,
   SIGNAL_STREAM_POSITION,
   SIGNAL_STATE_CHANGED,
+  SIGNAL_END_OF_STREAM,
   N_SIGNALS
 };
 
@@ -156,6 +157,16 @@ octopus_route_class_init(OctopusRouteClass *klass)
                       g_cclosure_marshal_VOID__UINT,
                       G_TYPE_NONE,
                       1, G_TYPE_UINT);
+
+  signals[SIGNAL_END_OF_STREAM] = 
+        g_signal_new ("end-of-stream",
+                      G_TYPE_FROM_CLASS(gobject_class),
+                      G_SIGNAL_NO_RECURSE,
+                      0,
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__VOID,
+                      G_TYPE_NONE,
+                      0);
 }
 
 static void
@@ -438,5 +449,11 @@ octopus_route_state_changed(OctopusRoute      *route,
   g_signal_emit(route, signals[SIGNAL_STATE_CHANGED], 0, state);
 }
 
+void
+octopus_route_end_of_stream(OctopusRoute *route)
+{
+  g_signal_emit(route, signals[SIGNAL_END_OF_STREAM], 0);
+}
+
 
 // vim: filetype=c:expandtab:shiftwidth=2:tabstop=2:softtabstop=2
index 18aabd7..def2d72 100644 (file)
@@ -115,6 +115,8 @@ octopus_route_stream_position          (OctopusRoute *route,
 void
 octopus_route_state_changed            (OctopusRoute      *route,
                                         OctopusRouteState state);
+void
+octopus_route_end_of_stream            (OctopusRoute      *route);
 
 #endif
 
index 13550e7..7390866 100644 (file)
@@ -43,6 +43,7 @@ enum {
   SIGNAL_PLAYBACK_ERROR,
   SIGNAL_STREAM_POSITION,
   SIGNAL_STREAM_STATE_CHANGED,
+  SIGNAL_END_OF_STREAM,
   N_SIGNALS
 };
 
@@ -69,6 +70,9 @@ static void
 route_state_changed(OctopusRoute      *route,
                     OctopusRouteState state,
                     gpointer          user_data);
+static void
+route_end_of_stream(OctopusRoute      *route,
+                    gpointer          user_data);
 
 static guint next_route_id = 1;
 static guint signals[N_SIGNALS];
@@ -115,6 +119,16 @@ octopus_server_class_init(OctopusServerClass *klass)
                       g_cclosure_user_marshal_VOID__UINT_UINT,
                       G_TYPE_NONE,
                       2, G_TYPE_UINT, G_TYPE_UINT);
+
+  signals[SIGNAL_END_OF_STREAM] = 
+        g_signal_new ("end-of-stream",
+                      G_TYPE_FROM_CLASS(gobject_class),
+                      G_SIGNAL_NO_RECURSE,
+                      0,
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__UINT,
+                      G_TYPE_NONE,
+                      1, G_TYPE_UINT);
 }
 
 static void
@@ -311,6 +325,7 @@ octopus_server_new(OctopusServer   *server,
   g_signal_connect(G_OBJECT(route), "playback-error", G_CALLBACK(route_playback_error), server);
   g_signal_connect(G_OBJECT(route), "stream-position", G_CALLBACK(route_stream_position), server);
   g_signal_connect(G_OBJECT(route), "state-changed", G_CALLBACK(route_state_changed), server);
+  g_signal_connect(G_OBJECT(route), "end-of-stream", G_CALLBACK(route_end_of_stream), server);
 
   g_hash_table_insert(server->priv->routes, key, route);
 
@@ -641,6 +656,18 @@ route_state_changed(OctopusRoute      *route,
   g_signal_emit(server, signals[SIGNAL_STREAM_STATE_CHANGED], 0, id, state);
 }
 
+static void
+route_end_of_stream(OctopusRoute      *route,
+                    gpointer          user_data)
+{
+  OctopusServer *server = (OctopusServer *)user_data;
+  guint         id;
+
+  g_object_get(G_OBJECT(route), "id", &id, NULL);
+
+  g_signal_emit(server, signals[SIGNAL_END_OF_STREAM], 0, id);
+}
+
 /* Emacs indentatation information
    Local Variables:
    indent-tabs-mode:nil