pulseutil: Add API for setting volume ratio 14/205414/2
authorSangchul Lee <sc11.lee@samsung.com>
Fri, 3 May 2019 02:58:14 +0000 (11:58 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Tue, 7 May 2019 23:55:59 +0000 (08:55 +0900)
In Tizen, a stream has one volume type such as media, notification,
alarm. Each type is so-called volume group which has its own volume
value of a certain volume level. It is managed on the Tizen policy
module of the PulseAudio. That's why the player framework has been
using volume element instead of volume property of gstpulsesink of
the pipeline to set individual volume of the stream itself.

Here we add a function to set volume ratio for the individual volume
value via the policy module of the PulseAudio which can be with the
volume group concept.

Change-Id: I6b2cf8d4814a01970e425a4dd25b49aa883ee7e1
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
configure.ac
ext/pulse/Makefile.am
ext/pulse/pulseutil.c
ext/pulse/pulseutil.h
packaging/gst-plugins-good.spec

index 09b5084..f4ede88 100644 (file)
@@ -273,6 +273,10 @@ AC_SUBST(VCONF_CFLAGS)
 AC_SUBST(VCONF_LIBS)
 fi
 
+PKG_CHECK_MODULES(GIO, gio-2.0)
+AC_SUBST(GIO_CFLAGS)
+AC_SUBST(GIO_LIBS)
+
 dnl Check for -Bsymbolic-functions linker flag used to avoid
 dnl intra-library PLT jumps, if available.
 AC_ARG_ENABLE(Bsymbolic,
index 5fed235..e52814c 100644 (file)
@@ -7,10 +7,10 @@ libgstpulseaudio_la_SOURCES = \
        pulsedeviceprovider.c \
        pulseutil.c
 
-libgstpulseaudio_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(PULSE_CFLAGS)
+libgstpulseaudio_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(PULSE_CFLAGS) $(GIO_CFLAGS)
 libgstpulseaudio_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_API_VERSION) \
        -lgstpbutils-$(GST_API_VERSION) \
-       $(GST_BASE_LIBS) $(GST_LIBS) $(PULSE_LIBS)
+       $(GST_BASE_LIBS) $(GST_LIBS) $(PULSE_LIBS) $(GIO_LIBS)
 libgstpulseaudio_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
 libgstpulseaudio_la_LIBTOOLFLAGS = $(GST_PLUGIN_LIBTOOLFLAGS)
 
index f4f7c97..662fb05 100644 (file)
@@ -512,3 +512,53 @@ gst_pulse_format_info_to_caps (pa_format_info * format)
 out:
   return ret;
 }
+
+#ifdef __TIZEN__
+#include <gio/gio.h>
+#define PA_BUS_NAME                                    "org.pulseaudio.Server"
+#define PA_STREAM_MANAGER_OBJECT_PATH                  "/org/pulseaudio/StreamManager"
+#define PA_STREAM_MANAGER_INTERFACE                    "org.pulseaudio.StreamManager"
+#define PA_STREAM_MANAGER_METHOD_NAME_SET_VOLUME_RATIO          "SetVolumeRatio"
+void
+gst_pulse_set_volume_ratio (uint32_t stream_index, const char *direction, double ratio)
+{
+  GDBusConnection *conn = NULL;
+  GError *err = NULL;
+  GVariant *result = NULL;
+  const gchar *dbus_ret = NULL;
+
+  conn = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &err);
+  if (!conn || err) {
+      GST_ERROR ("g_bus_get_sync() error (%s)", err ? err->message : NULL);
+    if (err)
+      g_error_free (err);
+    return;
+  }
+
+  result = g_dbus_connection_call_sync (conn,
+        PA_BUS_NAME,
+        PA_STREAM_MANAGER_OBJECT_PATH,
+        PA_STREAM_MANAGER_INTERFACE,
+        PA_STREAM_MANAGER_METHOD_NAME_SET_VOLUME_RATIO,
+        g_variant_new("(sud)", direction, stream_index, ratio),
+        G_VARIANT_TYPE("(s)"),
+        G_DBUS_CALL_FLAGS_NONE,
+        1000,
+        NULL,
+        &err);
+  if (!result || err) {
+    GST_ERROR ("g_dbus_connection_call_sync() for SET_VOLUME_RATIO error (%s)", err ? err->message : NULL);
+    if (err)
+      g_error_free (err);
+    goto finish;
+  }
+  g_variant_get (result, "(&s)", &dbus_ret);
+  GST_DEBUG ("SET_VOLUME_RATIO returns value(%s) for stream index(%u), ratio(%f)", dbus_ret, stream_index, ratio);
+
+finish:
+  g_variant_unref(result);
+  g_object_unref(conn);
+
+  return;
+}
+#endif
\ No newline at end of file
index 152c42d..a410d05 100644 (file)
@@ -91,4 +91,7 @@ GstStructure *gst_pulse_make_structure (pa_proplist *properties);
 
 GstCaps * gst_pulse_format_info_to_caps (pa_format_info * format);
 
+#ifdef __TIZEN__
+void gst_pulse_set_volume_ratio (uint32_t stream_index, const char *direction, double ratio);
+#endif
 #endif
index 2c436d9..3ccf003 100644 (file)
@@ -39,6 +39,7 @@ BuildRequires:  pkgconfig(zlib)
 BuildRequires:  pkgconfig(libv4l2)
 %endif
 BuildRequires:  pkgconfig(vconf)
+BuildRequires:  pkgconfig(gio-2.0)
 Requires:       gst-plugins-base >= 1.0.0
 Requires:       gstreamer >= 1.0.5