Merge branch 'master' into 0.11
authorSebastian Dröge <sebastian.droege@collabora.co.uk>
Fri, 2 Mar 2012 09:00:55 +0000 (10:00 +0100)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Fri, 2 Mar 2012 09:00:55 +0000 (10:00 +0100)
Conflicts:
NEWS
RELEASE
configure.ac
docs/plugins/gst-plugins-base-plugins.args
docs/plugins/gst-plugins-base-plugins.hierarchy
docs/plugins/gst-plugins-base-plugins.interfaces
docs/plugins/inspect/plugin-adder.xml
docs/plugins/inspect/plugin-alsa.xml
docs/plugins/inspect/plugin-app.xml
docs/plugins/inspect/plugin-audioconvert.xml
docs/plugins/inspect/plugin-audiorate.xml
docs/plugins/inspect/plugin-audioresample.xml
docs/plugins/inspect/plugin-audiotestsrc.xml
docs/plugins/inspect/plugin-cdparanoia.xml
docs/plugins/inspect/plugin-encoding.xml
docs/plugins/inspect/plugin-ffmpegcolorspace.xml
docs/plugins/inspect/plugin-gdp.xml
docs/plugins/inspect/plugin-gio.xml
docs/plugins/inspect/plugin-gnomevfs.xml
docs/plugins/inspect/plugin-libvisual.xml
docs/plugins/inspect/plugin-ogg.xml
docs/plugins/inspect/plugin-pango.xml
docs/plugins/inspect/plugin-playback.xml
docs/plugins/inspect/plugin-subparse.xml
docs/plugins/inspect/plugin-tcp.xml
docs/plugins/inspect/plugin-theora.xml
docs/plugins/inspect/plugin-typefindfunctions.xml
docs/plugins/inspect/plugin-uridecodebin.xml
docs/plugins/inspect/plugin-videorate.xml
docs/plugins/inspect/plugin-videoscale.xml
docs/plugins/inspect/plugin-videotestsrc.xml
docs/plugins/inspect/plugin-volume.xml
docs/plugins/inspect/plugin-vorbis.xml
docs/plugins/inspect/plugin-ximagesink.xml
docs/plugins/inspect/plugin-xvimagesink.xml
gst-libs/gst/app/gstappsink.c
gst-libs/gst/audio/mixer.c
gst-libs/gst/audio/mixer.h
gst-libs/gst/tag/gstxmptag.c
gst-libs/gst/video/colorbalance.c
gst-libs/gst/video/colorbalance.h
gst/adder/gstadder.c
gst/playback/gstplaybasebin.c
gst/playback/gstplaybin2.c
gst/playback/gstplaysink.c
gst/videoscale/gstvideoscale.c
tests/check/elements/videoscale.c
tests/examples/seek/seek.c
tests/examples/v4l/probe.c
win32/common/_stdint.h
win32/common/audio-enumtypes.c
win32/common/config.h

30 files changed:
autogen.sh
ext/alsa/gstalsadeviceprobe.c
ext/theora/gsttheoraenc.c
ext/theora/gsttheoraparse.c
gst-libs/gst/app/gstappsink.c
gst-libs/gst/audio/mixer.c
gst-libs/gst/audio/mixer.h
gst-libs/gst/audio/mixerutils.c
gst-libs/gst/interfaces/navigation.h
gst-libs/gst/tag/gstxmptag.c
gst-libs/gst/video/colorbalance.c
gst-libs/gst/video/colorbalance.h
gst/adder/gstadder.c
gst/adder/gstadder.h
gst/playback/gstplay-enum.c
gst/playback/gstplay-enum.h
gst/playback/gstplaybin2.c
gst/playback/gstplaysink.c
gst/playback/gstplaysinkaudioconvert.c
gst/playback/gstplaysinkvideoconvert.c
gst/playback/gstplaysinkvideoconvert.h
gst/videoscale/gstvideoscale.c
sys/xvimage/xvimagesink.c
tests/check/elements/adder.c
tests/check/elements/alsa.c
tests/check/elements/playbin.c
tests/check/elements/videoscale.c
tests/examples/seek/seek.c
tests/icles/test-colorkey.c
win32/common/config.h

index 4a4a8f4..9b38463 100755 (executable)
@@ -35,6 +35,9 @@ then
     ln -s ../../common/hooks/pre-commit.hook .git/hooks/pre-commit
 fi
 
+# GNU gettext automake support doesn't get along with git.
+# https://bugzilla.gnome.org/show_bug.cgi?id=661128
+touch -t 200001010000 po/gst-plugins-base-0.10.pot
 
 CONFIGURE_DEF_OPT='--enable-maintainer-mode --enable-gtk-doc'
 
index 8d34d3f..74c10e9 100644 (file)
  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray
+ * with newer GLib versions (>= 2.31.0) */
+#define GLIB_DISABLE_DEPRECATION_WARNINGS
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index dbca3ab..1caa272 100644 (file)
@@ -1361,7 +1361,7 @@ theora_enc_encode_and_push (GstTheoraEnc * enc, ogg_packet op,
     GstClockTime next_time, duration;
     GstClockTime timestamp = 0;
     GST_DEBUG_OBJECT (enc, "encoded. granule:%" G_GINT64_FORMAT ", packet:%p, "
-        "bytes:%ld", op.granulepos, op.packet, op.bytes);
+        "bytes:%ld", (gint64) op.granulepos, op.packet, op.bytes);
 
     next_time = th_granule_time (enc->encoder, op.granulepos) * GST_SECOND;
     duration = next_time - enc->next_ts;
index cda2f1a..a9fedae 100644 (file)
  * Last reviewed on 2008-05-28 (0.10.20)
  */
 
+/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray
+ * with newer GLib versions (>= 2.31.0) */
+#define GLIB_DISABLE_DEPRECATION_WARNINGS
+
 #ifdef HAVE_CONFIG_H
 #  include "config.h"
 #endif
index 5239e82..25c95eb 100644 (file)
@@ -158,6 +158,7 @@ static gboolean gst_app_sink_unlock_stop (GstBaseSink * bsink);
 static gboolean gst_app_sink_start (GstBaseSink * psink);
 static gboolean gst_app_sink_stop (GstBaseSink * psink);
 static gboolean gst_app_sink_event (GstBaseSink * sink, GstEvent * event);
+static gboolean gst_app_sink_query (GstBaseSink * bsink, GstQuery * query);
 static GstFlowReturn gst_app_sink_preroll (GstBaseSink * psink,
     GstBuffer * buffer);
 static GstFlowReturn gst_app_sink_render (GstBaseSink * psink,
@@ -337,6 +338,7 @@ gst_app_sink_class_init (GstAppSinkClass * klass)
   basesink_class->render = gst_app_sink_render;
   basesink_class->get_caps = gst_app_sink_getcaps;
   basesink_class->set_caps = gst_app_sink_setcaps;
+  basesink_class->query = gst_app_sink_query;
 
   klass->pull_preroll = gst_app_sink_pull_preroll;
   klass->pull_sample = gst_app_sink_pull_sample;
@@ -774,6 +776,30 @@ gst_app_sink_getcaps (GstBaseSink * psink, GstCaps * filter)
   return caps;
 }
 
+static gboolean
+gst_app_sink_query (GstBaseSink * bsink, GstQuery * query)
+{
+  gboolean ret;
+
+  switch (GST_QUERY_TYPE (query)) {
+    case GST_QUERY_SEEKING:{
+      GstFormat fmt;
+
+      /* we don't supporting seeking */
+      gst_query_parse_seeking (query, &fmt, NULL, NULL, NULL);
+      gst_query_set_seeking (query, fmt, FALSE, 0, -1);
+      ret = TRUE;
+      break;
+    }
+
+    default:
+      ret = GST_BASE_SINK_CLASS (parent_class)->query (bsink, query);
+      break;
+  }
+
+  return ret;
+}
+
 /* external API */
 
 /**
index 0fca9a8..4c52b25 100644 (file)
@@ -83,9 +83,8 @@ gst_mixer_get_type (void)
 static void
 gst_mixer_class_init (GstMixerInterface * iface)
 {
-  iface->mixer_type = GST_MIXER_SOFTWARE;
-
   /* default virtual functions */
+  iface->get_mixer_type = NULL;
   iface->list_tracks = NULL;
   iface->set_volume = NULL;
   iface->get_volume = NULL;
@@ -304,7 +303,8 @@ gst_mixer_get_mixer_type (GstMixer * mixer)
 {
   GstMixerInterface *iface = GST_MIXER_GET_INTERFACE (mixer);
 
-  return iface->mixer_type;
+  g_return_val_if_fail (iface->get_mixer_type != NULL, GST_MIXER_SOFTWARE);
+  return iface->get_mixer_type (mixer);
 }
 
 /**
index 2cb618b..1de602d 100644 (file)
@@ -37,8 +37,6 @@ G_BEGIN_DECLS
 #define GST_MIXER_GET_INTERFACE(inst) \
   (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_MIXER, GstMixerInterface))
 
-#define GST_MIXER_TYPE(iface) (iface->mixer_type)
-
 typedef struct _GstMixer GstMixer;
 typedef struct _GstMixerInterface GstMixerInterface;
 
@@ -112,8 +110,6 @@ typedef enum
 struct _GstMixerInterface {
   GTypeInterface iface;
 
-  GstMixerType mixer_type;
-
   /* virtual functions */
   const GList *  (* list_tracks)   (GstMixer      *mixer);
 
@@ -137,6 +133,8 @@ struct _GstMixerInterface {
                                     GstMixerOptions *opts);
 
   GstMixerFlags (* get_mixer_flags) (GstMixer *mixer);
+
+  GstMixerType  (* get_mixer_type)  (GstMixer *mixer);
 };
 
 GType           gst_mixer_get_type      (void);
index 9653d01..ff29ea3 100644 (file)
  * </refsect2>
  */
 
+/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray
+ * with newer GLib versions (>= 2.31.0) */
+#define GLIB_DISABLE_DEPRECATION_WARNINGS
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index 40cfff9..6bbe010 100644 (file)
@@ -44,7 +44,7 @@ typedef struct _GstNavigationInterface GstNavigationInterface;
  * @iface: the parent interface
  * @send_event: sending a navigation event
  *
- * Color-balance interface.
+ * Navigation interface.
  */
 struct _GstNavigationInterface {
   GTypeInterface iface;
index b011cb0..4f416b8 100644 (file)
@@ -173,9 +173,11 @@ xmp_tag_type_get_name (GstXmpTagType tagtype)
     case GstXmpTagTypeBag:
       return "rdf:Bag";
     default:
-      g_assert_not_reached ();
+      break;
   }
-  return NULL;                  /* make compiler happy with -DG_DISABLE_ASSERT */
+
+  /* Make compiler happy */
+  g_return_val_if_reached ("");
 }
 
 struct _PendingXmpTag
index a73c7d7..57a4de4 100644 (file)
@@ -106,12 +106,11 @@ gst_color_balance_class_init (GstColorBalanceInterface * iface)
     initialized = TRUE;
   }
 
-  iface->balance_type = GST_COLOR_BALANCE_SOFTWARE;
-
   /* default virtual functions */
   iface->list_channels = NULL;
   iface->set_value = NULL;
   iface->get_value = NULL;
+  iface->get_balance_type = NULL;
 }
 
 /**
@@ -215,7 +214,10 @@ gst_color_balance_get_balance_type (GstColorBalance * balance)
 
   iface = GST_COLOR_BALANCE_GET_INTERFACE (balance);
 
-  return iface->balance_type;
+  g_return_val_if_fail (iface->get_balance_type != NULL,
+      GST_COLOR_BALANCE_SOFTWARE);
+
+  return iface->get_balance_type (balance);
 }
 
 /**
index 8cc4276..7f43b0d 100644 (file)
@@ -36,8 +36,6 @@ G_BEGIN_DECLS
 #define GST_COLOR_BALANCE_GET_INTERFACE(inst) \
   (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_COLOR_BALANCE, GstColorBalanceInterface))
 
-#define GST_COLOR_BALANCE_TYPE(iface) (iface->balance_type)
-
 typedef struct _GstColorBalance GstColorBalance;
 typedef struct _GstColorBalanceInterface GstColorBalanceInterface;
 
@@ -73,8 +71,6 @@ typedef enum
 struct _GstColorBalanceInterface {
   GTypeInterface iface;
 
-  GstColorBalanceType balance_type;
-
   /* virtual functions */
   const GList * (* list_channels) (GstColorBalance        *balance);
 
@@ -83,11 +79,15 @@ struct _GstColorBalanceInterface {
                                    gint                    value);
   gint          (* get_value)     (GstColorBalance        *balance,
                                    GstColorBalanceChannel *channel);
+  GstColorBalanceType (*get_balance_type)  (GstColorBalance *balance);
 
   /* signals */
   void (* value_changed) (GstColorBalance        *balance,
                           GstColorBalanceChannel *channel,
                           gint                    value);
+
+  /*< private >*/
+  gpointer _gst_reserved[GST_PADDING-1];
 };
 
 GType   gst_color_balance_get_type      (void);
index 1256777..0e8af87 100644 (file)
@@ -116,8 +116,8 @@ static gboolean gst_adder_sink_query (GstPad * pad, GstObject * parent,
     GstQuery * query);
 static gboolean gst_adder_src_event (GstPad * pad, GstObject * parent,
     GstEvent * event);
-static gboolean gst_adder_sink_event (GstPad * pad, GstObject * parent,
-    GstEvent * event);
+static gboolean gst_adder_sink_event (GstCollectPads2 * pads,
+    GstCollectData2 * pad, GstEvent * event, gpointer user_data);
 
 static GstPad *gst_adder_request_new_pad (GstElement * element,
     GstPadTemplate * temp, const gchar * unused, const GstCaps * caps);
@@ -131,8 +131,6 @@ static GstFlowReturn gst_adder_do_clip (GstCollectPads2 * pads,
     gpointer user_data);
 static GstFlowReturn gst_adder_collected (GstCollectPads2 * pads,
     gpointer user_data);
-static gboolean gst_adder_event (GstCollectPads2 * pads, GstCollectData2 * pad,
-    GstEvent * event, gpointer user_data);
 
 /* non-clipping versions (for float) */
 #define MAKE_FUNC_NC(name,type)                                 \
@@ -561,6 +559,8 @@ gst_adder_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
   return res;
 }
 
+/* event handling */
+
 typedef struct
 {
   GstEvent *event;
@@ -763,14 +763,13 @@ done:
 }
 
 static gboolean
-gst_adder_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
+gst_adder_sink_event (GstCollectPads2 * pads, GstCollectData2 * pad,
+    GstEvent * event, gpointer user_data)
 {
-  GstAdder *adder;
-  gboolean ret = TRUE;
-
-  adder = GST_ADDER (parent);
+  GstAdder *adder = GST_ADDER (user_data);
+  gboolean res = FALSE;
 
-  GST_DEBUG_OBJECT (pad, "Got %s event on sink pad",
+  GST_DEBUG_OBJECT (pad->pad, "Got %s event on sink pad",
       GST_EVENT_TYPE_NAME (event));
 
   switch (GST_EVENT_TYPE (event)) {
@@ -779,34 +778,40 @@ gst_adder_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
       GstCaps *caps;
 
       gst_event_parse_caps (event, &caps);
-      ret = gst_adder_setcaps (adder, pad, caps);
+      res = gst_adder_setcaps (adder, pad->pad, caps);
       gst_event_unref (event);
 
-      goto beach;
+      break;
     }
+    case GST_EVENT_FLUSH_START:
+      res = gst_pad_event_default (pad->pad, GST_OBJECT (adder), event);
+      break;
     case GST_EVENT_FLUSH_STOP:
-      /* we received a flush-stop. The collect_event function will call the
-       * gst_adder_event function we have set on the GstCollectPads2, so we
-       * have control over whether the event is sent past our element.
-       * We will only forward it when flush_stop_pending is set, and we will
-       * unset it then.
+      /* we received a flush-stop. We will only forward it when
+       * flush_stop_pending is set, and we will unset it then.
        */
-      GST_COLLECT_PADS2_STREAM_LOCK (adder->collect);
-      g_atomic_int_set (&adder->new_segment_pending, TRUE);
+      if (g_atomic_int_compare_and_exchange (&adder->flush_stop_pending,
+              TRUE, FALSE)) {
+        g_atomic_int_set (&adder->new_segment_pending, TRUE);
+        GST_DEBUG_OBJECT (pad->pad, "forwarding flush stop");
+      } else {
+        gst_event_unref (event);
+        res = TRUE;
+        GST_DEBUG_OBJECT (pad->pad, "eating flush stop");
+      }
       /* Clear pending tags */
       if (adder->pending_events) {
         g_list_foreach (adder->pending_events, (GFunc) gst_event_unref, NULL);
         g_list_free (adder->pending_events);
         adder->pending_events = NULL;
       }
-      GST_COLLECT_PADS2_STREAM_UNLOCK (adder->collect);
+      res = gst_pad_event_default (pad->pad, GST_OBJECT (adder), event);
       break;
     case GST_EVENT_TAG:
-      GST_COLLECT_PADS2_STREAM_LOCK (adder->collect);
       /* collect tags here so we can push them out when we collect data */
       adder->pending_events = g_list_append (adder->pending_events, event);
-      GST_COLLECT_PADS2_STREAM_UNLOCK (adder->collect);
-      goto beach;
+      res = TRUE;
+      break;
     case GST_EVENT_SEGMENT:
       if (g_atomic_int_compare_and_exchange (&adder->wait_for_new_segment,
               TRUE, FALSE)) {
@@ -814,16 +819,19 @@ gst_adder_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
          * see FIXME in gst_adder_collected() */
         g_atomic_int_set (&adder->new_segment_pending, TRUE);
       }
+      gst_event_unref (event);
+      res = TRUE;
+      break;
+    case GST_EVENT_EOS:
+      gst_event_unref (event);
+      res = TRUE;
       break;
     default:
+      res = gst_pad_event_default (pad->pad, GST_OBJECT (adder), event);
       break;
   }
 
-  /* now GstCollectPads2 can take care of the rest, e.g. EOS */
-  ret = adder->collect_event (pad, parent, event);
-
-beach:
-  return ret;
+  return res;
 }
 
 static void
@@ -892,7 +900,7 @@ gst_adder_init (GstAdder * adder)
   gst_collect_pads2_set_clip_function (adder->collect,
       GST_DEBUG_FUNCPTR (gst_adder_do_clip), adder);
   gst_collect_pads2_set_event_function (adder->collect,
-      GST_DEBUG_FUNCPTR (gst_adder_event), adder);
+      GST_DEBUG_FUNCPTR (gst_adder_sink_event), adder);
 }
 
 static void
@@ -992,12 +1000,6 @@ gst_adder_request_new_pad (GstElement * element, GstPadTemplate * templ,
   gst_pad_set_query_function (newpad, GST_DEBUG_FUNCPTR (gst_adder_sink_query));
   gst_collect_pads2_add_pad (adder->collect, newpad, sizeof (GstCollectData2));
 
-  /* FIXME: hacked way to override/extend the event function of
-   * GstCollectPads2; because it sets its own event function giving the
-   * element no access to events */
-  adder->collect_event = (GstPadEventFunction) GST_PAD_EVENTFUNC (newpad);
-  gst_pad_set_event_function (newpad, GST_DEBUG_FUNCPTR (gst_adder_sink_event));
-
   /* takes ownership of the pad */
   if (!gst_element_add_pad (GST_ELEMENT (adder), newpad))
     goto could_not_add;
@@ -1218,7 +1220,7 @@ gst_adder_collected (GstCollectPads2 * pads, gpointer user_data)
 
     if (event) {
       if (!gst_pad_push_event (adder->srcpad, event)) {
-        GST_WARNING_OBJECT (adder->srcpad, "Sending event failed");
+        GST_WARNING_OBJECT (adder->srcpad, "Sending new segment event failed");
       }
     } else {
       GST_WARNING_OBJECT (adder->srcpad, "Creating new segment event for "
@@ -1292,32 +1294,6 @@ eos:
   }
 }
 
-static gboolean
-gst_adder_event (GstCollectPads2 * pads, GstCollectData2 * pad,
-    GstEvent * event, gpointer user_data)
-{
-  GstAdder *adder = GST_ADDER (user_data);
-  if (GST_EVENT_TYPE (event) == GST_EVENT_FLUSH_STOP) {
-    if (g_atomic_int_compare_and_exchange (&adder->flush_stop_pending,
-            TRUE, FALSE)) {
-
-      return gst_pad_event_default (pad->pad, GST_OBJECT (user_data), event);
-    } else {
-      gst_event_unref (event);
-      return TRUE;
-    }
-  } else {
-    if (GST_EVENT_TYPE (event) == GST_EVENT_SEGMENT ||
-        GST_EVENT_TYPE (event) == GST_EVENT_CAPS ||
-        GST_EVENT_TYPE (event) == GST_EVENT_EOS) {
-      gst_event_unref (event);
-      return TRUE;
-    } else {
-      return gst_pad_event_default (pad->pad, GST_OBJECT (user_data), event);
-    }
-  }
-}
-
 static GstStateChangeReturn
 gst_adder_change_state (GstElement * element, GstStateChange transition)
 {
@@ -1359,7 +1335,6 @@ gst_adder_change_state (GstElement * element, GstStateChange transition)
   return ret;
 }
 
-
 static gboolean
 plugin_init (GstPlugin * plugin)
 {
index d5ce7ef..9fedf06 100644 (file)
@@ -65,7 +65,6 @@ struct _GstAdder {
   gint64          offset;
 
   /* sink event handling */
-  GstPadEventFunction  collect_event;
   GstSegment      segment;
   volatile gboolean new_segment_pending;
   volatile gboolean wait_for_new_segment;
index e337fdf..4fe137d 100644 (file)
@@ -65,6 +65,8 @@ gst_play_flags_get_type (void)
         "buffering"},
     {C_FLAGS (GST_PLAY_FLAG_DEINTERLACE), "Deinterlace video if necessary",
         "deinterlace"},
+    {C_FLAGS (GST_PLAY_FLAG_SOFT_COLORBALANCE), "Use software color balance",
+        "soft-colorbalance"},
     {0, NULL, NULL}
   };
   static volatile GType id = 0;
index d385688..ac98569 100644 (file)
@@ -70,7 +70,8 @@ typedef enum {
   GST_PLAY_FLAG_NATIVE_VIDEO  = (1 << 6),
   GST_PLAY_FLAG_DOWNLOAD      = (1 << 7),
   GST_PLAY_FLAG_BUFFERING     = (1 << 8),
-  GST_PLAY_FLAG_DEINTERLACE   = (1 << 9)
+  GST_PLAY_FLAG_DEINTERLACE   = (1 << 9),
+  GST_PLAY_FLAG_SOFT_COLORBALANCE = (1 << 10)
 } GstPlayFlags;
 
 #define GST_TYPE_PLAY_FLAGS (gst_play_flags_get_type())
index f243c2a..c0f1da7 100644 (file)
  * <title>Embedding the video window in your application</title>
  * By default, playbin (or rather the video sinks used) will create their own
  * window. Applications will usually want to force output to a window of their
- * own, however. This can be done using the #GstXOverlay interface, which most
+ * own, however. This can be done using the #GstVideoOverlay interface, which most
  * video sinks implement. See the documentation there for more details.
  * </refsect2>
  * <refsect2>
 #include <gst/gst-i18n-plugin.h>
 #include <gst/pbutils/pbutils.h>
 #include <gst/audio/streamvolume.h>
-
+#include <gst/video/videooverlay.h>
+#include <gst/interfaces/navigation.h>
+#include <gst/video/colorbalance.h>
 #include "gstplay-enum.h"
 #include "gstplay-marshal.h"
 #include "gstplayback.h"
 #include "gstplaysink.h"
 #include "gstsubtitleoverlay.h"
-
 #include "gst/glib-compat-private.h"
-
 GST_DEBUG_CATEGORY_STATIC (gst_play_bin_debug);
 #define GST_CAT_DEFAULT gst_play_bin_debug
 
@@ -458,7 +458,7 @@ struct _GstPlayBinClass
 #define DEFAULT_SUBURI            NULL
 #define DEFAULT_SOURCE            NULL
 #define DEFAULT_FLAGS             GST_PLAY_FLAG_AUDIO | GST_PLAY_FLAG_VIDEO | GST_PLAY_FLAG_TEXT | \
-                                  GST_PLAY_FLAG_SOFT_VOLUME
+                                  GST_PLAY_FLAG_SOFT_VOLUME | GST_PLAY_FLAG_SOFT_COLORBALANCE
 #define DEFAULT_N_VIDEO           0
 #define DEFAULT_CURRENT_VIDEO     -1
 #define DEFAULT_N_AUDIO           0
@@ -580,6 +580,12 @@ if (id) {                                \
   id = 0;                                \
 }
 
+static void gst_play_bin_overlay_init (gpointer g_iface, gpointer g_iface_data);
+static void gst_play_bin_navigation_init (gpointer g_iface,
+    gpointer g_iface_data);
+static void gst_play_bin_colorbalance_init (gpointer g_iface,
+    gpointer g_iface_data);
+
 static GType
 gst_play_bin_get_type (void)
 {
@@ -601,12 +607,30 @@ gst_play_bin_get_type (void)
     static const GInterfaceInfo svol_info = {
       NULL, NULL, NULL
     };
+    static const GInterfaceInfo ov_info = {
+      gst_play_bin_overlay_init,
+      NULL, NULL
+    };
+    static const GInterfaceInfo nav_info = {
+      gst_play_bin_navigation_init,
+      NULL, NULL
+    };
+    static const GInterfaceInfo col_info = {
+      gst_play_bin_colorbalance_init,
+      NULL, NULL
+    };
 
     gst_play_bin_type = g_type_register_static (GST_TYPE_PIPELINE,
         "GstPlayBin", &gst_play_bin_info, 0);
 
     g_type_add_interface_static (gst_play_bin_type, GST_TYPE_STREAM_VOLUME,
         &svol_info);
+    g_type_add_interface_static (gst_play_bin_type, GST_TYPE_VIDEO_OVERLAY,
+        &ov_info);
+    g_type_add_interface_static (gst_play_bin_type, GST_TYPE_NAVIGATION,
+        &nav_info);
+    g_type_add_interface_static (gst_play_bin_type, GST_TYPE_COLOR_BALANCE,
+        &col_info);
   }
 
   return gst_play_bin_type;
@@ -1217,6 +1241,13 @@ notify_mute_cb (GObject * selector, GParamSpec * pspec, GstPlayBin * playbin)
   g_object_notify (G_OBJECT (playbin), "mute");
 }
 
+static void
+colorbalance_value_changed_cb (GstColorBalance * balance,
+    GstColorBalanceChannel * channel, gint value, GstPlayBin * playbin)
+{
+  gst_color_balance_value_changed (GST_COLOR_BALANCE (playbin), channel, value);
+}
+
 /* Must be called with elements lock! */
 static void
 gst_play_bin_update_elements_list (GstPlayBin * playbin)
@@ -1260,7 +1291,8 @@ gst_play_bin_init (GstPlayBin * playbin)
   g_mutex_init (&playbin->elements_lock);
 
   /* add sink */
-  playbin->playsink = g_object_new (GST_TYPE_PLAY_SINK, NULL);
+  playbin->playsink =
+      g_object_new (GST_TYPE_PLAY_SINK, "name", "playsink", NULL);
   gst_bin_add (GST_BIN_CAST (playbin), GST_ELEMENT_CAST (playbin->playsink));
   gst_play_sink_set_flags (playbin->playsink, DEFAULT_FLAGS);
   /* Connect to notify::volume and notify::mute signals for proxying */
@@ -1268,6 +1300,8 @@ gst_play_bin_init (GstPlayBin * playbin)
       G_CALLBACK (notify_volume_cb), playbin);
   g_signal_connect (playbin->playsink, "notify::mute",
       G_CALLBACK (notify_mute_cb), playbin);
+  g_signal_connect (playbin->playsink, "value-changed",
+      G_CALLBACK (colorbalance_value_changed_cb), playbin);
 
   playbin->current_video = DEFAULT_CURRENT_VIDEO;
   playbin->current_audio = DEFAULT_CURRENT_AUDIO;
@@ -4026,6 +4060,121 @@ failure:
   }
 }
 
+static void
+gst_play_bin_overlay_expose (GstVideoOverlay * overlay)
+{
+  GstPlayBin *playbin = GST_PLAY_BIN (overlay);
+
+  gst_video_overlay_expose (GST_VIDEO_OVERLAY (playbin->playsink));
+}
+
+static void
+gst_play_bin_overlay_handle_events (GstVideoOverlay * overlay,
+    gboolean handle_events)
+{
+  GstPlayBin *playbin = GST_PLAY_BIN (overlay);
+
+  gst_video_overlay_handle_events (GST_VIDEO_OVERLAY (playbin->playsink),
+      handle_events);
+}
+
+static void
+gst_play_bin_overlay_set_render_rectangle (GstVideoOverlay * overlay, gint x,
+    gint y, gint width, gint height)
+{
+  GstPlayBin *playbin = GST_PLAY_BIN (overlay);
+
+  gst_video_overlay_set_render_rectangle (GST_VIDEO_OVERLAY (playbin->playsink),
+      x, y, width, height);
+}
+
+static void
+gst_play_bin_overlay_set_window_handle (GstVideoOverlay * overlay,
+    guintptr handle)
+{
+  GstPlayBin *playbin = GST_PLAY_BIN (overlay);
+
+  gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (playbin->playsink),
+      handle);
+}
+
+static void
+gst_play_bin_overlay_init (gpointer g_iface, gpointer g_iface_data)
+{
+  GstVideoOverlayInterface *iface = (GstVideoOverlayInterface *) g_iface;
+  iface->expose = gst_play_bin_overlay_expose;
+  iface->handle_events = gst_play_bin_overlay_handle_events;
+  iface->set_render_rectangle = gst_play_bin_overlay_set_render_rectangle;
+  iface->set_window_handle = gst_play_bin_overlay_set_window_handle;
+}
+
+static void
+gst_play_bin_navigation_send_event (GstNavigation * navigation,
+    GstStructure * structure)
+{
+  GstPlayBin *playbin = GST_PLAY_BIN (navigation);
+
+  gst_navigation_send_event (GST_NAVIGATION (playbin->playsink), structure);
+}
+
+static void
+gst_play_bin_navigation_init (gpointer g_iface, gpointer g_iface_data)
+{
+  GstNavigationInterface *iface = (GstNavigationInterface *) g_iface;
+
+  iface->send_event = gst_play_bin_navigation_send_event;
+}
+
+static const GList *
+gst_play_bin_colorbalance_list_channels (GstColorBalance * balance)
+{
+  GstPlayBin *playbin = GST_PLAY_BIN (balance);
+
+  return
+      gst_color_balance_list_channels (GST_COLOR_BALANCE (playbin->playsink));
+}
+
+static void
+gst_play_bin_colorbalance_set_value (GstColorBalance * balance,
+    GstColorBalanceChannel * channel, gint value)
+{
+  GstPlayBin *playbin = GST_PLAY_BIN (balance);
+
+  gst_color_balance_set_value (GST_COLOR_BALANCE (playbin->playsink), channel,
+      value);
+}
+
+static gint
+gst_play_bin_colorbalance_get_value (GstColorBalance * balance,
+    GstColorBalanceChannel * channel)
+{
+  GstPlayBin *playbin = GST_PLAY_BIN (balance);
+
+  return gst_color_balance_get_value (GST_COLOR_BALANCE (playbin->playsink),
+      channel);
+}
+
+static GstColorBalanceType
+gst_play_bin_colorbalance_get_balance_type (GstColorBalance * balance)
+{
+  GstPlayBin *playbin = GST_PLAY_BIN (balance);
+
+  return
+      gst_color_balance_get_balance_type (GST_COLOR_BALANCE
+      (playbin->playsink));
+}
+
+static void
+gst_play_bin_colorbalance_init (gpointer g_iface, gpointer g_iface_data)
+{
+  GstColorBalanceInterface *iface = (GstColorBalanceInterface *) g_iface;
+
+  iface->list_channels = gst_play_bin_colorbalance_list_channels;
+  iface->set_value = gst_play_bin_colorbalance_set_value;
+  iface->get_value = gst_play_bin_colorbalance_get_value;
+  iface->get_balance_type = gst_play_bin_colorbalance_get_balance_type;
+}
+
 gboolean
 gst_play_bin2_plugin_init (GstPlugin * plugin)
 {
index e53b49c..c365378 100644 (file)
 #include <gst/gst-i18n-plugin.h>
 #include <gst/pbutils/pbutils.h>
 #include <gst/video/video.h>
+#include <gst/audio/streamvolume.h>
+#include <gst/video/colorbalance.h>
+#include <gst/video/videooverlay.h>
+#include <gst/interfaces/navigation.h>
 
 #include "gstplaysink.h"
 #include "gststreamsynchronizer.h"
@@ -40,7 +44,7 @@ GST_DEBUG_CATEGORY_STATIC (gst_play_sink_debug);
 #define VOLUME_MAX_DOUBLE 10.0
 
 #define DEFAULT_FLAGS             GST_PLAY_FLAG_AUDIO | GST_PLAY_FLAG_VIDEO | GST_PLAY_FLAG_TEXT | \
-                                  GST_PLAY_FLAG_SOFT_VOLUME
+                                  GST_PLAY_FLAG_SOFT_VOLUME | GST_PLAY_FLAG_SOFT_COLORBALANCE
 
 #define GST_PLAY_CHAIN(c) ((GstPlayChain *)(c))
 
@@ -202,6 +206,20 @@ struct _GstPlaySink
   gboolean volume_changed;      /* volume/mute changed while no audiochain */
   gboolean mute_changed;        /* ... has been created yet */
   gint64 av_offset;
+
+  /* videooverlay proxy interface */
+  GstVideoOverlay *overlay_element;     /* protected with LOCK */
+  gboolean overlay_handle_set;
+  guintptr overlay_handle;
+  gboolean overlay_render_rectangle_set;
+  gint overlay_x, overlay_y, overlay_width, overlay_height;
+  gboolean overlay_handle_events_set;
+  gboolean overlay_handle_events;
+
+  /* colorbalance proxy interface */
+  GstColorBalance *colorbalance_element;
+  GList *colorbalance_channels; /* CONTRAST, BRIGHTNESS, HUE, SATURATION */
+  gint colorbalance_values[4];
 };
 
 struct _GstPlaySinkClass
@@ -324,7 +342,40 @@ gst_play_marshal_SAMPLE__BOXED (GClosure * closure,
 
 /* static guint gst_play_sink_signals[LAST_SIGNAL] = { 0 }; */
 
-G_DEFINE_TYPE (GstPlaySink, gst_play_sink, GST_TYPE_BIN);
+static void gst_play_sink_overlay_init (gpointer g_iface,
+    gpointer g_iface_data);
+static void gst_play_sink_navigation_init (gpointer g_iface,
+    gpointer g_iface_data);
+static void gst_play_sink_colorbalance_init (gpointer g_iface,
+    gpointer g_iface_data);
+
+static void
+_do_init (GType type)
+{
+  static const GInterfaceInfo svol_info = {
+    NULL, NULL, NULL
+  };
+  static const GInterfaceInfo ov_info = {
+    gst_play_sink_overlay_init,
+    NULL, NULL
+  };
+  static const GInterfaceInfo nav_info = {
+    gst_play_sink_navigation_init,
+    NULL, NULL
+  };
+  static const GInterfaceInfo col_info = {
+    gst_play_sink_colorbalance_init,
+    NULL, NULL
+  };
+
+  g_type_add_interface_static (type, GST_TYPE_STREAM_VOLUME, &svol_info);
+  g_type_add_interface_static (type, GST_TYPE_VIDEO_OVERLAY, &ov_info);
+  g_type_add_interface_static (type, GST_TYPE_NAVIGATION, &nav_info);
+  g_type_add_interface_static (type, GST_TYPE_COLOR_BALANCE, &col_info);
+}
+
+G_DEFINE_TYPE_WITH_CODE (GstPlaySink, gst_play_sink, GST_TYPE_BIN,
+    _do_init (g_define_type_id));
 
 static void
 gst_play_sink_class_init (GstPlaySinkClass * klass)
@@ -434,6 +485,7 @@ gst_play_sink_class_init (GstPlaySinkClass * klass)
       g_param_spec_object ("audio-sink", "Audio Sink",
           "the audio output element to use (NULL = default sink)",
           GST_TYPE_ELEMENT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
   /**
    * GstPlaySink:text-sink:
    *
@@ -505,6 +557,8 @@ gst_play_sink_class_init (GstPlaySinkClass * klass)
 static void
 gst_play_sink_init (GstPlaySink * playsink)
 {
+  GstColorBalanceChannel *channel;
+
   /* init groups */
   playsink->video_sink = NULL;
   playsink->audio_sink = NULL;
@@ -522,6 +576,46 @@ gst_play_sink_init (GstPlaySink * playsink)
 
   g_rec_mutex_init (&playsink->lock);
   GST_OBJECT_FLAG_SET (playsink, GST_ELEMENT_FLAG_SINK);
+
+  channel =
+      GST_COLOR_BALANCE_CHANNEL (g_object_new (GST_TYPE_COLOR_BALANCE_CHANNEL,
+          NULL));
+  channel->label = g_strdup ("CONTRAST");
+  channel->min_value = -1000;
+  channel->max_value = 1000;
+  playsink->colorbalance_channels =
+      g_list_append (playsink->colorbalance_channels, channel);
+  playsink->colorbalance_values[0] = 0;
+
+  channel =
+      GST_COLOR_BALANCE_CHANNEL (g_object_new (GST_TYPE_COLOR_BALANCE_CHANNEL,
+          NULL));
+  channel->label = g_strdup ("BRIGHTNESS");
+  channel->min_value = -1000;
+  channel->max_value = 1000;
+  playsink->colorbalance_channels =
+      g_list_append (playsink->colorbalance_channels, channel);
+  playsink->colorbalance_values[1] = 0;
+
+  channel =
+      GST_COLOR_BALANCE_CHANNEL (g_object_new (GST_TYPE_COLOR_BALANCE_CHANNEL,
+          NULL));
+  channel->label = g_strdup ("HUE");
+  channel->min_value = -1000;
+  channel->max_value = 1000;
+  playsink->colorbalance_channels =
+      g_list_append (playsink->colorbalance_channels, channel);
+  playsink->colorbalance_values[2] = 0;
+
+  channel =
+      GST_COLOR_BALANCE_CHANNEL (g_object_new (GST_TYPE_COLOR_BALANCE_CHANNEL,
+          NULL));
+  channel->label = g_strdup ("SATURATION");
+  channel->min_value = -1000;
+  channel->max_value = 1000;
+  playsink->colorbalance_channels =
+      g_list_append (playsink->colorbalance_channels, channel);
+  playsink->colorbalance_values[3] = 0;
 }
 
 static void
@@ -613,6 +707,11 @@ gst_play_sink_dispose (GObject * object)
 
   playsink->stream_synchronizer = NULL;
 
+  g_list_foreach (playsink->colorbalance_channels, (GFunc) gst_object_unref,
+      NULL);
+  g_list_free (playsink->colorbalance_channels);
+  playsink->colorbalance_channels = NULL;
+
   G_OBJECT_CLASS (gst_play_sink_parent_class)->dispose (object);
 }
 
@@ -1231,6 +1330,149 @@ link_failed:
   }
 }
 
+static gboolean
+is_valid_color_balance_element (GstColorBalance * bal)
+{
+  gboolean have_brightness = FALSE;
+  gboolean have_contrast = FALSE;
+  gboolean have_hue = FALSE;
+  gboolean have_saturation = FALSE;
+  const GList *channels, *l;
+
+  channels = gst_color_balance_list_channels (bal);
+  for (l = channels; l; l = l->next) {
+    GstColorBalanceChannel *ch = l->data;
+
+    if (g_strrstr (ch->label, "BRIGHTNESS"))
+      have_brightness = TRUE;
+    else if (g_strrstr (ch->label, "CONTRAST"))
+      have_contrast = TRUE;
+    else if (g_strrstr (ch->label, "HUE"))
+      have_hue = TRUE;
+    else if (g_strrstr (ch->label, "SATURATION"))
+      have_saturation = TRUE;
+  }
+
+  return have_brightness && have_contrast && have_hue && have_saturation;
+}
+
+static void
+iterate_color_balance_elements (const GValue * item, gpointer user_data)
+{
+  gboolean valid;
+  GstColorBalance *cb, **cb_out = user_data;
+
+  cb = GST_COLOR_BALANCE (g_value_get_object (item));
+  valid = is_valid_color_balance_element (cb);
+  if (valid) {
+    if (*cb_out
+        && gst_color_balance_get_balance_type (*cb_out) ==
+        GST_COLOR_BALANCE_SOFTWARE) {
+      gst_object_unref (*cb_out);
+      *cb_out = GST_COLOR_BALANCE (gst_object_ref (cb));
+    } else if (!*cb_out) {
+      *cb_out = GST_COLOR_BALANCE (gst_object_ref (cb));
+    }
+  }
+}
+
+static GstColorBalance *
+find_color_balance_element (GstElement * element)
+{
+  GstIterator *it;
+  GstColorBalance *cb = NULL;
+
+  if (GST_IS_COLOR_BALANCE (element)
+      && is_valid_color_balance_element (GST_COLOR_BALANCE (element)))
+    return GST_COLOR_BALANCE (gst_object_ref (element));
+  else if (!GST_IS_BIN (element))
+    return FALSE;
+
+  it = gst_bin_iterate_all_by_interface (GST_BIN (element),
+      GST_TYPE_COLOR_BALANCE);
+  while (gst_iterator_foreach (it, iterate_color_balance_elements,
+          &cb) == GST_ITERATOR_RESYNC)
+    gst_iterator_resync (it);
+  gst_iterator_free (it);
+
+  return cb;
+}
+
+static void
+colorbalance_value_changed_cb (GstColorBalance * balance,
+    GstColorBalanceChannel * channel, gint value, GstPlaySink * playsink)
+{
+  GList *l;
+  gint i;
+
+  for (i = 0, l = playsink->colorbalance_channels; l; l = l->next, i++) {
+    GstColorBalanceChannel *proxy = l->data;
+
+    if (g_strrstr (channel->label, proxy->label)) {
+      gdouble new_val;
+
+      /* Convert to [0, 1] range */
+      new_val =
+          ((gdouble) value -
+          (gdouble) channel->min_value) / ((gdouble) channel->max_value -
+          (gdouble) channel->min_value);
+      /* Convert to proxy range */
+      new_val =
+          proxy->min_value + new_val * ((gdouble) proxy->max_value -
+          (gdouble) proxy->min_value);
+      playsink->colorbalance_values[i] = (gint) (0.5 + new_val);
+
+      gst_color_balance_value_changed (GST_COLOR_BALANCE (playsink), proxy,
+          playsink->colorbalance_values[i]);
+      break;
+    }
+  }
+}
+
+static void
+update_colorbalance (GstPlaySink * playsink)
+{
+  GstColorBalance *balance = NULL;
+  GList *l;
+  gint i;
+
+  GST_OBJECT_LOCK (playsink);
+  if (playsink->colorbalance_element) {
+    balance =
+        GST_COLOR_BALANCE (gst_object_ref (playsink->colorbalance_element));
+  }
+  GST_OBJECT_UNLOCK (playsink);
+  if (!balance)
+    return;
+
+  g_signal_handlers_block_by_func (balance,
+      G_CALLBACK (colorbalance_value_changed_cb), playsink);
+
+  for (i = 0, l = playsink->colorbalance_channels; l; l = l->next, i++) {
+    GstColorBalanceChannel *proxy = l->data;
+    GstColorBalanceChannel *channel = NULL;
+    const GList *channels, *k;
+
+    channels = gst_color_balance_list_channels (balance);
+    for (k = channels; k; k = k->next) {
+      GstColorBalanceChannel *tmp = k->data;
+
+      if (g_strrstr (tmp->label, proxy->label)) {
+        channel = tmp;
+        break;
+      }
+    }
+
+    g_assert (channel);
+
+    gst_color_balance_set_value (balance, channel,
+        playsink->colorbalance_values[i]);
+  }
+
+  g_signal_handlers_unblock_by_func (balance,
+      G_CALLBACK (colorbalance_value_changed_cb), playsink);
+}
+
 /* make the element (bin) that contains the elements needed to perform
  * video display.
  *
@@ -1298,6 +1540,13 @@ gen_video_chain (GstPlaySink * playsink, gboolean raw, gboolean async)
     chain->async = TRUE;
   }
 
+  /* Make sure the aspect ratio is kept */
+  elem =
+      gst_play_sink_find_property_sinks (playsink, chain->sink,
+      "force-aspect-ratio", G_TYPE_BOOLEAN);
+  if (elem)
+    g_object_set (elem, "force-aspect-ratio", TRUE, NULL);
+
   /* find ts-offset element */
   gst_object_replace ((GstObject **) & chain->ts_offset, (GstObject *)
       gst_play_sink_find_property_sinks (playsink, chain->sink, "ts-offset",
@@ -1310,6 +1559,34 @@ gen_video_chain (GstPlaySink * playsink, gboolean raw, gboolean async)
   gst_object_ref_sink (bin);
   gst_bin_add (bin, chain->sink);
 
+  /* Get the VideoOverlay element */
+  {
+    GstVideoOverlay *overlay = NULL;
+
+    GST_OBJECT_LOCK (playsink);
+    if (playsink->overlay_element)
+      gst_object_unref (playsink->overlay_element);
+    playsink->overlay_element =
+        GST_VIDEO_OVERLAY (gst_bin_get_by_interface (GST_BIN (chain->chain.bin),
+            GST_TYPE_VIDEO_OVERLAY));
+    if (playsink->overlay_element)
+      overlay = GST_VIDEO_OVERLAY (gst_object_ref (playsink->overlay_element));
+    GST_OBJECT_UNLOCK (playsink);
+
+    if (overlay) {
+      if (playsink->overlay_handle_set)
+        gst_video_overlay_set_window_handle (overlay, playsink->overlay_handle);
+      if (playsink->overlay_handle_events_set)
+        gst_video_overlay_handle_events (overlay,
+            playsink->overlay_handle_events);
+      if (playsink->overlay_render_rectangle_set)
+        gst_video_overlay_set_render_rectangle (overlay,
+            playsink->overlay_x, playsink->overlay_y,
+            playsink->overlay_width, playsink->overlay_height);
+      gst_object_unref (overlay);
+    }
+  }
+
   /* decouple decoder from sink, this improves playback quite a lot since the
    * decoder can continue while the sink blocks for synchronisation. We don't
    * need a lot of buffers as this consumes a lot of memory and we don't want
@@ -1329,10 +1606,34 @@ gen_video_chain (GstPlaySink * playsink, gboolean raw, gboolean async)
     head = prev = chain->queue;
   }
 
-  if (!(playsink->flags & GST_PLAY_FLAG_NATIVE_VIDEO)) {
+  GST_OBJECT_LOCK (playsink);
+  if (playsink->colorbalance_element) {
+    g_signal_handlers_disconnect_by_func (playsink->colorbalance_element,
+        G_CALLBACK (colorbalance_value_changed_cb), playsink);
+    gst_object_unref (playsink->colorbalance_element);
+  }
+  playsink->colorbalance_element = find_color_balance_element (chain->sink);
+  GST_OBJECT_UNLOCK (playsink);
+
+  if (!(playsink->flags & GST_PLAY_FLAG_NATIVE_VIDEO)
+      || (!playsink->colorbalance_element
+          && (playsink->flags & GST_PLAY_FLAG_SOFT_COLORBALANCE))) {
+    gboolean use_converters = !(playsink->flags & GST_PLAY_FLAG_NATIVE_VIDEO);
+    gboolean use_balance = !playsink->colorbalance_element
+        && (playsink->flags & GST_PLAY_FLAG_SOFT_COLORBALANCE);
+
     GST_DEBUG_OBJECT (playsink, "creating videoconverter");
     chain->conv =
-        g_object_new (GST_TYPE_PLAY_SINK_VIDEO_CONVERT, "name", "vconv", NULL);
+        g_object_new (GST_TYPE_PLAY_SINK_VIDEO_CONVERT, "name", "vconv",
+        "use-converters", use_converters, "use-balance", use_balance, NULL);
+
+    GST_OBJECT_LOCK (playsink);
+    if (use_balance && GST_PLAY_SINK_VIDEO_CONVERT (chain->conv)->balance)
+      playsink->colorbalance_element =
+          GST_COLOR_BALANCE (gst_object_ref (GST_PLAY_SINK_VIDEO_CONVERT
+              (chain->conv)->balance));
+    GST_OBJECT_UNLOCK (playsink);
+
     gst_bin_add (bin, chain->conv);
     if (prev) {
       if (!gst_element_link_pads_full (prev, "src", chain->conv, "sink",
@@ -1344,6 +1645,8 @@ gen_video_chain (GstPlaySink * playsink, gboolean raw, gboolean async)
     prev = chain->conv;
   }
 
+  update_colorbalance (playsink);
+
   if (prev) {
     GST_DEBUG_OBJECT (playsink, "linking to sink");
     if (!gst_element_link_pads_full (prev, "src", chain->sink, NULL,
@@ -1390,6 +1693,7 @@ no_sinks:
     free_chain ((GstPlayChain *) chain);
     return NULL;
   }
+
 link_failed:
   {
     GST_ELEMENT_ERROR (playsink, CORE, PAD,
@@ -1423,8 +1727,35 @@ setup_video_chain (GstPlaySink * playsink, gboolean raw, gboolean async)
   if (ret == GST_STATE_CHANGE_FAILURE)
     return FALSE;
 
-  /* find ts-offset element */
+  /* Get the VideoOverlay element */
+  {
+    GstVideoOverlay *overlay = NULL;
+
+    GST_OBJECT_LOCK (playsink);
+    if (playsink->overlay_element)
+      gst_object_unref (playsink->overlay_element);
+    playsink->overlay_element =
+        GST_VIDEO_OVERLAY (gst_bin_get_by_interface (GST_BIN (chain->chain.bin),
+            GST_TYPE_VIDEO_OVERLAY));
+    if (playsink->overlay_element)
+      overlay = GST_VIDEO_OVERLAY (gst_object_ref (playsink->overlay_element));
+    GST_OBJECT_UNLOCK (playsink);
+
+    if (overlay) {
+      if (playsink->overlay_handle_set)
+        gst_video_overlay_set_window_handle (overlay, playsink->overlay_handle);
+      if (playsink->overlay_handle_events_set)
+        gst_video_overlay_handle_events (overlay,
+            playsink->overlay_handle_events);
+      if (playsink->overlay_render_rectangle_set)
+        gst_video_overlay_set_render_rectangle (overlay,
+            playsink->overlay_x, playsink->overlay_y,
+            playsink->overlay_width, playsink->overlay_height);
+      gst_object_unref (overlay);
+    }
+  }
 
+  /* find ts-offset element */
   gst_object_replace ((GstObject **) & chain->ts_offset, (GstObject *)
       gst_play_sink_find_property_sinks (playsink, chain->sink, "ts-offset",
           G_TYPE_INT64));
@@ -1443,6 +1774,39 @@ setup_video_chain (GstPlaySink * playsink, gboolean raw, gboolean async)
     GST_DEBUG_OBJECT (playsink, "no async property on the sink");
     chain->async = TRUE;
   }
+
+  /* Make sure the aspect ratio is kept */
+  elem =
+      gst_play_sink_find_property_sinks (playsink, chain->sink,
+      "force-aspect-ratio", G_TYPE_BOOLEAN);
+  if (elem)
+    g_object_set (elem, "force-aspect-ratio", TRUE, NULL);
+
+  GST_OBJECT_LOCK (playsink);
+  if (playsink->colorbalance_element) {
+    g_signal_handlers_disconnect_by_func (playsink->colorbalance_element,
+        G_CALLBACK (colorbalance_value_changed_cb), playsink);
+    gst_object_unref (playsink->colorbalance_element);
+  }
+  playsink->colorbalance_element = find_color_balance_element (chain->sink);
+  GST_OBJECT_UNLOCK (playsink);
+
+  if (chain->conv) {
+    gboolean use_balance = !playsink->colorbalance_element
+        && (playsink->flags & GST_PLAY_FLAG_SOFT_COLORBALANCE);
+
+    g_object_set (chain->conv, "use-balance", use_balance, NULL);
+
+    GST_OBJECT_LOCK (playsink);
+    if (use_balance && GST_PLAY_SINK_VIDEO_CONVERT (chain->conv)->balance)
+      playsink->colorbalance_element =
+          GST_COLOR_BALANCE (gst_object_ref (GST_PLAY_SINK_VIDEO_CONVERT
+              (chain->conv)->balance));
+    GST_OBJECT_UNLOCK (playsink);
+  }
+
+  update_colorbalance (playsink);
+
   return TRUE;
 }
 
@@ -1801,10 +2165,10 @@ gen_audio_chain (GstPlaySink * playsink, gboolean raw)
   }
 
   if (!(playsink->flags & GST_PLAY_FLAG_NATIVE_AUDIO) || (!have_volume
-          && playsink->flags & GST_PLAY_FLAG_SOFT_VOLUME)) {
+          && (playsink->flags & GST_PLAY_FLAG_SOFT_VOLUME))) {
     gboolean use_converters = !(playsink->flags & GST_PLAY_FLAG_NATIVE_AUDIO);
     gboolean use_volume =
-        !have_volume && playsink->flags & GST_PLAY_FLAG_SOFT_VOLUME;
+        !have_volume && (playsink->flags & GST_PLAY_FLAG_SOFT_VOLUME);
     GST_DEBUG_OBJECT (playsink,
         "creating audioconvert with use-converters %d, use-volume %d",
         use_converters, use_volume);
@@ -1821,7 +2185,7 @@ gen_audio_chain (GstPlaySink * playsink, gboolean raw)
     }
     prev = chain->conv;
 
-    if (!have_volume && playsink->flags & GST_PLAY_FLAG_SOFT_VOLUME) {
+    if (!have_volume && (playsink->flags & GST_PLAY_FLAG_SOFT_VOLUME)) {
       GstPlaySinkAudioConvert *conv =
           GST_PLAY_SINK_AUDIO_CONVERT_CAST (chain->conv);
 
@@ -1974,13 +2338,14 @@ setup_audio_chain (GstPlaySink * playsink, gboolean raw)
         GST_PLAY_SINK_AUDIO_CONVERT_CAST (chain->conv);
 
     /* no volume, we need to add a volume element when we can */
-    g_object_set (chain->conv, "use-volume", TRUE, NULL);
+    g_object_set (chain->conv, "use-volume",
+        ! !(playsink->flags & GST_PLAY_FLAG_SOFT_VOLUME), NULL);
     GST_DEBUG_OBJECT (playsink, "the sink has no volume property");
 
     /* Disconnect signals */
     disconnect_chain (chain, playsink);
 
-    if (conv->volume) {
+    if (conv->volume && (playsink->flags & GST_PLAY_FLAG_SOFT_VOLUME)) {
       chain->volume = conv->volume;
       chain->mute = chain->volume;
 
@@ -2164,6 +2529,19 @@ gst_play_sink_reconfigure (GstPlaySink * playsink)
     need_text = TRUE;
   }
 
+  GST_OBJECT_LOCK (playsink);
+  if (playsink->overlay_element)
+    gst_object_unref (playsink->overlay_element);
+  playsink->overlay_element = NULL;
+
+  if (playsink->colorbalance_element) {
+    g_signal_handlers_disconnect_by_func (playsink->colorbalance_element,
+        G_CALLBACK (colorbalance_value_changed_cb), playsink);
+    gst_object_unref (playsink->colorbalance_element);
+  }
+  playsink->colorbalance_element = NULL;
+  GST_OBJECT_UNLOCK (playsink);
+
   if (((flags & GST_PLAY_FLAG_VIDEO)
           || (flags & GST_PLAY_FLAG_NATIVE_VIDEO)) && playsink->video_pad) {
     /* we have video and we are requested to show it */
@@ -3355,6 +3733,44 @@ gst_play_sink_handle_message (GstBin * bin, GstMessage * message)
       GST_BIN_CLASS (gst_play_sink_parent_class)->handle_message (bin, message);
       break;
     }
+    case GST_MESSAGE_ELEMENT:{
+      if (gst_is_video_overlay_prepare_window_handle_message (message)) {
+        GstVideoOverlay *overlay;
+
+        GST_OBJECT_LOCK (playsink);
+        if (playsink->overlay_element
+            && GST_OBJECT_CAST (playsink->overlay_element) !=
+            GST_MESSAGE_SRC (message)) {
+          gst_object_unref (playsink->overlay_element);
+          playsink->overlay_element = NULL;
+        }
+
+        if (!playsink->overlay_element)
+          playsink->overlay_element =
+              GST_VIDEO_OVERLAY (gst_object_ref (GST_MESSAGE_SRC (message)));
+        overlay =
+            GST_VIDEO_OVERLAY (gst_object_ref (playsink->overlay_element));
+        GST_OBJECT_UNLOCK (playsink);
+
+        GST_DEBUG_OBJECT (playsink, "Got prepare-xwindow-id message");
+
+        if (playsink->overlay_handle_set)
+          gst_video_overlay_set_window_handle (playsink->overlay_element,
+              playsink->overlay_handle);
+        if (playsink->overlay_handle_events_set)
+          gst_video_overlay_handle_events (playsink->overlay_element,
+              playsink->overlay_handle_events);
+        if (playsink->overlay_render_rectangle_set)
+          gst_video_overlay_set_render_rectangle (playsink->overlay_element,
+              playsink->overlay_x, playsink->overlay_y,
+              playsink->overlay_width, playsink->overlay_height);
+
+        gst_object_unref (overlay);
+        gst_message_unref (message);
+        gst_video_overlay_prepare_window_handle (GST_VIDEO_OVERLAY (playsink));
+      }
+      break;
+    }
     default:
       GST_BIN_CLASS (gst_play_sink_parent_class)->handle_message (bin, message);
       break;
@@ -3370,7 +3786,6 @@ static gboolean
 gst_play_sink_send_event_to_sink (GstPlaySink * playsink, GstEvent * event)
 {
   gboolean res = TRUE;
-
   if (playsink->textchain && playsink->textchain->sink) {
     gst_event_ref (event);
     if ((res = gst_element_send_event (playsink->textchain->chain.bin, event))) {
@@ -3411,9 +3826,7 @@ gst_play_sink_send_event (GstElement * element, GstEvent * event)
   gboolean res = FALSE;
   GstEventType event_type = GST_EVENT_TYPE (event);
   GstPlaySink *playsink;
-
   playsink = GST_PLAY_SINK_CAST (element);
-
   switch (event_type) {
     case GST_EVENT_SEEK:
       GST_DEBUG_OBJECT (element, "Sending event to a sink");
@@ -3425,10 +3838,8 @@ gst_play_sink_send_event (GstElement * element, GstEvent * event)
       guint64 amount;
       gdouble rate;
       gboolean flush, intermediate;
-
       gst_event_parse_step (event, &format, &amount, &rate, &flush,
           &intermediate);
-
       if (format == GST_FORMAT_BUFFERS) {
         /* for buffers, we will try to step video frames, for other formats we
          * send the step to all sinks */
@@ -3454,11 +3865,8 @@ gst_play_sink_change_state (GstElement * element, GstStateChange transition)
 {
   GstStateChangeReturn ret;
   GstStateChangeReturn bret;
-
   GstPlaySink *playsink;
-
   playsink = GST_PLAY_SINK (element);
-
   switch (transition) {
     case GST_STATE_CHANGE_READY_TO_PAUSED:
       playsink->need_async_start = TRUE;
@@ -3493,6 +3901,20 @@ gst_play_sink_change_state (GstElement * element, GstStateChange transition)
         gst_object_unref (playsink->videochain->ts_offset);
         playsink->videochain->ts_offset = NULL;
       }
+
+      GST_OBJECT_LOCK (playsink);
+      if (playsink->overlay_element)
+        gst_object_unref (playsink->overlay_element);
+      playsink->overlay_element = NULL;
+
+      if (playsink->colorbalance_element) {
+        g_signal_handlers_disconnect_by_func (playsink->colorbalance_element,
+            G_CALLBACK (colorbalance_value_changed_cb), playsink);
+        gst_object_unref (playsink->colorbalance_element);
+      }
+      playsink->colorbalance_element = NULL;
+      GST_OBJECT_UNLOCK (playsink);
+
       ret = GST_STATE_CHANGE_SUCCESS;
       break;
     default:
@@ -3602,7 +4024,6 @@ gst_play_sink_change_state (GstElement * element, GstStateChange transition)
         if (playsink->textchain && playsink->textchain->sink)
           gst_bin_remove (GST_BIN_CAST (playsink->textchain->chain.bin),
               playsink->textchain->sink);
-
         if (playsink->audio_sink != NULL)
           gst_element_set_state (playsink->audio_sink, GST_STATE_NULL);
         if (playsink->video_sink != NULL)
@@ -3611,7 +4032,6 @@ gst_play_sink_change_state (GstElement * element, GstStateChange transition)
           gst_element_set_state (playsink->visualisation, GST_STATE_NULL);
         if (playsink->text_sink != NULL)
           gst_element_set_state (playsink->text_sink, GST_STATE_NULL);
-
         free_chain ((GstPlayChain *) playsink->videodeinterlacechain);
         playsink->videodeinterlacechain = NULL;
         free_chain ((GstPlayChain *) playsink->videochain);
@@ -3628,7 +4048,6 @@ gst_play_sink_change_state (GstElement * element, GstStateChange transition)
       break;
   }
   return ret;
-
   /* ERRORS */
 activate_failed:
   {
@@ -3643,7 +4062,6 @@ gst_play_sink_set_property (GObject * object, guint prop_id,
     const GValue * value, GParamSpec * spec)
 {
   GstPlaySink *playsink = GST_PLAY_SINK (object);
-
   switch (prop_id) {
     case PROP_FLAGS:
       gst_play_sink_set_flags (playsink, g_value_get_flags (value));
@@ -3690,7 +4108,6 @@ gst_play_sink_get_property (GObject * object, guint prop_id,
     GValue * value, GParamSpec * spec)
 {
   GstPlaySink *playsink = GST_PLAY_SINK (object);
-
   switch (prop_id) {
     case PROP_FLAGS:
       g_value_set_flags (value, gst_play_sink_get_flags (playsink));
@@ -3735,12 +4152,273 @@ gst_play_sink_get_property (GObject * object, guint prop_id,
   }
 }
 
+static void
+gst_play_sink_overlay_expose (GstVideoOverlay * overlay)
+{
+  GstPlaySink *playsink = GST_PLAY_SINK (overlay);
+  GstVideoOverlay *overlay_element;
+
+  GST_OBJECT_LOCK (playsink);
+  if (playsink->overlay_element)
+    overlay_element =
+        GST_VIDEO_OVERLAY (gst_object_ref (playsink->overlay_element));
+  else
+    overlay_element = NULL;
+  GST_OBJECT_UNLOCK (playsink);
+
+  if (overlay_element) {
+    gst_video_overlay_expose (overlay_element);
+    gst_object_unref (overlay_element);
+  }
+}
+
+static void
+gst_play_sink_overlay_handle_events (GstVideoOverlay * overlay,
+    gboolean handle_events)
+{
+  GstPlaySink *playsink = GST_PLAY_SINK (overlay);
+  GstVideoOverlay *overlay_element;
+
+  GST_OBJECT_LOCK (playsink);
+  if (playsink->overlay_element)
+    overlay_element =
+        GST_VIDEO_OVERLAY (gst_object_ref (playsink->overlay_element));
+  else
+    overlay_element = NULL;
+  GST_OBJECT_UNLOCK (playsink);
+
+  playsink->overlay_handle_events_set = TRUE;
+  playsink->overlay_handle_events = handle_events;
+
+  if (overlay_element) {
+    gst_video_overlay_handle_events (overlay_element, handle_events);
+    gst_object_unref (overlay_element);
+  }
+}
+
+static void
+gst_play_sink_overlay_set_render_rectangle (GstVideoOverlay * overlay, gint x,
+    gint y, gint width, gint height)
+{
+  GstPlaySink *playsink = GST_PLAY_SINK (overlay);
+  GstVideoOverlay *overlay_element;
+
+  GST_OBJECT_LOCK (playsink);
+  if (playsink->overlay_element)
+    overlay_element =
+        GST_VIDEO_OVERLAY (gst_object_ref (playsink->overlay_element));
+  else
+    overlay_element = NULL;
+  GST_OBJECT_UNLOCK (playsink);
+
+  playsink->overlay_render_rectangle_set = TRUE;
+  playsink->overlay_x = x;
+  playsink->overlay_y = y;
+  playsink->overlay_width = width;
+  playsink->overlay_height = height;
+
+  if (overlay_element) {
+    gst_video_overlay_set_render_rectangle (overlay_element, x, y, width,
+        height);
+    gst_object_unref (overlay_element);
+  }
+}
+
+static void
+gst_play_sink_overlay_set_window_handle (GstVideoOverlay * overlay,
+    guintptr handle)
+{
+  GstPlaySink *playsink = GST_PLAY_SINK (overlay);
+  GstVideoOverlay *overlay_element;
+
+  GST_OBJECT_LOCK (playsink);
+  if (playsink->overlay_element)
+    overlay_element =
+        GST_VIDEO_OVERLAY (gst_object_ref (playsink->overlay_element));
+  else
+    overlay_element = NULL;
+  GST_OBJECT_UNLOCK (playsink);
+
+  playsink->overlay_handle_set = TRUE;
+  playsink->overlay_handle = handle;
+
+  if (overlay_element) {
+    gst_video_overlay_set_window_handle (overlay_element, handle);
+    gst_object_unref (overlay_element);
+  }
+}
+
+static void
+gst_play_sink_overlay_init (gpointer g_iface, gpointer g_iface_data)
+{
+  GstVideoOverlayInterface *iface = (GstVideoOverlayInterface *) g_iface;
+  iface->expose = gst_play_sink_overlay_expose;
+  iface->handle_events = gst_play_sink_overlay_handle_events;
+  iface->set_render_rectangle = gst_play_sink_overlay_set_render_rectangle;
+  iface->set_window_handle = gst_play_sink_overlay_set_window_handle;
+}
+
+static void
+gst_play_sink_navigation_send_event (GstNavigation * navigation,
+    GstStructure * structure)
+{
+  GstPlaySink *playsink = GST_PLAY_SINK (navigation);
+  GstBin *bin = NULL;
+
+  GST_PLAY_SINK_LOCK (playsink);
+  if (playsink->videochain && playsink->videochain->chain.bin)
+    bin = GST_BIN (gst_object_ref (playsink->videochain->chain.bin));
+  GST_PLAY_SINK_UNLOCK (playsink);
+
+  if (bin) {
+    GstElement *nav = gst_bin_get_by_interface (bin, GST_TYPE_NAVIGATION);
+
+    if (nav) {
+      gst_navigation_send_event (GST_NAVIGATION (nav), structure);
+      structure = NULL;
+      gst_object_unref (nav);
+    }
+
+    gst_object_unref (bin);
+  }
+
+  if (structure)
+    gst_structure_free (structure);
+}
+
+static void
+gst_play_sink_navigation_init (gpointer g_iface, gpointer g_iface_data)
+{
+  GstNavigationInterface *iface = (GstNavigationInterface *) g_iface;
+
+  iface->send_event = gst_play_sink_navigation_send_event;
+}
+
+static const GList *
+gst_play_sink_colorbalance_list_channels (GstColorBalance * balance)
+{
+  GstPlaySink *playsink = GST_PLAY_SINK (balance);
+
+  return playsink->colorbalance_channels;
+}
+
+static void
+gst_play_sink_colorbalance_set_value (GstColorBalance * balance,
+    GstColorBalanceChannel * proxy, gint value)
+{
+  GstPlaySink *playsink = GST_PLAY_SINK (balance);
+  GList *l;
+  gint i;
+  GstColorBalance *balance_element = NULL;
+
+  GST_OBJECT_LOCK (playsink);
+  if (playsink->colorbalance_element)
+    balance_element =
+        GST_COLOR_BALANCE (gst_object_ref (playsink->colorbalance_element));
+  GST_OBJECT_UNLOCK (playsink);
+
+  for (i = 0, l = playsink->colorbalance_channels; l; l = l->next, i++) {
+    GstColorBalanceChannel *proxy_tmp = l->data;
+    gdouble new_val;
+
+    if (proxy_tmp != proxy)
+      continue;
+
+    playsink->colorbalance_values[i] = value;
+
+    if (balance_element) {
+      GstColorBalanceChannel *channel = NULL;
+      const GList *channels, *k;
+
+      channels = gst_color_balance_list_channels (balance_element);
+      for (k = channels; k; k = k->next) {
+        GstColorBalanceChannel *tmp = l->data;
+
+        if (g_strrstr (tmp->label, proxy->label)) {
+          channel = tmp;
+          break;
+        }
+      }
+
+      g_assert (channel);
+
+      /* Convert to [0, 1] range */
+      new_val =
+          ((gdouble) value -
+          (gdouble) proxy->min_value) / ((gdouble) proxy->max_value -
+          (gdouble) proxy->min_value);
+      /* Convert to channel range */
+      new_val =
+          channel->min_value + new_val * ((gdouble) channel->max_value -
+          (gdouble) channel->min_value);
+
+      gst_color_balance_set_value (balance_element, channel,
+          (gint) (new_val + 0.5));
+
+      gst_object_unref (balance_element);
+    }
+
+    gst_color_balance_value_changed (balance, proxy, value);
+    break;
+  }
+}
+
+static gint
+gst_play_sink_colorbalance_get_value (GstColorBalance * balance,
+    GstColorBalanceChannel * proxy)
+{
+  GstPlaySink *playsink = GST_PLAY_SINK (balance);
+  GList *l;
+  gint i;
+
+  for (i = 0, l = playsink->colorbalance_channels; l; l = l->next, i++) {
+    GstColorBalanceChannel *proxy_tmp = l->data;
+
+    if (proxy_tmp != proxy)
+      continue;
+
+    return playsink->colorbalance_values[i];
+  }
+
+  g_return_val_if_reached (0);
+}
+
+static GstColorBalanceType
+gst_play_sink_colorbalance_get_balance_type (GstColorBalance * balance)
+{
+  GstPlaySink *playsink = GST_PLAY_SINK (balance);
+  GstColorBalance *balance_element = NULL;
+  GstColorBalanceType t = GST_COLOR_BALANCE_SOFTWARE;
+
+  GST_OBJECT_LOCK (playsink);
+  if (playsink->colorbalance_element)
+    balance_element =
+        GST_COLOR_BALANCE (gst_object_ref (playsink->colorbalance_element));
+  GST_OBJECT_UNLOCK (playsink);
+
+  if (balance_element) {
+    t = gst_color_balance_get_balance_type (balance_element);
+    gst_object_unref (balance_element);
+  }
+
+  return t;
+}
+
+static void
+gst_play_sink_colorbalance_init (gpointer g_iface, gpointer g_iface_data)
+{
+  GstColorBalanceInterface *iface = (GstColorBalanceInterface *) g_iface;
+
+  iface->list_channels = gst_play_sink_colorbalance_list_channels;
+  iface->set_value = gst_play_sink_colorbalance_set_value;
+  iface->get_value = gst_play_sink_colorbalance_get_value;
+  iface->get_balance_type = gst_play_sink_colorbalance_get_balance_type;
+}
 
 gboolean
 gst_play_sink_plugin_init (GstPlugin * plugin)
 {
   GST_DEBUG_CATEGORY_INIT (gst_play_sink_debug, "playsink", 0, "play bin");
-
   return gst_element_register (plugin, "playsink", GST_RANK_NONE,
       GST_TYPE_PLAY_SINK);
 }
index a0756bc..77504da 100644 (file)
@@ -64,7 +64,6 @@ gst_play_sink_audio_convert_add_conversion_elements (GstPlaySinkAudioConvert *
     el = gst_play_sink_convert_bin_add_conversion_element_factory (cbin,
         "audioresample", "resample");
     if (el) {
-
       if (prev) {
         if (!gst_element_link_pads_full (prev, "src", el, "sink",
                 GST_PAD_LINK_CHECK_TEMPLATE_CAPS))
index 72a9aff..38c8878 100644 (file)
@@ -34,6 +34,13 @@ GST_DEBUG_CATEGORY_STATIC (gst_play_sink_video_convert_debug);
 G_DEFINE_TYPE (GstPlaySinkVideoConvert, gst_play_sink_video_convert,
     GST_TYPE_PLAY_SINK_CONVERT_BIN);
 
+enum
+{
+  PROP_0,
+  PROP_USE_CONVERTERS,
+  PROP_USE_BALANCE,
+};
+
 static gboolean
 gst_play_sink_video_convert_add_conversion_elements (GstPlaySinkVideoConvert *
     self)
@@ -41,22 +48,51 @@ gst_play_sink_video_convert_add_conversion_elements (GstPlaySinkVideoConvert *
   GstPlaySinkConvertBin *cbin = GST_PLAY_SINK_CONVERT_BIN (self);
   GstElement *el, *prev = NULL;
 
-  el = gst_play_sink_convert_bin_add_conversion_element_factory (cbin,
-      COLORSPACE, "conv");
-  if (el)
-    prev = el;
+  g_assert (cbin->conversion_elements == NULL);
+
+  GST_DEBUG_OBJECT (self,
+      "Building video conversion with use-converters %d, use-balance %d",
+      self->use_converters, self->use_balance);
+
+  if (self->use_converters) {
+    el = gst_play_sink_convert_bin_add_conversion_element_factory (cbin,
+        COLORSPACE, "conv");
+    if (el)
+      prev = el;
+
+    el = gst_play_sink_convert_bin_add_conversion_element_factory (cbin,
+        "videoscale", "scale");
+    if (el) {
+      /* Add black borders if necessary to keep the DAR */
+      g_object_set (el, "add-borders", TRUE, NULL);
+      if (prev) {
+        if (!gst_element_link_pads_full (prev, "src", el, "sink",
+                GST_PAD_LINK_CHECK_TEMPLATE_CAPS))
+          goto link_failed;
+      }
+      prev = el;
+    }
+  }
 
-  el = gst_play_sink_convert_bin_add_conversion_element_factory (cbin,
-      "videoscale", "scale");
-  if (el) {
-    /* Add black borders if necessary to keep the DAR */
-    g_object_set (el, "add-borders", TRUE, NULL);
+  if (self->use_balance && self->balance) {
+    el = self->balance;
+    gst_play_sink_convert_bin_add_conversion_element (cbin, el);
     if (prev) {
       if (!gst_element_link_pads_full (prev, "src", el, "sink",
               GST_PAD_LINK_CHECK_TEMPLATE_CAPS))
         goto link_failed;
     }
     prev = el;
+
+    el = gst_play_sink_convert_bin_add_conversion_element_factory (cbin,
+        COLORSPACE, "conv2");
+    if (prev) {
+      if (!gst_element_link_pads_full (prev, "src", el, "sink",
+              GST_PAD_LINK_CHECK_TEMPLATE_CAPS))
+        goto link_failed;
+    }
+    if (el)
+      prev = el;
   }
 
   return TRUE;
@@ -66,15 +102,100 @@ link_failed:
 }
 
 static void
+gst_play_sink_video_convert_finalize (GObject * object)
+{
+  GstPlaySinkVideoConvert *self = GST_PLAY_SINK_VIDEO_CONVERT_CAST (object);
+
+  if (self->balance)
+    gst_object_unref (self->balance);
+
+  G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
+gst_play_sink_video_convert_set_property (GObject * object, guint prop_id,
+    const GValue * value, GParamSpec * pspec)
+{
+  GstPlaySinkVideoConvert *self = GST_PLAY_SINK_VIDEO_CONVERT_CAST (object);
+  gboolean v, changed = FALSE;
+
+  GST_PLAY_SINK_CONVERT_BIN_LOCK (self);
+  switch (prop_id) {
+    case PROP_USE_CONVERTERS:
+      v = g_value_get_boolean (value);
+      if (v != self->use_converters) {
+        self->use_converters = v;
+        changed = TRUE;
+      }
+      break;
+    case PROP_USE_BALANCE:
+      v = g_value_get_boolean (value);
+      if (v != self->use_balance) {
+        self->use_balance = v;
+        changed = TRUE;
+      }
+      break;
+    default:
+      break;
+  }
+
+  if (changed) {
+    GstPlaySinkConvertBin *cbin = GST_PLAY_SINK_CONVERT_BIN (self);
+    GST_DEBUG_OBJECT (self, "Rebuilding converter bin");
+    gst_play_sink_convert_bin_remove_elements (cbin);
+    gst_play_sink_video_convert_add_conversion_elements (self);
+    gst_play_sink_convert_bin_add_identity (cbin);
+    gst_play_sink_convert_bin_cache_converter_caps (cbin);
+  }
+  GST_PLAY_SINK_CONVERT_BIN_UNLOCK (self);
+}
+
+static void
+gst_play_sink_video_convert_get_property (GObject * object, guint prop_id,
+    GValue * value, GParamSpec * pspec)
+{
+  GstPlaySinkVideoConvert *self = GST_PLAY_SINK_VIDEO_CONVERT_CAST (object);
+
+  GST_PLAY_SINK_CONVERT_BIN_LOCK (self);
+  switch (prop_id) {
+    case PROP_USE_CONVERTERS:
+      g_value_set_boolean (value, self->use_converters);
+      break;
+    case PROP_USE_BALANCE:
+      g_value_set_boolean (value, self->use_balance);
+      break;
+    default:
+      break;
+  }
+  GST_PLAY_SINK_CONVERT_BIN_UNLOCK (self);
+}
+
+static void
 gst_play_sink_video_convert_class_init (GstPlaySinkVideoConvertClass * klass)
 {
+  GObjectClass *gobject_class;
   GstElementClass *gstelement_class;
 
   GST_DEBUG_CATEGORY_INIT (gst_play_sink_video_convert_debug,
       "playsinkvideoconvert", 0, "play bin");
 
+  gobject_class = (GObjectClass *) klass;
   gstelement_class = (GstElementClass *) klass;
 
+  gobject_class->finalize = gst_play_sink_video_convert_finalize;
+  gobject_class->set_property = gst_play_sink_video_convert_set_property;
+  gobject_class->get_property = gst_play_sink_video_convert_get_property;
+
+  g_object_class_install_property (gobject_class, PROP_USE_CONVERTERS,
+      g_param_spec_boolean ("use-converters", "Use converters",
+          "Whether to use conversion elements", FALSE,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+  g_object_class_install_property (gobject_class, PROP_USE_BALANCE,
+      g_param_spec_boolean ("use-balance", "Use balance",
+          "Whether to use a videobalance element", FALSE,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
   gst_element_class_set_details_simple (gstelement_class,
       "Player Sink Video Converter", "Video/Bin/Converter",
       "Convenience bin for video conversion",
@@ -87,6 +208,14 @@ gst_play_sink_video_convert_init (GstPlaySinkVideoConvert * self)
   GstPlaySinkConvertBin *cbin = GST_PLAY_SINK_CONVERT_BIN (self);
   cbin->audio = FALSE;
 
+  /* FIXME: Only create this on demand but for now we need
+   * it to always exist because of playsink's color balance
+   * proxying logic.
+   */
+  self->balance = gst_element_factory_make ("videobalance", "videobalance");
+  if (self->balance)
+    gst_object_ref_sink (self->balance);
+
   gst_play_sink_video_convert_add_conversion_elements (self);
   gst_play_sink_convert_bin_cache_converter_caps (cbin);
 }
index df56d97..5c50462 100644 (file)
@@ -43,6 +43,10 @@ struct _GstPlaySinkVideoConvert
 {
   GstPlaySinkConvertBin parent;
 
+  /* < pseudo public > */
+  GstElement *balance;
+  gboolean use_converters;
+  gboolean use_balance;
 };
 
 struct _GstPlaySinkVideoConvertClass
index 3ee139e..01015f1 100644 (file)
@@ -395,10 +395,121 @@ gst_video_scale_get_property (GObject * object, guint prop_id, GValue * value,
   }
 }
 
+#define NEAREST  (1 << GST_VIDEO_SCALE_NEAREST)
+#define BILINEAR (1 << GST_VIDEO_SCALE_BILINEAR)
+#define FOURTAP  (1 << GST_VIDEO_SCALE_4TAP)
+#define LANCZOS  (1 << GST_VIDEO_SCALE_LANCZOS)
+
+/* or we could just do lookups via table[format] if we could be bothered..  */
+static const struct
+{
+  GstVideoFormat format;
+  guint8 methods;
+} formats_methods_table[] = {
+  {
+  GST_VIDEO_FORMAT_RGBx, NEAREST | BILINEAR | FOURTAP | LANCZOS}, {
+  GST_VIDEO_FORMAT_xRGB, NEAREST | BILINEAR | FOURTAP | LANCZOS}, {
+  GST_VIDEO_FORMAT_BGRx, NEAREST | BILINEAR | FOURTAP | LANCZOS}, {
+  GST_VIDEO_FORMAT_xBGR, NEAREST | BILINEAR | FOURTAP | LANCZOS}, {
+  GST_VIDEO_FORMAT_RGBA, NEAREST | BILINEAR | FOURTAP | LANCZOS}, {
+  GST_VIDEO_FORMAT_ARGB, NEAREST | BILINEAR | FOURTAP | LANCZOS}, {
+  GST_VIDEO_FORMAT_BGRA, NEAREST | BILINEAR | FOURTAP | LANCZOS}, {
+  GST_VIDEO_FORMAT_ABGR, NEAREST | BILINEAR | FOURTAP | LANCZOS}, {
+  GST_VIDEO_FORMAT_AYUV, NEAREST | BILINEAR | FOURTAP | LANCZOS}, {
+  GST_VIDEO_FORMAT_ARGB64, NEAREST | BILINEAR | FOURTAP | LANCZOS}, {
+  GST_VIDEO_FORMAT_AYUV64, NEAREST | BILINEAR | FOURTAP | LANCZOS}, {
+  GST_VIDEO_FORMAT_RGB, NEAREST | BILINEAR | FOURTAP}, {
+  GST_VIDEO_FORMAT_BGR, NEAREST | BILINEAR | FOURTAP}, {
+  GST_VIDEO_FORMAT_v308, NEAREST | BILINEAR | FOURTAP}, {
+  GST_VIDEO_FORMAT_YUY2, NEAREST | BILINEAR | FOURTAP}, {
+  GST_VIDEO_FORMAT_YVYU, NEAREST | BILINEAR | FOURTAP}, {
+  GST_VIDEO_FORMAT_UYVY, NEAREST | BILINEAR | FOURTAP}, {
+  GST_VIDEO_FORMAT_Y800, NEAREST | BILINEAR | FOURTAP}, {
+  GST_VIDEO_FORMAT_GRAY8, NEAREST | BILINEAR | FOURTAP}, {
+  GST_VIDEO_FORMAT_GRAY16_LE, NEAREST | BILINEAR | FOURTAP}, {
+  GST_VIDEO_FORMAT_GRAY16_BE, NEAREST | BILINEAR | FOURTAP}, {
+  GST_VIDEO_FORMAT_Y16, NEAREST | BILINEAR | FOURTAP}, {
+  GST_VIDEO_FORMAT_I420, NEAREST | BILINEAR | FOURTAP | LANCZOS}, {
+  GST_VIDEO_FORMAT_YV12, NEAREST | BILINEAR | FOURTAP | LANCZOS}, {
+  GST_VIDEO_FORMAT_Y444, NEAREST | BILINEAR | FOURTAP | LANCZOS}, {
+  GST_VIDEO_FORMAT_Y42B, NEAREST | BILINEAR | FOURTAP | LANCZOS}, {
+  GST_VIDEO_FORMAT_Y41B, NEAREST | BILINEAR | FOURTAP | LANCZOS}, {
+  GST_VIDEO_FORMAT_NV12, NEAREST | BILINEAR}, {
+  GST_VIDEO_FORMAT_RGB16, NEAREST | BILINEAR | FOURTAP}, {
+  GST_VIDEO_FORMAT_RGB15, NEAREST | BILINEAR | FOURTAP}
+};
+
+static gboolean
+gst_video_scale_format_supported_for_method (GstVideoFormat format,
+    GstVideoScaleMethod method)
+{
+  int i;
+
+  for (i = 0; i < G_N_ELEMENTS (formats_methods_table); ++i) {
+    if (formats_methods_table[i].format == format)
+      return ((formats_methods_table[i].methods & (1 << method)) != 0);
+  }
+  return FALSE;
+}
+
+static gboolean
+gst_video_scale_transform_supported (GstVideoScale * videoscale,
+    GstVideoScaleMethod method, GstStructure * structure)
+{
+  const GValue *val;
+  GstVideoInfo info;
+  gboolean supported = TRUE;
+  GstStructure *s;
+  GstCaps *c;
+
+  /* we support these methods for all formats */
+  if (method == GST_VIDEO_SCALE_NEAREST || method == GST_VIDEO_SCALE_BILINEAR)
+    return TRUE;
+
+  /* we need fixed caps if we want to use gst_video_parse_caps() */
+  s = gst_structure_new (gst_structure_get_name (structure),
+      "width", G_TYPE_INT, 1, "height", G_TYPE_INT, 1, NULL);
+
+  if ((val = gst_structure_get_value (structure, "format"))) {
+    gst_structure_set_value (s, "format", val);
+  } else {
+    if ((val = gst_structure_get_value (structure, "endianness")))
+      gst_structure_set_value (s, "endianness", val);
+    if ((val = gst_structure_get_value (structure, "red_mask")))
+      gst_structure_set_value (s, "red_mask", val);
+    if ((val = gst_structure_get_value (structure, "blue_mask")))
+      gst_structure_set_value (s, "blue_mask", val);
+    if ((val = gst_structure_get_value (structure, "green_mask")))
+      gst_structure_set_value (s, "green_mask", val);
+    if ((val = gst_structure_get_value (structure, "alpha_mask")))
+      gst_structure_set_value (s, "alpha_mask", val);
+    if ((val = gst_structure_get_value (structure, "depth")))
+      gst_structure_set_value (s, "depth", val);
+    if ((val = gst_structure_get_value (structure, "bpp")))
+      gst_structure_set_value (s, "bpp", val);
+  }
+  c = gst_caps_new_full (s, NULL);
+
+  gst_video_info_init (&info);
+  if (!gst_video_info_from_caps (&info, c)) {
+    GST_ERROR_OBJECT (videoscale, "couldn't parse %" GST_PTR_FORMAT, c);
+  } else if (!gst_video_scale_format_supported_for_method (info.finfo->format,
+          method)) {
+    supported = FALSE;
+  }
+  GST_LOG_OBJECT (videoscale, "method %d %ssupported for format %d",
+      method, (supported) ? "" : "not ", info.finfo->format);
+  gst_caps_unref (c);
+
+  return supported;
+}
+
 static GstCaps *
 gst_video_scale_transform_caps (GstBaseTransform * trans,
     GstPadDirection direction, GstCaps * caps, GstCaps * filter)
 {
+  GstVideoScale *videoscale = GST_VIDEO_SCALE (trans);
+  GstVideoScaleMethod method;
   GstCaps *ret;
   GstStructure *structure;
   gint i, n;
@@ -407,6 +518,10 @@ gst_video_scale_transform_caps (GstBaseTransform * trans,
       "Transforming caps %" GST_PTR_FORMAT " in direction %s", caps,
       (direction == GST_PAD_SINK) ? "sink" : "src");
 
+  GST_OBJECT_LOCK (videoscale);
+  method = videoscale->method;
+  GST_OBJECT_UNLOCK (videoscale);
+
   ret = gst_caps_new_empty ();
   n = gst_caps_get_size (caps);
   for (i = 0; i < n; i++) {
@@ -417,6 +532,9 @@ gst_video_scale_transform_caps (GstBaseTransform * trans,
     if (i > 0 && gst_caps_is_subset_structure (ret, structure))
       continue;
 
+    if (!gst_video_scale_transform_supported (videoscale, method, structure))
+      goto format_not_supported;
+
     structure = gst_structure_copy (structure);
     gst_structure_set (structure,
         "width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
@@ -439,9 +557,19 @@ gst_video_scale_transform_caps (GstBaseTransform * trans,
     ret = intersection;
   }
 
+done:
+
   GST_DEBUG_OBJECT (trans, "returning caps: %" GST_PTR_FORMAT, ret);
 
   return ret;
+
+format_not_supported:
+  {
+    gst_structure_free (structure);
+    gst_caps_unref (ret);
+    ret = gst_caps_new_empty ();
+    goto done;
+  }
 }
 
 static gboolean
index 205fa0d..b0e62e3 100644 (file)
 
 /* for developers: there are two useful tools : xvinfo and xvattr */
 
+/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray
+ * with newer GLib versions (>= 2.31.0) */
+#define GLIB_DISABLE_DEPRECATION_WARNINGS
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
index e03a308..0a721d6 100644 (file)
@@ -101,8 +101,8 @@ GST_START_TEST (test_event)
   GstBus *bus;
   GstEvent *seek_event;
   gboolean res;
-  GstPad *srcpad;
-  GstStreamConsistency *consist;
+  GstPad *srcpad, *sinkpad;
+  GstStreamConsistency *chk_1, *chk_2, *chk_3;
 
   GST_INFO ("preparing test");
 
@@ -130,7 +130,22 @@ GST_START_TEST (test_event)
   fail_unless (res == TRUE, NULL);
 
   srcpad = gst_element_get_static_pad (adder, "src");
-  consist = gst_consistency_checker_new (srcpad);
+  chk_3 = gst_consistency_checker_new (srcpad);
+  gst_object_unref (srcpad);
+
+  /* create consistency checkers for the pads */
+  srcpad = gst_element_get_static_pad (src1, "src");
+  chk_1 = gst_consistency_checker_new (srcpad);
+  sinkpad = gst_pad_get_peer (srcpad);
+  gst_consistency_checker_add_pad (chk_3, sinkpad);
+  gst_object_unref (sinkpad);
+  gst_object_unref (srcpad);
+
+  srcpad = gst_element_get_static_pad (src2, "src");
+  chk_2 = gst_consistency_checker_new (srcpad);
+  sinkpad = gst_pad_get_peer (srcpad);
+  gst_consistency_checker_add_pad (chk_3, sinkpad);
+  gst_object_unref (sinkpad);
   gst_object_unref (srcpad);
 
   seek_event = gst_event_new_seek (1.0, GST_FORMAT_TIME,
@@ -174,7 +189,9 @@ GST_START_TEST (test_event)
 
   /* cleanup */
   g_main_loop_unref (main_loop);
-  gst_consistency_checker_free (consist);
+  gst_consistency_checker_free (chk_1);
+  gst_consistency_checker_free (chk_2);
+  gst_consistency_checker_free (chk_3);
   gst_object_unref (G_OBJECT (bus));
   gst_object_unref (G_OBJECT (bin));
 }
index 1f5181f..d42b40b 100644 (file)
  * Boston, MA 02111-1307, USA.
  */
 
+/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray
+ * with newer GLib versions (>= 2.31.0) */
+#define GLIB_DISABLE_DEPRECATION_WARNINGS
+
 #include <unistd.h>
 
 #include <gst/check/gstcheck.h>
index 6ad976b..924dd5a 100644 (file)
  * Boston, MA 02111-1307, USA.
  */
 
+/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray
+ * with newer GLib versions (>= 2.31.0) */
+#define GLIB_DISABLE_DEPRECATION_WARNINGS
+
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
index 0cf0812..e428dc0 100644 (file)
 #define LINK_CHECK_FLAGS GST_PAD_LINK_CHECK_NOTHING
 
 static GstCaps **
-videoscale_get_allowed_caps (void)
+videoscale_get_allowed_caps_for_method (int method)
 {
-  GstElement *scale = gst_element_factory_make ("videoscale", "scale");
-  GstPadTemplate *templ;
-  GstCaps *tmp, *caps, **ret;
+  GstElement *scale;
+  GstCaps *caps, **ret;
+  GstPad *pad;
   GstStructure *s;
   gint i, n;
 
-  templ =
-      gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (scale),
-      "sink");
-  fail_unless (templ != NULL);
-
-  tmp = gst_pad_template_get_caps (templ);
-  caps = gst_caps_normalize (tmp);
-  gst_caps_unref (tmp);
+  scale = gst_element_factory_make ("videoscale", "vscale");
+  g_object_set (scale, "method", method, NULL);
+  pad = gst_element_get_static_pad (scale, "sink");
+  caps = gst_pad_query_caps (pad, NULL);
+  gst_object_unref (pad);
+  gst_object_unref (scale);
 
   n = gst_caps_get_size (caps);
   ret = g_new0 (GstCaps *, n + 1);
@@ -54,10 +52,10 @@ videoscale_get_allowed_caps (void)
     s = gst_caps_get_structure (caps, i);
     ret[i] = gst_caps_new_empty ();
     gst_caps_append_structure (ret[i], gst_structure_copy (s));
+    GST_LOG ("method %d supports: %" GST_PTR_FORMAT, method, s);
   }
 
   gst_caps_unref (caps);
-  gst_object_unref (scale);
 
   return ret;
 }
@@ -212,15 +210,15 @@ on_src_handoff_passthrough (GstElement * element, GstBuffer * buffer,
   *list = g_list_prepend (*list, gst_buffer_ref (buffer));
 }
 
-GST_START_TEST (test_passthrough)
+static void
+test_passthrough (int method)
 {
   GList *l1, *l2, *src_buffers = NULL, *sink_buffers = NULL;
   GstCaps **allowed_caps = NULL, **p;
-  gint method;
   static const gint src_width = 640, src_height = 480;
   static const gint dest_width = 640, dest_height = 480;
 
-  p = allowed_caps = videoscale_get_allowed_caps ();
+  p = allowed_caps = videoscale_get_allowed_caps_for_method (method);
 
   while (*p) {
     GstCaps *caps = *p;
@@ -263,13 +261,38 @@ GST_START_TEST (test_passthrough)
       g_list_free (sink_buffers);
       sink_buffers = NULL;
     }
-
     gst_caps_unref (caps);
     p++;
   }
   g_free (allowed_caps);
 }
 
+GST_START_TEST (test_passthrough_method_0)
+{
+  test_passthrough (0);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_passthrough_method_1)
+{
+  test_passthrough (1);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_passthrough_method_2)
+{
+  test_passthrough (2);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_passthrough_method_3)
+{
+  test_passthrough (3);
+}
+
 GST_END_TEST;
 
 #define CREATE_TEST(name,method,src_width,src_height,dest_width,dest_height) \
@@ -277,7 +300,7 @@ GST_START_TEST (name) \
 { \
   GstCaps **allowed_caps = NULL, **p; \
   \
-  p = allowed_caps = videoscale_get_allowed_caps (); \
+  p = allowed_caps = videoscale_get_allowed_caps_for_method (method); \
   \
   while (*p) { \
     GstCaps *caps = *p; \
@@ -299,39 +322,51 @@ GST_END_TEST;
 CREATE_TEST (test_downscale_640x480_320x240_method_0, 0, 640, 480, 320, 240);
 CREATE_TEST (test_downscale_640x480_320x240_method_1, 1, 640, 480, 320, 240);
 CREATE_TEST (test_downscale_640x480_320x240_method_2, 2, 640, 480, 320, 240);
+CREATE_TEST (test_downscale_640x480_320x240_method_3, 3, 640, 480, 320, 240);
 CREATE_TEST (test_upscale_320x240_640x480_method_0, 0, 320, 240, 640, 480);
 CREATE_TEST (test_upscale_320x240_640x480_method_1, 1, 320, 240, 640, 480);
 CREATE_TEST (test_upscale_320x240_640x480_method_2, 2, 320, 240, 640, 480);
+CREATE_TEST (test_upscale_320x240_640x480_method_3, 3, 320, 240, 640, 480);
 CREATE_TEST (test_downscale_640x480_1x1_method_0, 0, 640, 480, 1, 1);
 CREATE_TEST (test_downscale_640x480_1x1_method_1, 1, 640, 480, 1, 1);
 CREATE_TEST (test_downscale_640x480_1x1_method_2, 2, 640, 480, 1, 1);
+CREATE_TEST (test_downscale_640x480_1x1_method_3, 3, 640, 480, 1, 1);
 CREATE_TEST (test_upscale_1x1_640x480_method_0, 0, 1, 1, 640, 480);
 CREATE_TEST (test_upscale_1x1_640x480_method_1, 1, 1, 1, 640, 480);
 CREATE_TEST (test_upscale_1x1_640x480_method_2, 2, 1, 1, 640, 480);
+CREATE_TEST (test_upscale_1x1_640x480_method_3, 3, 1, 1, 640, 480);
 CREATE_TEST (test_downscale_641x481_111x30_method_0, 0, 641, 481, 111, 30);
 CREATE_TEST (test_downscale_641x481_111x30_method_1, 1, 641, 481, 111, 30);
 CREATE_TEST (test_downscale_641x481_111x30_method_2, 2, 641, 481, 111, 30);
+CREATE_TEST (test_downscale_641x481_111x30_method_3, 3, 641, 481, 111, 30);
 CREATE_TEST (test_upscale_111x30_641x481_method_0, 0, 111, 30, 641, 481);
 CREATE_TEST (test_upscale_111x30_641x481_method_1, 1, 111, 30, 641, 481);
 CREATE_TEST (test_upscale_111x30_641x481_method_2, 2, 111, 30, 641, 481);
+CREATE_TEST (test_upscale_111x30_641x481_method_3, 2, 111, 30, 641, 481);
 CREATE_TEST (test_downscale_641x481_30x111_method_0, 0, 641, 481, 30, 111);
 CREATE_TEST (test_downscale_641x481_30x111_method_1, 1, 641, 481, 30, 111);
 CREATE_TEST (test_downscale_641x481_30x111_method_2, 2, 641, 481, 30, 111);
+CREATE_TEST (test_downscale_641x481_30x111_method_3, 3, 641, 481, 30, 111);
 CREATE_TEST (test_upscale_30x111_641x481_method_0, 0, 30, 111, 641, 481);
 CREATE_TEST (test_upscale_30x111_641x481_method_1, 1, 30, 111, 641, 481);
 CREATE_TEST (test_upscale_30x111_641x481_method_2, 2, 30, 111, 641, 481);
+CREATE_TEST (test_upscale_30x111_641x481_method_3, 3, 30, 111, 641, 481);
 CREATE_TEST (test_downscale_640x480_320x1_method_0, 0, 640, 480, 320, 1);
 CREATE_TEST (test_downscale_640x480_320x1_method_1, 1, 640, 480, 320, 1);
 CREATE_TEST (test_downscale_640x480_320x1_method_2, 2, 640, 480, 320, 1);
+CREATE_TEST (test_downscale_640x480_320x1_method_3, 3, 640, 480, 320, 1);
 CREATE_TEST (test_upscale_320x1_640x480_method_0, 0, 320, 1, 640, 480);
 CREATE_TEST (test_upscale_320x1_640x480_method_1, 1, 320, 1, 640, 480);
 CREATE_TEST (test_upscale_320x1_640x480_method_2, 2, 320, 1, 640, 480);
+CREATE_TEST (test_upscale_320x1_640x480_method_3, 3, 320, 1, 640, 480);
 CREATE_TEST (test_downscale_640x480_1x240_method_0, 0, 640, 480, 1, 240);
 CREATE_TEST (test_downscale_640x480_1x240_method_1, 1, 640, 480, 1, 240);
 CREATE_TEST (test_downscale_640x480_1x240_method_2, 2, 640, 480, 1, 240);
+CREATE_TEST (test_downscale_640x480_1x240_method_3, 3, 640, 480, 1, 240);
 CREATE_TEST (test_upscale_1x240_640x480_method_0, 0, 1, 240, 640, 480);
 CREATE_TEST (test_upscale_1x240_640x480_method_1, 1, 1, 240, 640, 480);
 CREATE_TEST (test_upscale_1x240_640x480_method_2, 2, 1, 240, 640, 480);
+CREATE_TEST (test_upscale_1x240_640x480_method_3, 3, 1, 240, 640, 480);
 
 typedef struct
 {
@@ -823,6 +858,13 @@ GST_START_TEST (test_basetransform_negotiation)
 
 GST_END_TEST;
 
+#ifndef tcase_skip_broken_test
+#define tcase_skip_broken_test(chain,test_func) \
+  if (0) { tcase_add_test(chain,test_func); } else { \
+    GST_ERROR ("FIXME: skipping test %s because it's broken.", G_STRINGIFY (test_func)); \
+  }
+#endif
+
 static Suite *
 videoscale_suite (void)
 {
@@ -831,43 +873,58 @@ videoscale_suite (void)
 
   suite_add_tcase (s, tc_chain);
   tcase_set_timeout (tc_chain, 180);
-  tcase_add_test (tc_chain, test_passthrough);
+  tcase_add_test (tc_chain, test_passthrough_method_0);
+  tcase_add_test (tc_chain, test_passthrough_method_1);
+  tcase_add_test (tc_chain, test_passthrough_method_2);
+  tcase_add_test (tc_chain, test_passthrough_method_3);
   tcase_add_test (tc_chain, test_downscale_640x480_320x240_method_0);
   tcase_add_test (tc_chain, test_downscale_640x480_320x240_method_1);
   tcase_add_test (tc_chain, test_downscale_640x480_320x240_method_2);
+  tcase_add_test (tc_chain, test_downscale_640x480_320x240_method_3);
   tcase_add_test (tc_chain, test_upscale_320x240_640x480_method_0);
   tcase_add_test (tc_chain, test_upscale_320x240_640x480_method_1);
   tcase_add_test (tc_chain, test_upscale_320x240_640x480_method_2);
+  tcase_add_test (tc_chain, test_upscale_320x240_640x480_method_3);
   tcase_add_test (tc_chain, test_downscale_640x480_1x1_method_0);
   tcase_add_test (tc_chain, test_downscale_640x480_1x1_method_1);
   tcase_add_test (tc_chain, test_downscale_640x480_1x1_method_2);
+  tcase_skip_broken_test (tc_chain, test_downscale_640x480_1x1_method_3);
   tcase_add_test (tc_chain, test_upscale_1x1_640x480_method_0);
   tcase_add_test (tc_chain, test_upscale_1x1_640x480_method_1);
   tcase_add_test (tc_chain, test_upscale_1x1_640x480_method_2);
+  tcase_add_test (tc_chain, test_upscale_1x1_640x480_method_3);
   tcase_add_test (tc_chain, test_downscale_641x481_111x30_method_0);
   tcase_add_test (tc_chain, test_downscale_641x481_111x30_method_1);
   tcase_add_test (tc_chain, test_downscale_641x481_111x30_method_2);
+  tcase_add_test (tc_chain, test_downscale_641x481_111x30_method_3);
   tcase_add_test (tc_chain, test_upscale_111x30_641x481_method_0);
   tcase_add_test (tc_chain, test_upscale_111x30_641x481_method_1);
   tcase_add_test (tc_chain, test_upscale_111x30_641x481_method_2);
+  tcase_add_test (tc_chain, test_upscale_111x30_641x481_method_3);
   tcase_add_test (tc_chain, test_downscale_641x481_30x111_method_0);
   tcase_add_test (tc_chain, test_downscale_641x481_30x111_method_1);
   tcase_add_test (tc_chain, test_downscale_641x481_30x111_method_2);
+  tcase_add_test (tc_chain, test_downscale_641x481_30x111_method_3);
   tcase_add_test (tc_chain, test_upscale_30x111_641x481_method_0);
   tcase_add_test (tc_chain, test_upscale_30x111_641x481_method_1);
   tcase_add_test (tc_chain, test_upscale_30x111_641x481_method_2);
+  tcase_add_test (tc_chain, test_upscale_30x111_641x481_method_3);
   tcase_add_test (tc_chain, test_downscale_640x480_320x1_method_0);
   tcase_add_test (tc_chain, test_downscale_640x480_320x1_method_1);
   tcase_add_test (tc_chain, test_downscale_640x480_320x1_method_2);
+  tcase_skip_broken_test (tc_chain, test_downscale_640x480_320x1_method_3);
   tcase_add_test (tc_chain, test_upscale_320x1_640x480_method_0);
   tcase_add_test (tc_chain, test_upscale_320x1_640x480_method_1);
   tcase_add_test (tc_chain, test_upscale_320x1_640x480_method_2);
+  tcase_skip_broken_test (tc_chain, test_upscale_320x1_640x480_method_3);
   tcase_add_test (tc_chain, test_downscale_640x480_1x240_method_0);
   tcase_add_test (tc_chain, test_downscale_640x480_1x240_method_1);
   tcase_add_test (tc_chain, test_downscale_640x480_1x240_method_2);
+  tcase_add_test (tc_chain, test_downscale_640x480_1x240_method_3);
   tcase_add_test (tc_chain, test_upscale_1x240_640x480_method_0);
   tcase_add_test (tc_chain, test_upscale_1x240_640x480_method_1);
   tcase_add_test (tc_chain, test_upscale_1x240_640x480_method_2);
+  tcase_add_test (tc_chain, test_upscale_1x240_640x480_method_3);
   tcase_add_test (tc_chain, test_negotiation);
 #if 0
   tcase_add_test (tc_chain, test_reverse_negotiation);
index 235af66..6e4592b 100644 (file)
@@ -4,6 +4,8 @@
  *
  * Copyright (C) 2005 Wim Taymans <wim@fluendo.com>
  *               2006 Stefan Kost <ensonic@users.sf.net>
+ *               2012 Collabora Ltd.
+ *                 Author: Sebastian Dröge <sebastian.droege@collabora.co.uk>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -27,6 +29,7 @@
 /* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex
  * with newer GTK versions (>= 3.3.0) */
 #define GDK_DISABLE_DEPRECATION_WARNINGS
+#define GLIB_DISABLE_DEPRECATION_WARNINGS
 
 #include <stdlib.h>
 #include <math.h>
 #endif
 
 #include <gst/video/videooverlay.h>
+#include <gst/video/colorbalance.h>
 #include <gst/interfaces/navigation.h>
 
 GST_DEBUG_CATEGORY_STATIC (seek_debug);
 #define GST_CAT_DEFAULT (seek_debug)
 
-/* configuration */
-
-#define SOURCE "filesrc"
+/* Copied from gst-plugins-base/gst/playback/gstplay-enum.h */
+typedef enum
+{
+  GST_PLAY_FLAG_VIDEO = (1 << 0),
+  GST_PLAY_FLAG_AUDIO = (1 << 1),
+  GST_PLAY_FLAG_TEXT = (1 << 2),
+  GST_PLAY_FLAG_VIS = (1 << 3),
+  GST_PLAY_FLAG_SOFT_VOLUME = (1 << 4),
+  GST_PLAY_FLAG_NATIVE_AUDIO = (1 << 5),
+  GST_PLAY_FLAG_NATIVE_VIDEO = (1 << 6),
+  GST_PLAY_FLAG_DOWNLOAD = (1 << 7),
+  GST_PLAY_FLAG_BUFFERING = (1 << 8),
+  GST_PLAY_FLAG_DEINTERLACE = (1 << 9),
+  GST_PLAY_FLAG_SOFT_COLORBALANCE = (1 << 10)
+} GstPlayFlags;
 
-static gchar *opt_audiosink_str;        /* NULL */
-static gchar *opt_videosink_str;        /* NULL */
+/* configuration */
 
 #define FILL_INTERVAL 100
 //#define UPDATE_INTERVAL 500
@@ -75,61 +90,6 @@ static gchar *opt_videosink_str;        /* NULL */
 
 #define N_GRAD 1000.0
 
-static GList *seekable_elements = NULL;
-
-static gboolean accurate_seek = FALSE;
-static gboolean keyframe_seek = FALSE;
-static gboolean loop_seek = FALSE;
-static gboolean flush_seek = TRUE;
-static gboolean scrub = TRUE;
-static gboolean play_scrub = FALSE;
-static gboolean skip_seek = FALSE;
-static gdouble rate = 1.0;
-
-static GstElement *pipeline;
-static gint pipeline_type;
-static const gchar *pipeline_spec;
-static gint64 position = -1;
-static gint64 duration = -1;
-static GtkAdjustment *adjustment;
-static GtkWidget *hscale, *statusbar;
-static guint status_id = 0;
-static gboolean stats = FALSE;
-static gboolean verbose = FALSE;
-
-static gboolean is_live = FALSE;
-static gboolean buffering = FALSE;
-static GstBufferingMode mode;
-static gint64 buffering_left;
-static GstState state = GST_STATE_NULL;
-static guint update_id = 0;
-static guint seek_timeout_id = 0;
-static gulong changed_id;
-static guint fill_id = 0;
-
-static gint n_video = 0, n_audio = 0, n_text = 0;
-static gboolean need_streams = TRUE;
-static GtkWidget *video_combo, *audio_combo, *text_combo, *vis_combo;
-static GtkWidget *vis_checkbox, *video_checkbox, *audio_checkbox;
-static GtkWidget *text_checkbox, *mute_checkbox, *volume_spinbutton;
-static GtkWidget *skip_checkbox, *video_window, *download_checkbox;
-static GtkWidget *buffer_checkbox, *rate_spinbutton;
-
-static GMutex state_mutex;
-
-static GtkWidget *format_combo, *step_amount_spinbutton, *step_rate_spinbutton;
-static GtkWidget *shuttle_checkbox, *step_button;
-static GtkWidget *shuttle_hscale;
-static GtkAdjustment *shuttle_adjustment;
-
-static struct
-{
-  GstNavigationCommand cmd;
-  GtkWidget *button;
-} navigation_buttons[14];
-
-static GList *paths = NULL, *l = NULL;
-
 /* we keep an array of the visualisation entries so that we can easily switch
  * with the combo box index. */
 typedef struct
@@ -137,23 +97,118 @@ typedef struct
   GstElementFactory *factory;
 } VisEntry;
 
-static GArray *vis_entries;
+typedef struct
+{
+  /* GTK widgets */
+  GtkWidget *window;
+  GtkWidget *video_combo, *audio_combo, *text_combo, *vis_combo;
+  GtkWidget *video_window;
+
+  GtkWidget *vis_checkbox, *video_checkbox, *audio_checkbox;
+  GtkWidget *text_checkbox, *mute_checkbox, *volume_spinbutton;
+  GtkWidget *soft_volume_checkbox, *native_audio_checkbox,
+      *native_video_checkbox;
+  GtkWidget *download_checkbox, *buffering_checkbox, *deinterlace_checkbox;
+  GtkWidget *soft_colorbalance_checkbox;
+  GtkWidget *video_sink_entry, *audio_sink_entry, *text_sink_entry;
+  GtkWidget *buffer_size_entry, *buffer_duration_entry;
+  GtkWidget *ringbuffer_maxsize_entry, *connection_speed_entry;
+  GtkWidget *av_offset_entry, *subtitle_encoding_entry;
+  GtkWidget *subtitle_fontdesc_button;
+
+  GtkWidget *seek_format_combo, *seek_position_label, *seek_duration_label;
+  GtkWidget *seek_entry;
+
+  GtkWidget *seek_scale, *statusbar;
+  guint status_id;
+
+  GtkWidget *step_format_combo, *step_amount_spinbutton, *step_rate_spinbutton;
+  GtkWidget *shuttle_scale;
+
+  GtkWidget *contrast_scale, *brightness_scale, *hue_scale, *saturation_scale;
+
+  struct
+  {
+    GstNavigationCommand cmd;
+    GtkWidget *button;
+  } navigation_buttons[14];
+
+  guintptr embed_xid;
+
+  /* GStreamer pipeline */
+  GstElement *pipeline;
+
+  GstElement *navigation_element;
+  GstElement *colorbalance_element;
+  GstElement *overlay_element;
+
+  /* Settings */
+  gboolean accurate_seek;
+  gboolean keyframe_seek;
+  gboolean loop_seek;
+  gboolean flush_seek;
+  gboolean scrub;
+  gboolean play_scrub;
+  gboolean skip_seek;
+  gdouble rate;
+
+  /* From commandline parameters */
+  gboolean stats;
+  gboolean verbose;
+  const gchar *pipeline_spec;
+  gint pipeline_type;
+  GList *paths, *current_path;
+  GList *sub_paths, *current_sub_path;
+
+  gchar *audiosink_str, *videosink_str;
+
+  /* Internal state */
+  gint64 position, duration;
+
+  gboolean is_live;
+  gboolean buffering;
+  GstBufferingMode mode;
+  gint64 buffering_left;
+  GstState state;
+  guint update_id;
+  guint seek_timeout_id;
+  gulong changed_id;
+  guint fill_id;
+
+  gboolean need_streams;
+  gint n_video, n_audio, n_text;
+
+  GMutex state_mutex;
+
+  GArray *vis_entries;          /* Array of VisEntry structs */
+
+  gboolean shuttling;
+  gdouble shuttle_rate;
+  gdouble play_rate;
+
+  const GstFormatDefinition *seek_format;
+  GList *formats;
+} SeekApp;
 
-static void clear_streams (GstElement * pipeline);
+static void clear_streams (SeekApp * app);
+static void find_interface_elements (SeekApp * app);
 static void volume_notify_cb (GstElement * pipeline, GParamSpec * arg,
-    gpointer user_dat);
-static void find_navigation_element (void);
+    SeekApp * app);
+static void mute_notify_cb (GstElement * pipeline, GParamSpec * arg,
+    SeekApp * app);
+
+static void video_sink_activate_cb (GtkEntry * entry, SeekApp * app);
+static void text_sink_activate_cb (GtkEntry * entry, SeekApp * app);
+static void audio_sink_activate_cb (GtkEntry * entry, SeekApp * app);
+static void buffer_size_activate_cb (GtkEntry * entry, SeekApp * app);
+static void buffer_duration_activate_cb (GtkEntry * entry, SeekApp * app);
+static void ringbuffer_maxsize_activate_cb (GtkEntry * entry, SeekApp * app);
+static void connection_speed_activate_cb (GtkEntry * entry, SeekApp * app);
+static void av_offset_activate_cb (GtkEntry * entry, SeekApp * app);
+static void subtitle_encoding_activate_cb (GtkEntry * entry, SeekApp * app);
 
 /* pipeline construction */
 
-typedef struct
-{
-  const gchar *padname;
-  GstPad *target;
-  GstElement *bin;
-}
-dyn_link;
-
 static GstElement *
 gst_element_factory_make_or_warn (const gchar * type, const gchar * name)
 {
@@ -177,99 +232,83 @@ gst_element_factory_make_or_warn (const gchar * type, const gchar * name)
 }
 
 static void
-playerbin_set_uri (GstElement * player, const gchar * location)
+set_uri_property (GObject * object, const gchar * property,
+    const gchar * location)
 {
   gchar *uri;
 
   /* Add "file://" prefix for convenience */
-  if (g_str_has_prefix (location, "/") || !gst_uri_is_valid (location)) {
+  if (location && (g_str_has_prefix (location, "/")
+          || !gst_uri_is_valid (location))) {
     uri = gst_filename_to_uri (location, NULL);
     g_print ("Setting URI: %s\n", uri);
-    g_object_set (G_OBJECT (player), "uri", uri, NULL);
+    g_object_set (object, property, uri, NULL);
     g_free (uri);
   } else {
     g_print ("Setting URI: %s\n", location);
-    g_object_set (G_OBJECT (player), "uri", location, NULL);
+    g_object_set (object, property, location, NULL);
   }
 }
 
-static GstElement *
-construct_playbin (const gchar * name, const gchar * location)
+static void
+playbin_set_uri (GstElement * playbin, const gchar * location,
+    const gchar * sub_location)
 {
-  GstElement *player;
-  GstElement *avsink;
-
-  player = gst_element_factory_make (name, "player");
-  g_assert (player);
-
-  playerbin_set_uri (player, location);
-
-  seekable_elements = g_list_prepend (seekable_elements, player);
-
-  avsink = gst_element_factory_make_or_warn (opt_audiosink_str, "a_sink");
-  if (avsink)
-    g_object_set (player, "audio-sink", avsink, NULL);
-
-  avsink = gst_element_factory_make_or_warn (opt_videosink_str, "v_sink");
-  if (avsink)
-    g_object_set (player, "video-sink", avsink, NULL);
-
-  return player;
+  set_uri_property (G_OBJECT (playbin), "uri", location);
+  set_uri_property (G_OBJECT (playbin), "suburi", sub_location);
 }
 
-static GstElement *
-make_playbin_pipeline (const gchar * location)
+static void
+make_playbin_pipeline (SeekApp * app, const gchar * location)
 {
-  GstElement *pipeline = construct_playbin ("playbin", location);
+  GstElement *pipeline;
+
+  app->pipeline = pipeline = gst_element_factory_make ("playbin", "playbin");
+  g_assert (pipeline);
+
+  playbin_set_uri (pipeline, location,
+      app->current_sub_path ? app->current_sub_path->data : NULL);
 
-  /* FIXME: this is not triggered, playbin is not forwarding it from the sink */
   g_signal_connect (pipeline, "notify::volume", G_CALLBACK (volume_notify_cb),
-      NULL);
-  return pipeline;
+      app);
+  g_signal_connect (pipeline, "notify::mute", G_CALLBACK (mute_notify_cb), app);
+
+  app->navigation_element = GST_ELEMENT (gst_object_ref (pipeline));
+  app->colorbalance_element = GST_ELEMENT (gst_object_ref (pipeline));
 }
 
 #ifndef GST_DISABLE_PARSE
-static GstElement *
-make_parselaunch_pipeline (const gchar * description)
+static void
+make_parselaunch_pipeline (SeekApp * app, const gchar * description)
 {
-  GstElement *pipeline;
-  GError *error = NULL;
-
-  pipeline = gst_parse_launch (description, &error);
-
-  seekable_elements = g_list_prepend (seekable_elements, pipeline);
-
-  return pipeline;
+  app->pipeline = gst_parse_launch (description, NULL);
 }
 #endif
 
 typedef struct
 {
   const gchar *name;
-  GstElement *(*func) (const gchar * location);
+  void (*func) (SeekApp * app, const gchar * location);
 }
 Pipeline;
 
-static Pipeline pipelines[] = {
+static const Pipeline pipelines[] = {
   {"playbin", make_playbin_pipeline},
 #ifndef GST_DISABLE_PARSE
   {"parse-launch", make_parselaunch_pipeline},
 #endif
-  {NULL, NULL},
 };
 
-#define NUM_TYPES       ((sizeof (pipelines) / sizeof (Pipeline)) - 1)
-
 /* ui callbacks and helpers */
 
 static gchar *
-format_value (GtkScale * scale, gdouble value)
+format_value (GtkScale * scale, gdouble value, SeekApp * app)
 {
   gint64 real;
   gint64 seconds;
   gint64 subseconds;
 
-  real = value * duration / N_GRAD;
+  real = value * app->duration / N_GRAD;
   seconds = (gint64) real / GST_SECOND;
   subseconds = (gint64) real / (GST_SECOND / N_GRAD);
 
@@ -277,7 +316,6 @@ format_value (GtkScale * scale, gdouble value)
       G_GINT64_FORMAT, seconds / 60, seconds % 60, subseconds % 100);
 }
 
-
 static gchar *
 shuttle_format_value (GtkScale * scale, gdouble value)
 {
@@ -299,330 +337,341 @@ static seek_format seek_formats[] = {
   {NULL, 0},
 };
 
-G_GNUC_UNUSED static void
-query_positions_elems (void)
+static void
+query_positions (SeekApp * app)
 {
-  GList *walk = seekable_elements;
-
-  while (walk) {
-    GstElement *element = GST_ELEMENT (walk->data);
-    gint i = 0;
+  gint i = 0;
 
-    g_print ("positions %8.8s: ", GST_ELEMENT_NAME (element));
-    while (seek_formats[i].name) {
-      gint64 position, total;
-      GstFormat format;
+  g_print ("positions %8.8s: ", GST_ELEMENT_NAME (app->pipeline));
+  while (seek_formats[i].name) {
+    gint64 position, total;
+    GstFormat format;
 
-      format = seek_formats[i].format;
+    format = seek_formats[i].format;
 
-      if (gst_element_query_position (element, format, &position) &&
-          gst_element_query_duration (element, format, &total)) {
-        g_print ("%s %13" G_GINT64_FORMAT " / %13" G_GINT64_FORMAT " | ",
-            seek_formats[i].name, position, total);
-      } else {
-        g_print ("%s %13.13s / %13.13s | ", seek_formats[i].name, "*NA*",
-            "*NA*");
-      }
-      i++;
+    if (gst_element_query_position (app->pipeline, format, &position) &&
+        gst_element_query_duration (app->pipeline, format, &total)) {
+      g_print ("%s %13" G_GINT64_FORMAT " / %13" G_GINT64_FORMAT " | ",
+          seek_formats[i].name, position, total);
+    } else {
+      g_print ("%s %13.13s / %13.13s | ", seek_formats[i].name, "*NA*", "*NA*");
     }
-    g_print (" %s\n", GST_ELEMENT_NAME (element));
-
-    walk = g_list_next (walk);
+    i++;
   }
+  g_print (" %s\n", GST_ELEMENT_NAME (app->pipeline));
 }
 
-static gboolean start_seek (GtkWidget * widget, GdkEventButton * event,
-    gpointer user_data);
-static gboolean stop_seek (GtkWidget * widget, GdkEventButton * event,
-    gpointer user_data);
-static void seek_cb (GtkWidget * widget);
+static gboolean start_seek (GtkRange * range, GdkEventButton * event,
+    SeekApp * app);
+static gboolean stop_seek (GtkRange * range, GdkEventButton * event,
+    SeekApp * app);
+static void seek_cb (GtkRange * range, SeekApp * app);
 
 static void
-set_scale (gdouble value)
+set_scale (SeekApp * app, gdouble value)
 {
-  g_signal_handlers_block_by_func (hscale, (void *) start_seek,
-      (void *) pipeline);
-  g_signal_handlers_block_by_func (hscale, (void *) stop_seek,
-      (void *) pipeline);
-  g_signal_handlers_block_by_func (hscale, (void *) seek_cb, (void *) pipeline);
-  gtk_adjustment_set_value (adjustment, value);
-  g_signal_handlers_unblock_by_func (hscale, (void *) start_seek,
-      (void *) pipeline);
-  g_signal_handlers_unblock_by_func (hscale, (void *) stop_seek,
-      (void *) pipeline);
-  g_signal_handlers_unblock_by_func (hscale, (void *) seek_cb,
-      (void *) pipeline);
-  gtk_widget_queue_draw (hscale);
+  g_signal_handlers_block_by_func (app->seek_scale, start_seek, app);
+  g_signal_handlers_block_by_func (app->seek_scale, stop_seek, app);
+  g_signal_handlers_block_by_func (app->seek_scale, seek_cb, app);
+  gtk_range_set_value (GTK_RANGE (app->seek_scale), value);
+  g_signal_handlers_unblock_by_func (app->seek_scale, start_seek, app);
+  g_signal_handlers_unblock_by_func (app->seek_scale, stop_seek, app);
+  g_signal_handlers_unblock_by_func (app->seek_scale, seek_cb, app);
+  gtk_widget_queue_draw (app->seek_scale);
 }
 
 static gboolean
-update_fill (gpointer data)
-{
-  if (seekable_elements) {
-    GstElement *element = GST_ELEMENT (seekable_elements->data);
-    GstQuery *query;
-
-    query = gst_query_new_buffering (GST_FORMAT_PERCENT);
-    if (gst_element_query (element, query)) {
-      gint64 start, stop, buffering_total;
-      GstFormat format;
-      gdouble fill;
-      gboolean busy;
-      gint percent;
-      GstBufferingMode mode;
-      gint avg_in, avg_out;
-      gint64 buffering_left;
-
-      gst_query_parse_buffering_percent (query, &busy, &percent);
-      gst_query_parse_buffering_range (query, &format, &start, &stop,
-          &buffering_total);
-      gst_query_parse_buffering_stats (query, &mode, &avg_in, &avg_out,
-          &buffering_left);
-
-      /* note that we could start the playback when buffering_left < remaining
-       * playback time */
-      GST_DEBUG ("buffering total %" G_GINT64_FORMAT " ms, left %"
-          G_GINT64_FORMAT " ms", buffering_total, buffering_left);
-      GST_DEBUG ("start %" G_GINT64_FORMAT ", stop %" G_GINT64_FORMAT,
-          start, stop);
-
-      if (stop != -1)
-        fill = N_GRAD * stop / GST_FORMAT_PERCENT_MAX;
-      else
-        fill = N_GRAD;
-
-      gtk_range_set_fill_level (GTK_RANGE (hscale), fill);
-    }
-    gst_query_unref (query);
-  }
+update_fill (SeekApp * app)
+{
+  GstQuery *query;
+
+  query = gst_query_new_buffering (GST_FORMAT_PERCENT);
+  if (gst_element_query (app->pipeline, query)) {
+    gint64 start, stop, buffering_total;
+    GstFormat format;
+    gdouble fill;
+    gboolean busy;
+    gint percent;
+    GstBufferingMode mode;
+    gint avg_in, avg_out;
+    gint64 buffering_left;
+
+    gst_query_parse_buffering_percent (query, &busy, &percent);
+    gst_query_parse_buffering_range (query, &format, &start, &stop,
+        &buffering_total);
+    gst_query_parse_buffering_stats (query, &mode, &avg_in, &avg_out,
+        &buffering_left);
+
+    /* note that we could start the playback when buffering_left < remaining
+     * playback time */
+    GST_DEBUG ("buffering total %" G_GINT64_FORMAT " ms, left %"
+        G_GINT64_FORMAT " ms", buffering_total, buffering_left);
+    GST_DEBUG ("start %" G_GINT64_FORMAT ", stop %" G_GINT64_FORMAT,
+        start, stop);
+
+    if (stop != -1)
+      fill = N_GRAD * stop / GST_FORMAT_PERCENT_MAX;
+    else
+      fill = N_GRAD;
+
+    gtk_range_set_fill_level (GTK_RANGE (app->seek_scale), fill);
+  }
+  gst_query_unref (query);
+
   return TRUE;
 }
 
 static gboolean
-update_scale (gpointer data)
+update_scale (SeekApp * app)
 {
-  if (seekable_elements) {
-    GstElement *element = GST_ELEMENT (seekable_elements->data);
+  GstFormat format = GST_FORMAT_TIME;
+  gint64 seek_pos, seek_dur;
+  gchar *str;
 
-    gst_element_query_position (element, GST_FORMAT_TIME, &position);
-    gst_element_query_duration (element, GST_FORMAT_TIME, &duration);
-  }
+  //position = 0;
+  //duration = 0;
 
-  if (stats) {
-    query_positions_elems ();
-  }
+  gst_element_query_position (app->pipeline, format, &app->position);
+  gst_element_query_duration (app->pipeline, format, &app->duration);
+
+  if (app->stats)
+    query_positions (app);
 
-  if (position >= duration)
-    duration = position;
+  if (app->position >= app->duration)
+    app->duration = app->position;
 
-  if (duration > 0) {
-    set_scale (position * N_GRAD / duration);
+  if (app->duration > 0) {
+    set_scale (app, app->position * N_GRAD / app->duration);
   }
 
-  /* FIXME: see make_playerbin2_pipeline() and volume_notify_cb() */
-  if (pipeline_type == 16) {
-    g_object_notify (G_OBJECT (pipeline), "volume");
+  if (app->seek_format) {
+    format = app->seek_format->value;
+    seek_pos = seek_dur = -1;
+    gst_element_query_position (app->pipeline, format, &seek_pos);
+    gst_element_query_duration (app->pipeline, format, &seek_dur);
+
+    str = g_strdup_printf ("%" G_GINT64_FORMAT, seek_pos);
+    gtk_label_set_text (GTK_LABEL (app->seek_position_label), str);
+    g_free (str);
+
+    str = g_strdup_printf ("%" G_GINT64_FORMAT, seek_dur);
+    gtk_label_set_text (GTK_LABEL (app->seek_duration_label), str);
+    g_free (str);
   }
 
   return TRUE;
 }
 
-static void do_seek (GtkWidget * widget);
-static void connect_bus_signals (GstElement * pipeline);
-static void set_update_scale (gboolean active);
-static void set_update_fill (gboolean active);
+static void set_update_scale (SeekApp * app, gboolean active);
+static void set_update_fill (SeekApp * app, gboolean active);
 
 static gboolean
-end_scrub (GtkWidget * widget)
+end_scrub (SeekApp * app)
 {
   GST_DEBUG ("end scrub, PAUSE");
-  gst_element_set_state (pipeline, GST_STATE_PAUSED);
-  seek_timeout_id = 0;
+  gst_element_set_state (app->pipeline, GST_STATE_PAUSED);
+  app->seek_timeout_id = 0;
 
   return FALSE;
 }
 
 static gboolean
-send_event (GstEvent * event)
+send_event (SeekApp * app, GstEvent * event)
 {
   gboolean res = FALSE;
-  GList *walk = seekable_elements;
-
-  while (walk) {
-    GstElement *seekable = GST_ELEMENT (walk->data);
 
-    GST_DEBUG ("send event on element %s", GST_ELEMENT_NAME (seekable));
+  GST_DEBUG ("send event on element %s", GST_ELEMENT_NAME (app->pipeline));
+  res = gst_element_send_event (app->pipeline, event);
 
-    gst_event_ref (event);
-    res = gst_element_send_event (seekable, event);
-
-    walk = g_list_next (walk);
-  }
-  gst_event_unref (event);
   return res;
 }
 
 static void
-do_seek (GtkWidget * widget)
+do_seek (SeekApp * app, GstFormat format, gint64 position)
 {
-  gint64 real;
   gboolean res = FALSE;
   GstEvent *s_event;
   GstSeekFlags flags;
 
-  real = gtk_range_get_value (GTK_RANGE (widget)) * duration / N_GRAD;
-
-  GST_DEBUG ("value=%f, real=%" G_GINT64_FORMAT,
-      gtk_range_get_value (GTK_RANGE (widget)), real);
-
   flags = 0;
-  if (flush_seek)
+  if (app->flush_seek)
     flags |= GST_SEEK_FLAG_FLUSH;
-  if (accurate_seek)
+  if (app->accurate_seek)
     flags |= GST_SEEK_FLAG_ACCURATE;
-  if (keyframe_seek)
+  if (app->keyframe_seek)
     flags |= GST_SEEK_FLAG_KEY_UNIT;
-  if (loop_seek)
+  if (app->loop_seek)
     flags |= GST_SEEK_FLAG_SEGMENT;
-  if (skip_seek)
+  if (app->skip_seek)
     flags |= GST_SEEK_FLAG_SKIP;
 
-  if (rate >= 0) {
-    s_event = gst_event_new_seek (rate,
-        GST_FORMAT_TIME, flags, GST_SEEK_TYPE_SET, real, GST_SEEK_TYPE_SET,
+  if (app->rate >= 0) {
+    s_event = gst_event_new_seek (app->rate,
+        format, flags, GST_SEEK_TYPE_SET, position, GST_SEEK_TYPE_SET,
         GST_CLOCK_TIME_NONE);
     GST_DEBUG ("seek with rate %lf to %" GST_TIME_FORMAT " / %" GST_TIME_FORMAT,
-        rate, GST_TIME_ARGS (real), GST_TIME_ARGS (duration));
+        app->rate, GST_TIME_ARGS (position), GST_TIME_ARGS (app->duration));
   } else {
-    s_event = gst_event_new_seek (rate,
-        GST_FORMAT_TIME, flags, GST_SEEK_TYPE_SET, G_GINT64_CONSTANT (0),
-        GST_SEEK_TYPE_SET, real);
+    s_event = gst_event_new_seek (app->rate,
+        format, flags, GST_SEEK_TYPE_SET, G_GINT64_CONSTANT (0),
+        GST_SEEK_TYPE_SET, position);
     GST_DEBUG ("seek with rate %lf to %" GST_TIME_FORMAT " / %" GST_TIME_FORMAT,
-        rate, GST_TIME_ARGS (0), GST_TIME_ARGS (real));
+        app->rate, GST_TIME_ARGS (0), GST_TIME_ARGS (position));
   }
 
-  res = send_event (s_event);
+  res = send_event (app, s_event);
 
   if (res) {
-    if (flush_seek) {
-      gst_element_get_state (GST_ELEMENT (pipeline), NULL, NULL, SEEK_TIMEOUT);
+    if (app->flush_seek) {
+      gst_element_get_state (GST_ELEMENT (app->pipeline), NULL, NULL,
+          SEEK_TIMEOUT);
     } else {
-      set_update_scale (TRUE);
+      set_update_scale (app, TRUE);
     }
   } else {
     g_print ("seek failed\n");
-    set_update_scale (TRUE);
+    set_update_scale (app, TRUE);
   }
 }
 
 static void
-seek_cb (GtkWidget * widget)
+seek_cb (GtkRange * range, SeekApp * app)
 {
+  gint64 real;
   /* If the timer hasn't expired yet, then the pipeline is running */
-  if (play_scrub && seek_timeout_id != 0) {
+  if (app->play_scrub && app->seek_timeout_id != 0) {
     GST_DEBUG ("do scrub seek, PAUSED");
-    gst_element_set_state (pipeline, GST_STATE_PAUSED);
+    gst_element_set_state (app->pipeline, GST_STATE_PAUSED);
   }
 
+  real =
+      gtk_range_get_value (GTK_RANGE (app->seek_scale)) * app->duration /
+      N_GRAD;
+
+  GST_DEBUG ("value=%f, real=%" G_GINT64_FORMAT,
+      gtk_range_get_value (GTK_RANGE (app->seek_scale)), real);
+
   GST_DEBUG ("do seek");
-  do_seek (widget);
+  do_seek (app, GST_FORMAT_TIME, real);
 
-  if (play_scrub) {
+  if (app->play_scrub) {
     GST_DEBUG ("do scrub seek, PLAYING");
-    gst_element_set_state (pipeline, GST_STATE_PLAYING);
+    gst_element_set_state (app->pipeline, GST_STATE_PLAYING);
 
-    if (seek_timeout_id == 0) {
-      seek_timeout_id =
-          g_timeout_add (SCRUB_TIME, (GSourceFunc) end_scrub, widget);
+    if (app->seek_timeout_id == 0) {
+      app->seek_timeout_id =
+          g_timeout_add (SCRUB_TIME, (GSourceFunc) end_scrub, app);
     }
   }
 }
 
 static void
-set_update_fill (gboolean active)
+advanced_seek_button_cb (GtkButton * button, SeekApp * app)
+{
+  GstFormat fmt;
+  gint64 pos;
+  const gchar *text;
+  gchar *endptr;
+
+  fmt = app->seek_format->value;
+
+  text = gtk_entry_get_text (GTK_ENTRY (app->seek_entry));
+
+  pos = g_ascii_strtoll (text, &endptr, 10);
+  if (endptr != text && pos != G_MAXINT64 && pos != G_MININT64) {
+    do_seek (app, fmt, pos);
+  }
+}
+
+static void
+set_update_fill (SeekApp * app, gboolean active)
 {
   GST_DEBUG ("fill scale is %d", active);
 
   if (active) {
-    if (fill_id == 0) {
-      fill_id =
-          g_timeout_add (FILL_INTERVAL, (GSourceFunc) update_fill, pipeline);
+    if (app->fill_id == 0) {
+      app->fill_id =
+          g_timeout_add (FILL_INTERVAL, (GSourceFunc) update_fill, app);
     }
   } else {
-    if (fill_id) {
-      g_source_remove (fill_id);
-      fill_id = 0;
+    if (app->fill_id) {
+      g_source_remove (app->fill_id);
+      app->fill_id = 0;
     }
   }
 }
 
 static void
-set_update_scale (gboolean active)
+set_update_scale (SeekApp * app, gboolean active)
 {
-
   GST_DEBUG ("update scale is %d", active);
 
   if (active) {
-    if (update_id == 0) {
-      update_id =
-          g_timeout_add (UPDATE_INTERVAL, (GSourceFunc) update_scale, pipeline);
+    if (app->update_id == 0) {
+      app->update_id =
+          g_timeout_add (UPDATE_INTERVAL, (GSourceFunc) update_scale, app);
     }
   } else {
-    if (update_id) {
-      g_source_remove (update_id);
-      update_id = 0;
+    if (app->update_id) {
+      g_source_remove (app->update_id);
+      app->update_id = 0;
     }
   }
 }
 
 static gboolean
-start_seek (GtkWidget * widget, GdkEventButton * event, gpointer user_data)
+start_seek (GtkRange * range, GdkEventButton * event, SeekApp * app)
 {
   if (event->type != GDK_BUTTON_PRESS)
     return FALSE;
 
-  set_update_scale (FALSE);
+  set_update_scale (app, FALSE);
 
-  if (state == GST_STATE_PLAYING && flush_seek && scrub) {
+  if (app->state == GST_STATE_PLAYING && app->flush_seek && app->scrub) {
     GST_DEBUG ("start scrub seek, PAUSE");
-    gst_element_set_state (pipeline, GST_STATE_PAUSED);
+    gst_element_set_state (app->pipeline, GST_STATE_PAUSED);
   }
 
-  if (changed_id == 0 && flush_seek && scrub) {
-    changed_id =
-        g_signal_connect (hscale, "value_changed", G_CALLBACK (seek_cb),
-        pipeline);
+  if (app->changed_id == 0 && app->flush_seek && app->scrub) {
+    app->changed_id =
+        g_signal_connect (app->seek_scale, "value-changed",
+        G_CALLBACK (seek_cb), app);
   }
 
   return FALSE;
 }
 
 static gboolean
-stop_seek (GtkWidget * widget, GdkEventButton * event, gpointer user_data)
+stop_seek (GtkRange * range, GdkEventButton * event, SeekApp * app)
 {
-  if (changed_id) {
-    g_signal_handler_disconnect (hscale, changed_id);
-    changed_id = 0;
+  if (app->changed_id) {
+    g_signal_handler_disconnect (app->seek_scale, app->changed_id);
+    app->changed_id = 0;
   }
 
-  if (!flush_seek || !scrub) {
+  if (!app->flush_seek || !app->scrub) {
+    gint64 real;
+
     GST_DEBUG ("do final seek");
-    do_seek (widget);
+    real =
+        gtk_range_get_value (GTK_RANGE (app->seek_scale)) * app->duration /
+        N_GRAD;
+    do_seek (app, GST_FORMAT_TIME, real);
   }
 
-  if (seek_timeout_id != 0) {
-    g_source_remove (seek_timeout_id);
-    seek_timeout_id = 0;
+  if (app->seek_timeout_id != 0) {
+    g_source_remove (app->seek_timeout_id);
+    app->seek_timeout_id = 0;
     /* Still scrubbing, so the pipeline is playing, see if we need PAUSED
      * instead. */
-    if (state == GST_STATE_PAUSED) {
+    if (app->state == GST_STATE_PAUSED) {
       GST_DEBUG ("stop scrub seek, PAUSED");
-      gst_element_set_state (pipeline, GST_STATE_PAUSED);
+      gst_element_set_state (app->pipeline, GST_STATE_PAUSED);
     }
   } else {
-    if (state == GST_STATE_PLAYING) {
+    if (app->state == GST_STATE_PLAYING) {
       GST_DEBUG ("stop scrub seek, PLAYING");
-      gst_element_set_state (pipeline, GST_STATE_PLAYING);
+      gst_element_set_state (app->pipeline, GST_STATE_PLAYING);
     }
   }
 
@@ -630,26 +679,42 @@ stop_seek (GtkWidget * widget, GdkEventButton * event, gpointer user_data)
 }
 
 static void
-play_cb (GtkButton * button, gpointer data)
+play_cb (GtkButton * button, SeekApp * app)
 {
   GstStateChangeReturn ret;
 
-  if (state != GST_STATE_PLAYING) {
+  if (app->state != GST_STATE_PLAYING) {
     g_print ("PLAY pipeline\n");
-    gtk_statusbar_pop (GTK_STATUSBAR (statusbar), status_id);
+    gtk_statusbar_pop (GTK_STATUSBAR (app->statusbar), app->status_id);
+
+    if (app->pipeline_type == 0) {
+      video_sink_activate_cb (GTK_ENTRY (app->video_sink_entry), app);
+      audio_sink_activate_cb (GTK_ENTRY (app->audio_sink_entry), app);
+      text_sink_activate_cb (GTK_ENTRY (app->text_sink_entry), app);
+      buffer_size_activate_cb (GTK_ENTRY (app->buffer_size_entry), app);
+      buffer_duration_activate_cb (GTK_ENTRY (app->buffer_duration_entry), app);
+      ringbuffer_maxsize_activate_cb (GTK_ENTRY (app->ringbuffer_maxsize_entry),
+          app);
+      connection_speed_activate_cb (GTK_ENTRY (app->connection_speed_entry),
+          app);
+      av_offset_activate_cb (GTK_ENTRY (app->av_offset_entry), app);
+      subtitle_encoding_activate_cb (GTK_ENTRY (app->subtitle_encoding_entry),
+          app);
+    }
 
-    ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
+    ret = gst_element_set_state (app->pipeline, GST_STATE_PLAYING);
     switch (ret) {
       case GST_STATE_CHANGE_FAILURE:
         goto failed;
       case GST_STATE_CHANGE_NO_PREROLL:
-        is_live = TRUE;
+        app->is_live = TRUE;
         break;
       default:
         break;
     }
-    state = GST_STATE_PLAYING;
-    gtk_statusbar_push (GTK_STATUSBAR (statusbar), status_id, "Playing");
+    app->state = GST_STATE_PLAYING;
+    gtk_statusbar_push (GTK_STATUSBAR (app->statusbar), app->status_id,
+        "Playing");
   }
 
   return;
@@ -657,321 +722,368 @@ play_cb (GtkButton * button, gpointer data)
 failed:
   {
     g_print ("PLAY failed\n");
-    gtk_statusbar_push (GTK_STATUSBAR (statusbar), status_id, "Play failed");
+    gtk_statusbar_push (GTK_STATUSBAR (app->statusbar), app->status_id,
+        "Play failed");
   }
 }
 
 static void
-pause_cb (GtkButton * button, gpointer data)
+pause_cb (GtkButton * button, SeekApp * app)
 {
-  g_mutex_lock (&state_mutex);
-  if (state != GST_STATE_PAUSED) {
+  g_mutex_lock (&app->state_mutex);
+  if (app->state != GST_STATE_PAUSED) {
     GstStateChangeReturn ret;
 
-    gtk_statusbar_pop (GTK_STATUSBAR (statusbar), status_id);
+    gtk_statusbar_pop (GTK_STATUSBAR (app->statusbar), app->status_id);
     g_print ("PAUSE pipeline\n");
-    ret = gst_element_set_state (pipeline, GST_STATE_PAUSED);
+    ret = gst_element_set_state (app->pipeline, GST_STATE_PAUSED);
     switch (ret) {
       case GST_STATE_CHANGE_FAILURE:
         goto failed;
       case GST_STATE_CHANGE_NO_PREROLL:
-        is_live = TRUE;
+        app->is_live = TRUE;
         break;
       default:
         break;
     }
 
-    state = GST_STATE_PAUSED;
-    gtk_statusbar_push (GTK_STATUSBAR (statusbar), status_id, "Paused");
+    app->state = GST_STATE_PAUSED;
+    gtk_statusbar_push (GTK_STATUSBAR (app->statusbar), app->status_id,
+        "Paused");
   }
-  g_mutex_unlock (&state_mutex);
+  g_mutex_unlock (&app->state_mutex);
 
   return;
 
 failed:
   {
-    g_mutex_unlock (&state_mutex);
+    g_mutex_unlock (&app->state_mutex);
     g_print ("PAUSE failed\n");
-    gtk_statusbar_push (GTK_STATUSBAR (statusbar), status_id, "Pause failed");
+    gtk_statusbar_push (GTK_STATUSBAR (app->statusbar), app->status_id,
+        "Pause failed");
   }
 }
 
 static void
-stop_cb (GtkButton * button, gpointer data)
+stop_cb (GtkButton * button, SeekApp * app)
 {
-  if (state != STOP_STATE) {
+  if (app->state != STOP_STATE) {
     GstStateChangeReturn ret;
     gint i;
 
     g_print ("READY pipeline\n");
-    gtk_statusbar_pop (GTK_STATUSBAR (statusbar), status_id);
+    gtk_statusbar_pop (GTK_STATUSBAR (app->statusbar), app->status_id);
 
-    g_mutex_lock (&state_mutex);
-    ret = gst_element_set_state (pipeline, STOP_STATE);
+    g_mutex_lock (&app->state_mutex);
+    ret = gst_element_set_state (app->pipeline, STOP_STATE);
     if (ret == GST_STATE_CHANGE_FAILURE)
       goto failed;
 
-    state = STOP_STATE;
-    gtk_statusbar_push (GTK_STATUSBAR (statusbar), status_id, "Stopped");
-    gtk_widget_queue_draw (video_window);
-
-    is_live = FALSE;
-    buffering = FALSE;
-    set_update_scale (FALSE);
-    set_scale (0.0);
-    set_update_fill (FALSE);
-
-    if (pipeline_type == 16)
-      clear_streams (pipeline);
-    g_mutex_unlock (&state_mutex);
-
-#if 0
-    /* if one uses parse_launch, play, stop and play again it fails as all the
-     * pads after the demuxer can't be reconnected
-     */
-    if (!strcmp (pipelines[pipeline_type].name, "parse-launch")) {
-      gst_element_set_state (pipeline, GST_STATE_NULL);
-      gst_object_unref (pipeline);
-
-      g_list_free (seekable_elements);
-      seekable_elements = NULL;
-
-      pipeline = pipelines[pipeline_type].func (pipeline_spec);
-      g_assert (pipeline);
-      gst_element_set_state (pipeline, STOP_STATE);
-      connect_bus_signals (pipeline);
-    }
-#endif
-    gtk_widget_set_sensitive (GTK_WIDGET (hscale), TRUE);
-    for (i = 0; i < G_N_ELEMENTS (navigation_buttons); i++)
-      gtk_widget_set_sensitive (navigation_buttons[i].button, FALSE);
+    app->state = STOP_STATE;
+    gtk_statusbar_push (GTK_STATUSBAR (app->statusbar), app->status_id,
+        "Stopped");
+    gtk_widget_queue_draw (app->video_window);
+
+    app->is_live = FALSE;
+    app->buffering = FALSE;
+    set_update_scale (app, FALSE);
+    set_scale (app, 0.0);
+    set_update_fill (app, FALSE);
+
+    if (app->pipeline_type == 0)
+      clear_streams (app);
+    g_mutex_unlock (&app->state_mutex);
+
+    gtk_widget_set_sensitive (GTK_WIDGET (app->seek_scale), TRUE);
+    for (i = 0; i < G_N_ELEMENTS (app->navigation_buttons); i++)
+      gtk_widget_set_sensitive (app->navigation_buttons[i].button, FALSE);
   }
   return;
 
 failed:
   {
-    g_mutex_unlock (&state_mutex);
+    g_mutex_unlock (&app->state_mutex);
     g_print ("STOP failed\n");
-    gtk_statusbar_push (GTK_STATUSBAR (statusbar), status_id, "Stop failed");
+    gtk_statusbar_push (GTK_STATUSBAR (app->statusbar), app->status_id,
+        "Stop failed");
   }
 }
 
 static void
-accurate_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
+accurate_toggle_cb (GtkToggleButton * button, SeekApp * app)
 {
-  accurate_seek = gtk_toggle_button_get_active (button);
+  app->accurate_seek = gtk_toggle_button_get_active (button);
 }
 
 static void
-key_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
+key_toggle_cb (GtkToggleButton * button, SeekApp * app)
 {
-  keyframe_seek = gtk_toggle_button_get_active (button);
+  app->keyframe_seek = gtk_toggle_button_get_active (button);
 }
 
 static void
-loop_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
+loop_toggle_cb (GtkToggleButton * button, SeekApp * app)
 {
-  loop_seek = gtk_toggle_button_get_active (button);
-  if (state == GST_STATE_PLAYING) {
-    do_seek (hscale);
+  app->loop_seek = gtk_toggle_button_get_active (button);
+  if (app->state == GST_STATE_PLAYING) {
+    gint64 real;
+
+    real =
+        gtk_range_get_value (GTK_RANGE (app->seek_scale)) * app->duration /
+        N_GRAD;
+    do_seek (app, GST_FORMAT_TIME, real);
   }
 }
 
 static void
-flush_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
+flush_toggle_cb (GtkToggleButton * button, SeekApp * app)
 {
-  flush_seek = gtk_toggle_button_get_active (button);
+  app->flush_seek = gtk_toggle_button_get_active (button);
 }
 
 static void
-scrub_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
+scrub_toggle_cb (GtkToggleButton * button, SeekApp * app)
 {
-  scrub = gtk_toggle_button_get_active (button);
+  app->scrub = gtk_toggle_button_get_active (button);
 }
 
 static void
-play_scrub_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
+play_scrub_toggle_cb (GtkToggleButton * button, SeekApp * app)
 {
-  play_scrub = gtk_toggle_button_get_active (button);
+  app->play_scrub = gtk_toggle_button_get_active (button);
 }
 
 static void
-skip_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
+skip_toggle_cb (GtkToggleButton * button, SeekApp * app)
 {
-  skip_seek = gtk_toggle_button_get_active (button);
-  if (state == GST_STATE_PLAYING) {
-    do_seek (hscale);
+  app->skip_seek = gtk_toggle_button_get_active (button);
+  if (app->state == GST_STATE_PLAYING) {
+    gint64 real;
+
+    real =
+        gtk_range_get_value (GTK_RANGE (app->seek_scale)) * app->duration /
+        N_GRAD;
+    do_seek (app, GST_FORMAT_TIME, real);
   }
 }
 
 static void
-rate_spinbutton_changed_cb (GtkSpinButton * button, GstPipeline * pipeline)
+rate_spinbutton_changed_cb (GtkSpinButton * button, SeekApp * app)
 {
   gboolean res = FALSE;
   GstEvent *s_event;
   GstSeekFlags flags;
 
-  rate = gtk_spin_button_get_value (button);
+  app->rate = gtk_spin_button_get_value (button);
 
-  GST_DEBUG ("rate changed to %lf", rate);
+  GST_DEBUG ("rate changed to %lf", app->rate);
 
   flags = 0;
-  if (flush_seek)
+  if (app->flush_seek)
     flags |= GST_SEEK_FLAG_FLUSH;
-  if (loop_seek)
+  if (app->loop_seek)
     flags |= GST_SEEK_FLAG_SEGMENT;
-  if (accurate_seek)
+  if (app->accurate_seek)
     flags |= GST_SEEK_FLAG_ACCURATE;
-  if (keyframe_seek)
+  if (app->keyframe_seek)
     flags |= GST_SEEK_FLAG_KEY_UNIT;
-  if (skip_seek)
+  if (app->skip_seek)
     flags |= GST_SEEK_FLAG_SKIP;
 
-  if (rate >= 0.0) {
-    s_event = gst_event_new_seek (rate,
-        GST_FORMAT_TIME, flags, GST_SEEK_TYPE_SET, position,
+  if (app->rate >= 0.0) {
+    s_event = gst_event_new_seek (app->rate,
+        GST_FORMAT_TIME, flags, GST_SEEK_TYPE_SET, app->position,
         GST_SEEK_TYPE_SET, GST_CLOCK_TIME_NONE);
   } else {
-    s_event = gst_event_new_seek (rate,
+    s_event = gst_event_new_seek (app->rate,
         GST_FORMAT_TIME, flags, GST_SEEK_TYPE_SET, G_GINT64_CONSTANT (0),
-        GST_SEEK_TYPE_SET, position);
+        GST_SEEK_TYPE_SET, app->position);
   }
 
-  res = send_event (s_event);
+  res = send_event (app, s_event);
 
   if (res) {
-    if (flush_seek) {
-      gst_element_get_state (GST_ELEMENT (pipeline), NULL, NULL, SEEK_TIMEOUT);
+    if (app->flush_seek) {
+      gst_element_get_state (GST_ELEMENT (app->pipeline), NULL, NULL,
+          SEEK_TIMEOUT);
     }
   } else
     g_print ("seek failed\n");
 }
 
 static void
-update_flag (GstPipeline * pipeline, gint num, gboolean state)
+update_flag (GstElement * pipeline, GstPlayFlags flag, gboolean state)
 {
   gint flags;
 
+  g_print ("%ssetting flag 0x%08x\n", (state ? "" : "un"), flag);
+
   g_object_get (pipeline, "flags", &flags, NULL);
   if (state)
-    flags |= (1 << num);
+    flags |= flag;
   else
-    flags &= ~(1 << num);
+    flags &= ~(flag);
   g_object_set (pipeline, "flags", flags, NULL);
 }
 
 static void
-vis_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
+vis_toggle_cb (GtkToggleButton * button, SeekApp * app)
 {
   gboolean state;
 
   state = gtk_toggle_button_get_active (button);
-  update_flag (pipeline, 3, state);
-  gtk_widget_set_sensitive (vis_combo, state);
+  update_flag (app->pipeline, GST_PLAY_FLAG_VIS, state);
+  gtk_widget_set_sensitive (app->vis_combo, state);
 }
 
 static void
-audio_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
+audio_toggle_cb (GtkToggleButton * button, SeekApp * app)
 {
   gboolean state;
 
   state = gtk_toggle_button_get_active (button);
-  update_flag (pipeline, 1, state);
-  gtk_widget_set_sensitive (audio_combo, state);
+  update_flag (app->pipeline, GST_PLAY_FLAG_AUDIO, state);
+  gtk_widget_set_sensitive (app->audio_combo, state);
 }
 
 static void
-video_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
+video_toggle_cb (GtkToggleButton * button, SeekApp * app)
 {
   gboolean state;
 
   state = gtk_toggle_button_get_active (button);
-  update_flag (pipeline, 0, state);
-  gtk_widget_set_sensitive (video_combo, state);
+  update_flag (app->pipeline, GST_PLAY_FLAG_VIDEO, state);
+  gtk_widget_set_sensitive (app->video_combo, state);
 }
 
 static void
-text_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
+text_toggle_cb (GtkToggleButton * button, SeekApp * app)
 {
   gboolean state;
 
   state = gtk_toggle_button_get_active (button);
-  update_flag (pipeline, 2, state);
-  gtk_widget_set_sensitive (text_combo, state);
+  update_flag (app->pipeline, GST_PLAY_FLAG_TEXT, state);
+  gtk_widget_set_sensitive (app->text_combo, state);
 }
 
 static void
-mute_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
+mute_toggle_cb (GtkToggleButton * button, SeekApp * app)
 {
   gboolean mute;
 
   mute = gtk_toggle_button_get_active (button);
-  g_object_set (pipeline, "mute", mute, NULL);
+  g_object_set (app->pipeline, "mute", mute, NULL);
+}
+
+static void
+download_toggle_cb (GtkToggleButton * button, SeekApp * app)
+{
+  gboolean state;
+
+  state = gtk_toggle_button_get_active (button);
+  update_flag (app->pipeline, GST_PLAY_FLAG_DOWNLOAD, state);
+}
+
+static void
+buffering_toggle_cb (GtkToggleButton * button, SeekApp * app)
+{
+  gboolean state;
+
+  state = gtk_toggle_button_get_active (button);
+  update_flag (app->pipeline, GST_PLAY_FLAG_BUFFERING, state);
+}
+
+static void
+soft_volume_toggle_cb (GtkToggleButton * button, SeekApp * app)
+{
+  gboolean state;
+
+  state = gtk_toggle_button_get_active (button);
+  update_flag (app->pipeline, GST_PLAY_FLAG_SOFT_VOLUME, state);
+}
+
+static void
+native_audio_toggle_cb (GtkToggleButton * button, SeekApp * app)
+{
+  gboolean state;
+
+  state = gtk_toggle_button_get_active (button);
+  update_flag (app->pipeline, GST_PLAY_FLAG_NATIVE_AUDIO, state);
+}
+
+static void
+native_video_toggle_cb (GtkToggleButton * button, SeekApp * app)
+{
+  gboolean state;
+
+  state = gtk_toggle_button_get_active (button);
+  update_flag (app->pipeline, GST_PLAY_FLAG_NATIVE_VIDEO, state);
 }
 
 static void
-download_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
+deinterlace_toggle_cb (GtkToggleButton * button, SeekApp * app)
 {
   gboolean state;
 
   state = gtk_toggle_button_get_active (button);
-  update_flag (pipeline, 7, state);
+  update_flag (app->pipeline, GST_PLAY_FLAG_DEINTERLACE, state);
 }
 
 static void
-buffer_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
+soft_colorbalance_toggle_cb (GtkToggleButton * button, SeekApp * app)
 {
   gboolean state;
 
   state = gtk_toggle_button_get_active (button);
-  update_flag (pipeline, 8, state);
+  update_flag (app->pipeline, GST_PLAY_FLAG_SOFT_COLORBALANCE, state);
 }
 
 static void
-clear_streams (GstElement * pipeline)
+clear_streams (SeekApp * app)
 {
   gint i;
 
   /* remove previous info */
-  for (i = 0; i < n_video; i++)
-    gtk_combo_box_text_remove (GTK_COMBO_BOX_TEXT (video_combo), 0);
-  for (i = 0; i < n_audio; i++)
-    gtk_combo_box_text_remove (GTK_COMBO_BOX_TEXT (audio_combo), 0);
-  for (i = 0; i < n_text; i++)
-    gtk_combo_box_text_remove (GTK_COMBO_BOX_TEXT (text_combo), 0);
+  for (i = 0; i < app->n_video; i++)
+    gtk_combo_box_text_remove (GTK_COMBO_BOX_TEXT (app->video_combo), 0);
+  for (i = 0; i < app->n_audio; i++)
+    gtk_combo_box_text_remove (GTK_COMBO_BOX_TEXT (app->audio_combo), 0);
+  for (i = 0; i < app->n_text; i++)
+    gtk_combo_box_text_remove (GTK_COMBO_BOX_TEXT (app->text_combo), 0);
 
-  n_audio = n_video = n_text = 0;
-  gtk_widget_set_sensitive (video_combo, FALSE);
-  gtk_widget_set_sensitive (audio_combo, FALSE);
-  gtk_widget_set_sensitive (text_combo, FALSE);
+  app->n_audio = app->n_video = app->n_text = 0;
+  gtk_widget_set_sensitive (app->video_combo, FALSE);
+  gtk_widget_set_sensitive (app->audio_combo, FALSE);
+  gtk_widget_set_sensitive (app->text_combo, FALSE);
 
-  need_streams = TRUE;
+  app->need_streams = TRUE;
 }
 
 static void
-update_streams (GstPipeline * pipeline)
+update_streams (SeekApp * app)
 {
   gint i;
 
-  if (pipeline_type == 16 && need_streams) {
+  if (app->pipeline_type == 0 && app->need_streams) {
     GstTagList *tags;
     gchar *name, *str;
     gint active_idx;
     gboolean state;
 
     /* remove previous info */
-    clear_streams (GST_ELEMENT_CAST (pipeline));
+    clear_streams (app);
 
     /* here we get and update the different streams detected by playbin */
-    g_object_get (pipeline, "n-video", &n_video, NULL);
-    g_object_get (pipeline, "n-audio", &n_audio, NULL);
-    g_object_get (pipeline, "n-text", &n_text, NULL);
+    g_object_get (app->pipeline, "n-video", &app->n_video, NULL);
+    g_object_get (app->pipeline, "n-audio", &app->n_audio, NULL);
+    g_object_get (app->pipeline, "n-text", &app->n_text, NULL);
 
-    g_print ("video %d, audio %d, text %d\n", n_video, n_audio, n_text);
+    g_print ("video %d, audio %d, text %d\n", app->n_video, app->n_audio,
+        app->n_text);
 
     active_idx = 0;
-    for (i = 0; i < n_video; i++) {
-      g_signal_emit_by_name (pipeline, "get-video-tags", i, &tags);
+    for (i = 0; i < app->n_video; i++) {
+      g_signal_emit_by_name (app->pipeline, "get-video-tags", i, &tags);
       if (tags) {
         str = gst_structure_to_string ((GstStructure *) tags);
         g_print ("video %d: %s\n", i, str);
@@ -979,16 +1091,18 @@ update_streams (GstPipeline * pipeline)
       }
       /* find good name for the label */
       name = g_strdup_printf ("video %d", i + 1);
-      gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (video_combo), name);
+      gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (app->video_combo),
+          name);
       g_free (name);
     }
-    state = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (video_checkbox));
-    gtk_widget_set_sensitive (video_combo, state && n_video > 0);
-    gtk_combo_box_set_active (GTK_COMBO_BOX (video_combo), active_idx);
+    state =
+        gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (app->video_checkbox));
+    gtk_widget_set_sensitive (app->video_combo, state && app->n_video > 0);
+    gtk_combo_box_set_active (GTK_COMBO_BOX (app->video_combo), active_idx);
 
     active_idx = 0;
-    for (i = 0; i < n_audio; i++) {
-      g_signal_emit_by_name (pipeline, "get-audio-tags", i, &tags);
+    for (i = 0; i < app->n_audio; i++) {
+      g_signal_emit_by_name (app->pipeline, "get-audio-tags", i, &tags);
       if (tags) {
         str = gst_structure_to_string ((GstStructure *) tags);
         g_print ("audio %d: %s\n", i, str);
@@ -996,16 +1110,18 @@ update_streams (GstPipeline * pipeline)
       }
       /* find good name for the label */
       name = g_strdup_printf ("audio %d", i + 1);
-      gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (audio_combo), name);
+      gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (app->audio_combo),
+          name);
       g_free (name);
     }
-    state = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (audio_checkbox));
-    gtk_widget_set_sensitive (audio_combo, state && n_audio > 0);
-    gtk_combo_box_set_active (GTK_COMBO_BOX (audio_combo), active_idx);
+    state =
+        gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (app->audio_checkbox));
+    gtk_widget_set_sensitive (app->audio_combo, state && app->n_audio > 0);
+    gtk_combo_box_set_active (GTK_COMBO_BOX (app->audio_combo), active_idx);
 
     active_idx = 0;
-    for (i = 0; i < n_text; i++) {
-      g_signal_emit_by_name (pipeline, "get-text-tags", i, &tags);
+    for (i = 0; i < app->n_text; i++) {
+      g_signal_emit_by_name (app->pipeline, "get-text-tags", i, &tags);
 
       name = NULL;
       if (tags) {
@@ -1025,52 +1141,54 @@ update_streams (GstPipeline * pipeline)
       if (name == NULL)
         name = g_strdup_printf ("text %d", i + 1);
 
-      gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (text_combo), name);
+      gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (app->text_combo),
+          name);
       g_free (name);
     }
-    state = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (text_checkbox));
-    gtk_widget_set_sensitive (text_combo, state && n_text > 0);
-    gtk_combo_box_set_active (GTK_COMBO_BOX (text_combo), active_idx);
+    state =
+        gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (app->text_checkbox));
+    gtk_widget_set_sensitive (app->text_combo, state && app->n_text > 0);
+    gtk_combo_box_set_active (GTK_COMBO_BOX (app->text_combo), active_idx);
 
-    need_streams = FALSE;
+    app->need_streams = FALSE;
   }
 }
 
 static void
-video_combo_cb (GtkComboBox * combo, GstPipeline * pipeline)
+video_combo_cb (GtkComboBox * combo, SeekApp * app)
 {
   gint active;
 
   active = gtk_combo_box_get_active (combo);
 
   g_print ("setting current video track %d\n", active);
-  g_object_set (pipeline, "current-video", active, NULL);
+  g_object_set (app->pipeline, "current-video", active, NULL);
 }
 
 static void
-audio_combo_cb (GtkComboBox * combo, GstPipeline * pipeline)
+audio_combo_cb (GtkComboBox * combo, SeekApp * app)
 {
   gint active;
 
   active = gtk_combo_box_get_active (combo);
 
   g_print ("setting current audio track %d\n", active);
-  g_object_set (pipeline, "current-audio", active, NULL);
+  g_object_set (app->pipeline, "current-audio", active, NULL);
 }
 
 static void
-text_combo_cb (GtkComboBox * combo, GstPipeline * pipeline)
+text_combo_cb (GtkComboBox * combo, SeekApp * app)
 {
   gint active;
 
   active = gtk_combo_box_get_active (combo);
 
   g_print ("setting current text track %d\n", active);
-  g_object_set (pipeline, "current-text", active, NULL);
+  g_object_set (app->pipeline, "current-text", active, NULL);
 }
 
 static gboolean
-filter_features (GstPluginFeature * feature, gpointer data)
+filter_vis_features (GstPluginFeature * feature, gpointer data)
 {
   GstElementFactory *f;
 
@@ -1084,14 +1202,14 @@ filter_features (GstPluginFeature * feature, gpointer data)
 }
 
 static void
-init_visualization_features (void)
+init_visualization_features (SeekApp * app)
 {
   GList *list, *walk;
 
-  vis_entries = g_array_new (FALSE, FALSE, sizeof (VisEntry));
+  app->vis_entries = g_array_new (FALSE, FALSE, sizeof (VisEntry));
 
   list = gst_registry_feature_filter (gst_registry_get (),
-      filter_features, FALSE, NULL);
+      filter_vis_features, FALSE, NULL);
 
   for (walk = list; walk; walk = g_list_next (walk)) {
     VisEntry entry;
@@ -1100,23 +1218,23 @@ init_visualization_features (void)
     entry.factory = GST_ELEMENT_FACTORY (walk->data);
     name = gst_element_factory_get_longname (entry.factory);
 
-    g_array_append_val (vis_entries, entry);
-    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (vis_combo), name);
+    g_array_append_val (app->vis_entries, entry);
+    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (app->vis_combo), name);
   }
-  gtk_combo_box_set_active (GTK_COMBO_BOX (vis_combo), 0);
+  gtk_combo_box_set_active (GTK_COMBO_BOX (app->vis_combo), 0);
 }
 
 static void
-vis_combo_cb (GtkComboBox * combo, GstPipeline * pipeline)
+vis_combo_cb (GtkComboBox * combo, SeekApp * app)
 {
   guint index;
   VisEntry *entry;
   GstElement *element;
 
   /* get the selected index and get the factory for this index */
-  index = gtk_combo_box_get_active (GTK_COMBO_BOX (vis_combo));
-  if (vis_entries->len > 0) {
-    entry = &g_array_index (vis_entries, VisEntry, index);
+  index = gtk_combo_box_get_active (GTK_COMBO_BOX (app->vis_combo));
+  if (app->vis_entries->len > 0) {
+    entry = &g_array_index (app->vis_entries, VisEntry, index);
 
     /* create an instance of the element from the factory */
     element = gst_element_factory_create (entry->factory, NULL);
@@ -1124,41 +1242,74 @@ vis_combo_cb (GtkComboBox * combo, GstPipeline * pipeline)
       return;
 
     /* set vis plugin for playbin */
-    g_object_set (pipeline, "vis-plugin", element, NULL);
+    g_object_set (app->pipeline, "vis-plugin", element, NULL);
   }
 }
 
 static void
-volume_spinbutton_changed_cb (GtkSpinButton * button, GstPipeline * pipeline)
+volume_spinbutton_changed_cb (GtkSpinButton * button, SeekApp * app)
 {
   gdouble volume;
 
   volume = gtk_spin_button_get_value (button);
 
-  g_object_set (pipeline, "volume", volume, NULL);
+  g_object_set (app->pipeline, "volume", volume, NULL);
 }
 
-static void
-volume_notify_cb (GstElement * pipeline, GParamSpec * arg, gpointer user_dat)
+static gboolean
+volume_notify_idle_cb (SeekApp * app)
 {
   gdouble cur_volume, new_volume;
 
-  if (volume_spinbutton == NULL)
-    return;
-
-  g_object_get (pipeline, "volume", &new_volume, NULL);
-  cur_volume = gtk_spin_button_get_value (GTK_SPIN_BUTTON (volume_spinbutton));
+  g_object_get (app->pipeline, "volume", &new_volume, NULL);
+  cur_volume =
+      gtk_spin_button_get_value (GTK_SPIN_BUTTON (app->volume_spinbutton));
   if (fabs (cur_volume - new_volume) > 0.001) {
-    g_signal_handlers_block_by_func (volume_spinbutton,
-        volume_spinbutton_changed_cb, pipeline);
-    gtk_spin_button_set_value (GTK_SPIN_BUTTON (volume_spinbutton), new_volume);
-    g_signal_handlers_unblock_by_func (volume_spinbutton,
-        volume_spinbutton_changed_cb, pipeline);
+    g_signal_handlers_block_by_func (app->volume_spinbutton,
+        volume_spinbutton_changed_cb, app);
+    gtk_spin_button_set_value (GTK_SPIN_BUTTON (app->volume_spinbutton),
+        new_volume);
+    g_signal_handlers_unblock_by_func (app->volume_spinbutton,
+        volume_spinbutton_changed_cb, app);
   }
+
+  return FALSE;
 }
 
 static void
-shot_cb (GtkButton * button, gpointer data)
+volume_notify_cb (GstElement * pipeline, GParamSpec * arg, SeekApp * app)
+{
+  /* Do this from the main thread */
+  g_idle_add ((GSourceFunc) volume_notify_idle_cb, app);
+}
+
+static gboolean
+mute_notify_idle_cb (SeekApp * app)
+{
+  gboolean cur_mute, new_mute;
+
+  g_object_get (app->pipeline, "mute", &new_mute, NULL);
+  cur_mute =
+      gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (app->mute_checkbox));
+  if (cur_mute != new_mute) {
+    g_signal_handlers_block_by_func (app->mute_checkbox, mute_toggle_cb, app);
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (app->mute_checkbox),
+        new_mute);
+    g_signal_handlers_unblock_by_func (app->mute_checkbox, mute_toggle_cb, app);
+  }
+
+  return FALSE;
+}
+
+static void
+mute_notify_cb (GstElement * pipeline, GParamSpec * arg, SeekApp * app)
+{
+  /* Do this from the main thread */
+  g_idle_add ((GSourceFunc) mute_notify_idle_cb, app);
+}
+
+static void
+shot_cb (GtkButton * button, SeekApp * app)
 {
   GstSample *sample = NULL;
   GstCaps *caps;
@@ -1173,7 +1324,7 @@ shot_cb (GtkButton * button, gpointer data)
       "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1, NULL);
 
   /* convert the latest sample to the requested format */
-  g_signal_emit_by_name (pipeline, "convert-sample", caps, &sample);
+  g_signal_emit_by_name (app->pipeline, "convert-sample", caps, &sample);
   gst_caps_unref (caps);
 
   if (sample) {
@@ -1224,7 +1375,7 @@ shot_cb (GtkButton * button, gpointer data)
 
 /* called when the Step button is pressed */
 static void
-step_cb (GtkButton * button, gpointer data)
+step_cb (GtkButton * button, SeekApp * app)
 {
   GstEvent *event;
   GstFormat format;
@@ -1233,11 +1384,12 @@ step_cb (GtkButton * button, gpointer data)
   gboolean flush, res;
   gint active;
 
-  active = gtk_combo_box_get_active (GTK_COMBO_BOX (format_combo));
+  active = gtk_combo_box_get_active (GTK_COMBO_BOX (app->step_format_combo));
   amount =
       gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON
-      (step_amount_spinbutton));
-  rate = gtk_spin_button_get_value (GTK_SPIN_BUTTON (step_rate_spinbutton));
+      (app->step_amount_spinbutton));
+  rate =
+      gtk_spin_button_get_value (GTK_SPIN_BUTTON (app->step_rate_spinbutton));
   flush = TRUE;
 
   switch (active) {
@@ -1255,7 +1407,7 @@ step_cb (GtkButton * button, gpointer data)
 
   event = gst_event_new_step (format, amount, rate, flush, FALSE);
 
-  res = send_event (event);
+  res = send_event (app, event);
 
   if (!res) {
     g_print ("Sending step event failed\n");
@@ -1263,17 +1415,17 @@ step_cb (GtkButton * button, gpointer data)
 }
 
 static void
-message_received (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
+message_received (GstBus * bus, GstMessage * message, SeekApp * app)
 {
   const GstStructure *s;
 
   switch (GST_MESSAGE_TYPE (message)) {
     case GST_MESSAGE_ERROR:
-      GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline),
+      GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (app->pipeline),
           GST_DEBUG_GRAPH_SHOW_ALL, "seek.error");
       break;
     case GST_MESSAGE_WARNING:
-      GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline),
+      GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (app->pipeline),
           GST_DEBUG_GRAPH_SHOW_ALL, "seek.warning");
       break;
     default:
@@ -1295,27 +1447,23 @@ message_received (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
   }
 }
 
-static gboolean shuttling = FALSE;
-static gdouble shuttle_rate = 0.0;
-static gdouble play_rate = 1.0;
-
 static void
-do_shuttle (GstElement * element)
+do_shuttle (SeekApp * app)
 {
   guint64 duration;
 
-  if (shuttling)
+  if (app->shuttling)
     duration = 40 * GST_MSECOND;
   else
     duration = -1;
 
-  gst_element_send_event (element,
-      gst_event_new_step (GST_FORMAT_TIME, duration, shuttle_rate, FALSE,
+  gst_element_send_event (app->pipeline,
+      gst_event_new_step (GST_FORMAT_TIME, duration, app->shuttle_rate, FALSE,
           FALSE));
 }
 
 static void
-msg_sync_step_done (GstBus * bus, GstMessage * message, GstElement * element)
+msg_sync_step_done (GstBus * bus, GstMessage * message, SeekApp * app)
 {
   GstFormat format;
   guint64 amount;
@@ -1333,10 +1481,10 @@ msg_sync_step_done (GstBus * bus, GstMessage * message, GstElement * element)
     return;
   }
 
-  if (g_mutex_trylock (&state_mutex)) {
-    if (shuttling)
-      do_shuttle (element);
-    g_mutex_unlock (&state_mutex);
+  if (g_mutex_trylock (&app->state_mutex)) {
+    if (app->shuttling)
+      do_shuttle (app);
+    g_mutex_unlock (&app->state_mutex);
   } else {
     /* ignore step messages that come while we are doing a state change */
     g_print ("state change is busy\n");
@@ -1344,123 +1492,278 @@ msg_sync_step_done (GstBus * bus, GstMessage * message, GstElement * element)
 }
 
 static void
-shuttle_toggled (GtkToggleButton * button, GstElement * element)
+shuttle_toggled (GtkToggleButton * button, SeekApp * app)
 {
   gboolean active;
 
   active = gtk_toggle_button_get_active (button);
 
-  if (active != shuttling) {
-    shuttling = active;
-    g_print ("shuttling %s\n", shuttling ? "active" : "inactive");
+  if (active != app->shuttling) {
+    app->shuttling = active;
+    g_print ("shuttling %s\n", app->shuttling ? "active" : "inactive");
     if (active) {
-      shuttle_rate = 0.0;
-      play_rate = 1.0;
-      pause_cb (NULL, NULL);
-      gst_element_get_state (element, NULL, NULL, -1);
+      app->shuttle_rate = 0.0;
+      app->play_rate = 1.0;
+      pause_cb (NULL, app);
+      gst_element_get_state (app->pipeline, NULL, NULL, -1);
     }
   }
 }
 
 static void
-shuttle_rate_switch (GstElement * element)
+shuttle_rate_switch (SeekApp * app)
 {
   GstSeekFlags flags;
   GstEvent *s_event;
   gboolean res;
 
-  if (state == GST_STATE_PLAYING) {
+  if (app->state == GST_STATE_PLAYING) {
     /* pause when we need to */
-    pause_cb (NULL, NULL);
-    gst_element_get_state (element, NULL, NULL, -1);
+    pause_cb (NULL, app);
+    gst_element_get_state (app->pipeline, NULL, NULL, -1);
   }
 
-  if (play_rate == 1.0)
-    play_rate = -1.0;
+  if (app->play_rate == 1.0)
+    app->play_rate = -1.0;
   else
-    play_rate = 1.0;
+    app->play_rate = 1.0;
 
-  g_print ("rate changed to %lf %" GST_TIME_FORMAT "\n", play_rate,
-      GST_TIME_ARGS (position));
+  g_print ("rate changed to %lf %" GST_TIME_FORMAT "\n", app->play_rate,
+      GST_TIME_ARGS (app->position));
 
   flags = GST_SEEK_FLAG_FLUSH;
   flags |= GST_SEEK_FLAG_ACCURATE;
 
-  if (play_rate >= 0.0) {
-    s_event = gst_event_new_seek (play_rate,
-        GST_FORMAT_TIME, flags, GST_SEEK_TYPE_SET, position,
+  if (app->play_rate >= 0.0) {
+    s_event = gst_event_new_seek (app->play_rate,
+        GST_FORMAT_TIME, flags, GST_SEEK_TYPE_SET, app->position,
         GST_SEEK_TYPE_SET, GST_CLOCK_TIME_NONE);
   } else {
-    s_event = gst_event_new_seek (play_rate,
+    s_event = gst_event_new_seek (app->play_rate,
         GST_FORMAT_TIME, flags, GST_SEEK_TYPE_SET, G_GINT64_CONSTANT (0),
-        GST_SEEK_TYPE_SET, position);
+        GST_SEEK_TYPE_SET, app->position);
   }
-  res = send_event (s_event);
+  res = send_event (app, s_event);
   if (res) {
-    gst_element_get_state (element, NULL, NULL, SEEK_TIMEOUT);
+    gst_element_get_state (app->pipeline, NULL, NULL, SEEK_TIMEOUT);
   } else {
     g_print ("seek failed\n");
   }
 }
 
 static void
-shuttle_value_changed (GtkRange * range, GstElement * element)
+shuttle_value_changed (GtkRange * range, SeekApp * app)
 {
   gdouble rate;
 
-  rate = gtk_adjustment_get_value (shuttle_adjustment);
+  rate = gtk_range_get_value (range);
 
   if (rate == 0.0) {
     g_print ("rate 0.0, pause\n");
-    pause_cb (NULL, NULL);
-    gst_element_get_state (element, NULL, NULL, -1);
+    pause_cb (NULL, app);
+    gst_element_get_state (app->pipeline, NULL, NULL, -1);
   } else {
     g_print ("rate changed %0.3g\n", rate);
 
-    if ((rate < 0.0 && play_rate > 0.0) || (rate > 0.0 && play_rate < 0.0)) {
-      shuttle_rate_switch (element);
+    if ((rate < 0.0 && app->play_rate > 0.0) || (rate > 0.0
+            && app->play_rate < 0.0)) {
+      shuttle_rate_switch (app);
     }
 
-    shuttle_rate = ABS (rate);
-    if (state != GST_STATE_PLAYING) {
-      do_shuttle (element);
-      play_cb (NULL, NULL);
+    app->shuttle_rate = ABS (rate);
+    if (app->state != GST_STATE_PLAYING) {
+      do_shuttle (app);
+      play_cb (NULL, app);
     }
   }
 }
 
 static void
-msg_async_done (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
+colorbalance_value_changed (GtkRange * range, SeekApp * app)
+{
+  const gchar *label;
+  gdouble val;
+  gint ival;
+  GstColorBalanceChannel *channel = NULL;
+  const GList *channels, *l;
+
+  if (range == GTK_RANGE (app->contrast_scale))
+    label = "CONTRAST";
+  else if (range == GTK_RANGE (app->brightness_scale))
+    label = "BRIGHTNESS";
+  else if (range == GTK_RANGE (app->hue_scale))
+    label = "HUE";
+  else if (range == GTK_RANGE (app->saturation_scale))
+    label = "SATURATION";
+  else
+    g_assert_not_reached ();
+
+  val = gtk_range_get_value (range);
+
+  g_print ("colorbalance %s value changed %lf\n", label, val / N_GRAD);
+
+  if (!app->colorbalance_element) {
+    find_interface_elements (app);
+    if (!app->colorbalance_element)
+      return;
+  }
+
+  channels =
+      gst_color_balance_list_channels (GST_COLOR_BALANCE
+      (app->colorbalance_element));
+  for (l = channels; l; l = l->next) {
+    GstColorBalanceChannel *tmp = l->data;
+
+    if (g_strrstr (tmp->label, label)) {
+      channel = tmp;
+      break;
+    }
+  }
+
+  if (!channel)
+    return;
+
+  ival =
+      (gint) (0.5 + channel->min_value +
+      (val / N_GRAD) * ((gdouble) channel->max_value -
+          (gdouble) channel->min_value));
+  gst_color_balance_set_value (GST_COLOR_BALANCE (app->colorbalance_element),
+      channel, ival);
+}
+
+static void
+seek_format_changed_cb (GtkComboBox * box, SeekApp * app)
+{
+  gchar *format_str;
+  GList *l;
+  const GstFormatDefinition *format = NULL;
+
+  format_str = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (box));
+
+  for (l = app->formats; l; l = l->next) {
+    const GstFormatDefinition *tmp = l->data;
+
+    if (g_strcmp0 (tmp->nick, format_str) == 0) {
+      format = tmp;
+      break;
+    }
+  }
+
+  if (!format)
+    goto done;
+
+  app->seek_format = format;
+  update_scale (app);
+
+done:
+  g_free (format_str);
+}
+
+static void
+update_formats (SeekApp * app)
+{
+  GstIterator *it;
+  gboolean done;
+  GList *l;
+  GValue item = { 0, };
+  gchar *selected;
+  gint selected_idx = 0, i;
+
+  selected =
+      gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT
+      (app->seek_format_combo));
+  if (selected == NULL)
+    selected = g_strdup ("time");
+
+  it = gst_format_iterate_definitions ();
+  done = FALSE;
+
+  g_list_free (app->formats);
+  app->formats = NULL;
+
+  while (!done) {
+    switch (gst_iterator_next (it, &item)) {
+      case GST_ITERATOR_OK:{
+        GstFormatDefinition *def = g_value_get_pointer (&item);
+
+        app->formats = g_list_prepend (app->formats, def);
+        g_value_reset (&item);
+        break;
+      }
+      case GST_ITERATOR_RESYNC:
+        g_list_free (app->formats);
+        app->formats = NULL;
+        gst_iterator_resync (it);
+        break;
+      case GST_ITERATOR_ERROR:
+      case GST_ITERATOR_DONE:
+      default:
+        done = TRUE;
+        break;
+    }
+  }
+  g_value_unset (&item);
+
+  app->formats = g_list_reverse (app->formats);
+  gst_iterator_free (it);
+
+  g_signal_handlers_block_by_func (app->seek_format_combo,
+      seek_format_changed_cb, app);
+  gtk_combo_box_text_remove_all (GTK_COMBO_BOX_TEXT (app->seek_format_combo));
+
+  for (i = 0, l = app->formats; l; l = l->next, i++) {
+    const GstFormatDefinition *def = l->data;
+
+    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (app->seek_format_combo),
+        def->nick);
+    if (g_strcmp0 (def->nick, selected) == 0)
+      selected_idx = i;
+  }
+  g_signal_handlers_unblock_by_func (app->seek_format_combo,
+      seek_format_changed_cb, app);
+
+  gtk_combo_box_set_active (GTK_COMBO_BOX (app->seek_format_combo),
+      selected_idx);
+
+  g_free (selected);
+}
+
+static void
+msg_async_done (GstBus * bus, GstMessage * message, SeekApp * app)
 {
   GST_DEBUG ("async done");
+
+  /* Now query all available GstFormats */
+  update_formats (app);
+
   /* when we get ASYNC_DONE we can query position, duration and other
    * properties */
-  update_scale (pipeline);
+  update_scale (app);
 
   /* update the available streams */
-  update_streams (pipeline);
+  update_streams (app);
 
-  find_navigation_element ();
+  find_interface_elements (app);
 }
 
 static void
-msg_state_changed (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
+msg_state_changed (GstBus * bus, GstMessage * message, SeekApp * app)
 {
   const GstStructure *s;
 
   s = gst_message_get_structure (message);
 
   /* We only care about state changed on the pipeline */
-  if (s && GST_MESSAGE_SRC (message) == GST_OBJECT_CAST (pipeline)) {
+  if (s && GST_MESSAGE_SRC (message) == GST_OBJECT_CAST (app->pipeline)) {
     GstState old, new, pending;
 
     gst_message_parse_state_changed (message, &old, &new, &pending);
 
     /* When state of the pipeline changes to paused or playing we start updating scale */
     if (new == GST_STATE_PLAYING) {
-      set_update_scale (TRUE);
+      set_update_scale (app, TRUE);
     } else {
-      set_update_scale (FALSE);
+      set_update_scale (app, FALSE);
     }
 
     /* dump graph for (some) pipeline state changes */
@@ -1470,7 +1773,7 @@ msg_state_changed (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
       dump_name = g_strdup_printf ("seek.%s_%s",
           gst_element_state_get_name (old), gst_element_state_get_name (new));
 
-      GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline),
+      GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (app->pipeline),
           GST_DEBUG_GRAPH_SHOW_ALL, dump_name);
 
       g_free (dump_name);
@@ -1479,33 +1782,34 @@ msg_state_changed (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
 }
 
 static void
-msg_segment_done (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
+msg_segment_done (GstBus * bus, GstMessage * message, SeekApp * app)
 {
   GstEvent *s_event;
   GstSeekFlags flags;
   gboolean res;
   GstFormat format;
 
-  GST_DEBUG ("position is %" GST_TIME_FORMAT, GST_TIME_ARGS (position));
-  gst_message_parse_segment_done (message, &format, &position);
-  GST_DEBUG ("end of segment at %" GST_TIME_FORMAT, GST_TIME_ARGS (position));
+  GST_DEBUG ("position is %" GST_TIME_FORMAT, GST_TIME_ARGS (app->position));
+  gst_message_parse_segment_done (message, &format, &app->position);
+  GST_DEBUG ("end of segment at %" GST_TIME_FORMAT,
+      GST_TIME_ARGS (app->position));
 
   flags = 0;
   /* in the segment-done callback we never flush as this would not make sense
    * for seamless playback. */
-  if (loop_seek)
+  if (app->loop_seek)
     flags |= GST_SEEK_FLAG_SEGMENT;
-  if (skip_seek)
+  if (app->skip_seek)
     flags |= GST_SEEK_FLAG_SKIP;
 
-  s_event = gst_event_new_seek (rate,
+  s_event = gst_event_new_seek (app->rate,
       GST_FORMAT_TIME, flags, GST_SEEK_TYPE_SET, G_GINT64_CONSTANT (0),
-      GST_SEEK_TYPE_SET, duration);
+      GST_SEEK_TYPE_SET, app->duration);
 
   GST_DEBUG ("restart loop with rate %lf to 0 / %" GST_TIME_FORMAT,
-      rate, GST_TIME_ARGS (duration));
+      app->rate, GST_TIME_ARGS (app->duration));
 
-  res = send_event (s_event);
+  res = send_event (app, s_event);
   if (!res)
     g_print ("segment seek failed\n");
 }
@@ -1513,193 +1817,270 @@ msg_segment_done (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
 /* in stream buffering mode we PAUSE the pipeline until we receive a 100%
  * message */
 static void
-do_stream_buffering (gint percent)
+do_stream_buffering (SeekApp * app, gint percent)
 {
   gchar *bufstr;
 
-  gtk_statusbar_pop (GTK_STATUSBAR (statusbar), status_id);
+  gtk_statusbar_pop (GTK_STATUSBAR (app->statusbar), app->status_id);
   bufstr = g_strdup_printf ("Buffering...%d", percent);
-  gtk_statusbar_push (GTK_STATUSBAR (statusbar), status_id, bufstr);
+  gtk_statusbar_push (GTK_STATUSBAR (app->statusbar), app->status_id, bufstr);
   g_free (bufstr);
 
   if (percent == 100) {
     /* a 100% message means buffering is done */
-    buffering = FALSE;
+    app->buffering = FALSE;
     /* if the desired state is playing, go back */
-    if (state == GST_STATE_PLAYING) {
+    if (app->state == GST_STATE_PLAYING) {
       /* no state management needed for live pipelines */
-      if (!is_live) {
+      if (!app->is_live) {
         fprintf (stderr, "Done buffering, setting pipeline to PLAYING ...\n");
-        gst_element_set_state (pipeline, GST_STATE_PLAYING);
+        gst_element_set_state (app->pipeline, GST_STATE_PLAYING);
       }
-      gtk_statusbar_pop (GTK_STATUSBAR (statusbar), status_id);
-      gtk_statusbar_push (GTK_STATUSBAR (statusbar), status_id, "Playing");
+      gtk_statusbar_pop (GTK_STATUSBAR (app->statusbar), app->status_id);
+      gtk_statusbar_push (GTK_STATUSBAR (app->statusbar), app->status_id,
+          "Playing");
     }
   } else {
     /* buffering busy */
-    if (buffering == FALSE && state == GST_STATE_PLAYING) {
+    if (app->buffering == FALSE && app->state == GST_STATE_PLAYING) {
       /* we were not buffering but PLAYING, PAUSE  the pipeline. */
-      if (!is_live) {
+      if (!app->is_live) {
         fprintf (stderr, "Buffering, setting pipeline to PAUSED ...\n");
-        gst_element_set_state (pipeline, GST_STATE_PAUSED);
+        gst_element_set_state (app->pipeline, GST_STATE_PAUSED);
       }
     }
-    buffering = TRUE;
+    app->buffering = TRUE;
   }
 }
 
 static void
-do_download_buffering (gint percent)
+do_download_buffering (SeekApp * app, gint percent)
 {
-  if (!buffering && percent < 100) {
+  if (!app->buffering && percent < 100) {
     gchar *bufstr;
 
-    buffering = TRUE;
+    app->buffering = TRUE;
 
     bufstr = g_strdup_printf ("Downloading...");
-    gtk_statusbar_push (GTK_STATUSBAR (statusbar), status_id, bufstr);
+    gtk_statusbar_push (GTK_STATUSBAR (app->statusbar), app->status_id, bufstr);
     g_free (bufstr);
 
     /* once we get a buffering message, we'll do the fill update */
-    set_update_fill (TRUE);
+    set_update_fill (app, TRUE);
 
-    if (state == GST_STATE_PLAYING && !is_live) {
+    if (app->state == GST_STATE_PLAYING && !app->is_live) {
       fprintf (stderr, "Downloading, setting pipeline to PAUSED ...\n");
-      gst_element_set_state (pipeline, GST_STATE_PAUSED);
+      gst_element_set_state (app->pipeline, GST_STATE_PAUSED);
       /* user has to manually start the playback */
-      state = GST_STATE_PAUSED;
+      app->state = GST_STATE_PAUSED;
     }
   }
 }
 
 static void
-msg_buffering (GstBus * bus, GstMessage * message, GstPipeline * data)
+msg_buffering (GstBus * bus, GstMessage * message, SeekApp * app)
 {
   gint percent;
 
   gst_message_parse_buffering (message, &percent);
 
   /* get more stats */
-  gst_message_parse_buffering_stats (message, &mode, NULL, NULL,
-      &buffering_left);
+  gst_message_parse_buffering_stats (message, &app->mode, NULL, NULL,
+      &app->buffering_left);
 
-  switch (mode) {
+  switch (app->mode) {
     case GST_BUFFERING_DOWNLOAD:
-      do_download_buffering (percent);
+      do_download_buffering (app, percent);
       break;
     case GST_BUFFERING_LIVE:
-      is_live = TRUE;
+      app->is_live = TRUE;
     case GST_BUFFERING_TIMESHIFT:
     case GST_BUFFERING_STREAM:
-      do_stream_buffering (percent);
+      do_stream_buffering (app, percent);
       break;
   }
 }
 
 static void
-msg_clock_lost (GstBus * bus, GstMessage * message, GstPipeline * data)
+msg_clock_lost (GstBus * bus, GstMessage * message, SeekApp * app)
 {
   g_print ("clock lost! PAUSE and PLAY to select a new clock\n");
-  if (state == GST_STATE_PLAYING) {
-    gst_element_set_state (pipeline, GST_STATE_PAUSED);
-    gst_element_set_state (pipeline, GST_STATE_PLAYING);
+  if (app->state == GST_STATE_PLAYING) {
+    gst_element_set_state (app->pipeline, GST_STATE_PAUSED);
+    gst_element_set_state (app->pipeline, GST_STATE_PLAYING);
   }
 }
 
-static GstElement *navigation_element = NULL;
+static gboolean
+is_valid_color_balance_element (GstElement * element)
+{
+  GstColorBalance *bal = GST_COLOR_BALANCE (element);
+  gboolean have_brightness = FALSE;
+  gboolean have_contrast = FALSE;
+  gboolean have_hue = FALSE;
+  gboolean have_saturation = FALSE;
+  const GList *channels, *l;
+
+  channels = gst_color_balance_list_channels (bal);
+  for (l = channels; l; l = l->next) {
+    GstColorBalanceChannel *ch = l->data;
+
+    if (g_strrstr (ch->label, "BRIGHTNESS"))
+      have_brightness = TRUE;
+    else if (g_strrstr (ch->label, "CONTRAST"))
+      have_contrast = TRUE;
+    else if (g_strrstr (ch->label, "HUE"))
+      have_hue = TRUE;
+    else if (g_strrstr (ch->label, "SATURATION"))
+      have_saturation = TRUE;
+  }
+
+  return have_brightness && have_contrast && have_hue && have_saturation;
+}
 
 static void
-find_navigation_element (void)
+find_interface_elements (SeekApp * app)
 {
-  GstElement *video_sink;
+  GstIterator *it;
+  GValue item = { 0, };
+  gboolean done = FALSE, hardware = FALSE;
 
-  g_object_get (pipeline, "video-sink", &video_sink, NULL);
-  if (!video_sink)
+  if (app->pipeline_type == 0)
     return;
 
-  if (navigation_element)
-    gst_object_unref (navigation_element);
+  if (app->navigation_element)
+    gst_object_unref (app->navigation_element);
+  app->navigation_element = NULL;
+
+  if (app->colorbalance_element)
+    gst_object_unref (app->colorbalance_element);
+  app->colorbalance_element = NULL;
+
+  app->navigation_element =
+      gst_bin_get_by_interface (GST_BIN (app->pipeline), GST_TYPE_NAVIGATION);
+
+  it = gst_bin_iterate_all_by_interface (GST_BIN (app->pipeline),
+      GST_TYPE_COLOR_BALANCE);
+  while (!done) {
+    switch (gst_iterator_next (it, &item)) {
+      case GST_ITERATOR_OK:{
+        GstElement *element = GST_ELEMENT (g_value_get_object (&item));
+
+        if (is_valid_color_balance_element (element)) {
+          if (!app->colorbalance_element) {
+            app->colorbalance_element =
+                GST_ELEMENT_CAST (gst_object_ref (element));
+            hardware =
+                (gst_color_balance_get_balance_type (GST_COLOR_BALANCE
+                    (element)) == GST_COLOR_BALANCE_HARDWARE);
+          } else if (!hardware) {
+            gboolean tmp =
+                (gst_color_balance_get_balance_type (GST_COLOR_BALANCE
+                    (element)) == GST_COLOR_BALANCE_HARDWARE);
+
+            if (tmp) {
+              if (app->colorbalance_element)
+                gst_object_unref (app->colorbalance_element);
+              app->colorbalance_element =
+                  GST_ELEMENT_CAST (gst_object_ref (element));
+              hardware = TRUE;
+            }
+          }
+        }
 
-  if (GST_IS_NAVIGATION (video_sink)) {
-    navigation_element = gst_object_ref (video_sink);
-  } else if (GST_IS_BIN (video_sink)) {
-    navigation_element =
-        gst_bin_get_by_interface (GST_BIN (video_sink), GST_TYPE_NAVIGATION);
-  } else {
-    navigation_element = NULL;
+        g_value_reset (&item);
+
+        if (hardware && app->colorbalance_element)
+          done = TRUE;
+        break;
+      }
+      case GST_ITERATOR_RESYNC:
+        gst_iterator_resync (it);
+        done = FALSE;
+        hardware = FALSE;
+        if (app->colorbalance_element)
+          gst_object_unref (app->colorbalance_element);
+        app->colorbalance_element = NULL;
+        break;
+      case GST_ITERATOR_DONE:
+      case GST_ITERATOR_ERROR:
+      default:
+        done = TRUE;
+    }
   }
 
-  gst_object_unref (video_sink);
+  g_value_unset (&item);
+  gst_iterator_free (it);
 }
 
 /* called when Navigation command button is pressed */
 static void
-navigation_cmd_cb (GtkButton * button, gpointer data)
+navigation_cmd_cb (GtkButton * button, SeekApp * app)
 {
-  GstNavigationCommand cmd = GPOINTER_TO_INT (data);
+  GstNavigationCommand cmd = GST_NAVIGATION_COMMAND_INVALID;
+  gint i;
 
-  if (!navigation_element) {
-    find_navigation_element ();
-    if (!navigation_element)
+  if (!app->navigation_element) {
+    find_interface_elements (app);
+    if (!app->navigation_element)
       return;
   }
 
-  gst_navigation_send_command (GST_NAVIGATION (navigation_element), cmd);
+  for (i = 0; i < G_N_ELEMENTS (app->navigation_buttons); i++) {
+    if (app->navigation_buttons[i].button == GTK_WIDGET (button)) {
+      cmd = app->navigation_buttons[i].cmd;
+      break;
+    }
+  }
+
+  if (cmd != GST_NAVIGATION_COMMAND_INVALID)
+    gst_navigation_send_command (GST_NAVIGATION (app->navigation_element), cmd);
 }
 
 #if defined (GDK_WINDOWING_X11) || defined (GDK_WINDOWING_WIN32) || defined (GDK_WINDOWING_QUARTZ)
-
-static GstElement *overlay_element = NULL;
-static guintptr embed_handle = 0;
-
-/* We set the xid here in response to the prepare-window-handle message via a
+/* We set the xid here in response to the prepare-xwindow-id message via a
  * bus sync handler because we don't know the actual videosink used from the
  * start (as we don't know the pipeline, or bin elements such as autovideosink
  * or gconfvideosink may be used which create the actual videosink only once
  * the pipeline is started) */
 static GstBusSyncReply
-bus_sync_handler (GstBus * bus, GstMessage * message, GstPipeline * data)
+bus_sync_handler (GstBus * bus, GstMessage * message, SeekApp * app)
 {
-  GstElement *element;
+  if (gst_is_video_overlay_prepare_window_handle_message (message)) {
+    GstElement *element = GST_ELEMENT (GST_MESSAGE_SRC (message));
 
-  if (!gst_is_video_overlay_prepare_window_handle_message (message))
-    return GST_BUS_PASS;
+    if (app->overlay_element)
+      gst_object_unref (app->overlay_element);
+    app->overlay_element = GST_ELEMENT (gst_object_ref (element));
 
-  element = GST_ELEMENT (GST_MESSAGE_SRC (message));
+    g_print ("got prepare-xwindow-id, setting XID %" G_GUINTPTR_FORMAT "\n",
+        app->embed_xid);
 
-  if (overlay_element)
-    gst_object_unref (overlay_element);
-  overlay_element = GST_ELEMENT (gst_object_ref (element));
-
-  if (g_object_class_find_property (G_OBJECT_GET_CLASS (element),
-          "force-aspect-ratio")) {
-    g_object_set (element, "force-aspect-ratio", TRUE, NULL);
-  }
-
-  /* Should have been initialised from main thread before (can't use
-   * GDK_WINDOW_XID here with Gtk+ >= 2.18, because the sync handler will
-   * be called from a streaming thread and GDK_WINDOW_XID maps to more than
-   * a simple structure lookup with Gtk+ >= 2.18, where 'more' is stuff that
-   * shouldn't be done from a non-GUI thread without explicit locking).  */
-  g_assert (embed_handle != 0);
-
-  g_print ("got prepare-window-handle, setting handle %" G_GUINTPTR_FORMAT "\n",
-      embed_handle);
+    if (g_object_class_find_property (G_OBJECT_GET_CLASS (element),
+            "force-aspect-ratio")) {
+      g_object_set (element, "force-aspect-ratio", TRUE, NULL);
+    }
 
-  gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (element),
-      embed_handle);
-  gst_video_overlay_handle_events (GST_VIDEO_OVERLAY (element), FALSE);
+    /* Should have been initialised from main thread before (can't use
+     * GDK_WINDOW_XID here with Gtk+ >= 2.18, because the sync handler will
+     * be called from a streaming thread and GDK_WINDOW_XID maps to more than
+     * a simple structure lookup with Gtk+ >= 2.18, where 'more' is stuff that
+     * shouldn't be done from a non-GUI thread without explicit locking).  */
+    g_assert (app->embed_xid != 0);
 
-  find_navigation_element ();
+    gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (element),
+        app->embed_xid);
 
+    find_interface_elements (app);
+  }
   return GST_BUS_PASS;
 }
 #endif
 
 static gboolean
-draw_cb (GtkWidget * widget, cairo_t * cr, gpointer data)
+draw_cb (GtkWidget * widget, cairo_t * cr, SeekApp * app)
 {
-  if (state < GST_STATE_PAUSED) {
+  if (app->state < GST_STATE_PAUSED) {
     int width, height;
 
     width = gtk_widget_get_allocated_width (widget);
@@ -1710,14 +2091,14 @@ draw_cb (GtkWidget * widget, cairo_t * cr, gpointer data)
     return TRUE;
   }
 
-  if (overlay_element)
-    gst_video_overlay_expose (GST_VIDEO_OVERLAY (overlay_element));
+  if (app->overlay_element)
+    gst_video_overlay_expose (GST_VIDEO_OVERLAY (app->overlay_element));
 
   return FALSE;
 }
 
 static void
-realize_cb (GtkWidget * widget, gpointer data)
+realize_cb (GtkWidget * widget, SeekApp * app)
 {
   GdkWindow *window = gtk_widget_get_window (widget);
 
@@ -1727,97 +2108,97 @@ realize_cb (GtkWidget * widget, gpointer data)
     g_error ("Couldn't create native window needed for GstXOverlay!");
 
 #if defined (GDK_WINDOWING_WIN32)
-  embed_handle = GDK_WINDOW_HWND (window);
-  g_print ("Window realize: video window HWND = %lu\n", embed_handle);
+  app->embed_xid = GDK_WINDOW_HWND (window);
+  g_print ("Window realize: video window HWND = %lu\n", app->embed_xid);
 #elif defined (GDK_WINDOWING_QUARTZ)
-  embed_handle = gdk_quartz_window_get_nsview (window);
-  g_print ("Window realize: video window NSView = %p\n", embed_handle);
+  app->embed_xid = gdk_quartz_window_get_nsview (window);
+  g_print ("Window realize: video window NSView = %p\n", app->embed_xid);
 #elif defined (GDK_WINDOWING_X11)
-  embed_handle = GDK_WINDOW_XID (window);
+  app->embed_xid = GDK_WINDOW_XID (window);
   g_print ("Window realize: video window XID = %" G_GUINTPTR_FORMAT "\n",
-      embed_handle);
+      app->embed_xid);
 #endif
 }
 
 static gboolean
-button_press_cb (GtkWidget * widget, GdkEventButton * event, gpointer user_data)
+button_press_cb (GtkWidget * widget, GdkEventButton * event, SeekApp * app)
 {
   gtk_widget_grab_focus (widget);
 
-  if (navigation_element)
-    gst_navigation_send_mouse_event (GST_NAVIGATION (navigation_element),
+  if (app->navigation_element)
+    gst_navigation_send_mouse_event (GST_NAVIGATION (app->navigation_element),
         "mouse-button-press", event->button, event->x, event->y);
 
   return FALSE;
 }
 
 static gboolean
-button_release_cb (GtkWidget * widget, GdkEventButton * event,
-    gpointer user_data)
+button_release_cb (GtkWidget * widget, GdkEventButton * event, SeekApp * app)
 {
-  if (navigation_element)
-    gst_navigation_send_mouse_event (GST_NAVIGATION (navigation_element),
+  if (app->navigation_element)
+    gst_navigation_send_mouse_event (GST_NAVIGATION (app->navigation_element),
         "mouse-button-release", event->button, event->x, event->y);
 
   return FALSE;
 }
 
 static gboolean
-key_press_cb (GtkWidget * widget, GdkEventKey * event, gpointer user_data)
+key_press_cb (GtkWidget * widget, GdkEventKey * event, SeekApp * app)
 {
-  if (navigation_element)
-    gst_navigation_send_key_event (GST_NAVIGATION (navigation_element),
+  if (app->navigation_element)
+    gst_navigation_send_key_event (GST_NAVIGATION (app->navigation_element),
         "key-press", gdk_keyval_name (event->keyval));
 
   return FALSE;
 }
 
 static gboolean
-key_release_cb (GtkWidget * widget, GdkEventKey * event, gpointer user_data)
+key_release_cb (GtkWidget * widget, GdkEventKey * event, SeekApp * app)
 {
-  if (navigation_element)
-    gst_navigation_send_key_event (GST_NAVIGATION (navigation_element),
+  if (app->navigation_element)
+    gst_navigation_send_key_event (GST_NAVIGATION (app->navigation_element),
         "key-release", gdk_keyval_name (event->keyval));
 
   return FALSE;
 }
 
 static gboolean
-motion_notify_cb (GtkWidget * widget, GdkEventMotion * event,
-    gpointer user_data)
+motion_notify_cb (GtkWidget * widget, GdkEventMotion * event, SeekApp * app)
 {
-  if (navigation_element)
-    gst_navigation_send_mouse_event (GST_NAVIGATION (navigation_element),
+  if (app->navigation_element)
+    gst_navigation_send_mouse_event (GST_NAVIGATION (app->navigation_element),
         "mouse-move", 0, event->x, event->y);
 
   return FALSE;
 }
 
 static void
-msg_eos (GstBus * bus, GstMessage * message, GstPipeline * data)
+msg_eos (GstBus * bus, GstMessage * message, SeekApp * app)
 {
-  message_received (bus, message, data);
+  message_received (bus, message, app);
 
   /* Set new uri for playerbins and continue playback */
-  if (l && (pipeline_type == 14 || pipeline_type == 16)) {
-    stop_cb (NULL, NULL);
-    l = g_list_next (l);
-    if (l) {
-      playerbin_set_uri (GST_ELEMENT (data), l->data);
-      play_cb (NULL, NULL);
+  if (app->current_path && app->pipeline_type == 0) {
+    stop_cb (NULL, app);
+    app->current_path = g_list_next (app->current_path);
+    app->current_sub_path = g_list_next (app->current_sub_path);
+    if (app->current_path) {
+      playbin_set_uri (app->pipeline, app->current_path->data,
+          app->current_sub_path ? app->current_sub_path->data : NULL);
+      play_cb (NULL, app);
     }
   }
 }
 
 static void
-msg_step_done (GstBus * bus, GstMessage * message, GstPipeline * data)
+msg_step_done (GstBus * bus, GstMessage * message, SeekApp * app)
 {
-  if (!shuttling)
-    message_received (bus, message, data);
+  if (!app->shuttling)
+    message_received (bus, message, app);
 }
 
 static void
-msg (GstBus * bus, GstMessage * message, GstPipeline * data)
+msg (GstBus * bus, GstMessage * message, SeekApp * app)
 {
   GstNavigationMessageType nav_type;
 
@@ -1831,8 +2212,8 @@ msg (GstBus * bus, GstMessage * message, GstPipeline * data)
       query = gst_navigation_query_new_commands ();
       res = gst_element_query (GST_ELEMENT (GST_MESSAGE_SRC (message)), query);
 
-      for (j = 0; j < G_N_ELEMENTS (navigation_buttons); j++)
-        gtk_widget_set_sensitive (navigation_buttons[j].button, FALSE);
+      for (j = 0; j < G_N_ELEMENTS (app->navigation_buttons); j++)
+        gtk_widget_set_sensitive (app->navigation_buttons[j].button, FALSE);
 
       if (res) {
         gboolean is_menu = FALSE;
@@ -1851,21 +2232,23 @@ msg (GstBus * bus, GstMessage * message, GstPipeline * data)
             is_menu |= (cmd == GST_NAVIGATION_COMMAND_UP);
             is_menu |= (cmd == GST_NAVIGATION_COMMAND_DOWN);
 
-            for (j = 0; j < G_N_ELEMENTS (navigation_buttons); j++) {
-              if (navigation_buttons[j].cmd != cmd)
+            for (j = 0; j < G_N_ELEMENTS (app->navigation_buttons); j++) {
+              if (app->navigation_buttons[j].cmd != cmd)
                 continue;
 
-              gtk_widget_set_sensitive (navigation_buttons[j].button, TRUE);
+              gtk_widget_set_sensitive (app->navigation_buttons[j].button,
+                  TRUE);
             }
           }
         }
 
-        gtk_widget_set_sensitive (GTK_WIDGET (hscale), !is_menu);
+        gtk_widget_set_sensitive (GTK_WIDGET (app->seek_scale), !is_menu);
       } else {
         g_assert_not_reached ();
       }
 
       gst_query_unref (query);
+      message_received (bus, message, app);
       break;
     }
     default:
@@ -1874,50 +2257,48 @@ msg (GstBus * bus, GstMessage * message, GstPipeline * data)
 }
 
 static void
-connect_bus_signals (GstElement * pipeline)
+connect_bus_signals (SeekApp * app)
 {
-  GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
+  GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (app->pipeline));
 
 #if defined (GDK_WINDOWING_X11) || defined (GDK_WINDOWING_WIN32) || defined (GDK_WINDOWING_QUARTZ)
-  /* handle prepare-window-handle element message synchronously */
-  gst_bus_set_sync_handler (bus, (GstBusSyncHandler) bus_sync_handler,
-      pipeline);
+  if (app->pipeline_type != 0) {
+    /* handle prepare-xwindow-id element message synchronously, but only for non-playbin */
+    gst_bus_set_sync_handler (bus, (GstBusSyncHandler) bus_sync_handler, app);
+  }
 #endif
 
   gst_bus_add_signal_watch_full (bus, G_PRIORITY_HIGH);
   gst_bus_enable_sync_message_emission (bus);
 
   g_signal_connect (bus, "message::state-changed",
-      (GCallback) msg_state_changed, pipeline);
-  g_signal_connect (bus, "message::segment-done", (GCallback) msg_segment_done,
-      pipeline);
-  g_signal_connect (bus, "message::async-done", (GCallback) msg_async_done,
-      pipeline);
-
-  g_signal_connect (bus, "message::new-clock", (GCallback) message_received,
-      pipeline);
-  g_signal_connect (bus, "message::clock-lost", (GCallback) msg_clock_lost,
-      pipeline);
-  g_signal_connect (bus, "message::error", (GCallback) message_received,
-      pipeline);
-  g_signal_connect (bus, "message::warning", (GCallback) message_received,
-      pipeline);
-  g_signal_connect (bus, "message::eos", (GCallback) msg_eos, pipeline);
-  g_signal_connect (bus, "message::tag", (GCallback) message_received,
-      pipeline);
-  g_signal_connect (bus, "message::element", (GCallback) message_received,
-      pipeline);
-  g_signal_connect (bus, "message::segment-done", (GCallback) message_received,
-      pipeline);
-  g_signal_connect (bus, "message::buffering", (GCallback) msg_buffering,
-      pipeline);
-//  g_signal_connect (bus, "message::step-done", (GCallback) msg_step_done,
-//      pipeline);
-  g_signal_connect (bus, "message::step-start", (GCallback) msg_step_done,
-      pipeline);
+      G_CALLBACK (msg_state_changed), app);
+  g_signal_connect (bus, "message::segment-done", G_CALLBACK (msg_segment_done),
+      app);
+  g_signal_connect (bus, "message::async-done", G_CALLBACK (msg_async_done),
+      app);
+
+  g_signal_connect (bus, "message::new-clock", G_CALLBACK (message_received),
+      app);
+  g_signal_connect (bus, "message::clock-lost", G_CALLBACK (msg_clock_lost),
+      app);
+  g_signal_connect (bus, "message::error", G_CALLBACK (message_received), app);
+  g_signal_connect (bus, "message::warning", G_CALLBACK (message_received),
+      app);
+  g_signal_connect (bus, "message::eos", G_CALLBACK (msg_eos), app);
+  g_signal_connect (bus, "message::tag", G_CALLBACK (message_received), app);
+  g_signal_connect (bus, "message::element", G_CALLBACK (message_received),
+      app);
+  g_signal_connect (bus, "message::segment-done", G_CALLBACK (message_received),
+      app);
+  g_signal_connect (bus, "message::buffering", G_CALLBACK (msg_buffering), app);
+//  g_signal_connect (bus, "message::step-done", G_CALLBACK (msg_step_done),
+//      app);
+  g_signal_connect (bus, "message::step-start", G_CALLBACK (msg_step_done),
+      app);
   g_signal_connect (bus, "sync-message::step-done",
-      (GCallback) msg_sync_step_done, pipeline);
-  g_signal_connect (bus, "message", (GCallback) msg, pipeline);
+      G_CALLBACK (msg_sync_step_done), app);
+  g_signal_connect (bus, "message", G_CALLBACK (msg), app);
 
   gst_object_unref (bus);
 }
@@ -1957,125 +2338,205 @@ out:
 }
 
 static void
-delete_event_cb (void)
+delete_event_cb (GtkWidget * widget, GdkEvent * event, SeekApp * app)
 {
-  stop_cb (NULL, NULL);
+  stop_cb (NULL, app);
   gtk_main_quit ();
 }
 
 static void
-print_usage (int argc, char **argv)
+video_sink_activate_cb (GtkEntry * entry, SeekApp * app)
 {
-  gint i;
+  GstElement *sink = NULL;
+  const gchar *text;
 
-  g_print ("usage: %s <type> <filename>\n", argv[0]);
-  g_print ("   possible types:\n");
-
-  for (i = 0; i < NUM_TYPES; i++) {
-    g_print ("     %d = %s\n", i, pipelines[i].name);
+  text = gtk_entry_get_text (entry);
+  if (text != NULL && *text != '\0') {
+    sink = gst_element_factory_make_or_warn (text, NULL);
   }
+
+  g_object_set (app->pipeline, "video-sink", sink, NULL);
 }
 
-int
-main (int argc, char **argv)
+static void
+audio_sink_activate_cb (GtkEntry * entry, SeekApp * app)
 {
-  GtkWidget *window, *hbox, *vbox, *panel, *expander, *pb2vbox, *boxes,
-      *flagtable, *boxes2, *step, *navigation;
-  GtkWidget *play_button, *pause_button, *stop_button, *shot_button;
-  GtkWidget *accurate_checkbox, *key_checkbox, *loop_checkbox, *flush_checkbox;
-  GtkWidget *scrub_checkbox, *play_scrub_checkbox;
-  GtkWidget *rate_label, *volume_label;
-  GOptionEntry options[] = {
-    {"audiosink", '\0', 0, G_OPTION_ARG_STRING, &opt_audiosink_str,
-        "audio sink to use (default: " DEFAULT_AUDIOSINK ")", NULL},
-    {"stats", 's', 0, G_OPTION_ARG_NONE, &stats,
-        "Show pad stats", NULL},
-    {"verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose,
-        "Verbose properties", NULL},
-    {"videosink", '\0', 0, G_OPTION_ARG_STRING, &opt_videosink_str,
-        "video sink to use (default: " DEFAULT_VIDEOSINK ")", NULL},
-    {NULL}
-  };
-  GOptionContext *ctx;
-  GError *err = NULL;
+  GstElement *sink = NULL;
+  const gchar *text;
 
-  ctx = g_option_context_new ("- test seeking in gsteamer");
-  g_option_context_add_main_entries (ctx, options, NULL);
-  g_option_context_add_group (ctx, gst_init_get_option_group ());
-  g_option_context_add_group (ctx, gtk_get_option_group (TRUE));
+  text = gtk_entry_get_text (entry);
+  if (text != NULL && *text != '\0') {
+    sink = gst_element_factory_make_or_warn (text, NULL);
+  }
 
-  if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
-    g_print ("Error initializing: %s\n", err->message);
-    exit (1);
+  g_object_set (app->pipeline, "audio-sink", sink, NULL);
+}
+
+static void
+text_sink_activate_cb (GtkEntry * entry, SeekApp * app)
+{
+  GstElement *sink = NULL;
+  const gchar *text;
+
+  text = gtk_entry_get_text (entry);
+  if (text != NULL && *text != '\0') {
+    sink = gst_element_factory_make_or_warn (text, NULL);
   }
 
-  if (opt_audiosink_str == NULL)
-    opt_audiosink_str = g_strdup (DEFAULT_AUDIOSINK);
+  g_object_set (app->pipeline, "text-sink", sink, NULL);
+}
 
-  if (opt_videosink_str == NULL)
-    opt_videosink_str = g_strdup (DEFAULT_VIDEOSINK);
+static void
+buffer_size_activate_cb (GtkEntry * entry, SeekApp * app)
+{
+  const gchar *text;
 
-  GST_DEBUG_CATEGORY_INIT (seek_debug, "seek", 0, "seek example");
+  text = gtk_entry_get_text (entry);
+  if (text != NULL && *text != '\0') {
+    gint v;
+    gchar *endptr;
 
-  if (argc != 3) {
-    print_usage (argc, argv);
-    exit (-1);
+    v = g_ascii_strtoll (text, &endptr, 10);
+    if (endptr != text && v != G_MAXINT64 && v != G_MININT64) {
+      g_object_set (app->pipeline, "buffer-size", v, NULL);
+    }
   }
+}
 
-  pipeline_type = atoi (argv[1]);
+static void
+buffer_duration_activate_cb (GtkEntry * entry, SeekApp * app)
+{
+  const gchar *text;
 
-  if (pipeline_type < 0 || pipeline_type >= NUM_TYPES) {
-    print_usage (argc, argv);
-    exit (-1);
+  text = gtk_entry_get_text (entry);
+  if (text != NULL && *text != '\0') {
+    gint64 v;
+    gchar *endptr;
+
+    v = g_ascii_strtoll (text, &endptr, 10);
+    if (endptr != text && v != G_MAXINT64 && v != G_MININT64) {
+      g_object_set (app->pipeline, "buffer-duration", v, NULL);
+    }
   }
+}
 
-  pipeline_spec = argv[2];
+static void
+ringbuffer_maxsize_activate_cb (GtkEntry * entry, SeekApp * app)
+{
+  const gchar *text;
 
-  if (g_path_is_absolute (pipeline_spec) &&
-      (g_strrstr (pipeline_spec, "*") != NULL ||
-          g_strrstr (pipeline_spec, "?") != NULL)) {
-    paths = handle_wildcards (pipeline_spec);
-  } else {
-    paths = g_list_prepend (paths, g_strdup (pipeline_spec));
+  text = gtk_entry_get_text (entry);
+  if (text != NULL && *text != '\0') {
+    guint64 v;
+    gchar *endptr;
+
+    v = g_ascii_strtoull (text, &endptr, 10);
+    if (endptr != text && v != G_MAXUINT64) {
+      g_object_set (app->pipeline, "ring-buffer-max-size", v, NULL);
+    }
   }
+}
 
-  if (!paths) {
-    g_print ("opening %s failed\n", pipeline_spec);
-    exit (-1);
+static void
+connection_speed_activate_cb (GtkEntry * entry, SeekApp * app)
+{
+  const gchar *text;
+
+  text = gtk_entry_get_text (entry);
+  if (text != NULL && *text != '\0') {
+    guint v;
+    gchar *endptr;
+
+    v = g_ascii_strtoll (text, &endptr, 10);
+    if (endptr != text && v != G_MAXINT64 && v != G_MININT64) {
+      g_object_set (app->pipeline, "connection-speed", v, NULL);
+    }
   }
+}
 
-  l = paths;
+static void
+subtitle_encoding_activate_cb (GtkEntry * entry, SeekApp * app)
+{
+  const gchar *text;
 
-  pipeline = pipelines[pipeline_type].func ((gchar *) l->data);
-  g_assert (pipeline);
+  text = gtk_entry_get_text (entry);
+  g_object_set (app->pipeline, "subtitle-encoding", text, NULL);
+}
+
+static void
+subtitle_fontdesc_cb (GtkFontButton * button, SeekApp * app)
+{
+  const gchar *text;
+
+  text = gtk_font_button_get_font_name (button);
+  g_object_set (app->pipeline, "subtitle-font-desc", text, NULL);
+}
+
+static void
+av_offset_activate_cb (GtkEntry * entry, SeekApp * app)
+{
+  const gchar *text;
+
+  text = gtk_entry_get_text (entry);
+  if (text != NULL && *text != '\0') {
+    gint64 v;
+    gchar *endptr;
+
+    v = g_ascii_strtoll (text, &endptr, 10);
+    if (endptr != text && v != G_MAXINT64 && v != G_MININT64) {
+      g_object_set (app->pipeline, "av-offset", v, NULL);
+    }
+  }
+}
+
+static void
+print_usage (int argc, char **argv)
+{
+  gint i;
+
+  g_print ("usage: %s <type> <filename>\n", argv[0]);
+  g_print ("   possible types:\n");
+
+  for (i = 0; i < G_N_ELEMENTS (pipelines); i++) {
+    g_print ("     %d = %s\n", i, pipelines[i].name);
+  }
+}
+
+static void
+create_ui (SeekApp * app)
+{
+  GtkWidget *hbox, *vbox, *seek, *playbin, *step, *navigation, *colorbalance;
+  GtkWidget *play_button, *pause_button, *stop_button;
+  GtkAdjustment *adjustment;
 
   /* initialize gui elements ... */
-  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-  video_window = gtk_drawing_area_new ();
-  g_signal_connect (video_window, "draw", G_CALLBACK (draw_cb), NULL);
-  g_signal_connect (video_window, "realize", G_CALLBACK (realize_cb), NULL);
-  g_signal_connect (video_window, "button-press-event",
-      G_CALLBACK (button_press_cb), NULL);
-  g_signal_connect (video_window, "button-release-event",
-      G_CALLBACK (button_release_cb), NULL);
-  g_signal_connect (video_window, "key-press-event", G_CALLBACK (key_press_cb),
-      NULL);
-  g_signal_connect (video_window, "key-release-event",
-      G_CALLBACK (key_release_cb), NULL);
-  g_signal_connect (video_window, "motion-notify-event",
-      G_CALLBACK (motion_notify_cb), NULL);
-  gtk_widget_set_can_focus (video_window, TRUE);
-  gtk_widget_set_double_buffered (video_window, FALSE);
-  gtk_widget_add_events (video_window,
+  app->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+  app->video_window = gtk_drawing_area_new ();
+  g_signal_connect (app->video_window, "draw", G_CALLBACK (draw_cb), app);
+  g_signal_connect (app->video_window, "realize", G_CALLBACK (realize_cb), app);
+  g_signal_connect (app->video_window, "button-press-event",
+      G_CALLBACK (button_press_cb), app);
+  g_signal_connect (app->video_window, "button-release-event",
+      G_CALLBACK (button_release_cb), app);
+  g_signal_connect (app->video_window, "key-press-event",
+      G_CALLBACK (key_press_cb), app);
+  g_signal_connect (app->video_window, "key-release-event",
+      G_CALLBACK (key_release_cb), app);
+  g_signal_connect (app->video_window, "motion-notify-event",
+      G_CALLBACK (motion_notify_cb), app);
+  gtk_widget_set_can_focus (app->video_window, TRUE);
+  gtk_widget_set_double_buffered (app->video_window, FALSE);
+  gtk_widget_add_events (app->video_window,
       GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
       | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK);
 
-  statusbar = gtk_statusbar_new ();
-  status_id = gtk_statusbar_get_context_id (GTK_STATUSBAR (statusbar), "seek");
-  gtk_statusbar_push (GTK_STATUSBAR (statusbar), status_id, "Stopped");
+  app->statusbar = gtk_statusbar_new ();
+  app->status_id =
+      gtk_statusbar_get_context_id (GTK_STATUSBAR (app->statusbar), "seek");
+  gtk_statusbar_push (GTK_STATUSBAR (app->statusbar), app->status_id,
+      "Stopped");
   hbox = gtk_hbox_new (FALSE, 0);
   vbox = gtk_vbox_new (FALSE, 0);
-  flagtable = gtk_table_new (4, 2, FALSE);
   gtk_container_set_border_width (GTK_CONTAINER (vbox), 3);
 
   /* media controls */
@@ -2083,87 +2544,177 @@ main (int argc, char **argv)
   pause_button = gtk_button_new_from_stock (GTK_STOCK_MEDIA_PAUSE);
   stop_button = gtk_button_new_from_stock (GTK_STOCK_MEDIA_STOP);
 
-  /* seek flags */
-  accurate_checkbox = gtk_check_button_new_with_label ("Accurate Seek");
-  key_checkbox = gtk_check_button_new_with_label ("Key-unit Seek");
-  loop_checkbox = gtk_check_button_new_with_label ("Loop");
-  flush_checkbox = gtk_check_button_new_with_label ("Flush");
-  scrub_checkbox = gtk_check_button_new_with_label ("Scrub");
-  play_scrub_checkbox = gtk_check_button_new_with_label ("Play Scrub");
-  skip_checkbox = gtk_check_button_new_with_label ("Play Skip");
-  rate_spinbutton = gtk_spin_button_new_with_range (-100, 100, 0.1);
-  gtk_spin_button_set_digits (GTK_SPIN_BUTTON (rate_spinbutton), 3);
-  rate_label = gtk_label_new ("Rate");
-
-  gtk_widget_set_tooltip_text (accurate_checkbox,
-      "accurate position is requested, this might be considerably slower for some formats");
-  gtk_widget_set_tooltip_text (key_checkbox,
-      "seek to the nearest keyframe. This might be faster but less accurate");
-  gtk_widget_set_tooltip_text (loop_checkbox, "loop playback");
-  gtk_widget_set_tooltip_text (flush_checkbox, "flush pipeline after seeking");
-  gtk_widget_set_tooltip_text (rate_spinbutton, "define the playback rate, "
-      "negative value trigger reverse playback");
-  gtk_widget_set_tooltip_text (scrub_checkbox, "show images while seeking");
-  gtk_widget_set_tooltip_text (play_scrub_checkbox, "play video while seeking");
-  gtk_widget_set_tooltip_text (skip_checkbox,
-      "Skip frames while playing at high frame rates");
-
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (flush_checkbox), TRUE);
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (scrub_checkbox), TRUE);
-
-  gtk_spin_button_set_value (GTK_SPIN_BUTTON (rate_spinbutton), rate);
+  /* seek expander */
+  {
+    GtkWidget *accurate_checkbox, *key_checkbox, *loop_checkbox,
+        *flush_checkbox;
+    GtkWidget *scrub_checkbox, *play_scrub_checkbox, *rate_label;
+    GtkWidget *skip_checkbox, *rate_spinbutton;
+    GtkWidget *flagtable, *advanced_seek, *advanced_seek_grid;
+    GtkWidget *duration_label, *position_label, *seek_button;
+
+    seek = gtk_expander_new ("seek options");
+    flagtable = gtk_grid_new ();
+    gtk_grid_set_row_spacing (GTK_GRID (flagtable), 2);
+    gtk_grid_set_row_homogeneous (GTK_GRID (flagtable), FALSE);
+    gtk_grid_set_column_spacing (GTK_GRID (flagtable), 2);
+    gtk_grid_set_column_homogeneous (GTK_GRID (flagtable), TRUE);
+
+    accurate_checkbox = gtk_check_button_new_with_label ("Accurate Seek");
+    key_checkbox = gtk_check_button_new_with_label ("Key-unit Seek");
+    loop_checkbox = gtk_check_button_new_with_label ("Loop");
+    flush_checkbox = gtk_check_button_new_with_label ("Flush");
+    scrub_checkbox = gtk_check_button_new_with_label ("Scrub");
+    play_scrub_checkbox = gtk_check_button_new_with_label ("Play Scrub");
+    skip_checkbox = gtk_check_button_new_with_label ("Play Skip");
+    rate_spinbutton = gtk_spin_button_new_with_range (-100, 100, 0.1);
+    gtk_spin_button_set_digits (GTK_SPIN_BUTTON (rate_spinbutton), 3);
+    rate_label = gtk_label_new ("Rate");
+
+    gtk_widget_set_tooltip_text (accurate_checkbox,
+        "accurate position is requested, this might be considerably slower for some formats");
+    gtk_widget_set_tooltip_text (key_checkbox,
+        "seek to the nearest keyframe. This might be faster but less accurate");
+    gtk_widget_set_tooltip_text (loop_checkbox, "loop playback");
+    gtk_widget_set_tooltip_text (flush_checkbox,
+        "flush pipeline after seeking");
+    gtk_widget_set_tooltip_text (rate_spinbutton,
+        "define the playback rate, " "negative value trigger reverse playback");
+    gtk_widget_set_tooltip_text (scrub_checkbox, "show images while seeking");
+    gtk_widget_set_tooltip_text (play_scrub_checkbox,
+        "play video while seeking");
+    gtk_widget_set_tooltip_text (skip_checkbox,
+        "Skip frames while playing at high frame rates");
+
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (flush_checkbox), TRUE);
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (scrub_checkbox), TRUE);
+
+    gtk_spin_button_set_value (GTK_SPIN_BUTTON (rate_spinbutton), app->rate);
+
+    g_signal_connect (G_OBJECT (accurate_checkbox), "toggled",
+        G_CALLBACK (accurate_toggle_cb), app);
+    g_signal_connect (G_OBJECT (key_checkbox), "toggled",
+        G_CALLBACK (key_toggle_cb), app);
+    g_signal_connect (G_OBJECT (loop_checkbox), "toggled",
+        G_CALLBACK (loop_toggle_cb), app);
+    g_signal_connect (G_OBJECT (flush_checkbox), "toggled",
+        G_CALLBACK (flush_toggle_cb), app);
+    g_signal_connect (G_OBJECT (scrub_checkbox), "toggled",
+        G_CALLBACK (scrub_toggle_cb), app);
+    g_signal_connect (G_OBJECT (play_scrub_checkbox), "toggled",
+        G_CALLBACK (play_scrub_toggle_cb), app);
+    g_signal_connect (G_OBJECT (skip_checkbox), "toggled",
+        G_CALLBACK (skip_toggle_cb), app);
+    g_signal_connect (G_OBJECT (rate_spinbutton), "value-changed",
+        G_CALLBACK (rate_spinbutton_changed_cb), app);
+
+    gtk_grid_attach (GTK_GRID (flagtable), accurate_checkbox, 0, 0, 1, 1);
+    gtk_grid_attach (GTK_GRID (flagtable), flush_checkbox, 1, 0, 1, 1);
+    gtk_grid_attach (GTK_GRID (flagtable), loop_checkbox, 2, 0, 1, 1);
+    gtk_grid_attach (GTK_GRID (flagtable), key_checkbox, 0, 1, 1, 1);
+    gtk_grid_attach (GTK_GRID (flagtable), scrub_checkbox, 1, 1, 1, 1);
+    gtk_grid_attach (GTK_GRID (flagtable), play_scrub_checkbox, 2, 1, 1, 1);
+    gtk_grid_attach (GTK_GRID (flagtable), skip_checkbox, 3, 0, 1, 1);
+    gtk_grid_attach (GTK_GRID (flagtable), rate_label, 4, 0, 1, 1);
+    gtk_grid_attach (GTK_GRID (flagtable), rate_spinbutton, 4, 1, 1, 1);
+
+    advanced_seek = gtk_frame_new ("Advanced Seek");
+    advanced_seek_grid = gtk_grid_new ();
+    gtk_grid_set_row_spacing (GTK_GRID (advanced_seek_grid), 2);
+    gtk_grid_set_row_homogeneous (GTK_GRID (advanced_seek_grid), FALSE);
+    gtk_grid_set_column_spacing (GTK_GRID (advanced_seek_grid), 5);
+    gtk_grid_set_column_homogeneous (GTK_GRID (advanced_seek_grid), FALSE);
+
+    app->seek_format_combo = gtk_combo_box_text_new ();
+    g_signal_connect (app->seek_format_combo, "changed",
+        G_CALLBACK (seek_format_changed_cb), app);
+    gtk_grid_attach (GTK_GRID (advanced_seek_grid), app->seek_format_combo, 0,
+        0, 1, 1);
+
+    app->seek_entry = gtk_entry_new ();
+    gtk_entry_set_width_chars (GTK_ENTRY (app->seek_entry), 12);
+    gtk_grid_attach (GTK_GRID (advanced_seek_grid), app->seek_entry, 0, 1, 1,
+        1);
+
+    seek_button = gtk_button_new_with_label ("Seek");
+    g_signal_connect (G_OBJECT (seek_button), "clicked",
+        G_CALLBACK (advanced_seek_button_cb), app);
+    gtk_grid_attach (GTK_GRID (advanced_seek_grid), seek_button, 1, 0, 1, 1);
+
+    position_label = gtk_label_new ("Position:");
+    gtk_grid_attach (GTK_GRID (advanced_seek_grid), position_label, 2, 0, 1, 1);
+    duration_label = gtk_label_new ("Duration:");
+    gtk_grid_attach (GTK_GRID (advanced_seek_grid), duration_label, 2, 1, 1, 1);
+
+    app->seek_position_label = gtk_label_new ("-1");
+    gtk_grid_attach (GTK_GRID (advanced_seek_grid), app->seek_position_label, 3,
+        0, 1, 1);
+    app->seek_duration_label = gtk_label_new ("-1");
+    gtk_grid_attach (GTK_GRID (advanced_seek_grid), app->seek_duration_label, 3,
+        1, 1, 1);
+
+    gtk_container_add (GTK_CONTAINER (advanced_seek), advanced_seek_grid);
+    gtk_grid_attach (GTK_GRID (flagtable), advanced_seek, 0, 2, 3, 2);
+    gtk_container_add (GTK_CONTAINER (seek), flagtable);
+  }
 
   /* step expander */
   {
     GtkWidget *hbox;
+    GtkWidget *step_button, *shuttle_checkbox;
 
     step = gtk_expander_new ("step options");
     hbox = gtk_hbox_new (FALSE, 0);
 
-    format_combo = gtk_combo_box_text_new ();
-    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (format_combo),
+    app->step_format_combo = gtk_combo_box_text_new ();
+    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (app->step_format_combo),
         "frames");
-    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (format_combo),
+    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (app->step_format_combo),
         "time (ms)");
-    gtk_combo_box_set_active (GTK_COMBO_BOX (format_combo), 0);
-    gtk_box_pack_start (GTK_BOX (hbox), format_combo, FALSE, FALSE, 2);
-
-    step_amount_spinbutton = gtk_spin_button_new_with_range (1, 1000, 1);
-    gtk_spin_button_set_digits (GTK_SPIN_BUTTON (step_amount_spinbutton), 0);
-    gtk_spin_button_set_value (GTK_SPIN_BUTTON (step_amount_spinbutton), 1.0);
-    gtk_box_pack_start (GTK_BOX (hbox), step_amount_spinbutton, FALSE, FALSE,
+    gtk_combo_box_set_active (GTK_COMBO_BOX (app->step_format_combo), 0);
+    gtk_box_pack_start (GTK_BOX (hbox), app->step_format_combo, FALSE, FALSE,
         2);
 
-    step_rate_spinbutton = gtk_spin_button_new_with_range (0.0, 100, 0.1);
-    gtk_spin_button_set_digits (GTK_SPIN_BUTTON (step_rate_spinbutton), 3);
-    gtk_spin_button_set_value (GTK_SPIN_BUTTON (step_rate_spinbutton), 1.0);
-    gtk_box_pack_start (GTK_BOX (hbox), step_rate_spinbutton, FALSE, FALSE, 2);
+    app->step_amount_spinbutton = gtk_spin_button_new_with_range (1, 1000, 1);
+    gtk_spin_button_set_digits (GTK_SPIN_BUTTON (app->step_amount_spinbutton),
+        0);
+    gtk_spin_button_set_value (GTK_SPIN_BUTTON (app->step_amount_spinbutton),
+        1.0);
+    gtk_box_pack_start (GTK_BOX (hbox), app->step_amount_spinbutton, FALSE,
+        FALSE, 2);
+
+    app->step_rate_spinbutton = gtk_spin_button_new_with_range (0.0, 100, 0.1);
+    gtk_spin_button_set_digits (GTK_SPIN_BUTTON (app->step_rate_spinbutton), 3);
+    gtk_spin_button_set_value (GTK_SPIN_BUTTON (app->step_rate_spinbutton),
+        1.0);
+    gtk_box_pack_start (GTK_BOX (hbox), app->step_rate_spinbutton, FALSE, FALSE,
+        2);
 
     step_button = gtk_button_new_from_stock (GTK_STOCK_MEDIA_FORWARD);
     gtk_button_set_label (GTK_BUTTON (step_button), "Step");
     gtk_box_pack_start (GTK_BOX (hbox), step_button, FALSE, FALSE, 2);
 
     g_signal_connect (G_OBJECT (step_button), "clicked", G_CALLBACK (step_cb),
-        pipeline);
+        app);
 
     /* shuttle scale */
     shuttle_checkbox = gtk_check_button_new_with_label ("Shuttle");
     gtk_box_pack_start (GTK_BOX (hbox), shuttle_checkbox, FALSE, FALSE, 2);
     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (shuttle_checkbox), FALSE);
     g_signal_connect (shuttle_checkbox, "toggled", G_CALLBACK (shuttle_toggled),
-        pipeline);
+        app);
 
-    shuttle_adjustment =
+    adjustment =
         GTK_ADJUSTMENT (gtk_adjustment_new (0.0, -3.00, 4.0, 0.1, 1.0, 1.0));
-    shuttle_hscale = gtk_hscale_new (shuttle_adjustment);
-    gtk_scale_set_digits (GTK_SCALE (shuttle_hscale), 2);
-    gtk_scale_set_value_pos (GTK_SCALE (shuttle_hscale), GTK_POS_TOP);
-    g_signal_connect (shuttle_hscale, "value_changed",
-        G_CALLBACK (shuttle_value_changed), pipeline);
-    g_signal_connect (shuttle_hscale, "format_value",
-        G_CALLBACK (shuttle_format_value), pipeline);
+    app->shuttle_scale = gtk_hscale_new (adjustment);
+    gtk_scale_set_digits (GTK_SCALE (app->shuttle_scale), 2);
+    gtk_scale_set_value_pos (GTK_SCALE (app->shuttle_scale), GTK_POS_TOP);
+    g_signal_connect (app->shuttle_scale, "value-changed",
+        G_CALLBACK (shuttle_value_changed), app);
+    g_signal_connect (app->shuttle_scale, "format_value",
+        G_CALLBACK (shuttle_format_value), app);
 
-    gtk_box_pack_start (GTK_BOX (hbox), shuttle_hscale, TRUE, TRUE, 2);
+    gtk_box_pack_start (GTK_BOX (hbox), app->shuttle_scale, TRUE, TRUE, 2);
 
     gtk_container_add (GTK_CONTAINER (step), hbox);
   }
@@ -2177,342 +2728,623 @@ main (int argc, char **argv)
     navigation = gtk_expander_new ("navigation commands");
     grid = gtk_grid_new ();
     gtk_grid_set_row_spacing (GTK_GRID (grid), 2);
-    gtk_grid_set_row_homogeneous (GTK_GRID (grid), TRUE);
+    gtk_grid_set_row_homogeneous (GTK_GRID (grid), FALSE);
     gtk_grid_set_column_spacing (GTK_GRID (grid), 2);
     gtk_grid_set_column_homogeneous (GTK_GRID (grid), TRUE);
 
     navigation_button = gtk_button_new_with_label ("Menu 1");
     g_signal_connect (G_OBJECT (navigation_button), "clicked",
-        G_CALLBACK (navigation_cmd_cb),
-        GINT_TO_POINTER (GST_NAVIGATION_COMMAND_MENU1));
+        G_CALLBACK (navigation_cmd_cb), app);
     gtk_grid_attach (GTK_GRID (grid), navigation_button, i, 0, 1, 1);
     gtk_widget_set_sensitive (navigation_button, FALSE);
     gtk_widget_set_tooltip_text (navigation_button, "DVD Menu");
-    navigation_buttons[i].button = navigation_button;
-    navigation_buttons[i++].cmd = GST_NAVIGATION_COMMAND_MENU1;
+    app->navigation_buttons[i].button = navigation_button;
+    app->navigation_buttons[i++].cmd = GST_NAVIGATION_COMMAND_MENU1;
 
     navigation_button = gtk_button_new_with_label ("Menu 2");
     g_signal_connect (G_OBJECT (navigation_button), "clicked",
-        G_CALLBACK (navigation_cmd_cb),
-        GINT_TO_POINTER (GST_NAVIGATION_COMMAND_MENU2));
+        G_CALLBACK (navigation_cmd_cb), app);
     gtk_grid_attach (GTK_GRID (grid), navigation_button, i, 0, 1, 1);
     gtk_widget_set_sensitive (navigation_button, FALSE);
     gtk_widget_set_tooltip_text (navigation_button, "DVD Title Menu");
-    navigation_buttons[i].button = navigation_button;
-    navigation_buttons[i++].cmd = GST_NAVIGATION_COMMAND_MENU2;
+    app->navigation_buttons[i].button = navigation_button;
+    app->navigation_buttons[i++].cmd = GST_NAVIGATION_COMMAND_MENU2;
 
     navigation_button = gtk_button_new_with_label ("Menu 3");
     g_signal_connect (G_OBJECT (navigation_button), "clicked",
-        G_CALLBACK (navigation_cmd_cb),
-        GINT_TO_POINTER (GST_NAVIGATION_COMMAND_MENU3));
+        G_CALLBACK (navigation_cmd_cb), app);
     gtk_grid_attach (GTK_GRID (grid), navigation_button, i, 0, 1, 1);
     gtk_widget_set_sensitive (navigation_button, FALSE);
     gtk_widget_set_tooltip_text (navigation_button, "DVD Root Menu");
-    navigation_buttons[i].button = navigation_button;
-    navigation_buttons[i++].cmd = GST_NAVIGATION_COMMAND_MENU3;
+    app->navigation_buttons[i].button = navigation_button;
+    app->navigation_buttons[i++].cmd = GST_NAVIGATION_COMMAND_MENU3;
 
     navigation_button = gtk_button_new_with_label ("Menu 4");
     g_signal_connect (G_OBJECT (navigation_button), "clicked",
-        G_CALLBACK (navigation_cmd_cb),
-        GINT_TO_POINTER (GST_NAVIGATION_COMMAND_MENU4));
+        G_CALLBACK (navigation_cmd_cb), app);
     gtk_grid_attach (GTK_GRID (grid), navigation_button, i, 0, 1, 1);
     gtk_widget_set_sensitive (navigation_button, FALSE);
     gtk_widget_set_tooltip_text (navigation_button, "DVD Subpicture Menu");
-    navigation_buttons[i].button = navigation_button;
-    navigation_buttons[i++].cmd = GST_NAVIGATION_COMMAND_MENU4;
+    app->navigation_buttons[i].button = navigation_button;
+    app->navigation_buttons[i++].cmd = GST_NAVIGATION_COMMAND_MENU4;
 
     navigation_button = gtk_button_new_with_label ("Menu 5");
     g_signal_connect (G_OBJECT (navigation_button), "clicked",
-        G_CALLBACK (navigation_cmd_cb),
-        GINT_TO_POINTER (GST_NAVIGATION_COMMAND_MENU5));
+        G_CALLBACK (navigation_cmd_cb), app);
     gtk_grid_attach (GTK_GRID (grid), navigation_button, i, 0, 1, 1);
     gtk_widget_set_sensitive (navigation_button, FALSE);
     gtk_widget_set_tooltip_text (navigation_button, "DVD Audio Menu");
-    navigation_buttons[i].button = navigation_button;
-    navigation_buttons[i++].cmd = GST_NAVIGATION_COMMAND_MENU5;
+    app->navigation_buttons[i].button = navigation_button;
+    app->navigation_buttons[i++].cmd = GST_NAVIGATION_COMMAND_MENU5;
 
     navigation_button = gtk_button_new_with_label ("Menu 6");
     g_signal_connect (G_OBJECT (navigation_button), "clicked",
-        G_CALLBACK (navigation_cmd_cb),
-        GINT_TO_POINTER (GST_NAVIGATION_COMMAND_MENU6));
+        G_CALLBACK (navigation_cmd_cb), app);
     gtk_grid_attach (GTK_GRID (grid), navigation_button, i, 0, 1, 1);
     gtk_widget_set_sensitive (navigation_button, FALSE);
     gtk_widget_set_tooltip_text (navigation_button, "DVD Angle Menu");
-    navigation_buttons[i].button = navigation_button;
-    navigation_buttons[i++].cmd = GST_NAVIGATION_COMMAND_MENU6;
+    app->navigation_buttons[i].button = navigation_button;
+    app->navigation_buttons[i++].cmd = GST_NAVIGATION_COMMAND_MENU6;
 
     navigation_button = gtk_button_new_with_label ("Menu 7");
     g_signal_connect (G_OBJECT (navigation_button), "clicked",
-        G_CALLBACK (navigation_cmd_cb),
-        GINT_TO_POINTER (GST_NAVIGATION_COMMAND_MENU7));
+        G_CALLBACK (navigation_cmd_cb), app);
     gtk_grid_attach (GTK_GRID (grid), navigation_button, i, 0, 1, 1);
     gtk_widget_set_sensitive (navigation_button, FALSE);
     gtk_widget_set_tooltip_text (navigation_button, "DVD Chapter Menu");
-    navigation_buttons[i].button = navigation_button;
-    navigation_buttons[i++].cmd = GST_NAVIGATION_COMMAND_MENU7;
+    app->navigation_buttons[i].button = navigation_button;
+    app->navigation_buttons[i++].cmd = GST_NAVIGATION_COMMAND_MENU7;
 
     navigation_button = gtk_button_new_with_label ("Left");
     g_signal_connect (G_OBJECT (navigation_button), "clicked",
-        G_CALLBACK (navigation_cmd_cb),
-        GINT_TO_POINTER (GST_NAVIGATION_COMMAND_LEFT));
+        G_CALLBACK (navigation_cmd_cb), app);
     gtk_grid_attach (GTK_GRID (grid), navigation_button, i - 7, 1, 1, 1);
     gtk_widget_set_sensitive (navigation_button, FALSE);
-    navigation_buttons[i].button = navigation_button;
-    navigation_buttons[i++].cmd = GST_NAVIGATION_COMMAND_LEFT;
+    app->navigation_buttons[i].button = navigation_button;
+    app->navigation_buttons[i++].cmd = GST_NAVIGATION_COMMAND_LEFT;
 
     navigation_button = gtk_button_new_with_label ("Right");
     g_signal_connect (G_OBJECT (navigation_button), "clicked",
-        G_CALLBACK (navigation_cmd_cb),
-        GINT_TO_POINTER (GST_NAVIGATION_COMMAND_RIGHT));
+        G_CALLBACK (navigation_cmd_cb), app);
     gtk_grid_attach (GTK_GRID (grid), navigation_button, i - 7, 1, 1, 1);
     gtk_widget_set_sensitive (navigation_button, FALSE);
-    navigation_buttons[i].button = navigation_button;
-    navigation_buttons[i++].cmd = GST_NAVIGATION_COMMAND_RIGHT;
+    app->navigation_buttons[i].button = navigation_button;
+    app->navigation_buttons[i++].cmd = GST_NAVIGATION_COMMAND_RIGHT;
 
     navigation_button = gtk_button_new_with_label ("Up");
     g_signal_connect (G_OBJECT (navigation_button), "clicked",
-        G_CALLBACK (navigation_cmd_cb),
-        GINT_TO_POINTER (GST_NAVIGATION_COMMAND_UP));
+        G_CALLBACK (navigation_cmd_cb), app);
     gtk_grid_attach (GTK_GRID (grid), navigation_button, i - 7, 1, 1, 1);
     gtk_widget_set_sensitive (navigation_button, FALSE);
-    navigation_buttons[i].button = navigation_button;
-    navigation_buttons[i++].cmd = GST_NAVIGATION_COMMAND_UP;
+    app->navigation_buttons[i].button = navigation_button;
+    app->navigation_buttons[i++].cmd = GST_NAVIGATION_COMMAND_UP;
 
     navigation_button = gtk_button_new_with_label ("Down");
     g_signal_connect (G_OBJECT (navigation_button), "clicked",
-        G_CALLBACK (navigation_cmd_cb),
-        GINT_TO_POINTER (GST_NAVIGATION_COMMAND_DOWN));
+        G_CALLBACK (navigation_cmd_cb), app);
     gtk_grid_attach (GTK_GRID (grid), navigation_button, i - 7, 1, 1, 1);
     gtk_widget_set_sensitive (navigation_button, FALSE);
-    navigation_buttons[i].button = navigation_button;
-    navigation_buttons[i++].cmd = GST_NAVIGATION_COMMAND_DOWN;
+    app->navigation_buttons[i].button = navigation_button;
+    app->navigation_buttons[i++].cmd = GST_NAVIGATION_COMMAND_DOWN;
 
     navigation_button = gtk_button_new_with_label ("Activate");
     g_signal_connect (G_OBJECT (navigation_button), "clicked",
-        G_CALLBACK (navigation_cmd_cb),
-        GINT_TO_POINTER (GST_NAVIGATION_COMMAND_ACTIVATE));
+        G_CALLBACK (navigation_cmd_cb), app);
     gtk_grid_attach (GTK_GRID (grid), navigation_button, i - 7, 1, 1, 1);
     gtk_widget_set_sensitive (navigation_button, FALSE);
-    navigation_buttons[i].button = navigation_button;
-    navigation_buttons[i++].cmd = GST_NAVIGATION_COMMAND_ACTIVATE;
+    app->navigation_buttons[i].button = navigation_button;
+    app->navigation_buttons[i++].cmd = GST_NAVIGATION_COMMAND_ACTIVATE;
 
     navigation_button = gtk_button_new_with_label ("Prev. Angle");
     g_signal_connect (G_OBJECT (navigation_button), "clicked",
-        G_CALLBACK (navigation_cmd_cb),
-        GINT_TO_POINTER (GST_NAVIGATION_COMMAND_PREV_ANGLE));
+        G_CALLBACK (navigation_cmd_cb), app);
     gtk_grid_attach (GTK_GRID (grid), navigation_button, i - 7, 1, 1, 1);
     gtk_widget_set_sensitive (navigation_button, FALSE);
-    navigation_buttons[i].button = navigation_button;
-    navigation_buttons[i++].cmd = GST_NAVIGATION_COMMAND_PREV_ANGLE;
+    app->navigation_buttons[i].button = navigation_button;
+    app->navigation_buttons[i++].cmd = GST_NAVIGATION_COMMAND_PREV_ANGLE;
 
     navigation_button = gtk_button_new_with_label ("Next. Angle");
     g_signal_connect (G_OBJECT (navigation_button), "clicked",
-        G_CALLBACK (navigation_cmd_cb),
-        GINT_TO_POINTER (GST_NAVIGATION_COMMAND_NEXT_ANGLE));
+        G_CALLBACK (navigation_cmd_cb), app);
     gtk_grid_attach (GTK_GRID (grid), navigation_button, i - 7, 1, 1, 1);
     gtk_widget_set_sensitive (navigation_button, FALSE);
-    navigation_buttons[i].button = navigation_button;
-    navigation_buttons[i++].cmd = GST_NAVIGATION_COMMAND_NEXT_ANGLE;
+    app->navigation_buttons[i].button = navigation_button;
+    app->navigation_buttons[i++].cmd = GST_NAVIGATION_COMMAND_NEXT_ANGLE;
 
     gtk_container_add (GTK_CONTAINER (navigation), grid);
   }
 
+  /* colorbalance expander */
+  {
+    GtkWidget *vbox, *frame;
+
+    colorbalance = gtk_expander_new ("color balance options");
+    vbox = gtk_vbox_new (FALSE, 0);
+
+    /* contrast scale */
+    frame = gtk_frame_new ("Contrast");
+    adjustment =
+        GTK_ADJUSTMENT (gtk_adjustment_new (N_GRAD / 2.0, 0.00, N_GRAD, 0.1,
+            1.0, 1.0));
+    app->contrast_scale = gtk_hscale_new (adjustment);
+    gtk_scale_set_draw_value (GTK_SCALE (app->contrast_scale), FALSE);
+    g_signal_connect (app->contrast_scale, "value-changed",
+        G_CALLBACK (colorbalance_value_changed), app);
+    gtk_container_add (GTK_CONTAINER (frame), app->contrast_scale);
+    gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 2);
+
+    /* brightness scale */
+    frame = gtk_frame_new ("Brightness");
+    adjustment =
+        GTK_ADJUSTMENT (gtk_adjustment_new (N_GRAD / 2.0, 0.00, N_GRAD, 0.1,
+            1.0, 1.0));
+    app->brightness_scale = gtk_hscale_new (adjustment);
+    gtk_scale_set_draw_value (GTK_SCALE (app->brightness_scale), FALSE);
+    g_signal_connect (app->brightness_scale, "value-changed",
+        G_CALLBACK (colorbalance_value_changed), app);
+    gtk_container_add (GTK_CONTAINER (frame), app->brightness_scale);
+    gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 2);
+
+    /* hue scale */
+    frame = gtk_frame_new ("Hue");
+    adjustment =
+        GTK_ADJUSTMENT (gtk_adjustment_new (N_GRAD / 2.0, 0.00, N_GRAD, 0.1,
+            1.0, 1.0));
+    app->hue_scale = gtk_hscale_new (adjustment);
+    gtk_scale_set_draw_value (GTK_SCALE (app->hue_scale), FALSE);
+    g_signal_connect (app->hue_scale, "value-changed",
+        G_CALLBACK (colorbalance_value_changed), app);
+    gtk_container_add (GTK_CONTAINER (frame), app->hue_scale);
+    gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 2);
+
+    /* saturation scale */
+    frame = gtk_frame_new ("Saturation");
+    adjustment =
+        GTK_ADJUSTMENT (gtk_adjustment_new (N_GRAD / 2.0, 0.00, N_GRAD, 0.1,
+            1.0, 1.0));
+    app->saturation_scale = gtk_hscale_new (adjustment);
+    gtk_scale_set_draw_value (GTK_SCALE (app->saturation_scale), FALSE);
+    g_signal_connect (app->saturation_scale, "value-changed",
+        G_CALLBACK (colorbalance_value_changed), app);
+    gtk_container_add (GTK_CONTAINER (frame), app->saturation_scale);
+    gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 2);
+
+    gtk_container_add (GTK_CONTAINER (colorbalance), vbox);
+  }
+
   /* seek bar */
   adjustment =
       GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.00, N_GRAD, 0.1, 1.0, 1.0));
-  hscale = gtk_hscale_new (adjustment);
-  gtk_scale_set_digits (GTK_SCALE (hscale), 2);
-  gtk_scale_set_value_pos (GTK_SCALE (hscale), GTK_POS_RIGHT);
-  gtk_range_set_show_fill_level (GTK_RANGE (hscale), TRUE);
-  gtk_range_set_fill_level (GTK_RANGE (hscale), N_GRAD);
-
-  g_signal_connect (hscale, "button_press_event", G_CALLBACK (start_seek),
-      pipeline);
-  g_signal_connect (hscale, "button_release_event", G_CALLBACK (stop_seek),
-      pipeline);
-  g_signal_connect (hscale, "format_value", G_CALLBACK (format_value),
-      pipeline);
-
-  if (pipeline_type == 0) {
+  app->seek_scale = gtk_hscale_new (adjustment);
+  gtk_scale_set_digits (GTK_SCALE (app->seek_scale), 2);
+  gtk_scale_set_value_pos (GTK_SCALE (app->seek_scale), GTK_POS_RIGHT);
+  gtk_range_set_show_fill_level (GTK_RANGE (app->seek_scale), TRUE);
+  gtk_range_set_fill_level (GTK_RANGE (app->seek_scale), N_GRAD);
+
+  g_signal_connect (app->seek_scale, "button_press_event",
+      G_CALLBACK (start_seek), app);
+  g_signal_connect (app->seek_scale, "button_release_event",
+      G_CALLBACK (stop_seek), app);
+  g_signal_connect (app->seek_scale, "format_value", G_CALLBACK (format_value),
+      app);
+
+  if (app->pipeline_type == 0) {
+    GtkWidget *pb2vbox, *boxes, *boxes2, *panel, *boxes3;
+    GtkWidget *volume_label, *shot_button;
+    GtkWidget *label;
+
+    playbin = gtk_expander_new ("playbin options");
     /* the playbin panel controls for the video/audio/subtitle tracks */
     panel = gtk_hbox_new (FALSE, 0);
-    video_combo = gtk_combo_box_text_new ();
-    audio_combo = gtk_combo_box_text_new ();
-    text_combo = gtk_combo_box_text_new ();
-    gtk_widget_set_sensitive (video_combo, FALSE);
-    gtk_widget_set_sensitive (audio_combo, FALSE);
-    gtk_widget_set_sensitive (text_combo, FALSE);
-    gtk_box_pack_start (GTK_BOX (panel), video_combo, TRUE, TRUE, 2);
-    gtk_box_pack_start (GTK_BOX (panel), audio_combo, TRUE, TRUE, 2);
-    gtk_box_pack_start (GTK_BOX (panel), text_combo, TRUE, TRUE, 2);
-    g_signal_connect (G_OBJECT (video_combo), "changed",
-        G_CALLBACK (video_combo_cb), pipeline);
-    g_signal_connect (G_OBJECT (audio_combo), "changed",
-        G_CALLBACK (audio_combo_cb), pipeline);
-    g_signal_connect (G_OBJECT (text_combo), "changed",
-        G_CALLBACK (text_combo_cb), pipeline);
+    app->video_combo = gtk_combo_box_text_new ();
+    app->audio_combo = gtk_combo_box_text_new ();
+    app->text_combo = gtk_combo_box_text_new ();
+    gtk_widget_set_sensitive (app->video_combo, FALSE);
+    gtk_widget_set_sensitive (app->audio_combo, FALSE);
+    gtk_widget_set_sensitive (app->text_combo, FALSE);
+    gtk_box_pack_start (GTK_BOX (panel), app->video_combo, TRUE, TRUE, 2);
+    gtk_box_pack_start (GTK_BOX (panel), app->audio_combo, TRUE, TRUE, 2);
+    gtk_box_pack_start (GTK_BOX (panel), app->text_combo, TRUE, TRUE, 2);
+    g_signal_connect (G_OBJECT (app->video_combo), "changed",
+        G_CALLBACK (video_combo_cb), app);
+    g_signal_connect (G_OBJECT (app->audio_combo), "changed",
+        G_CALLBACK (audio_combo_cb), app);
+    g_signal_connect (G_OBJECT (app->text_combo), "changed",
+        G_CALLBACK (text_combo_cb), app);
     /* playbin panel for flag checkboxes and volume/mute */
-    boxes = gtk_hbox_new (FALSE, 0);
-    vis_checkbox = gtk_check_button_new_with_label ("Vis");
-    video_checkbox = gtk_check_button_new_with_label ("Video");
-    audio_checkbox = gtk_check_button_new_with_label ("Audio");
-    text_checkbox = gtk_check_button_new_with_label ("Text");
-    mute_checkbox = gtk_check_button_new_with_label ("Mute");
-    download_checkbox = gtk_check_button_new_with_label ("Download");
-    buffer_checkbox = gtk_check_button_new_with_label ("Buffer");
+    boxes = gtk_grid_new ();
+    gtk_grid_set_row_spacing (GTK_GRID (boxes), 2);
+    gtk_grid_set_row_homogeneous (GTK_GRID (boxes), FALSE);
+    gtk_grid_set_column_spacing (GTK_GRID (boxes), 2);
+    gtk_grid_set_column_homogeneous (GTK_GRID (boxes), TRUE);
+
+    app->video_checkbox = gtk_check_button_new_with_label ("Video");
+    app->audio_checkbox = gtk_check_button_new_with_label ("Audio");
+    app->text_checkbox = gtk_check_button_new_with_label ("Text");
+    app->vis_checkbox = gtk_check_button_new_with_label ("Vis");
+    app->soft_volume_checkbox = gtk_check_button_new_with_label ("Soft Volume");
+    app->native_audio_checkbox =
+        gtk_check_button_new_with_label ("Native Audio");
+    app->native_video_checkbox =
+        gtk_check_button_new_with_label ("Native Video");
+    app->download_checkbox = gtk_check_button_new_with_label ("Download");
+    app->buffering_checkbox = gtk_check_button_new_with_label ("Buffering");
+    app->deinterlace_checkbox = gtk_check_button_new_with_label ("Deinterlace");
+    app->soft_colorbalance_checkbox =
+        gtk_check_button_new_with_label ("Soft Colorbalance");
+    app->mute_checkbox = gtk_check_button_new_with_label ("Mute");
     volume_label = gtk_label_new ("Volume");
-    volume_spinbutton = gtk_spin_button_new_with_range (0, 10.0, 0.1);
-    gtk_spin_button_set_value (GTK_SPIN_BUTTON (volume_spinbutton), 1.0);
-    gtk_box_pack_start (GTK_BOX (boxes), video_checkbox, TRUE, TRUE, 2);
-    gtk_box_pack_start (GTK_BOX (boxes), audio_checkbox, TRUE, TRUE, 2);
-    gtk_box_pack_start (GTK_BOX (boxes), text_checkbox, TRUE, TRUE, 2);
-    gtk_box_pack_start (GTK_BOX (boxes), vis_checkbox, TRUE, TRUE, 2);
-    gtk_box_pack_start (GTK_BOX (boxes), mute_checkbox, TRUE, TRUE, 2);
-    gtk_box_pack_start (GTK_BOX (boxes), download_checkbox, TRUE, TRUE, 2);
-    gtk_box_pack_start (GTK_BOX (boxes), buffer_checkbox, TRUE, TRUE, 2);
-    gtk_box_pack_start (GTK_BOX (boxes), volume_label, TRUE, TRUE, 2);
-    gtk_box_pack_start (GTK_BOX (boxes), volume_spinbutton, TRUE, TRUE, 2);
-    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (vis_checkbox), FALSE);
-    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (audio_checkbox), TRUE);
-    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (video_checkbox), TRUE);
-    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (text_checkbox), TRUE);
-    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mute_checkbox), FALSE);
-    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (download_checkbox), FALSE);
-    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (buffer_checkbox), FALSE);
-    g_signal_connect (G_OBJECT (vis_checkbox), "toggled",
-        G_CALLBACK (vis_toggle_cb), pipeline);
-    g_signal_connect (G_OBJECT (audio_checkbox), "toggled",
-        G_CALLBACK (audio_toggle_cb), pipeline);
-    g_signal_connect (G_OBJECT (video_checkbox), "toggled",
-        G_CALLBACK (video_toggle_cb), pipeline);
-    g_signal_connect (G_OBJECT (text_checkbox), "toggled",
-        G_CALLBACK (text_toggle_cb), pipeline);
-    g_signal_connect (G_OBJECT (mute_checkbox), "toggled",
-        G_CALLBACK (mute_toggle_cb), pipeline);
-    g_signal_connect (G_OBJECT (download_checkbox), "toggled",
-        G_CALLBACK (download_toggle_cb), pipeline);
-    g_signal_connect (G_OBJECT (buffer_checkbox), "toggled",
-        G_CALLBACK (buffer_toggle_cb), pipeline);
-    g_signal_connect (G_OBJECT (volume_spinbutton), "value_changed",
-        G_CALLBACK (volume_spinbutton_changed_cb), pipeline);
+    app->volume_spinbutton = gtk_spin_button_new_with_range (0, 10.0, 0.1);
+
+    gtk_grid_attach (GTK_GRID (boxes), app->video_checkbox, 0, 0, 1, 1);
+    gtk_grid_attach (GTK_GRID (boxes), app->audio_checkbox, 1, 0, 1, 1);
+    gtk_grid_attach (GTK_GRID (boxes), app->text_checkbox, 2, 0, 1, 1);
+    gtk_grid_attach (GTK_GRID (boxes), app->vis_checkbox, 3, 0, 1, 1);
+    gtk_grid_attach (GTK_GRID (boxes), app->soft_volume_checkbox, 4, 0, 1, 1);
+    gtk_grid_attach (GTK_GRID (boxes), app->native_audio_checkbox, 5, 0, 1, 1);
+    gtk_grid_attach (GTK_GRID (boxes), app->native_video_checkbox, 0, 1, 1, 1);
+    gtk_grid_attach (GTK_GRID (boxes), app->download_checkbox, 1, 1, 1, 1);
+    gtk_grid_attach (GTK_GRID (boxes), app->buffering_checkbox, 2, 1, 1, 1);
+    gtk_grid_attach (GTK_GRID (boxes), app->deinterlace_checkbox, 3, 1, 1, 1);
+    gtk_grid_attach (GTK_GRID (boxes), app->soft_colorbalance_checkbox, 4, 1, 1,
+        1);
+
+    gtk_grid_attach (GTK_GRID (boxes), app->mute_checkbox, 7, 0, 2, 1);
+    gtk_grid_attach (GTK_GRID (boxes), volume_label, 6, 1, 1, 1);
+    gtk_grid_attach (GTK_GRID (boxes), app->volume_spinbutton, 7, 1, 1, 1);
+
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (app->video_checkbox),
+        TRUE);
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (app->audio_checkbox),
+        TRUE);
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (app->text_checkbox), TRUE);
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (app->vis_checkbox), FALSE);
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (app->soft_volume_checkbox),
+        TRUE);
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+        (app->native_audio_checkbox), FALSE);
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+        (app->native_video_checkbox), FALSE);
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (app->download_checkbox),
+        FALSE);
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (app->buffering_checkbox),
+        FALSE);
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (app->deinterlace_checkbox),
+        FALSE);
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
+        (app->soft_colorbalance_checkbox), TRUE);
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (app->mute_checkbox),
+        FALSE);
+    gtk_spin_button_set_value (GTK_SPIN_BUTTON (app->volume_spinbutton), 1.0);
+
+    g_signal_connect (G_OBJECT (app->video_checkbox), "toggled",
+        G_CALLBACK (video_toggle_cb), app);
+    g_signal_connect (G_OBJECT (app->audio_checkbox), "toggled",
+        G_CALLBACK (audio_toggle_cb), app);
+    g_signal_connect (G_OBJECT (app->text_checkbox), "toggled",
+        G_CALLBACK (text_toggle_cb), app);
+    g_signal_connect (G_OBJECT (app->vis_checkbox), "toggled",
+        G_CALLBACK (vis_toggle_cb), app);
+    g_signal_connect (G_OBJECT (app->soft_volume_checkbox), "toggled",
+        G_CALLBACK (soft_volume_toggle_cb), app);
+    g_signal_connect (G_OBJECT (app->native_audio_checkbox), "toggled",
+        G_CALLBACK (native_audio_toggle_cb), app);
+    g_signal_connect (G_OBJECT (app->native_video_checkbox), "toggled",
+        G_CALLBACK (native_video_toggle_cb), app);
+    g_signal_connect (G_OBJECT (app->download_checkbox), "toggled",
+        G_CALLBACK (download_toggle_cb), app);
+    g_signal_connect (G_OBJECT (app->buffering_checkbox), "toggled",
+        G_CALLBACK (buffering_toggle_cb), app);
+    g_signal_connect (G_OBJECT (app->deinterlace_checkbox), "toggled",
+        G_CALLBACK (deinterlace_toggle_cb), app);
+    g_signal_connect (G_OBJECT (app->soft_colorbalance_checkbox), "toggled",
+        G_CALLBACK (soft_colorbalance_toggle_cb), app);
+    g_signal_connect (G_OBJECT (app->mute_checkbox), "toggled",
+        G_CALLBACK (mute_toggle_cb), app);
+    g_signal_connect (G_OBJECT (app->volume_spinbutton), "value-changed",
+        G_CALLBACK (volume_spinbutton_changed_cb), app);
     /* playbin panel for snapshot */
     boxes2 = gtk_hbox_new (FALSE, 0);
     shot_button = gtk_button_new_from_stock (GTK_STOCK_SAVE);
     gtk_widget_set_tooltip_text (shot_button,
         "save a screenshot .png in the current directory");
     g_signal_connect (G_OBJECT (shot_button), "clicked", G_CALLBACK (shot_cb),
-        pipeline);
-    vis_combo = gtk_combo_box_text_new ();
-    g_signal_connect (G_OBJECT (vis_combo), "changed",
-        G_CALLBACK (vis_combo_cb), pipeline);
-    gtk_widget_set_sensitive (vis_combo, FALSE);
+        app);
+    app->vis_combo = gtk_combo_box_text_new ();
+    g_signal_connect (G_OBJECT (app->vis_combo), "changed",
+        G_CALLBACK (vis_combo_cb), app);
+    gtk_widget_set_sensitive (app->vis_combo, FALSE);
     gtk_box_pack_start (GTK_BOX (boxes2), shot_button, TRUE, TRUE, 2);
-    gtk_box_pack_start (GTK_BOX (boxes2), vis_combo, TRUE, TRUE, 2);
+    gtk_box_pack_start (GTK_BOX (boxes2), app->vis_combo, TRUE, TRUE, 2);
 
     /* fill the vis combo box and the array of factories */
-    init_visualization_features ();
+    init_visualization_features (app);
+
+    /* Grid with other properties */
+    boxes3 = gtk_grid_new ();
+    gtk_grid_set_row_spacing (GTK_GRID (boxes3), 2);
+    gtk_grid_set_row_homogeneous (GTK_GRID (boxes3), FALSE);
+    gtk_grid_set_column_spacing (GTK_GRID (boxes3), 2);
+    gtk_grid_set_column_homogeneous (GTK_GRID (boxes3), TRUE);
+
+    label = gtk_label_new ("Video sink");
+    gtk_grid_attach (GTK_GRID (boxes3), label, 0, 0, 1, 1);
+    app->video_sink_entry = gtk_entry_new ();
+    g_signal_connect (app->video_sink_entry, "activate",
+        G_CALLBACK (video_sink_activate_cb), app);
+    gtk_grid_attach (GTK_GRID (boxes3), app->video_sink_entry, 0, 1, 1, 1);
+
+    label = gtk_label_new ("Audio sink");
+    gtk_grid_attach (GTK_GRID (boxes3), label, 1, 0, 1, 1);
+    app->audio_sink_entry = gtk_entry_new ();
+    g_signal_connect (app->audio_sink_entry, "activate",
+        G_CALLBACK (audio_sink_activate_cb), app);
+    gtk_grid_attach (GTK_GRID (boxes3), app->audio_sink_entry, 1, 1, 1, 1);
+
+    label = gtk_label_new ("Text sink");
+    gtk_grid_attach (GTK_GRID (boxes3), label, 2, 0, 1, 1);
+    app->text_sink_entry = gtk_entry_new ();
+    g_signal_connect (app->text_sink_entry, "activate",
+        G_CALLBACK (text_sink_activate_cb), app);
+    gtk_grid_attach (GTK_GRID (boxes3), app->text_sink_entry, 2, 1, 1, 1);
+
+    label = gtk_label_new ("Buffer Size");
+    gtk_grid_attach (GTK_GRID (boxes3), label, 0, 2, 1, 1);
+    app->buffer_size_entry = gtk_entry_new ();
+    gtk_entry_set_text (GTK_ENTRY (app->buffer_size_entry), "-1");
+    g_signal_connect (app->buffer_size_entry, "activate",
+        G_CALLBACK (buffer_size_activate_cb), app);
+    gtk_grid_attach (GTK_GRID (boxes3), app->buffer_size_entry, 0, 3, 1, 1);
+
+    label = gtk_label_new ("Buffer Duration");
+    gtk_grid_attach (GTK_GRID (boxes3), label, 1, 2, 1, 1);
+    app->buffer_duration_entry = gtk_entry_new ();
+    gtk_entry_set_text (GTK_ENTRY (app->buffer_duration_entry), "-1");
+    g_signal_connect (app->buffer_duration_entry, "activate",
+        G_CALLBACK (buffer_duration_activate_cb), app);
+    gtk_grid_attach (GTK_GRID (boxes3), app->buffer_duration_entry, 1, 3, 1, 1);
+
+    label = gtk_label_new ("Ringbuffer Max Size");
+    gtk_grid_attach (GTK_GRID (boxes3), label, 2, 2, 1, 1);
+    app->ringbuffer_maxsize_entry = gtk_entry_new ();
+    gtk_entry_set_text (GTK_ENTRY (app->ringbuffer_maxsize_entry), "0");
+    g_signal_connect (app->ringbuffer_maxsize_entry, "activate",
+        G_CALLBACK (ringbuffer_maxsize_activate_cb), app);
+    gtk_grid_attach (GTK_GRID (boxes3), app->ringbuffer_maxsize_entry, 2, 3, 1,
+        1);
+
+    label = gtk_label_new ("Connection Speed");
+    gtk_grid_attach (GTK_GRID (boxes3), label, 3, 2, 1, 1);
+    app->connection_speed_entry = gtk_entry_new ();
+    gtk_entry_set_text (GTK_ENTRY (app->connection_speed_entry), "0");
+    g_signal_connect (app->connection_speed_entry, "activate",
+        G_CALLBACK (connection_speed_activate_cb), app);
+    gtk_grid_attach (GTK_GRID (boxes3), app->connection_speed_entry, 3, 3, 1,
+        1);
+
+    label = gtk_label_new ("A/V offset");
+    gtk_grid_attach (GTK_GRID (boxes3), label, 4, 2, 1, 1);
+    app->av_offset_entry = gtk_entry_new ();
+    g_signal_connect (app->av_offset_entry, "activate",
+        G_CALLBACK (av_offset_activate_cb), app);
+    gtk_entry_set_text (GTK_ENTRY (app->av_offset_entry), "0");
+    g_signal_connect (app->av_offset_entry, "activate",
+        G_CALLBACK (av_offset_activate_cb), app);
+    gtk_grid_attach (GTK_GRID (boxes3), app->av_offset_entry, 4, 3, 1, 1);
+
+    label = gtk_label_new ("Subtitle Encoding");
+    gtk_grid_attach (GTK_GRID (boxes3), label, 0, 4, 1, 1);
+    app->subtitle_encoding_entry = gtk_entry_new ();
+    g_signal_connect (app->subtitle_encoding_entry, "activate",
+        G_CALLBACK (subtitle_encoding_activate_cb), app);
+    gtk_grid_attach (GTK_GRID (boxes3), app->subtitle_encoding_entry, 0, 5, 1,
+        1);
+
+    label = gtk_label_new ("Subtitle Fontdesc");
+    gtk_grid_attach (GTK_GRID (boxes3), label, 1, 4, 1, 1);
+    app->subtitle_fontdesc_button = gtk_font_button_new ();
+    g_signal_connect (app->subtitle_fontdesc_button, "font-set",
+        G_CALLBACK (subtitle_fontdesc_cb), app);
+    gtk_grid_attach (GTK_GRID (boxes3), app->subtitle_fontdesc_button, 1, 5, 1,
+        1);
+
+    pb2vbox = gtk_vbox_new (FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (pb2vbox), panel, FALSE, FALSE, 2);
+    gtk_box_pack_start (GTK_BOX (pb2vbox), boxes, FALSE, FALSE, 2);
+    gtk_box_pack_start (GTK_BOX (pb2vbox), boxes2, FALSE, FALSE, 2);
+    gtk_box_pack_start (GTK_BOX (pb2vbox), boxes3, FALSE, FALSE, 2);
+    gtk_container_add (GTK_CONTAINER (playbin), pb2vbox);
   } else {
-    panel = boxes = boxes2 = NULL;
+    playbin = NULL;
   }
 
   /* do the packing stuff ... */
-  gtk_window_set_default_size (GTK_WINDOW (window), 250, 96);
+  gtk_window_set_default_size (GTK_WINDOW (app->window), 250, 96);
   /* FIXME: can we avoid this for audio only? */
-  gtk_widget_set_size_request (GTK_WIDGET (video_window), -1,
+  gtk_widget_set_size_request (GTK_WIDGET (app->video_window), -1,
       DEFAULT_VIDEO_HEIGHT);
-  gtk_container_add (GTK_CONTAINER (window), vbox);
-  gtk_box_pack_start (GTK_BOX (vbox), video_window, TRUE, TRUE, 2);
+  gtk_container_add (GTK_CONTAINER (app->window), vbox);
+  gtk_box_pack_start (GTK_BOX (vbox), app->video_window, TRUE, TRUE, 2);
   gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 2);
   gtk_box_pack_start (GTK_BOX (hbox), play_button, FALSE, FALSE, 2);
   gtk_box_pack_start (GTK_BOX (hbox), pause_button, FALSE, FALSE, 2);
   gtk_box_pack_start (GTK_BOX (hbox), stop_button, FALSE, FALSE, 2);
-  gtk_box_pack_start (GTK_BOX (hbox), flagtable, FALSE, FALSE, 2);
-  gtk_table_attach_defaults (GTK_TABLE (flagtable), accurate_checkbox, 0, 1, 0,
-      1);
-  gtk_table_attach_defaults (GTK_TABLE (flagtable), flush_checkbox, 1, 2, 0, 1);
-  gtk_table_attach_defaults (GTK_TABLE (flagtable), loop_checkbox, 2, 3, 0, 1);
-  gtk_table_attach_defaults (GTK_TABLE (flagtable), key_checkbox, 0, 1, 1, 2);
-  gtk_table_attach_defaults (GTK_TABLE (flagtable), scrub_checkbox, 1, 2, 1, 2);
-  gtk_table_attach_defaults (GTK_TABLE (flagtable), play_scrub_checkbox, 2, 3,
-      1, 2);
-  gtk_table_attach_defaults (GTK_TABLE (flagtable), skip_checkbox, 3, 4, 0, 1);
-  gtk_table_attach_defaults (GTK_TABLE (flagtable), rate_label, 4, 5, 0, 1);
-  gtk_table_attach_defaults (GTK_TABLE (flagtable), rate_spinbutton, 4, 5, 1,
-      2);
-  if (panel && boxes && boxes2) {
-    expander = gtk_expander_new ("playbin options");
-    pb2vbox = gtk_vbox_new (FALSE, 0);
-    gtk_box_pack_start (GTK_BOX (pb2vbox), panel, FALSE, FALSE, 2);
-    gtk_box_pack_start (GTK_BOX (pb2vbox), boxes, FALSE, FALSE, 2);
-    gtk_box_pack_start (GTK_BOX (pb2vbox), boxes2, FALSE, FALSE, 2);
-    gtk_container_add (GTK_CONTAINER (expander), pb2vbox);
-    gtk_box_pack_start (GTK_BOX (vbox), expander, FALSE, FALSE, 2);
-  }
+
+  gtk_box_pack_start (GTK_BOX (vbox), seek, FALSE, FALSE, 2);
+  if (playbin)
+    gtk_box_pack_start (GTK_BOX (vbox), playbin, FALSE, FALSE, 2);
   gtk_box_pack_start (GTK_BOX (vbox), step, FALSE, FALSE, 2);
   gtk_box_pack_start (GTK_BOX (vbox), navigation, FALSE, FALSE, 2);
-  gtk_box_pack_start (GTK_BOX (vbox), hscale, FALSE, FALSE, 2);
-  gtk_box_pack_start (GTK_BOX (vbox), statusbar, FALSE, FALSE, 2);
+  gtk_box_pack_start (GTK_BOX (vbox), colorbalance, FALSE, FALSE, 2);
+  gtk_box_pack_start (GTK_BOX (vbox), gtk_hseparator_new (), FALSE, FALSE, 2);
+  gtk_box_pack_start (GTK_BOX (vbox), app->seek_scale, FALSE, FALSE, 2);
+  gtk_box_pack_start (GTK_BOX (vbox), app->statusbar, FALSE, FALSE, 2);
 
   /* connect things ... */
   g_signal_connect (G_OBJECT (play_button), "clicked", G_CALLBACK (play_cb),
-      pipeline);
+      app);
   g_signal_connect (G_OBJECT (pause_button), "clicked", G_CALLBACK (pause_cb),
-      pipeline);
+      app);
   g_signal_connect (G_OBJECT (stop_button), "clicked", G_CALLBACK (stop_cb),
-      pipeline);
-  g_signal_connect (G_OBJECT (accurate_checkbox), "toggled",
-      G_CALLBACK (accurate_toggle_cb), pipeline);
-  g_signal_connect (G_OBJECT (key_checkbox), "toggled",
-      G_CALLBACK (key_toggle_cb), pipeline);
-  g_signal_connect (G_OBJECT (loop_checkbox), "toggled",
-      G_CALLBACK (loop_toggle_cb), pipeline);
-  g_signal_connect (G_OBJECT (flush_checkbox), "toggled",
-      G_CALLBACK (flush_toggle_cb), pipeline);
-  g_signal_connect (G_OBJECT (scrub_checkbox), "toggled",
-      G_CALLBACK (scrub_toggle_cb), pipeline);
-  g_signal_connect (G_OBJECT (play_scrub_checkbox), "toggled",
-      G_CALLBACK (play_scrub_toggle_cb), pipeline);
-  g_signal_connect (G_OBJECT (skip_checkbox), "toggled",
-      G_CALLBACK (skip_toggle_cb), pipeline);
-  g_signal_connect (G_OBJECT (rate_spinbutton), "value_changed",
-      G_CALLBACK (rate_spinbutton_changed_cb), pipeline);
-
-  g_signal_connect (G_OBJECT (window), "delete-event", delete_event_cb, NULL);
+      app);
+
+  g_signal_connect (G_OBJECT (app->window), "delete-event",
+      G_CALLBACK (delete_event_cb), app);
+}
+
+static void
+set_defaults (SeekApp * app)
+{
+  memset (app, 0, sizeof (SeekApp));
+
+  app->flush_seek = TRUE;
+  app->scrub = TRUE;
+  app->rate = 1.0;
+
+  app->position = app->duration = -1;
+  app->state = GST_STATE_NULL;
+
+  app->need_streams = TRUE;
+
+  g_mutex_init (&app->state_mutex);
+
+  app->play_rate = 1.0;
+}
+
+static void
+reset_app (SeekApp * app)
+{
+  g_free (app->audiosink_str);
+  g_free (app->videosink_str);
+
+  g_list_free (app->formats);
+
+  g_mutex_clear (&app->state_mutex);
+
+  if (app->overlay_element)
+    gst_object_unref (app->overlay_element);
+  if (app->navigation_element)
+    gst_object_unref (app->navigation_element);
+
+  g_list_foreach (app->paths, (GFunc) g_free, NULL);
+  g_list_free (app->paths);
+  g_list_foreach (app->sub_paths, (GFunc) g_free, NULL);
+  g_list_free (app->sub_paths);
+
+  g_print ("free pipeline\n");
+  gst_object_unref (app->pipeline);
+}
+
+int
+main (int argc, char **argv)
+{
+  SeekApp app;
+  GOptionEntry options[] = {
+    {"stats", 's', 0, G_OPTION_ARG_NONE, &app.stats,
+        "Show pad stats", NULL},
+    {"verbose", 'v', 0, G_OPTION_ARG_NONE, &app.verbose,
+        "Verbose properties", NULL},
+    {NULL}
+  };
+  GOptionContext *ctx;
+  GError *err = NULL;
+
+  set_defaults (&app);
+
+  ctx = g_option_context_new ("- test seeking in gsteamer");
+  g_option_context_add_main_entries (ctx, options, NULL);
+  g_option_context_add_group (ctx, gst_init_get_option_group ());
+  g_option_context_add_group (ctx, gtk_get_option_group (TRUE));
+
+  if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
+    g_print ("Error initializing: %s\n", err->message);
+    exit (1);
+  }
+
+  GST_DEBUG_CATEGORY_INIT (seek_debug, "seek", 0, "seek example");
+
+  if (argc < 3) {
+    print_usage (argc, argv);
+    exit (-1);
+  }
+
+  app.pipeline_type = atoi (argv[1]);
+
+  if (app.pipeline_type < 0 || app.pipeline_type >= G_N_ELEMENTS (pipelines)) {
+    print_usage (argc, argv);
+    exit (-1);
+  }
+
+  app.pipeline_spec = argv[2];
+
+  if (g_path_is_absolute (app.pipeline_spec) &&
+      (g_strrstr (app.pipeline_spec, "*") != NULL ||
+          g_strrstr (app.pipeline_spec, "?") != NULL)) {
+    app.paths = handle_wildcards (app.pipeline_spec);
+  } else {
+    app.paths = g_list_prepend (app.paths, g_strdup (app.pipeline_spec));
+  }
+
+  if (!app.paths) {
+    g_print ("opening %s failed\n", app.pipeline_spec);
+    exit (-1);
+  }
+
+  app.current_path = app.paths;
+
+  if (argc > 3 && argv[3]) {
+    if (g_path_is_absolute (argv[3]) &&
+        (g_strrstr (argv[3], "*") != NULL ||
+            g_strrstr (argv[3], "?") != NULL)) {
+      app.sub_paths = handle_wildcards (argv[3]);
+    } else {
+      app.sub_paths = g_list_prepend (app.sub_paths, g_strdup (argv[3]));
+    }
+
+    if (!app.sub_paths) {
+      g_print ("opening %s failed\n", argv[3]);
+      exit (-1);
+    }
+
+    app.current_sub_path = app.sub_paths;
+  }
+
+  pipelines[app.pipeline_type].func (&app, app.current_path->data);
+  g_assert (app.pipeline);
+
+  create_ui (&app);
 
   /* show the gui. */
-  gtk_widget_show_all (window);
+  gtk_widget_show_all (app.window);
 
   /* realize window now so that the video window gets created and we can
    * obtain its XID before the pipeline is started up and the videosink
    * asks for the XID of the window to render onto */
-  gtk_widget_realize (window);
+  gtk_widget_realize (app.window);
 
 #if defined (GDK_WINDOWING_X11) || defined (GDK_WINDOWING_WIN32) || defined (GDK_WINDOWING_QUARTZ)
-  /* we should have the handle now */
-  g_assert (embed_handle != 0);
+  /* we should have the XID now */
+  g_assert (app.embed_xid != 0);
+
+  if (app.pipeline_type == 0) {
+    gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (app.pipeline),
+        app.embed_xid);
+  }
 #endif
 
-  if (verbose) {
-    g_signal_connect (pipeline, "deep_notify",
+  if (app.verbose) {
+    g_signal_connect (app.pipeline, "deep_notify",
         G_CALLBACK (gst_object_default_deep_notify), NULL);
   }
 
-  connect_bus_signals (pipeline);
+  connect_bus_signals (&app);
+
   gtk_main ();
 
   g_print ("NULL pipeline\n");
-  gst_element_set_state (pipeline, GST_STATE_NULL);
-
-  if (overlay_element)
-    gst_object_unref (overlay_element);
-  if (navigation_element)
-    gst_object_unref (navigation_element);
-
-  g_print ("free pipeline\n");
-  gst_object_unref (pipeline);
+  gst_element_set_state (app.pipeline, GST_STATE_NULL);
 
-  g_list_foreach (paths, (GFunc) g_free, NULL);
-  g_list_free (paths);
+  reset_app (&app);
 
   return 0;
 }
index d47df63..5cecb64 100644 (file)
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
+
 /* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex
  * with newer GTK versions (>= 3.3.0) */
+#define GLIB_DISABLE_DEPRECATION_WARNINGS
 #define GDK_DISABLE_DEPRECATION_WARNINGS
 
 #include <stdlib.h>
index 0a4a9f6..f383317 100644 (file)
@@ -53,9 +53,6 @@
 /* system wide data directory */
 #define GST_DATADIR PREFIX "\\share"
 
-/* set to disable libxml2-dependent code in subparse */
-#undef GST_DISABLE_XML
-
 /* Extra platform specific plugin suffix */
 #undef GST_EXTRA_MODULE_SUFFIX
 
 /* Define to 1 if you have the <dlfcn.h> header file. */
 #undef HAVE_DLFCN_H
 
+/* Define to 1 if you have the <emmintrin.h> header file. */
+#undef HAVE_EMMINTRIN_H
+
 /* Define to enable building of experimental plug-ins. */
 #undef HAVE_EXPERIMENTAL
 
 /* Define to enable X libraries and plugins (used by ximagesink). */
 #undef HAVE_X
 
+/* Define to 1 if you have the <xmmintrin.h> header file. */
+#undef HAVE_XMMINTRIN_H
+
 /* Define to enable X Shared Memory extension. */
 #undef HAVE_XSHM