gst/playback/: Move setup_output_pads into a virtual function, remove group-switch...
authorRonald S. Bultje <rbultje@ronald.bitfreak.net>
Thu, 12 May 2005 16:16:14 +0000 (16:16 +0000)
committerRonald S. Bultje <rbultje@ronald.bitfreak.net>
Thu, 12 May 2005 16:16:14 +0000 (16:16 +0000)
Original commit message from CVS:
* gst/playback/gstdecodebin.c: (gst_decode_bin_class_init),
(try_to_link_1):
* gst/playback/gstplaybasebin.c: (gst_play_base_bin_class_init),
(group_commit), (probe_triggered), (setup_source),
(gst_play_base_bin_change_state):
* gst/playback/gstplaybasebin.h:
* gst/playback/gstplaybin.c: (gst_play_bin_class_init),
(gst_play_bin_init), (remove_sinks), (setup_sinks),
(gst_play_bin_change_state):
Move setup_output_pads into a virtual function, remove
group-switch (no longer needed) and redirect (handled by bus
now) signals.

ChangeLog
gst/playback/gstdecodebin.c
gst/playback/gstplaybasebin.c
gst/playback/gstplaybasebin.h
gst/playback/gstplaybin.c

index 804f53c..882de55 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,20 @@
 2005-05-12  Ronald S. Bultje  <rbultje@ronald.bitfreak.net>
 
+       * gst/playback/gstdecodebin.c: (gst_decode_bin_class_init),
+       (try_to_link_1):
+       * gst/playback/gstplaybasebin.c: (gst_play_base_bin_class_init),
+       (group_commit), (probe_triggered), (setup_source),
+       (gst_play_base_bin_change_state):
+       * gst/playback/gstplaybasebin.h:
+       * gst/playback/gstplaybin.c: (gst_play_bin_class_init),
+       (gst_play_bin_init), (remove_sinks), (setup_sinks),
+       (gst_play_bin_change_state):
+         Move setup_output_pads into a virtual function, remove
+         group-switch (no longer needed) and redirect (handled by bus
+         now) signals.
+
+2005-05-12  Ronald S. Bultje  <rbultje@ronald.bitfreak.net>
+
        * gst/playback/gstplaybasebin.c: (gst_play_base_bin_get_type),
        (gst_play_base_bin_class_init), (gst_play_base_bin_finalize),
        (get_active_group), (get_building_group), (group_destroy),
index 314f088..005b45a 100644 (file)
@@ -78,8 +78,6 @@ struct _GstDecodeBinClass
   void (*removed_decoded_pad) (GstElement * element, GstPad * pad);
   /* signal fired when we found a pad that we cannot decode */
   void (*unknown_type) (GstElement * element, GstPad * pad, GstCaps * caps);
-  /* signal fired when we got a redirect attempt */
-  void (*got_redirect) (GstElement * element, const gchar * new_location);
 };
 
 #define DEFAULT_THREADED       FALSE
@@ -209,11 +207,6 @@ gst_decode_bin_class_init (GstDecodeBinClass * klass)
       G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstDecodeBinClass, unknown_type),
       NULL, NULL, gst_marshal_VOID__OBJECT_BOXED, G_TYPE_NONE, 2,
       GST_TYPE_PAD, GST_TYPE_CAPS);
-  gst_decode_bin_signals[SIGNAL_REDIRECT] =
-      g_signal_new ("got-redirect", G_TYPE_FROM_CLASS (klass),
-      G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstDecodeBinClass, got_redirect),
-      NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1,
-      G_TYPE_STRING);
 
   gobject_klass->dispose = GST_DEBUG_FUNCPTR (gst_decode_bin_dispose);
 
@@ -549,17 +542,6 @@ many_types:
   }
 }
 
-/*
- * Called when we're redirected to a new URI.
- */
-static void
-got_redirect (GstElement * element,
-    const gchar * new_location, GstDecodeBin * decode_bin)
-{
-  g_signal_emit (decode_bin, gst_decode_bin_signals[SIGNAL_REDIRECT], 0,
-      new_location);
-}
-
 /** 
  * given a list of element factories, try to link one of the factories
  * to the given pad.
@@ -624,11 +606,6 @@ try_to_link_1 (GstDecodeBin * decode_bin, GstPad * pad, GList * factories)
            * because that would consume less memory. */
         }
       }
-      /* catch redirects */
-      if (g_signal_lookup ("got-redirect", G_OBJECT_TYPE (element))) {
-        g_signal_connect (element, "got-redirect",
-            G_CALLBACK (got_redirect), decode_bin);
-      }
 
       /* make sure we catch unlink signals */
       sig = g_signal_connect (G_OBJECT (GST_PAD_REALIZE (pad)), "unlinked",
index 519696d..5c4e574 100644 (file)
@@ -56,10 +56,7 @@ enum
 /* signals */
 enum
 {
-  SIGNAL_SETUP_OUTPUT_PADS,
   SIGNAL_BUFFERING,
-  SIGNAL_GROUP_SWITCH,
-  SIGNAL_REDIRECT,
   LAST_SIGNAL
 };
 
@@ -175,27 +172,11 @@ gst_play_base_bin_class_init (GstPlayBaseBinClass * klass)
       "playbasebin");
 
   /* signals */
-  gst_play_base_bin_signals[SIGNAL_SETUP_OUTPUT_PADS] =
-      g_signal_new ("setup-output-pads", G_TYPE_FROM_CLASS (klass),
-      G_SIGNAL_RUN_LAST,
-      G_STRUCT_OFFSET (GstPlayBaseBinClass, setup_output_pads),
-      NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
   gst_play_base_bin_signals[SIGNAL_BUFFERING] =
       g_signal_new ("buffering", G_TYPE_FROM_CLASS (klass),
       G_SIGNAL_RUN_LAST,
       G_STRUCT_OFFSET (GstPlayBaseBinClass, buffering),
       NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
-  gst_play_base_bin_signals[SIGNAL_GROUP_SWITCH] =
-      g_signal_new ("group-switch", G_TYPE_FROM_CLASS (klass),
-      G_SIGNAL_RUN_LAST,
-      G_STRUCT_OFFSET (GstPlayBaseBinClass, group_switch),
-      NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
-  gst_play_base_bin_signals[SIGNAL_REDIRECT] =
-      g_signal_new ("got-redirect", G_TYPE_FROM_CLASS (klass),
-      G_SIGNAL_RUN_LAST,
-      G_STRUCT_OFFSET (GstPlayBaseBinClass, got_redirect),
-      NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1,
-      G_TYPE_STRING);
 
   gobject_klass->dispose = GST_DEBUG_FUNCPTR (gst_play_base_bin_dispose);
   gobject_klass->finalize = GST_DEBUG_FUNCPTR (gst_play_base_bin_finalize);
@@ -437,8 +418,8 @@ group_commit (GstPlayBaseBin * play_base_bin, gboolean fatal, gboolean subtitle)
 
     setup_substreams (play_base_bin);
     GST_DEBUG ("Emitting signal");
-    g_signal_emit (play_base_bin,
-        gst_play_base_bin_signals[SIGNAL_SETUP_OUTPUT_PADS], 0);
+    GST_PLAY_BASE_BIN_GET_CLASS (play_base_bin)->
+        setup_output_pads (play_base_bin, group);
     GST_DEBUG ("done");
 
     GROUP_UNLOCK (play_base_bin);
@@ -846,13 +827,12 @@ probe_triggered (GstProbe * probe, GstData ** data, gpointer user_data)
         GST_DEBUG ("switching to next group %p - emitting signal",
             play_base_bin->queued_groups->data);
         /* and signal the new group */
-        g_signal_emit (play_base_bin,
-            gst_play_base_bin_signals[SIGNAL_SETUP_OUTPUT_PADS], 0);
+        GST_PLAY_BASE_BIN_GET_CLASS (play_base_bin)->
+            setup_output_pads (play_base_bin, group);
 
         GROUP_UNLOCK (play_base_bin);
 
-        g_signal_emit (play_base_bin,
-            gst_play_base_bin_signals[SIGNAL_GROUP_SWITCH], 0);
+        g_object_notify (G_OBJECT (play_base_bin), "streaminfo");
 
         /* get rid of the EOS event */
         return FALSE;
@@ -1122,18 +1102,6 @@ setup_substreams (GstPlayBaseBin * play_base_bin)
   }
 }
 
-/*
- * Called when we're redirected to a new URI.
- */
-static void
-got_redirect (GstElement * element, const gchar * new_location, gpointer data)
-{
-  gchar **location = data;
-
-  if (!*location)
-    *location = g_strdup (new_location);
-}
-
 /* construct and run the source and decoder elements until we found
  * all the streams or until a preroll queue has been filled.
 */
@@ -1328,8 +1296,6 @@ setup_source (GstPlayBaseBin * play_base_bin,
 
   /* set up callbacks to create the links between decoded data
    * and video/audio/subtitle rendering/output. */
-  g_signal_connect (play_base_bin->decoder, "got_redirect",
-      G_CALLBACK (got_redirect), new_location);
   g_signal_connect (G_OBJECT (play_base_bin->decoder),
       "new-decoded-pad", G_CALLBACK (new_decoded_pad), play_base_bin);
   g_signal_connect (G_OBJECT (play_base_bin->decoder), "no-more-pads",
@@ -1714,16 +1680,9 @@ gst_play_base_bin_change_state (GstElement * element)
 
   switch (transition) {
     case GST_STATE_READY_TO_PAUSED:
-      if (new_location) {
-        g_signal_emit (play_base_bin,
-            gst_play_base_bin_signals[SIGNAL_REDIRECT], 0, new_location);
-        g_free (new_location);
-        ret = GST_STATE_FAILURE;
-      } else if (ret == GST_STATE_SUCCESS) {
+      if (ret == GST_STATE_SUCCESS) {
         finish_source (play_base_bin);
-      }
-
-      if (ret != GST_STATE_SUCCESS) {
+      } else {
         /* clean up leftover groups */
         remove_groups (play_base_bin);
         play_base_bin->need_rebuild = TRUE;
index 27cd574..6ea5223 100644 (file)
@@ -30,6 +30,9 @@ G_BEGIN_DECLS
 #define GST_PLAY_BASE_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_PLAY_BASE_BIN,GstPlayBaseBinClass))
 #define GST_IS_PLAY_BASE_BIN(obj)              (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_PLAY_BASE_BIN))
 #define GST_IS_PLAY_BASE_BIN_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_PLAY_BASE_BIN))
+#define GST_PLAY_BASE_BIN_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_PLAY_BASE_BIN, \
+                             GstPlayBaseBinClass))
 
 typedef struct _GstPlayBaseBin GstPlayBaseBin;
 typedef struct _GstPlayBaseBinClass GstPlayBaseBinClass;
@@ -88,20 +91,15 @@ struct _GstPlayBaseBin {
 struct _GstPlayBaseBinClass {
   GstPipelineClass parent_class;
 
-  /* signals */
-  void (*setup_output_pads)    (GstPlayBaseBin *play_base_bin);
-  void (*removed_output_pad)   (GstPlayBaseBin *play_base_bin,
-                                GstStreamInfo *info);
+  /* virtual fuctions */
+  void (*setup_output_pads)    (GstPlayBaseBin *play_base_bin,
+                                GstPlayBaseGroup *group);
 
+  /* signals */
   /* 0: buf=empty (underrun) - will re-cache,
    * 100: buf=full (overrun) - will flush head of cache (latency) */
   void (*buffering)            (GstPlayBaseBin *play_base_bin,
                                 gint            percentage);
-  void (*group_switch)         (GstPlayBaseBin *play_base_bin);
-
-  /* Called on redirect */
-  void (*got_redirect)         (GstPlayBaseBin *play_base_bin,
-                                const gchar    *new_location);
 };
 
 GType gst_play_base_bin_get_type (void);
index abe3414..92d10ba 100644 (file)
@@ -62,9 +62,6 @@ struct _GstPlayBin
   /* our cache for the sinks */
   GHashTable *cache;
 
-  /* boolean to see if we're currently switching groups */
-  gboolean group_switch;
-
   /* font description */
   gchar *font_desc;
 };
@@ -96,8 +93,8 @@ static void gst_play_bin_class_init (GstPlayBinClass * klass);
 static void gst_play_bin_init (GstPlayBin * play_bin);
 static void gst_play_bin_dispose (GObject * object);
 
-static void group_switch (GstPlayBaseBin * play_base_bin);
-static void setup_sinks (GstPlayBaseBin * play_base_bin);
+static void setup_sinks (GstPlayBaseBin * play_base_bin,
+    GstPlayBaseGroup * group);
 static void remove_sinks (GstPlayBin * play_bin);
 
 static void gst_play_bin_set_property (GObject * object, guint prop_id,
@@ -194,7 +191,6 @@ gst_play_bin_class_init (GstPlayBinClass * klass)
       GST_DEBUG_FUNCPTR (gst_play_bin_change_state);
 
   playbasebin_klass->setup_output_pads = setup_sinks;
-  playbasebin_klass->group_switch = group_switch;
 }
 
 static void
@@ -211,7 +207,6 @@ gst_play_bin_init (GstPlayBin * play_bin)
   play_bin->font_desc = NULL;
   play_bin->cache = g_hash_table_new_full (g_str_hash, g_str_equal,
       NULL, (GDestroyNotify) gst_object_unref);
-  play_bin->group_switch = FALSE;
 }
 
 static void
@@ -624,13 +619,6 @@ gen_vis_element (GstPlayBin * play_bin)
   return element;
 }
 
-/* set for group switch */
-static void
-group_switch (GstPlayBaseBin * play_base_bin)
-{
-  GST_PLAY_BIN (play_base_bin)->group_switch = TRUE;
-}
-
 /* get rid of all installed sinks */
 static void
 remove_sinks (GstPlayBin * play_bin)
@@ -640,7 +628,6 @@ remove_sinks (GstPlayBin * play_bin)
   GstElement *element;
 
   GST_DEBUG ("removesinks");
-  play_bin->group_switch = FALSE;
   element = g_hash_table_lookup (play_bin->cache, "abin");
   if (element != NULL) {
     parent = gst_element_get_parent (element);
@@ -730,10 +717,9 @@ add_sink (GstPlayBin * play_bin, GstElement * sink, GstPad * srcpad)
 }
 
 static void
-setup_sinks (GstPlayBaseBin * play_base_bin)
+setup_sinks (GstPlayBaseBin * play_base_bin, GstPlayBaseGroup * group)
 {
   GstPlayBin *play_bin = GST_PLAY_BIN (play_base_bin);
-  GstPlayBaseGroup *group;
   GList *streaminfo = NULL, *s;
   gboolean need_vis = FALSE;
   gboolean need_text = FALSE;
@@ -747,7 +733,6 @@ setup_sinks (GstPlayBaseBin * play_base_bin)
   GST_DEBUG ("setupsinks");
 
   /* find out what to do */
-  group = play_base_bin->queued_groups->data;
   if (group->type[GST_STREAM_TYPE_VIDEO - 1].npads > 0 &&
       group->type[GST_STREAM_TYPE_TEXT - 1].npads > 0) {
     need_text = TRUE;
@@ -838,7 +823,7 @@ gst_play_bin_change_state (GstElement * element)
     case GST_STATE_PLAYING_TO_PAUSED:
       /* Set audio sink state to NULL to release the sound device,
        * but only if we own it (else we might be in chain-transition). */
-      //if (play_bin->audio_sink != NULL && !play_bin->group_switch &&
+      //if (play_bin->audio_sink != NULL &&
       //    GST_STATE (play_bin->audio_sink) == GST_STATE_PAUSED) {
       //  gst_element_set_state (play_bin->audio_sink, GST_STATE_NULL);
       //}