Add API - espp_client_set/get_audio_volume()
authorEunhye Choi <eunhae1.choi@samsung.com>
Wed, 28 Jun 2023 10:15:42 +0000 (19:15 +0900)
committer이상철/Tizen Platform Lab(SR)/삼성전자 <sc11.lee@samsung.com>
Fri, 30 Jun 2023 02:06:36 +0000 (11:06 +0900)
[Version] 0.3.8

packaging/espp-service.spec
project_def.prop
src/client/espp_service_client.c
src/client/espp_service_client.h
src/client/espp_service_client_priv.h
src/client/espp_service_client_socket.c
src/client/project_def.prop
src/common/espp_service_ipc.c
src/common/espp_service_ipc.h
src/daemon/espp_service_handler.c
tizen-manifest.xml

index 0f4e01457ac705232c3c7ed6ed39bae54aa7ce91..85e1afda486b1d39efd65b1e715de6b82be990e1 100644 (file)
@@ -1,6 +1,6 @@
 Name:       espp-service
 Summary:    ESPP service package which contains client lib. and daemon binary
-Version:    0.3.7
+Version:    0.3.8
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index eda5583e466b10c1e378aad1619c145aafb126a7..24b4087b3e1ba6537a5deb4e9532d1ca18317b70 100644 (file)
@@ -11,7 +11,7 @@ profile = mobile-7.0
 USER_SRCS = ./src/daemon/*.c ./src/common/*.c
 
 # User Defines
-USER_DEFS = USE_DLOG USE_SERVICE_APP ESPP_SERVICE_VERSION="0.3.7"
+USER_DEFS = USE_DLOG USE_SERVICE_APP ESPP_SERVICE_VERSION="0.3.8"
 
 # User Includes
 USER_INC_DIRS = ./src/daemon ./src/common ./inc ./inc/esplusplayer_capi
index 61850da95847897e9350a184edf30275eef588e2..fe993a985827bae2a50f74d53f451ea8a128cc6d 100644 (file)
@@ -587,6 +587,41 @@ int espp_client_set_audio_mute(espp_h espp, bool mute)
        return ESPP_CLIENT_ERROR_NONE;
 }
 
+int espp_client_set_audio_volume(espp_h espp, int volume)
+{
+       espp_s *_espp = (espp_s *)espp;
+       g_autoptr(GMutexLocker) locker = NULL;
+
+       RET_VAL_IF(!espp, ESPP_CLIENT_ERROR_INVALID_PARAMETER, "espp is NULL");
+
+       locker = g_mutex_locker_new(&_espp->mutex);
+
+       if (espp_service_client_socket_request_set_audio_volume(_espp, volume) != 0)
+               return ESPP_CLIENT_ERROR_INVALID_OPERATION;
+
+       LOG_INFO("espp[%p] volume[%d]", espp, volume);
+
+       return ESPP_CLIENT_ERROR_NONE;
+}
+
+int espp_client_get_audio_volume(espp_h espp, int *volume)
+{
+       espp_s *_espp = (espp_s *)espp;
+       g_autoptr(GMutexLocker) locker = NULL;
+
+       RET_VAL_IF(!espp, ESPP_CLIENT_ERROR_INVALID_PARAMETER, "espp is NULL");
+       RET_VAL_IF(!volume, ESPP_CLIENT_ERROR_INVALID_PARAMETER, "volume is NULL");
+
+       locker = g_mutex_locker_new(&_espp->mutex);
+
+       if (espp_service_client_socket_request_get_audio_volume(_espp, volume) != 0)
+               return ESPP_CLIENT_ERROR_INVALID_OPERATION;
+
+       LOG_INFO("espp[%p] volume[%d]", espp, *volume);
+
+       return ESPP_CLIENT_ERROR_NONE;
+}
+
 int espp_client_submit_packet(espp_h espp, espp_packet_s *packet, espp_submit_error_e *error)
 {
        espp_s *_espp = (espp_s *)espp;
index 66c673e205b9a537a906e3d9caf2afdc709d9523..6df7b05f3c9165a9b9c4477a1cb055e6e63f1216 100644 (file)
@@ -701,6 +701,36 @@ int espp_client_set_display_visible(espp_h espp, bool visible);
  */
 int espp_client_set_audio_mute(espp_h espp, bool mute);
 
+/**
+ * @brief Sets volume of the audio stream.
+ * @param[in] espp    ESPP service client handle
+ * @param[in] volume  Volume level from 0 to 100
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #ESPP_CLIENT_ERROR_NONE Successful
+ * @retval #ESPP_CLIENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ESPP_CLIENT_ERROR_INVALID_OPERATION Invalid operation
+ * @pre espp_client_open() must be called before calling this function.
+ * @see espp_client_open()
+ * @see espp_client_get_audio_volume()
+ */
+int espp_client_set_audio_volume(espp_h espp, int volume);
+
+/**
+ * @brief Gets the current volume of the audio stream.
+ * @param[in] espp    ESPP service client handle
+ * @param[out] volume  Volume level from 0 to 100
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #ESPP_CLIENT_ERROR_NONE Successful
+ * @retval #ESPP_CLIENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ESPP_CLIENT_ERROR_INVALID_OPERATION Invalid operation
+ * @pre espp_client_open() must be called before calling this function.
+ * @see espp_client_open()
+ * @see espp_client_set_audio_volume()
+ */
+int espp_client_get_audio_volume(espp_h espp, int *volume);
+
 /**
  * @brief Submits ESPP packet.
  * @param[in] espp    ESPP service client handle
index ba6645dc64071fc7790e75467a51aa7e21bd30e2..02a8c13e0538414c0fd1002858b59ef963e80a3b 100644 (file)
@@ -91,6 +91,8 @@ int espp_service_client_socket_request_set_display_mode(espp_s *espp, espp_displ
 int espp_service_client_socket_request_set_display_roi(espp_s *espp, int x, int y, int w, int h);
 int espp_service_client_socket_request_set_display_visible(espp_s *espp, bool visible);
 int espp_service_client_socket_request_set_audio_mute(espp_s *espp, bool mute);
+int espp_service_client_socket_request_set_audio_volume(espp_s *espp, int volume);
+int espp_service_client_socket_request_get_audio_volume(espp_s *espp, int *volume);
 int espp_service_client_socket_request_set_callback(espp_s *espp, espp_service_event_e type, void *callback, void *user_data);
 int espp_service_client_socket_request_submit_packet(espp_s *espp, espp_packet_s *packet, espp_submit_error_e *error);
 int espp_service_client_socket_request_submit_eos_packet(espp_s *espp, espp_stream_type_e stream_type, espp_submit_error_e *error);
index 645b3a11a563de9fceb7d116d25600ee667d03fc..b78ac4933c8f595cfa794a7759da7fdcec4049cd 100644 (file)
@@ -703,6 +703,49 @@ int espp_service_client_socket_request_set_audio_mute(espp_s *espp, bool mute)
        return 0;
 }
 
+int espp_service_client_socket_request_set_audio_volume(espp_s *espp, int volume)
+{
+       espp_service_data_from_client_s data;
+       espp_service_data_from_server_s result;
+
+       ASSERT(espp);
+       RET_VAL_IF(espp->fd == -1, -1, "fd is -1");
+
+       FILL_SOCKET_MSG_REQUEST(data, ESPP_SERVICE_REQUEST_SET_AUDIO_VOLUME);
+       FILL_SOCKET_MSG_PARAMS(data, ESPP_SERVICE_REQUEST_SET_AUDIO_VOLUME, "volume", volume);
+       if (send_data(espp->fd, &data, &result) != 0)
+               return -1;
+
+       RET_VAL_IF_SERVER_RESULT_ERROR(result, -1);
+
+       LOG_DEBUG("espp[%p], fd[%d]", espp, espp->fd);
+
+       return 0;
+}
+
+int espp_service_client_socket_request_get_audio_volume(espp_s *espp, int *volume)
+{
+       espp_service_data_from_client_s data;
+       espp_service_data_from_server_s result;
+
+       ASSERT(espp);
+       ASSERT(volume);
+
+       RET_VAL_IF(espp->fd == -1, -1, "fd is -1");
+
+       FILL_SOCKET_MSG_REQUEST(data, ESPP_SERVICE_REQUEST_GET_AUDIO_VOLUME);
+       if (send_data(espp->fd, &data, &result) != 0)
+               return -1;
+
+       RET_VAL_IF_SERVER_RESULT_ERROR(result, -1);
+
+       LOG_DEBUG("espp[%p], fd[%d]", espp, espp->fd);
+
+       *volume = result.ret_int;
+
+       return 0;
+}
+
 int espp_service_client_socket_request_set_callback(espp_s *espp, espp_service_event_e type, void *callback, void *user_data)
 {
        espp_service_data_from_client_s data;
index 435bc2480fcb8613e576303cc820474302911b15..67adb3fec93c1cf75521a8478eae4e5490d3e5f8 100644 (file)
@@ -11,7 +11,7 @@ profile = mobile-7.0
 USER_SRCS = ../common/*.c ./*.c
 
 # User Defines
-USER_DEFS = USE_DLOG USE_SERVICE_APP ESPP_SERVICE_VERSION="0.3.7"
+USER_DEFS = USE_DLOG USE_SERVICE_APP ESPP_SERVICE_VERSION="0.3.8"
 
 # User Includes
 USER_INC_DIRS = ../common ./
index 7daf6336bf2dc585ddad9675fa33e43f0b179199..c69b18ea0cb9933b674a3c413b40cd45bdb33a4b 100644 (file)
@@ -47,6 +47,8 @@ espp_service_ipc_data_s requests[] = {
        [ESPP_SERVICE_REQUEST_SET_DISPLAY_ROI] = { "SetDisplayRoi", "iiii" },
        [ESPP_SERVICE_REQUEST_SET_DISPLAY_VISIBLE] = { "SetDisplayVisible", "b" },
        [ESPP_SERVICE_REQUEST_SET_AUDIO_MUTE] = { "SetAudioMute", "b" },
+       [ESPP_SERVICE_REQUEST_SET_AUDIO_VOLUME] = { "SetAudioVolume", "i" },
+       [ESPP_SERVICE_REQUEST_GET_AUDIO_VOLUME] = { "GetAudioVolume", NULL },
        [ESPP_SERVICE_REQUEST_SUBMIT_PACKET] = { "SubmitPacket", "iukku" },
        [ESPP_SERVICE_REQUEST_SUBMIT_EOS_PACKET] = { "SubmitEosPacket", "i" },
        [ESPP_SERVICE_REQUEST_SET_BUFFER_SIZE] = { "SetBufferSize", "ik" },
index 273b394b53f349b3103f1a0b54cedf509aeaec2b..aab3a17c66b6ccd22866bb464f0097acd3500eb5 100644 (file)
@@ -48,6 +48,8 @@ typedef enum {
        ESPP_SERVICE_REQUEST_SET_DISPLAY_ROI,
        ESPP_SERVICE_REQUEST_SET_DISPLAY_VISIBLE,
        ESPP_SERVICE_REQUEST_SET_AUDIO_MUTE,
+       ESPP_SERVICE_REQUEST_SET_AUDIO_VOLUME,
+       ESPP_SERVICE_REQUEST_GET_AUDIO_VOLUME,
        ESPP_SERVICE_REQUEST_SUBMIT_PACKET,
        ESPP_SERVICE_REQUEST_SUBMIT_EOS_PACKET,
        ESPP_SERVICE_REQUEST_SET_BUFFER_SIZE,
index 24853d63d1020ba4ef870ecf51883a19b36e98e1..6d16495d89b755c06631307621be8e15c9d4e6dd 100644 (file)
@@ -609,6 +609,56 @@ static void __handle_set_audio_mute(handler_userdata_s *hdata, espp_service_data
        result->ret = 0;
 }
 
+static void __handle_set_audio_volume(handler_userdata_s *hdata, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
+{
+       int ret;
+       int volume;
+
+       ASSERT(hdata);
+       ASSERT(data);
+       ASSERT(result);
+       ASSERT(hdata->svc);
+       ASSERT(hdata->fd >= 0);
+
+       result->ret = -1;
+
+       RET_IF(!g_hash_table_lookup(hdata->svc->fd_table, hdata->key), "failed to g_hash_table_lookup(), key[%s]", hdata->key);
+
+       ret = espp_service_msg_parse_params(data->params, data->request, &volume);
+       if (ret != 0)
+               return;
+
+       ret = esplusplayer_set_volume((esplusplayer_handle)hdata->espp, volume);
+       RET_IF(ret != ESPLUSPLAYER_ERROR_TYPE_NONE, "failed to esplusplayer_set_volume(), ESPP[%p], volume[%d]", hdata->espp, volume);
+
+       LOG_INFO("fd[%d], ESPP[%p]: esplusplayer_set_volume() success, volume[%d]", hdata->fd, hdata->espp, volume);
+
+       result->ret = 0;
+}
+
+static void __handle_get_audio_volume(handler_userdata_s *hdata, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
+{
+       int ret;
+
+       ASSERT(hdata);
+       ASSERT(data);
+       ASSERT(result);
+       ASSERT(hdata->svc);
+       ASSERT(hdata->fd >= 0);
+
+       result->ret = -1;
+
+       RET_IF(!g_hash_table_lookup(hdata->svc->fd_table, hdata->key), "failed to g_hash_table_lookup(), key[%s]", hdata->key);
+
+       ret = esplusplayer_get_volume((esplusplayer_handle)hdata->espp, &result->ret_int);
+       RET_IF(ret != ESPLUSPLAYER_ERROR_TYPE_NONE, "failed to esplusplayer_get_volume(), ESPP[%p]", hdata->espp);
+
+       LOG_INFO("fd[%d], ESPP[%p]: esplusplayer_get_volume() success, volume[%d]",
+               hdata->fd, hdata->espp, result->ret_int);
+
+       result->ret = 0;
+}
+
 static void __handle_submit_packet(handler_userdata_s *hdata, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
 {
        int ret;
@@ -927,6 +977,8 @@ static func_handler handlers[] = {
        [ESPP_SERVICE_REQUEST_SET_DISPLAY_ROI] = __handle_set_display_roi,
        [ESPP_SERVICE_REQUEST_SET_DISPLAY_VISIBLE] = __handle_set_display_visible,
        [ESPP_SERVICE_REQUEST_SET_AUDIO_MUTE] = __handle_set_audio_mute,
+       [ESPP_SERVICE_REQUEST_SET_AUDIO_VOLUME] = __handle_set_audio_volume,
+       [ESPP_SERVICE_REQUEST_GET_AUDIO_VOLUME] = __handle_get_audio_volume,
        [ESPP_SERVICE_REQUEST_SUBMIT_PACKET] = __handle_submit_packet,
        [ESPP_SERVICE_REQUEST_SUBMIT_EOS_PACKET] = __handle_submit_eos_packet,
        [ESPP_SERVICE_REQUEST_SET_BUFFER_SIZE] = __handle_set_buffer_size,
index bdb71296096033ae344bacdecb1d1bdda76ff5f6..dbe94b76d9c867414d6cbc24712a7b10af3b8e87 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<manifest xmlns="http://tizen.org/ns/packages" api-version="7.0" package="com.samsung.tizen.espp-service" version="0.3.7">
+<manifest xmlns="http://tizen.org/ns/packages" api-version="7.0" package="com.samsung.tizen.espp-service" version="0.3.8">
     <profile name="mobile"/>
     <description>espp-service</description>
     <service-application appid="com.samsung.tizen.espp-service" auto-restart="false" exec="espp-service" multiple="false" nodisplay="false" on-boot="false" taskmanage="false" type="capp">