Add API - espp_client_set_playback_rate()
authorSangchul Lee <sc11.lee@samsung.com>
Mon, 15 May 2023 05:46:27 +0000 (14:46 +0900)
committer이상철/Tizen Platform Lab(SR)/삼성전자 <sc11.lee@samsung.com>
Mon, 15 May 2023 08:22:29 +0000 (17:22 +0900)
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
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/common/espp_service_ipc.c
src/common/espp_service_ipc.h
src/daemon/espp_service_handler.c

index ccf83bbc437e8d372188bd263b43393d835cfbbc..af8dfc1c193712bb7863efd940dde5cd7540d5db 100644 (file)
@@ -433,6 +433,23 @@ int espp_client_set_video_stream_info(espp_h espp, espp_video_stream_info_s *inf
        return ESPP_CLIENT_ERROR_NONE;
 }
 
+int espp_client_set_playback_rate(espp_h espp, double rate, bool mute_audio)
+{
+       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_playback_rate(_espp, rate, mute_audio) != 0)
+               return ESPP_CLIENT_ERROR_INVALID_OPERATION;
+
+       LOG_INFO("espp[%p] rate[%f] mute_audio[%d]", espp, rate, mute_audio);
+
+       return ESPP_CLIENT_ERROR_NONE;
+}
+
 int espp_client_set_display_surface_id(espp_h espp, espp_display_type_e type, unsigned int surface_id, int x, int y, int w, int h)
 {
        espp_s *_espp = (espp_s *)espp;
index 447ce968d3d7364743a5336a3d7307202b1dbdca..01b226981aefbecb654c456b029c78542bdb1279 100644 (file)
@@ -545,6 +545,22 @@ int espp_client_set_audio_stream_info(espp_h espp, espp_audio_stream_info_s *inf
  */
 int espp_client_set_video_stream_info(espp_h espp, espp_video_stream_info_s *info);
 
+/**
+ * @brief Sets the playback rate.
+ * @remarks User has to push the data as fast as playback rate.
+ * @param[in] espp       ESPP service client handle
+ * @param[in] rate       The playback rate from 0.0 to 2.0
+ * @param[in] mute_audio Mute audio or not (@c true = mute, @c false = not mute)
+ * @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 The state must be one of #ESPP_STATE_READY or #ESPP_STATE_PAUSED or #ESPP_STATE_PLAYING.
+ * @see espp_client_prepare_async()
+ */
+int espp_client_set_playback_rate(espp_h espp, double rate, bool mute_audio);
+
 /**
  * @brief Sets the video display surface id.
  * @param[in] espp       ESPP service client handle
index dec45c6909c451644b87dcf5d5f60658b5c37d86..a900b1eefb854f6542f3723c99e97817912cfed1 100644 (file)
@@ -83,6 +83,7 @@ int espp_service_client_socket_request_get_state(espp_s *espp, espp_state_e *sta
 int espp_service_client_socket_request_get_playing_time(espp_s *espp, uint64_t *time_ms);
 int espp_service_client_socket_request_set_audio_stream_info(espp_s *espp, espp_audio_stream_info_s *info);
 int espp_service_client_socket_request_set_video_stream_info(espp_s *espp, espp_video_stream_info_s *info);
+int espp_service_client_socket_request_set_playback_rate(espp_s *espp, double rate, bool mute_audio);
 int espp_service_client_socket_request_set_display_surface_id(espp_s *espp, espp_display_type_e type, unsigned int surface_id, int x, int y, int w, int h);
 int espp_service_client_socket_request_set_display_mode(espp_s *espp, espp_display_mode_e mode);
 int espp_service_client_socket_request_set_display_roi(espp_s *espp, int x, int y, int w, int h);
index c0c56f7e392f3ad0ed5afc68596eab5ba69bf4ca..ecfddd03df19e00c83fd2b756e5c528a6f9a25e6 100644 (file)
@@ -568,6 +568,28 @@ int espp_service_client_socket_request_set_video_stream_info(espp_s *espp, espp_
        return 0;
 }
 
+
+int espp_service_client_socket_request_set_playback_rate(espp_s *espp, double rate, bool mute_audio)
+{
+       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_PLAYBACK_RATE);
+       FILL_SOCKET_MSG_PARAMS(data, ESPP_SERVICE_REQUEST_SET_PLAYBACK_RATE,
+               "rate", rate, "mute_audio", mute_audio);
+       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_set_display_surface_id(espp_s *espp, espp_display_type_e type, unsigned int surface_id, int x, int y, int w, int h)
 {
        espp_service_data_from_client_s data;
index fc075094aa5cc27a069b7219c99d99222662202a..c9eb3e5716aea3403a3762f456a2af5adca39bb4 100644 (file)
@@ -33,6 +33,7 @@ espp_service_ipc_data_s requests[] = {
        [ESPP_SERVICE_REQUEST_GET_PLAYING_TIME] = { "GetPlayingTime", NULL },
        [ESPP_SERVICE_REQUEST_SET_AUDIO_STREAM_INFO] = { "SetAudioStreamInfo", "suiuuu" },
        [ESPP_SERVICE_REQUEST_SET_VIDEO_STREAM_INFO] = { "SetVideoStreamInfo", "suiuuuuuu" },
+       [ESPP_SERVICE_REQUEST_SET_PLAYBACK_RATE] = { "SetPlaybackRate", "db" },
        [ESPP_SERVICE_REQUEST_SET_DISPLAY_SURFACE_ID] = { "SetDisplaySurfaceId", "iuiiii" },
        [ESPP_SERVICE_REQUEST_SET_DISPLAY_MODE] = { "SetDisplayMode", "i" },
        [ESPP_SERVICE_REQUEST_SET_DISPLAY_ROI] = { "SetDisplayRoi", "iiii" },
index 85e669a399529ebe1bbf3503865435cd28f8338d..11b1375cf1646f009a9b41cfe3c2b2ad07e141ac 100644 (file)
@@ -42,6 +42,7 @@ typedef enum {
        ESPP_SERVICE_REQUEST_GET_PLAYING_TIME,
        ESPP_SERVICE_REQUEST_SET_AUDIO_STREAM_INFO,
        ESPP_SERVICE_REQUEST_SET_VIDEO_STREAM_INFO,
+       ESPP_SERVICE_REQUEST_SET_PLAYBACK_RATE,
        ESPP_SERVICE_REQUEST_SET_DISPLAY_SURFACE_ID,
        ESPP_SERVICE_REQUEST_SET_DISPLAY_MODE,
        ESPP_SERVICE_REQUEST_SET_DISPLAY_ROI,
index 56ed60128ff8597c2970b57518258d5e429ba608..4df647f703edcd5967d93443a5124e5b4042f003 100644 (file)
@@ -408,6 +408,37 @@ static void __handle_set_video_stream_info(handler_userdata_s *hdata, espp_servi
        result->ret = 0;
 }
 
+static void __handle_set_playback_rate(handler_userdata_s *hdata, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
+{
+       int ret;
+       double rate;
+       bool mute_audio;
+
+       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,
+               &rate, &mute_audio);
+       if (ret != 0)
+               return;
+
+       ret = esplusplayer_set_playback_rate((esplusplayer_handle)hdata->espp, rate, mute_audio);
+       RET_IF(ret != ESPLUSPLAYER_ERROR_TYPE_NONE, "failed to esplusplayer_set_playback_rate(), ESPP[%p], rate[%f], mute_audio[%d]",
+               hdata->espp, rate, mute_audio);
+
+       LOG_INFO("fd[%d], ESPP[%p]: esplusplayer_set_playback_rate() success, rate[%f], mute_audio[%d]",
+               hdata->fd, hdata->espp, rate, mute_audio);
+
+       result->ret = 0;
+}
+
 static void __handle_set_display_surface_id(handler_userdata_s *hdata, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
 {
        int ret;
@@ -809,6 +840,7 @@ static func_handler handlers[] = {
        [ESPP_SERVICE_REQUEST_GET_PLAYING_TIME] = __handle_get_playing_time,
        [ESPP_SERVICE_REQUEST_SET_AUDIO_STREAM_INFO] = __handle_set_audio_stream_info,
        [ESPP_SERVICE_REQUEST_SET_VIDEO_STREAM_INFO] = __handle_set_video_stream_info,
+       [ESPP_SERVICE_REQUEST_SET_PLAYBACK_RATE] = __handle_set_playback_rate,
        [ESPP_SERVICE_REQUEST_SET_DISPLAY_SURFACE_ID] = __handle_set_display_surface_id,
        [ESPP_SERVICE_REQUEST_SET_DISPLAY_MODE] = __handle_set_display_mode,
        [ESPP_SERVICE_REQUEST_SET_DISPLAY_ROI] = __handle_set_display_roi,