gst-libs/gst/colorbalance/colorbalancechannel.c: Adding safety check in dispose method.
authorJulien Moutte <julien@moutte.net>
Mon, 12 Jan 2004 19:50:29 +0000 (19:50 +0000)
committerJulien Moutte <julien@moutte.net>
Mon, 12 Jan 2004 19:50:29 +0000 (19:50 +0000)
Original commit message from CVS:
2004-01-12  Julien MOUTTE <julien@moutte.net>

* gst-libs/gst/colorbalance/colorbalancechannel.c:
(gst_color_balance_channel_dispose): Adding safety check in dispose
method.
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_xcontext_get),
(gst_xvimagesink_xcontext_clear),
(gst_xvimagesink_interface_supported),
(gst_xvimagesink_colorbalance_list_channels),
(gst_xvimagesink_colorbalance_set_value),
(gst_xvimagesink_colorbalance_get_value),
(gst_xvimagesink_colorbalance_init), (gst_xvimagesink_get_type):
Adding colorbalance interface support to set XV parameters such as
HUE, BRIGHTNESS, CONTRAST, SATURATION.
* sys/xvimage/xvimagesink.h: Adding the channels list for colorbalance
interface.

ChangeLog
gst-libs/gst/colorbalance/colorbalancechannel.c
gst-libs/gst/interfaces/colorbalancechannel.c
sys/xvimage/xvimagesink.c
sys/xvimage/xvimagesink.h

index 7fa934a7b5328e5cf0fd3adcd9e1e82a474e3f8b..8c6e86eb30409e9d1afe8bc055397dd4abaa761b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2004-01-12  Julien MOUTTE <julien@moutte.net>
+
+       * gst-libs/gst/colorbalance/colorbalancechannel.c:
+       (gst_color_balance_channel_dispose): Adding safety check in dispose
+       method.
+       * sys/xvimage/xvimagesink.c: (gst_xvimagesink_xcontext_get),
+       (gst_xvimagesink_xcontext_clear),
+       (gst_xvimagesink_interface_supported),
+       (gst_xvimagesink_colorbalance_list_channels),
+       (gst_xvimagesink_colorbalance_set_value),
+       (gst_xvimagesink_colorbalance_get_value),
+       (gst_xvimagesink_colorbalance_init), (gst_xvimagesink_get_type):
+       Adding colorbalance interface support to set XV parameters such as
+       HUE, BRIGHTNESS, CONTRAST, SATURATION.
+       * sys/xvimage/xvimagesink.h: Adding the channels list for colorbalance
+       interface.
+
 2004-01-12  Thomas Vander Stichele  <thomas at apestaart dot org>
 
        * gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_get_type),
index f87101200f063bf823940b40bbd04c1b748ad202..e8c6e87bbec7f6e038adcce3cb27794772625926 100644 (file)
@@ -96,7 +96,10 @@ gst_color_balance_channel_dispose (GObject *object)
 {
   GstColorBalanceChannel *channel = GST_COLOR_BALANCE_CHANNEL (object);
 
-  g_free (channel->label);
+  if (channel->label)
+    g_free (channel->label);
+  
+  channel->label = NULL;
 
   if (parent_class->dispose)
     parent_class->dispose (object);
index f87101200f063bf823940b40bbd04c1b748ad202..e8c6e87bbec7f6e038adcce3cb27794772625926 100644 (file)
@@ -96,7 +96,10 @@ gst_color_balance_channel_dispose (GObject *object)
 {
   GstColorBalanceChannel *channel = GST_COLOR_BALANCE_CHANNEL (object);
 
-  g_free (channel->label);
+  if (channel->label)
+    g_free (channel->label);
+  
+  channel->label = NULL;
 
   if (parent_class->dispose)
     parent_class->dispose (object);
index a9f6d16bb24799237501a8997018da80f2ddaa66..1835887de0dca1653445b041fedad5462b6603e6 100644 (file)
@@ -24,6 +24,7 @@
 /* Our interfaces */
 #include <gst/navigation/navigation.h>
 #include <gst/xoverlay/xoverlay.h>
+#include <gst/colorbalance/colorbalance.h>
 
 /* Object header */
 #include "xvimagesink.h"
@@ -529,6 +530,8 @@ gst_xvimagesink_xcontext_get (GstXvImageSink *xvimagesink)
   GstXContext *xcontext = NULL;
   XPixmapFormatValues *px_formats = NULL;
   gint nb_formats = 0, i;
+  char *channels[4] = { "XV_HUE", "XV_SATURATION",
+                        "XV_BRIGHTNESS", "XV_CONTRAST" };
   
   g_return_val_if_fail (xvimagesink != NULL, NULL);
   g_return_val_if_fail (GST_IS_XVIMAGESINK (xvimagesink), NULL);
@@ -616,6 +619,19 @@ gst_xvimagesink_xcontext_get (GstXvImageSink *xvimagesink)
     
   g_mutex_unlock (xvimagesink->x_lock);
   
+  /* Generate the channels list */
+  for (i = 0; i < (sizeof (channels) / sizeof (char *)); i++)
+    {
+      GstColorBalanceChannel *channel;
+    
+      channel = g_object_new (GST_TYPE_COLOR_BALANCE_CHANNEL, NULL);
+      channel->label = g_strdup (channels[i]);
+      channel->min_value = -1000;
+      channel->max_value = 1000;
+      xcontext->channels_list = g_list_append (xcontext->channels_list,
+                                               channel);
+    }
+    
   return xcontext;
 }
 
@@ -624,24 +640,36 @@ gst_xvimagesink_xcontext_get (GstXvImageSink *xvimagesink)
 static void
 gst_xvimagesink_xcontext_clear (GstXvImageSink *xvimagesink)
 {
-  GList *list;
+  GList *formats_list, *channels_list;
   
   g_return_if_fail (xvimagesink != NULL);
   g_return_if_fail (GST_IS_XVIMAGESINK (xvimagesink));
   
-  list = xvimagesink->xcontext->formats_list;
+  formats_list = xvimagesink->xcontext->formats_list;
   
-  while (list)
+  while (formats_list)
     {
-      GstXvImageFormat *format = list->data;
+      GstXvImageFormat *format = formats_list->data;
       gst_caps_free (format->caps);
       g_free (format);
-      list = g_list_next (list);
+      formats_list = g_list_next (formats_list);
     }
     
   if (xvimagesink->xcontext->formats_list)
     g_list_free (xvimagesink->xcontext->formats_list);
+  
+  channels_list = xvimagesink->xcontext->channels_list;
+  
+  while (channels_list)
+    {
+      GstColorBalanceChannel *channel = channels_list->data;
+      g_object_unref (channel);
+      channels_list = g_list_next (channels_list);
+    }
     
+  if (xvimagesink->xcontext->channels_list)
+    g_list_free (xvimagesink->xcontext->channels_list);
+  
   gst_caps_free (xvimagesink->xcontext->caps);
   
   g_mutex_lock (xvimagesink->x_lock);
@@ -1039,7 +1067,9 @@ gst_xvimagesink_imagepool_clear (GstXvImageSink *xvimagesink)
 static gboolean
 gst_xvimagesink_interface_supported (GstImplementsInterface *iface, GType type)
 {
-  g_assert (type == GST_TYPE_NAVIGATION || type == GST_TYPE_X_OVERLAY);
+  g_assert (type == GST_TYPE_NAVIGATION ||
+            type == GST_TYPE_X_OVERLAY ||
+            type == GST_TYPE_COLOR_BALANCE);
   return TRUE;
 }
 
@@ -1192,6 +1222,72 @@ gst_xvimagesink_xoverlay_init (GstXOverlayClass *iface)
   iface->get_desired_size = gst_xvimagesink_get_desired_size;
 }
 
+static const GList *
+gst_xvimagesink_colorbalance_list_channels (GstColorBalance *balance)
+{
+  GstXvImageSink *xvimagesink = GST_XVIMAGESINK (balance);
+  
+  g_return_val_if_fail (xvimagesink != NULL, NULL);
+  g_return_val_if_fail (GST_IS_XVIMAGESINK (xvimagesink), NULL);
+  
+  if (xvimagesink->xcontext)
+    return xvimagesink->xcontext->channels_list;
+  else
+    return NULL;
+}
+
+static void
+gst_xvimagesink_colorbalance_set_value (GstColorBalance        *balance,
+                                        GstColorBalanceChannel *channel,
+                                        gint                    value)
+{
+  GstXvImageSink *xvimagesink = GST_XVIMAGESINK (balance);
+  
+  g_return_if_fail (xvimagesink != NULL);
+  g_return_if_fail (GST_IS_XVIMAGESINK (xvimagesink));
+  g_return_if_fail (channel->label != NULL);
+  
+  g_mutex_lock (xvimagesink->x_lock);
+  
+  XvSetPortAttribute (xvimagesink->xcontext->disp,
+                      xvimagesink->xcontext->xv_port_id,
+                      XInternAtom (xvimagesink->xcontext->disp,
+                                   channel->label, 1), value);
+  
+  g_mutex_unlock (xvimagesink->x_lock);
+}
+
+static gint
+gst_xvimagesink_colorbalance_get_value (GstColorBalance        *balance,
+                                        GstColorBalanceChannel *channel)
+{
+  GstXvImageSink *xvimagesink = GST_XVIMAGESINK (balance);
+  gint value;
+  
+  g_return_val_if_fail (xvimagesink != NULL, 0);
+  g_return_val_if_fail (GST_IS_XVIMAGESINK (xvimagesink), 0);
+  g_return_val_if_fail (channel->label != NULL, 0);
+  
+  g_mutex_lock (xvimagesink->x_lock);
+  
+  XvGetPortAttribute (xvimagesink->xcontext->disp,
+                      xvimagesink->xcontext->xv_port_id,
+                      XInternAtom (xvimagesink->xcontext->disp,
+                                   channel->label, 1), &value);
+  
+  g_mutex_unlock (xvimagesink->x_lock);
+  
+  return value;
+}
+
+static void
+gst_xvimagesink_colorbalance_init (GstColorBalanceClass *iface)
+{
+  iface->list_channels = gst_xvimagesink_colorbalance_list_channels;
+  iface->set_value = gst_xvimagesink_colorbalance_set_value;
+  iface->get_value = gst_xvimagesink_colorbalance_get_value;
+}
+
 /* =========================================== */
 /*                                             */
 /*              Init & Class init              */
@@ -1339,6 +1435,11 @@ gst_xvimagesink_get_type (void)
         NULL,
         NULL,
       };
+      static const GInterfaceInfo colorbalance_info = {
+        (GInterfaceInitFunc) gst_xvimagesink_colorbalance_init,
+        NULL,
+        NULL,
+      };
       
       xvimagesink_type = g_type_register_static (GST_TYPE_VIDEOSINK,
                                                  "GstXvImageSink",
@@ -1350,6 +1451,8 @@ gst_xvimagesink_get_type (void)
                                    &navigation_info);
       g_type_add_interface_static (xvimagesink_type, GST_TYPE_X_OVERLAY,
                                    &overlay_info);
+      g_type_add_interface_static (xvimagesink_type, GST_TYPE_COLOR_BALANCE,
+                                   &colorbalance_info);
     }
     
   return xvimagesink_type;
index 74a471ad029e26d346529e36f71b305c2486ba80..36c1a68e2e34c5ef7e1845f576bc682d6ab922c9 100644 (file)
@@ -84,6 +84,7 @@ struct _GstXContext {
   gint im_format;
   
   GList *formats_list;
+  GList *channels_list;
   
   GstCaps *caps;
 };