rgvolume: Add enable-rgvolume property for enable/disable rgvolume
authorGilbok Lee <gilbok.lee@samsung.com>
Thu, 8 Mar 2018 08:11:25 +0000 (17:11 +0900)
committerGilbok Lee <gilbok.lee@samsung.com>
Mon, 12 Mar 2018 07:09:27 +0000 (16:09 +0900)
If rgvulme is disabled, the rgvolume isn't affected by tag and properties

Change-Id: I5ce1eb6296a1e0f88e6b4c3a93ecf62be58c070e

gst/replaygain/gstrgvolume.c
gst/replaygain/gstrgvolume.h
packaging/gst-plugins-good.spec

index 7c4f281..f7201b0 100644 (file)
@@ -1,19 +1,19 @@
 /* GStreamer ReplayGain volume adjustment
  *
  * Copyright (C) 2007 Rene Stadler <mail@renestadler.de>
- * 
+ *
  * gstrgvolume.c: Element to apply ReplayGain volume adjustment
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
  * as published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
- * 
+ *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  * The information carried by these tags must have been calculated beforehand by
  * performing the ReplayGain analysis.  This is implemented by the <link
  * linkend="GstRgAnalysis">rganalysis</link> element.
- * 
+ *
  * The signal compression/limiting recommendations outlined in the proposed
  * standard are not implemented by this element.  This has to be handled by
  * separate elements because applications might want to have additional filters
  * between the volume adjustment and the limiting stage.  A basic limiter is
  * included with this plugin: The <link linkend="GstRgLimiter">rglimiter</link>
  * element applies -6 dB hard limiting as mentioned in the ReplayGain standard.
- * 
+ *
  * <refsect2>
  * <title>Example launch line</title>
  * |[
@@ -73,6 +73,9 @@ GST_DEBUG_CATEGORY_STATIC (gst_rg_volume_debug);
 enum
 {
   PROP_0,
+#ifdef TIZEN_FEATURE_RGVOLUME_MODIFICATION
+  PROP_ENABLE_RGVOLUME,
+#endif
   PROP_ALBUM_MODE,
   PROP_HEADROOM,
   PROP_PRE_AMP,
@@ -81,6 +84,9 @@ enum
   PROP_RESULT_GAIN
 };
 
+#ifdef TIZEN_FEATURE_RGVOLUME_MODIFICATION
+#define DEFAULT_ENABLE_RGVOLUME TRUE
+#endif
 #define DEFAULT_ALBUM_MODE TRUE
 #define DEFAULT_HEADROOM 0.0
 #define DEFAULT_PRE_AMP 0.0
@@ -148,6 +154,20 @@ gst_rg_volume_class_init (GstRgVolumeClass * klass)
   gobject_class->get_property = gst_rg_volume_get_property;
   gobject_class->dispose = gst_rg_volume_dispose;
 
+#ifdef TIZEN_FEATURE_RGVOLUME_MODIFICATION
+  /**
+   * GstRgVolume:enable-rgvolume:
+   *
+   * Whether to enable replaygain volume.
+   *
+   * If rgvulme is disabled, the rgvolume isn't affected by tag and properties.
+   */
+  g_object_class_install_property (gobject_class, PROP_ENABLE_RGVOLUME,
+      g_param_spec_boolean ("enable-rgvolume", "Enable rg volume",
+          "Whether to enable replaygain volume", DEFAULT_ENABLE_RGVOLUME,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+#endif
+
   /**
    * GstRgVolume:album-mode:
    *
@@ -288,6 +308,9 @@ gst_rg_volume_init (GstRgVolume * self)
   GObjectClass *volume_class;
   GstPad *volume_pad, *ghost_pad;
 
+#ifdef TIZEN_FEATURE_RGVOLUME_MODIFICATION
+  self->enable_rgvolume = DEFAULT_ENABLE_RGVOLUME;
+#endif
   self->album_mode = DEFAULT_ALBUM_MODE;
   self->headroom = DEFAULT_HEADROOM;
   self->pre_amp = DEFAULT_PRE_AMP;
@@ -337,6 +360,11 @@ gst_rg_volume_set_property (GObject * object, guint prop_id,
   GstRgVolume *self = GST_RG_VOLUME (object);
 
   switch (prop_id) {
+#ifdef TIZEN_FEATURE_RGVOLUME_MODIFICATION
+    case PROP_ENABLE_RGVOLUME:
+      self->enable_rgvolume = g_value_get_boolean (value);
+      break;
+#endif
     case PROP_ALBUM_MODE:
       self->album_mode = g_value_get_boolean (value);
       break;
@@ -364,6 +392,11 @@ gst_rg_volume_get_property (GObject * object, guint prop_id,
   GstRgVolume *self = GST_RG_VOLUME (object);
 
   switch (prop_id) {
+#ifdef TIZEN_FEATURE_RGVOLUME_MODIFICATION
+    case PROP_ENABLE_RGVOLUME:
+      g_value_set_boolean (value, self->enable_rgvolume);
+      break;
+#endif
     case PROP_ALBUM_MODE:
       g_value_set_boolean (value, self->album_mode);
       break;
@@ -378,9 +411,17 @@ gst_rg_volume_get_property (GObject * object, guint prop_id,
       break;
     case PROP_TARGET_GAIN:
       g_value_set_double (value, self->target_gain);
+#ifdef TIZEN_FEATURE_RGVOLUME_MODIFICATION
+      if (!self->enable_rgvolume)
+        g_value_set_double (value, 0.0);
+#endif
       break;
     case PROP_RESULT_GAIN:
       g_value_set_double (value, self->result_gain);
+#ifdef TIZEN_FEATURE_RGVOLUME_MODIFICATION
+      if (!self->enable_rgvolume)
+        g_value_set_double (value, 0.0);
+#endif
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -594,6 +635,12 @@ gst_rg_volume_update_gain (GstRgVolume * self)
   gdouble target_gain, result_gain, result_volume;
   gboolean target_gain_changed, result_gain_changed;
 
+#ifdef TIZEN_FEATURE_RGVOLUME_MODIFICATION
+  if (!self->enable_rgvolume) {
+    g_object_set (self->volume_element, "volume", 1.0, NULL);
+    return;
+  }
+#endif
   gst_rg_volume_determine_gain (self, &target_gain, &result_gain);
 
   result_volume = DB_TO_LINEAR (result_gain);
index a0a5a8c..5228ee0 100644 (file)
@@ -8,12 +8,12 @@
  * modify it under the terms of the GNU Lesser General Public License
  * as published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
- * 
+ *
  * This library is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
@@ -55,6 +55,9 @@ struct _GstRgVolume
   GstElement *volume_element;
   gdouble max_volume;
 
+#ifdef TIZEN_FEATURE_RGVOLUME_MODIFICATION
+  gboolean enable_rgvolume;
+#endif
   gboolean album_mode;
   gdouble headroom;
   gdouble pre_amp;
index d7679cc..7a916a9 100644 (file)
@@ -79,6 +79,7 @@ export CFLAGS+=" -DTIZEN_FEATURE_V4L2SRC_MODIFICATION\
                 -DTIZEN_FEATURE_RTSP_MODIFICATION\
                -DTIZEN_FEATURE_GST_MUX_ENHANCEMENT\
                -DTIZEN_FEATURE_SOUP_MODIFICATION\
+               -DTIZEN_FEATURE_RGVOLUME_MODIFICATION\
                -DTIZEN_FEATURE_BASEPARSE_MODIFICATION"
 %configure\
 %if ! 0%{?ENABLE_AALIB}
@@ -109,7 +110,6 @@ export CFLAGS+=" -DTIZEN_FEATURE_V4L2SRC_MODIFICATION\
        --disable-goom2k1\
        --disable-level\
        --disable-multipart\
-       --disable-replaygain\
        --disable-smpte\
        --disable-spectrum\
        --disable-cutter\
@@ -169,7 +169,7 @@ make %{?_smp_mflags} CFLAGS+="-Wno-error" CXXFLAGS+="-Wno-error"
 #%{_libdir}/gstreamer-%{gst_branch}/libgstossaudio.so
 #%{_libdir}/gstreamer-%{gst_branch}/libgstpng.so
 %{_libdir}/gstreamer-%{gst_branch}/libgstpulseaudio.so
-#%{_libdir}/gstreamer-%{gst_branch}/libgstreplaygain.so
+%{_libdir}/gstreamer-%{gst_branch}/libgstreplaygain.so
 %{_libdir}/gstreamer-%{gst_branch}/libgstrtp.so
 %{_libdir}/gstreamer-%{gst_branch}/libgstrtpmanager.so
 %{_libdir}/gstreamer-%{gst_branch}/libgstrtsp.so