libmm-sound: add new sound filter API 98/87398/20
authorKimJeongYeon <jeongyeon.kim@samsung.com>
Wed, 7 Sep 2016 06:55:43 +0000 (15:55 +0900)
committerSeungbae Shin <seungbae.shin@samsung.com>
Thu, 30 Mar 2017 06:07:18 +0000 (23:07 -0700)
Filter APIs (for proposal)
 1) int mm_sound_set_filter(const char *stream_type, const char *filter_name, const char *filter_parameters, const char *filter_group)
 2) int mm_sound_unset_filter(const char *stream_type)
 3) int mm_sound_control_filter(const char *stream_type, const char *filter_name, const char *filter_controls)

[Version] 0.10.107
[Profile] Common
[Issue Type] New Feature

Signed-off-by: KimJeongYeon <jeongyeon.kim@samsung.com>
Change-Id: Ibfc2b2d00739b84d12742b014565a2b83bf43833

common/mm_sound_dbus.c
include/mm_sound.h
include/mm_sound_client.h
include/mm_sound_intf.h
include/mm_sound_proxy.h
mm_sound.c
mm_sound_client.c
mm_sound_proxy.c
packaging/libmm-sound.spec

index d3ecf1c..bbd357a 100644 (file)
@@ -114,6 +114,15 @@ const mm_sound_dbus_method_info_t g_methods[AUDIO_METHOD_MAX] = {
        [AUDIO_METHOD_UNWATCH_FOCUS] = {
                .name = "UnwatchFocus",
        },
+       [AUDIO_METHOD_SET_FILTER] = {
+               .name = "SetFilter",
+       },
+       [AUDIO_METHOD_UNSET_FILTER] = {
+               .name = "UnsetFilter",
+       },
+       [AUDIO_METHOD_CONTROL_FILTER] = {
+               .name = "ControlFilter",
+       },
 };
 
 const mm_sound_dbus_signal_info_t g_events[AUDIO_EVENT_MAX] = {
index 9c07aca..4b29cc0 100644 (file)
@@ -502,6 +502,53 @@ int mm_sound_volume_primary_type_set(volume_type_t type);
 int mm_sound_volume_primary_type_get(volume_type_t *type);
 
 /**
+ * This function is to set sound filter and apply to selected stream type.
+ *
+ * @param      stream_type                     [in]    stream type to apply
+ * @param      filter_name                     [in]    name of filter module to apply
+ * @param      filter_parameters       [in]    extra filter parameters(optional)
+ * @param      filter_group            [in]    extra filter group(optional)
+ *
+ * @return     This function returns MM_ERROR_NONE on success, or negative value
+ *                     with error code.
+ * @remark     None
+ * @pre                None
+ * @post       None
+ * @see                None
+ */
+int mm_sound_set_filter(const char *stream_type, const char *filter_name, const char *filter_parameters, const char *filter_group);
+
+/**
+ * This function is to unset sound filter and remove from selected stream type.
+ *
+ * @param      stream_type                     [in]    stream type to remove
+ *
+ * @return     This function returns MM_ERROR_NONE on success, or negative value
+ *                     with error code.
+ * @remark     None
+ * @pre                None
+ * @post       None
+ * @see                None
+ */
+int mm_sound_unset_filter(const char *stream_type);
+
+/**
+ * This function is to control filter configurations to selected stream type.
+ *
+ * @param      stream_type                     [in]    stream type to apply
+ * @param      filter_name                     [in]    specify filter module to apply
+ * @param      filter_controls         [in]    filter control parameters(e.g, "0.0, 0.1, 3.0")
+ *
+ * @return     This function returns MM_ERROR_NONE on success, or negative value
+ *                     with error code.
+ * @remark     None
+ * @pre                None
+ * @post       None
+ * @see                None
+ */
+int mm_sound_control_filter(const char *stream_type, const char *filter_name, const char *filter_controls);
+
+/**
  * Terminate callback function type.
  *
  * @param      data            [in]    Argument passed when callback was set
index 367d135..4771c66 100644 (file)
@@ -45,6 +45,9 @@ int mm_sound_client_stop_sound(int handle);
 int mm_sound_client_set_volume_by_type(const int volume_type, const unsigned int volume_level);
 int mm_sound_client_add_volume_changed_callback(mm_sound_volume_changed_cb func, void* user_data, unsigned int *subs_id);
 int mm_sound_client_remove_volume_changed_callback(unsigned int subs_id);
+int mm_sound_client_set_filter_by_type(const char *stream_type, const char *filter_name, const char *filter_parameters, const char *filter_group);
+int mm_sound_client_unset_filter_by_type(const char *stream_type);
+int mm_sound_client_control_filter_by_type(const char *stream_type, const char *filter_name, const char *filter_controls);
 int mm_sound_client_get_current_connected_device_list(int device_flgas, mm_sound_device_list_t *device_list);
 int mm_sound_client_add_device_connected_callback(int device_flags, mm_sound_device_connected_cb func, void* user_data, unsigned int *subs_id);
 int mm_sound_client_remove_device_connected_callback(unsigned int subs_id);
index 63a4ab1..bf4a8b5 100644 (file)
@@ -69,6 +69,10 @@ typedef enum audio_method {
        AUDIO_METHOD_WATCH_FOCUS,
        AUDIO_METHOD_UNWATCH_FOCUS,
 
+       AUDIO_METHOD_SET_FILTER,
+       AUDIO_METHOD_UNSET_FILTER,
+       AUDIO_METHOD_CONTROL_FILTER,
+
        AUDIO_METHOD_MAX
 } audio_method_t;
 
index 0e72331..b4a98e3 100644 (file)
@@ -64,6 +64,9 @@ int mm_sound_proxy_set_volume_by_type(const char *volume_type, const unsigned vo
 int mm_sound_proxy_add_volume_changed_callback(mm_sound_volume_changed_wrapper_cb func, void* userdata, mm_sound_proxy_userdata_free freefunc, unsigned *subs_id);
 int mm_sound_proxy_remove_volume_changed_callback(unsigned subs_id);
 int mm_sound_proxy_emergent_exit(int exit_pid);
+int mm_sound_proxy_set_filter_by_type(const char *stream_type, const char *filter_name, const char *filter_parameters, const char *filter_group);
+int mm_sound_proxy_unset_filter_by_type(const char *stream_type);
+int mm_sound_proxy_control_filter_by_type(const char *stream_type, const char *filter_name, const char *filter_controls);
 
 #ifdef USE_FOCUS
 int mm_sound_proxy_get_unique_id(int *id);
index bc5d325..0ed72c2 100644 (file)
@@ -234,6 +234,52 @@ int mm_sound_volume_primary_type_get(volume_type_t *type)
        return ret;
 }
 
+EXPORT_API
+int mm_sound_set_filter(const char *stream_type, const char *filter_name, const char *filter_parameters, const char *filter_group)
+{
+       /* Check input param */
+       if (!stream_type || !filter_name) {
+               debug_error("invalid argument");
+               return MM_ERROR_INVALID_ARGUMENT;
+       }
+       if (!filter_parameters)
+               filter_parameters = "";
+       if (!filter_group)
+               filter_group = "default";
+
+       debug_msg("stream_type(%s), filter_name(%s), filter_parameters(%s), filter_group(%s)", stream_type, filter_name, filter_parameters, filter_group);
+
+       return mm_sound_client_set_filter_by_type(stream_type, filter_name, filter_parameters, filter_group);
+}
+
+EXPORT_API
+int mm_sound_unset_filter(const char *stream_type)
+{
+       /* Check input param */
+       if (!stream_type) {
+               debug_error("invalid argument");
+               return MM_ERROR_INVALID_ARGUMENT;
+       }
+
+       debug_msg("stream_type(%s)", stream_type);
+
+       return mm_sound_client_unset_filter_by_type(stream_type);
+}
+
+EXPORT_API
+int mm_sound_control_filter(const char *stream_type, const char *filter_name, const char *filter_controls)
+{
+       /* Check input param */
+       if (!stream_type || !filter_name || !filter_controls) {
+               debug_error("invalid argument");
+               return MM_ERROR_INVALID_ARGUMENT;
+       }
+
+       debug_msg("stream_type(%s), filter_name(%s), filter_controls(%s)", stream_type, filter_name, filter_controls);
+
+       return mm_sound_client_control_filter_by_type(stream_type, filter_name, filter_controls);
+}
+
 ///////////////////////////////////
 ////     MMSOUND PLAY APIs
 ///////////////////////////////////
index 1515874..bd93b1f 100644 (file)
@@ -1033,6 +1033,39 @@ int mm_sound_client_remove_volume_changed_callback(unsigned int subs_id)
        return ret;
 }
 
+int mm_sound_client_set_filter_by_type(const char *stream_type, const char *filter_name, const char *filter_parameters, const char *filter_group)
+{
+       int ret = MM_ERROR_NONE;
+       debug_fenter();
+
+       ret = mm_sound_proxy_set_filter_by_type(stream_type, filter_name, filter_parameters, filter_group);
+
+       debug_fleave();
+       return ret;
+}
+
+int mm_sound_client_unset_filter_by_type(const char *stream_type)
+{
+       int ret = MM_ERROR_NONE;
+       debug_fenter();
+
+       ret = mm_sound_proxy_unset_filter_by_type(stream_type);
+
+       debug_fleave();
+       return ret;
+}
+
+int mm_sound_client_control_filter_by_type(const char *stream_type, const char *filter_name, const char *filter_controls)
+{
+       int ret = MM_ERROR_NONE;
+       debug_fenter();
+
+       ret = mm_sound_proxy_control_filter_by_type(stream_type, filter_name, filter_controls);
+
+       debug_fleave();
+       return ret;
+}
+
 #ifdef USE_FOCUS
 int mm_sound_client_set_session_interrupt_callback(mm_sound_focus_session_interrupt_cb callback, void* user_data)
 {
index 023843a..56cc7fd 100644 (file)
@@ -566,6 +566,114 @@ int mm_sound_proxy_remove_volume_changed_callback(unsigned subs_id)
        return ret;
 }
 
+int mm_sound_proxy_set_filter_by_type(const char *stream_type, const char *filter_name, const char *filter_parameters, const char *filter_group)
+{
+       int ret = MM_ERROR_NONE;
+       char *reply = NULL;
+       GVariant *params = NULL, *result = NULL;
+
+       debug_fenter();
+
+       params = g_variant_new("(ssss)", filter_name, filter_parameters, filter_group, stream_type);
+       if (params) {
+               if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_STREAM_MANAGER, AUDIO_METHOD_SET_FILTER, params, &result)) != MM_ERROR_NONE) {
+                       debug_error("dbus set filter by type failed");
+                       goto cleanup;
+               }
+       } else {
+               debug_error("construct param for method call failed");
+               return MM_ERROR_SOUND_INTERNAL;
+       }
+
+       if (result) {
+               g_variant_get(result, "(&s)", &reply);
+               debug_log("reply : %s", reply);
+               if (!strcmp(reply, "STREAM_MANAGER_RETURN_ERROR"))
+                       ret = MM_ERROR_SOUND_INTERNAL;
+       } else {
+               debug_error("reply null");
+       }
+
+cleanup:
+       if (result)
+               g_variant_unref(result);
+
+       debug_fleave();
+       return ret;
+}
+
+int mm_sound_proxy_unset_filter_by_type(const char *stream_type)
+{
+       int ret = MM_ERROR_NONE;
+       char *reply = NULL;
+       GVariant *params = NULL, *result = NULL;
+
+       debug_fenter();
+
+       params = g_variant_new("(s)", stream_type);
+       if (params) {
+               if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_STREAM_MANAGER, AUDIO_METHOD_UNSET_FILTER, params, &result)) != MM_ERROR_NONE) {
+                       debug_error("dbus unset filter by type failed");
+                       goto cleanup;
+               }
+       } else {
+               debug_error("construct param for method call failed");
+               return MM_ERROR_SOUND_INTERNAL;
+       }
+
+       if (result) {
+               g_variant_get(result, "(&s)", &reply);
+               debug_log("reply : %s", reply);
+               if (!strcmp(reply, "STREAM_MANAGER_RETURN_ERROR"))
+                       ret = MM_ERROR_SOUND_INTERNAL;
+       } else {
+               debug_error("reply null");
+       }
+
+cleanup:
+       if (result)
+               g_variant_unref(result);
+
+       debug_fleave();
+       return ret;
+}
+
+int mm_sound_proxy_control_filter_by_type(const char *stream_type, const char *filter_name, const char *filter_controls)
+{
+       int ret = MM_ERROR_NONE;
+       char *reply = NULL;
+       GVariant *params = NULL, *result = NULL;
+
+       debug_fenter();
+
+       params = g_variant_new("(sss)", filter_name, filter_controls, stream_type);
+       if (params) {
+               if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_STREAM_MANAGER, AUDIO_METHOD_CONTROL_FILTER, params, &result)) != MM_ERROR_NONE) {
+                       debug_error("dbus control filter by type failed");
+                       goto cleanup;
+               }
+       } else {
+               debug_error("construct param for method call failed");
+               return MM_ERROR_SOUND_INTERNAL;
+       }
+
+       if (result) {
+               g_variant_get(result, "(&s)", &reply);
+               debug_log("reply : %s", reply);
+               if (!strcmp(reply, "STREAM_MANAGER_RETURN_ERROR"))
+                       ret = MM_ERROR_SOUND_INTERNAL;
+       } else {
+               debug_error("reply null");
+       }
+
+cleanup:
+       if (result)
+               g_variant_unref(result);
+
+       debug_fleave();
+       return ret;
+}
+
 int mm_sound_proxy_play_tone(int tone, int repeat, int volume, int volume_config,
                           int session_type, int session_options, int client_pid,
                           bool enable_session, int *codechandle, char *stream_type, int stream_index)
index 78cea47..885f4b4 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-sound
 Summary:    MMSound Package contains client lib and sound_server binary
-Version:    0.10.106
+Version:    0.10.107
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0