[totem] backend: Get playbin2 to create our videobalance



commit bc6f874373f64a0036711bbfe845d76264ec097a
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Apr 27 17:14:19 2012 +0100

    backend: Get playbin2 to create our videobalance
    
    That way, we don't have to manage it ourselves, and we know
    that a videobalance will be present.

 configure.in                              |    3 +-
 src/backend/bacon-video-widget-gst-0.10.c |  101 +++++++++--------------------
 2 files changed, 32 insertions(+), 72 deletions(-)
---
diff --git a/configure.in b/configure.in
index a78f51d..6247709 100644
--- a/configure.in
+++ b/configure.in
@@ -79,6 +79,7 @@ dnl the two versions here implicate the gstreamer core and gst-plugins
 dnl release versions.
 GST_MAJORMINOR=0.10
 GST_REQS=0.10.30
+GST_PLUG_BASE_REQS=0.10.36.1
 GSTPLUG_REQS=0.10.30
 CLUTTER_REQS=1.6.8
 CLUTTER_GST_REQS=1.5.5
@@ -116,7 +117,7 @@ if test "x$enable_easy_codec_installation" != "xno"; then
 	])
 fi
 
-MM="gstreamer-0.10 >= $GST_REQS gstreamer-base-0.10 >= $GST_REQS gstreamer-plugins-base-0.10 >= $GSTPLUG_REQS gstreamer-tag-0.10 >= $GSTPLUG_REQS clutter-1.0 >= $CLUTTER_REQS clutter-gst-1.0 >= $CLUTTER_GST_REQS clutter-gtk-1.0 mx-1.0 gsettings-desktop-schemas"
+MM="gstreamer-0.10 >= $GST_REQS gstreamer-base-0.10 >= $GST_REQS gstreamer-plugins-base-0.10 >= $GST_PLUG_BASE_REQS gstreamer-tag-0.10 >= $GSTPLUG_REQS clutter-1.0 >= $CLUTTER_REQS clutter-gst-1.0 >= $CLUTTER_GST_REQS clutter-gtk-1.0 mx-1.0 gsettings-desktop-schemas"
 PKG_CHECK_MODULES(GST, $MM)
 GST_LIBS="$GST_LIBS -lgstbase-$GST_MAJORMINOR -lgstinterfaces-$GST_MAJORMINOR -lgstvideo-$GST_MAJORMINOR -lgstaudio-$GST_MAJORMINOR -lgstpbutils-$GST_MAJORMINOR -lgsttag-$GST_MAJORMINOR"
 AC_SUBST(GST_LIBS)
diff --git a/src/backend/bacon-video-widget-gst-0.10.c b/src/backend/bacon-video-widget-gst-0.10.c
index acc828e..0cd0fbc 100644
--- a/src/backend/bacon-video-widget-gst-0.10.c
+++ b/src/backend/bacon-video-widget-gst-0.10.c
@@ -175,7 +175,6 @@ struct BaconVideoWidgetPrivate
 
   GstElement                  *play;
   GstElement                  *source;
-  GstColorBalance             *balance;
   GstNavigation               *navigation;
 
   guint                        update_id;
@@ -4849,41 +4848,27 @@ int
 bacon_video_widget_get_video_property (BaconVideoWidget *bvw,
                                        BvwVideoProperty type)
 {
-  int ret;
+  GstColorBalanceChannel *found_channel = NULL;
+  int ret, cur;
 
   g_return_val_if_fail (BACON_IS_VIDEO_WIDGET (bvw), 65535/2);
-  
-  ret = 0;
-  
-  if (bvw->priv->balance && GST_IS_COLOR_BALANCE (bvw->priv->balance))
-    {
-      GstColorBalanceChannel *found_channel = NULL;
-      
-      found_channel = bvw_get_color_balance_channel (bvw->priv->balance, type);
-      
-      if (found_channel && GST_IS_COLOR_BALANCE_CHANNEL (found_channel)) {
-        gint cur;
+  g_return_val_if_fail (bvw->priv->play != NULL, 65535/2);
 
-        cur = gst_color_balance_get_value (bvw->priv->balance,
-                                           found_channel);
+  ret = 0;
 
-        GST_DEBUG ("channel %s: cur=%d, min=%d, max=%d", found_channel->label,
-            cur, found_channel->min_value, found_channel->max_value);
 
-        ret = floor (0.5 +
-            ((double) cur - found_channel->min_value) * 65535 /
-            ((double) found_channel->max_value - found_channel->min_value));
+  found_channel = bvw_get_color_balance_channel (GST_COLOR_BALANCE (bvw->priv->play), type);
+  cur = gst_color_balance_get_value (GST_COLOR_BALANCE (bvw->priv->play), found_channel);
 
-        GST_DEBUG ("channel %s: returning value %d", found_channel->label, ret);
-        g_object_unref (found_channel);
-        return ret;
-      } else {
-	ret = -1;
-      }
-    }
+  GST_DEBUG ("channel %s: cur=%d, min=%d, max=%d", found_channel->label,
+	     cur, found_channel->min_value, found_channel->max_value);
 
-  GST_DEBUG ("nothing found for type %d, returning value %d", type, ret);
+  ret = floor (0.5 +
+	       ((double) cur - found_channel->min_value) * 65535 /
+	       ((double) found_channel->max_value - found_channel->min_value));
 
+  GST_DEBUG ("channel %s: returning value %d", found_channel->label, ret);
+  g_object_unref (found_channel);
   return ret;
 }
 
@@ -5015,36 +5000,27 @@ bacon_video_widget_set_video_property (BaconVideoWidget *bvw,
                                        int value)
 {
   g_return_if_fail (BACON_IS_VIDEO_WIDGET (bvw));
-  
+  g_return_if_fail (bvw->priv->play != NULL);
+  GstColorBalanceChannel *found_channel = NULL;
+  int i_value;
+
   GST_DEBUG ("set video property type %d to value %d", type, value);
-  
+
   if ( !(value <= 65535 && value >= 0) )
     return;
 
-  if (bvw->priv->balance && GST_IS_COLOR_BALANCE (bvw->priv->balance))
-    {
-      GstColorBalanceChannel *found_channel = NULL;
-      
-      found_channel = bvw_get_color_balance_channel (bvw->priv->balance, type);
+  found_channel = bvw_get_color_balance_channel (GST_COLOR_BALANCE (bvw->priv->play), type);
+  i_value = floor (0.5 + value * ((double) found_channel->max_value -
+				  found_channel->min_value) / 65535 + found_channel->min_value);
 
-      if (found_channel && GST_IS_COLOR_BALANCE_CHANNEL (found_channel))
-        {
-          int i_value;
-          
-          i_value = floor (0.5 + value * ((double) found_channel->max_value -
-              found_channel->min_value) / 65535 + found_channel->min_value);
+  GST_DEBUG ("channel %s: set to %d/65535", found_channel->label, value);
 
-          GST_DEBUG ("channel %s: set to %d/65535", found_channel->label, value);
+  gst_color_balance_set_value (GST_COLOR_BALANCE (bvw->priv->play), found_channel, i_value);
 
-          gst_color_balance_set_value (bvw->priv->balance, found_channel,
-                                       i_value);
+  GST_DEBUG ("channel %s: val=%d, min=%d, max=%d", found_channel->label,
+	     i_value, found_channel->min_value, found_channel->max_value);
 
-          GST_DEBUG ("channel %s: val=%d, min=%d, max=%d", found_channel->label,
-              i_value, found_channel->min_value, found_channel->max_value);
-
-          g_object_unref (found_channel);
-        }
-    }
+  g_object_unref (found_channel);
 
   /* Notify of the property change */
   g_object_notify (G_OBJECT (bvw), video_props_str[type]);
@@ -5825,8 +5801,6 @@ bacon_video_widget_initable_init (GInitable     *initable,
   gchar *version_str;
   GstPlayFlags flags;
   ClutterConstraint *constraint;
-  GstElement *balance, *sink, *bin;
-  GstPad *pad, *ghostpad;
   GstElement *audio_bin;
   GstPad *audio_pad;
 
@@ -5884,24 +5858,20 @@ bacon_video_widget_initable_init (GInitable     *initable,
   bvw->priv->stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (bvw));
   clutter_actor_set_background_color (CLUTTER_ACTOR (bvw->priv->stage), CLUTTER_COLOR_Black);
 
-  /* Bin */
-  bin = gst_bin_new ("video_sink_bin");
-
   /* Video sink, with aspect frame */
   bvw->priv->texture = g_object_new (CLUTTER_TYPE_TEXTURE,
 				     "disable-slicing", TRUE,
 				     NULL);
-  sink = gst_element_factory_make ("cluttersink", NULL);
-  if (sink == NULL) {
+  video_sink = gst_element_factory_make ("cluttersink", NULL);
+  if (video_sink == NULL) {
     g_critical ("Could not create Clutter video sink");
     g_set_error_literal (error, BVW_ERROR, BVW_ERROR_PLUGIN_LOAD,
                  _("Failed to create a GStreamer play object. "
                    "Please check your GStreamer installation."));
     return FALSE;
   }
-  g_object_set (G_OBJECT (sink), "texture", bvw->priv->texture, NULL);
-  bvw->priv->navigation = GST_NAVIGATION (sink);
-  gst_bin_add (GST_BIN (bin), sink);
+  g_object_set (G_OBJECT (video_sink), "texture", bvw->priv->texture, NULL);
+  bvw->priv->navigation = GST_NAVIGATION (video_sink);
 
   /* The logo */
   bvw->priv->logo_frame = totem_aspect_frame_new ();
@@ -5939,18 +5909,7 @@ bacon_video_widget_initable_init (GInitable     *initable,
 					 bvw->priv->frame);
   bacon_video_osd_actor_hide (BACON_VIDEO_OSD_ACTOR (bvw->priv->osd));
 
-  /* Add video balance */
-  balance = gst_element_factory_make ("videobalance", "video_balance");
-  gst_bin_add (GST_BIN (bin), balance);
-  bvw->priv->balance = GST_COLOR_BALANCE (balance);
-  pad = gst_element_get_static_pad (balance, "sink");
-  ghostpad = gst_ghost_pad_new ("sink", pad);
-  gst_element_add_pad (bin, ghostpad);
-
-  gst_element_link (balance, sink);
-
   /* And tell playbin */
-  video_sink = bin;
   g_object_set (bvw->priv->play, "video-sink", video_sink, NULL);
 
   /* Audio sink */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]