uridecodebin: remove commented code
[platform/upstream/gstreamer.git] / gst / playback / gstplaysink.c
index 6107d55..475ae2f 100644 (file)
@@ -14,8 +14,8 @@
  *
  * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
  */
 
 #ifdef HAVE_CONFIG_H
@@ -133,7 +133,8 @@ typedef struct
   GstElement *queue;
   GstElement *conv;
   GstElement *resample;
-  GstPad *blockpad;             /* srcpad of resample, used for switching the vis */
+  GstPad *blockpad;             /* srcpad of queue, used for blocking the vis */
+  GstPad *vispeerpad;           /* srcpad of resample, used for unlinking the vis */
   GstPad *vissinkpad;           /* visualisation sinkpad, */
   GstElement *vis;
   GstPad *vissrcpad;            /* visualisation srcpad, */
@@ -382,6 +383,8 @@ static void notify_mute_cb (GObject * object, GParamSpec * pspec,
 
 static void update_av_offset (GstPlaySink * playsink);
 
+static gboolean gst_play_sink_do_reconfigure (GstPlaySink * playsink);
+
 static GQuark _playsink_reset_segment_event_marker_id = 0;
 
 /* static guint gst_play_sink_signals[LAST_SIGNAL] = { 0 }; */
@@ -625,6 +628,9 @@ gst_play_sink_class_init (GstPlaySinkClass * klass)
 
   _playsink_reset_segment_event_marker_id =
       g_quark_from_static_string ("gst-playsink-reset-segment-event-marker");
+
+  g_type_class_ref (GST_TYPE_STREAM_SYNCHRONIZER);
+  g_type_class_ref (GST_TYPE_COLOR_BALANCE_CHANNEL);
 }
 
 static void
@@ -906,7 +912,7 @@ gst_play_sink_vis_blocked (GstPad * tee_pad, GstPadProbeInfo * info,
     goto done;
 
   /* unlink the old plugin and unghost the pad */
-  gst_pad_unlink (chain->blockpad, chain->vissinkpad);
+  gst_pad_unlink (chain->vispeerpad, chain->vissinkpad);
   gst_ghost_pad_set_target (GST_GHOST_PAD_CAST (chain->srcpad), NULL);
 
   /* set the old plugin to NULL and remove */
@@ -923,7 +929,7 @@ gst_play_sink_vis_blocked (GstPad * tee_pad, GstPadProbeInfo * info,
   chain->vissrcpad = gst_element_get_static_pad (chain->vis, "src");
 
   /* link pads */
-  gst_pad_link_full (chain->blockpad, chain->vissinkpad,
+  gst_pad_link_full (chain->vispeerpad, chain->vissinkpad,
       GST_PAD_LINK_CHECK_NOTHING);
   gst_ghost_pad_set_target (GST_GHOST_PAD_CAST (chain->srcpad),
       chain->vissrcpad);
@@ -1362,6 +1368,10 @@ gen_video_deinterlace_chain (GstPlaySink * playsink)
   GST_DEBUG_OBJECT (playsink, "creating deinterlace");
   chain->deinterlace = gst_element_factory_make ("deinterlace", "deinterlace");
   if (chain->deinterlace == NULL) {
+    chain->deinterlace =
+        gst_element_factory_make ("avdeinterlace", "deinterlace");
+  }
+  if (chain->deinterlace == NULL) {
     post_missing_element_message (playsink, "deinterlace");
     GST_ELEMENT_WARNING (playsink, CORE, MISSING_PLUGIN,
         (_("Missing element '%s' - check your GStreamer installation."),
@@ -1694,6 +1704,10 @@ gen_video_chain (GstPlaySink * playsink, gboolean raw, gboolean async)
     gst_object_unref (playsink->colorbalance_element);
   }
   playsink->colorbalance_element = find_color_balance_element (chain->sink);
+  if (playsink->colorbalance_element) {
+    g_signal_connect (playsink->colorbalance_element, "value-changed",
+        G_CALLBACK (colorbalance_value_changed_cb), playsink);
+  }
   GST_OBJECT_UNLOCK (playsink);
 
   if (!(playsink->flags & GST_PLAY_FLAG_NATIVE_VIDEO)
@@ -1880,6 +1894,10 @@ setup_video_chain (GstPlaySink * playsink, gboolean raw, gboolean async)
     gst_object_unref (playsink->colorbalance_element);
   }
   playsink->colorbalance_element = find_color_balance_element (chain->sink);
+  if (playsink->colorbalance_element) {
+    g_signal_connect (playsink->colorbalance_element, "value-changed",
+        G_CALLBACK (colorbalance_value_changed_cb), playsink);
+  }
   GST_OBJECT_UNLOCK (playsink);
 
   if (chain->conv) {
@@ -1961,7 +1979,7 @@ gst_play_sink_sink_event (GstPad * pad, GstObject * parent, GstEvent * event,
   }
 
   GST_DEBUG_OBJECT (pad, "Forwarding event %" GST_PTR_FORMAT, event);
-  ret = gst_proxy_pad_event_default (pad, parent, gst_event_ref (event));
+  ret = gst_pad_event_default (pad, parent, gst_event_ref (event));
 
   if (GST_EVENT_TYPE (event) == GST_EVENT_SEGMENT) {
     const GstSegment *segment;
@@ -2200,7 +2218,7 @@ gst_play_sink_text_src_event (GstPad * pad, GstObject * parent,
     goto out;
   }
 
-  ret = gst_proxy_pad_event_default (pad, parent, gst_event_ref (event));
+  ret = gst_pad_event_default (pad, parent, gst_event_ref (event));
 
 out:
   gst_event_unref (event);
@@ -2829,8 +2847,12 @@ gen_vis_chain (GstPlaySink * playsink)
   gst_bin_add (bin, chain->resample);
 
   /* this pad will be used for blocking the dataflow and switching the vis
+   * plugin, we block right after the queue, this makes it possible for the
+   * resample and convert to convert to a format supported by the new vis
    * plugin */
-  chain->blockpad = gst_element_get_static_pad (chain->resample, "src");
+  chain->blockpad = gst_element_get_static_pad (chain->queue, "src");
+  /* this is the pad where the vis is linked to */
+  chain->vispeerpad = gst_element_get_static_pad (chain->resample, "src");
 
   if (playsink->visualisation) {
     GST_DEBUG_OBJECT (playsink, "trying configure vis");
@@ -2885,7 +2907,7 @@ no_audioconvert:
     post_missing_element_message (playsink, "audioconvert");
     GST_ELEMENT_ERROR (playsink, CORE, MISSING_PLUGIN,
         (_("Missing element '%s' - check your GStreamer installation."),
-            "audioconvert"), ("possibly a liboil version mismatch?"));
+            "audioconvert"), ("make sure audioconvert isn't blacklisted"));
     free_chain ((GstPlayChain *) chain);
     return NULL;
   }
@@ -2922,8 +2944,8 @@ link_failed:
  * have to construct the final pipeline. Based on the flags we construct the
  * final output pipelines.
  */
-gboolean
-gst_play_sink_reconfigure (GstPlaySink * playsink)
+static gboolean
+gst_play_sink_do_reconfigure (GstPlaySink * playsink)
 {
   GstPlayFlags flags;
   gboolean need_audio, need_video, need_deinterlace, need_vis, need_text;
@@ -3086,6 +3108,8 @@ gst_play_sink_reconfigure (GstPlaySink * playsink)
       add_chain (GST_PLAY_CHAIN (playsink->videodeinterlacechain), TRUE);
       activate_chain (GST_PLAY_CHAIN (playsink->videodeinterlacechain), TRUE);
 
+      gst_pad_unlink (playsink->video_srcpad_stream_synchronizer,
+          playsink->videochain->sinkpad);
       gst_pad_link_full (playsink->video_srcpad_stream_synchronizer,
           playsink->videodeinterlacechain->sinkpad, GST_PAD_LINK_CHECK_NOTHING);
     } else {
@@ -3103,6 +3127,12 @@ gst_play_sink_reconfigure (GstPlaySink * playsink)
     if (!need_vis && !need_text && (!playsink->textchain
             || !playsink->text_pad)) {
       GST_DEBUG_OBJECT (playsink, "ghosting video sinkpad");
+      gst_pad_unlink (playsink->video_srcpad_stream_synchronizer,
+          playsink->videochain->sinkpad);
+      if (playsink->videodeinterlacechain
+          && playsink->videodeinterlacechain->srcpad)
+        gst_pad_unlink (playsink->videodeinterlacechain->srcpad,
+            playsink->videochain->sinkpad);
       if (need_deinterlace)
         gst_pad_link_full (playsink->videodeinterlacechain->srcpad,
             playsink->videochain->sinkpad, GST_PAD_LINK_CHECK_NOTHING);
@@ -3582,8 +3612,10 @@ update_av_offset (GstPlaySink * playsink)
   vchain = (GstPlayVideoChain *) playsink->videochain;
 
   if (achain && vchain && achain->ts_offset && vchain->ts_offset) {
-    g_object_set (achain->ts_offset, "ts-offset", MAX (0, -av_offset), NULL);
-    g_object_set (vchain->ts_offset, "ts-offset", MAX (0, av_offset), NULL);
+    g_object_set (achain->ts_offset,
+        "ts-offset", MAX (G_GINT64_CONSTANT (0), -av_offset), NULL);
+    g_object_set (vchain->ts_offset,
+        "ts-offset", MAX (G_GINT64_CONSTANT (0), av_offset), NULL);
   } else {
     GST_LOG_OBJECT (playsink, "no ts_offset elements");
   }
@@ -3817,6 +3849,20 @@ text_set_blocked (GstPlaySink * playsink, gboolean blocked)
   }
 }
 
+gboolean
+gst_play_sink_reconfigure (GstPlaySink * playsink)
+{
+  GST_LOG_OBJECT (playsink, "Triggering reconfiguration");
+
+  GST_PLAY_SINK_LOCK (playsink);
+  video_set_blocked (playsink, TRUE);
+  audio_set_blocked (playsink, TRUE);
+  text_set_blocked (playsink, TRUE);
+  GST_PLAY_SINK_UNLOCK (playsink);
+
+  return TRUE;
+}
+
 static GstPadProbeReturn
 sinkpad_blocked_cb (GstPad * blockedpad, GstPadProbeInfo * info,
     gpointer user_data)
@@ -3863,7 +3909,7 @@ sinkpad_blocked_cb (GstPad * blockedpad, GstPadProbeInfo * info,
           playsink->audio_pad_raw);
     }
 
-    gst_play_sink_reconfigure (playsink);
+    gst_play_sink_do_reconfigure (playsink);
 
     video_set_blocked (playsink, FALSE);
     audio_set_blocked (playsink, FALSE);
@@ -3906,13 +3952,8 @@ caps_notify_cb (GstPad * pad, GParamSpec * unused, GstPlaySink * playsink)
 
   gst_caps_unref (caps);
 
-  if (reconfigure) {
-    GST_PLAY_SINK_LOCK (playsink);
-    video_set_blocked (playsink, TRUE);
-    audio_set_blocked (playsink, TRUE);
-    text_set_blocked (playsink, TRUE);
-    GST_PLAY_SINK_UNLOCK (playsink);
-  }
+  if (reconfigure)
+    gst_play_sink_reconfigure (playsink);
 }
 
 void
@@ -4140,12 +4181,15 @@ gst_play_sink_release_pad (GstPlaySink * playsink, GstPad * pad)
     res = &playsink->video_pad;
     g_signal_handlers_disconnect_by_func (playsink->video_pad, caps_notify_cb,
         playsink);
+    video_set_blocked (playsink, FALSE);
   } else if (pad == playsink->audio_pad) {
     res = &playsink->audio_pad;
     g_signal_handlers_disconnect_by_func (playsink->audio_pad, caps_notify_cb,
         playsink);
+    audio_set_blocked (playsink, FALSE);
   } else if (pad == playsink->text_pad) {
     res = &playsink->text_pad;
+    text_set_blocked (playsink, FALSE);
   } else {
     /* try to release the given pad anyway, these could be the FLUSHING pads. */
     res = &pad;
@@ -4370,40 +4414,8 @@ gst_play_sink_change_state (GstElement * element, GstStateChange transition)
       ret = GST_STATE_CHANGE_ASYNC;
 
       /* block all pads here */
-      GST_PLAY_SINK_LOCK (playsink);
-      if (playsink->video_pad && playsink->video_block_id == 0) {
-        GstPad *opad =
-            GST_PAD_CAST (gst_proxy_pad_get_internal (GST_PROXY_PAD
-                (playsink->video_pad)));
-        playsink->video_block_id =
-            gst_pad_add_probe (opad, GST_PAD_PROBE_TYPE_BLOCK_DOWNSTREAM,
-            sinkpad_blocked_cb, playsink, NULL);
-        PENDING_FLAG_SET (playsink, GST_PLAY_SINK_TYPE_VIDEO);
-        gst_object_unref (opad);
-      }
-
-      if (playsink->audio_pad && playsink->audio_block_id == 0) {
-        GstPad *opad =
-            GST_PAD_CAST (gst_proxy_pad_get_internal (GST_PROXY_PAD
-                (playsink->audio_pad)));
-        playsink->audio_block_id =
-            gst_pad_add_probe (opad, GST_PAD_PROBE_TYPE_BLOCK_DOWNSTREAM,
-            sinkpad_blocked_cb, playsink, NULL);
-        PENDING_FLAG_SET (playsink, GST_PLAY_SINK_TYPE_AUDIO);
-        gst_object_unref (opad);
-      }
-
-      if (playsink->text_pad && playsink->text_block_id == 0) {
-        GstPad *opad =
-            GST_PAD_CAST (gst_proxy_pad_get_internal (GST_PROXY_PAD
-                (playsink->text_pad)));
-        playsink->text_block_id =
-            gst_pad_add_probe (opad, GST_PAD_PROBE_TYPE_BLOCK_DOWNSTREAM,
-            sinkpad_blocked_cb, playsink, NULL);
-        PENDING_FLAG_SET (playsink, GST_PLAY_SINK_TYPE_TEXT);
-        gst_object_unref (opad);
-      }
-      GST_PLAY_SINK_UNLOCK (playsink);
+      if (!gst_play_sink_reconfigure (playsink))
+        ret = GST_STATE_CHANGE_FAILURE;
       break;
     case GST_STATE_CHANGE_PAUSED_TO_READY:
       /* unblock all pads here */