Add API - espp_client_set_render_time_offset() 29/301629/1 accepted/tizen/8.0/unified/20231122.173257
authorEunhye Choi <eunhae1.choi@samsung.com>
Mon, 20 Nov 2023 10:48:37 +0000 (19:48 +0900)
committereunhae choi <eunhae1.choi@samsung.com>
Tue, 21 Nov 2023 04:06:38 +0000 (04:06 +0000)
[Version] 0.3.13

Change-Id: Ib491ef20e5d35e71d2c46c8bd416b2c1f7e38f77
(cherry picked from commit 0b04c5368dccc61e5b3934a3f5f99c4293cfc86f)

packaging/espp-service.spec
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 d766b3a9b133a1888fab8ff06987b90111b26811..1e6977858caf5d1db9295cdcc6191b460327c6c2 100644 (file)
@@ -1,6 +1,6 @@
 Name:       espp-service
 Summary:    ESPP service package which contains client lib. and daemon binary
-Version:    0.3.12
+Version:    0.3.13
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index 707d845942a2015a88ddffc5f2f9d64fa14d462d..de836256bb65abbb51582a84c45aa9f565119fff 100644 (file)
@@ -760,3 +760,20 @@ int espp_client_take_snapshot(espp_h espp, espp_snapshot_cb callback, void *user
 
        return ESPP_CLIENT_ERROR_NONE;
 }
+
+int espp_client_set_render_time_offset(espp_h espp, espp_stream_type_e stream_type, int64_t time_offset_ms)
+{
+       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_render_time_offset(_espp, stream_type, time_offset_ms) != 0)
+               return ESPP_CLIENT_ERROR_INVALID_OPERATION;
+
+       LOG_INFO("espp[%p] stream_type[%d] time_offset_ms[%" PRId64 "]", espp, stream_type, time_offset_ms);
+
+       return ESPP_CLIENT_ERROR_NONE;
+}
index 36c0a19208bc76bab6f96072ce5b699b4b4b820d..c13fbc47b4b6eafde6d5c595616cc4c9af3641c8 100644 (file)
@@ -863,6 +863,24 @@ int espp_client_set_decoded_video_frame_buffer_type(espp_h espp, espp_decoded_vi
  */
 int espp_client_take_snapshot(espp_h espp, espp_snapshot_cb callback, void *user_data);
 
+/**
+ * @brief Sets the render time offset of the stream type.
+ * @remarks The default value of @a time_offset_ms is 0 and the valid range is between INT64_MIN/1000000 and INT64_MAX/1000000.
+ * @param[in] espp           ESPP service client handle
+ * @param[in] stream_type    The stream type to set render time offset
+ * @param[in] time_offset_ms Render time offset in milliseconds
+ * @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.
+ * @pre Low latency mode has to be set except for #ESPP_LOW_LATENCY_MODE_NONE and #ESPP_LOW_LATENCY_MODE_DISABLE_SYNC.
+ * @see espp_client_prepare_async()
+ * @see espp_client_set_low_latency_mode()
+ */
+int espp_client_set_render_time_offset(espp_h espp, espp_stream_type_e stream_type, int64_t time_offset_ms);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index 73ce028a790e6a0bd39b5ff66ee590681f51d49e..7678808d48da3e756af20b193f2a4395ca9208d4 100644 (file)
@@ -102,6 +102,7 @@ int espp_service_client_socket_request_set_buffer_size(espp_s *espp, espp_buffer
 int espp_service_client_socket_request_set_low_latency_mode(espp_s *espp, espp_low_latency_mode_e mode);
 int espp_service_client_socket_request_set_decoded_video_frame_buffer_type(espp_s *espp, espp_decoded_video_frame_buffer_type_e type);
 int espp_service_client_socket_request_take_snapshot(espp_s *espp, int id);
+int espp_service_client_socket_request_set_render_time_offset(espp_s *espp, espp_stream_type_e stream_type, int64_t time_offset_ms);
 
 /* event handler */
 gpointer espp_service_client_event_handler_thread_func(gpointer user_data);
index b46f7f958e20e3e1bfc76015827d5325f6a59208..ae2ee049b9f73f72789b697f798ea6ff21747ce1 100644 (file)
@@ -899,3 +899,25 @@ int espp_service_client_socket_request_take_snapshot(espp_s *espp, int id)
 
        return 0;
 }
+
+int espp_service_client_socket_request_set_render_time_offset(espp_s *espp, espp_stream_type_e stream_type, int64_t time_offset_ms)
+{
+       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_RENDER_TIME_OFFSET);
+       FILL_SOCKET_MSG_PARAMS(data, ESPP_SERVICE_REQUEST_SET_RENDER_TIME_OFFSET,
+               "stream_type", stream_type, "time_offset_ms", time_offset_ms);
+
+       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;
+}
index 77c5f75127da849a0a7cb850b5410c9daaaa566a..f1ab57232fba117e6eaea1aeac845de1ecdd11ab 100644 (file)
@@ -55,6 +55,7 @@ espp_service_ipc_data_s requests[] = {
        [ESPP_SERVICE_REQUEST_SET_LOW_LATENCY_MODE] = { "SetLowLatencyMode", "i" },
        [ESPP_SERVICE_REQUEST_SET_DECODED_VIDEO_FRAME_BUFFER_TYPE] = { "SetDecodedVideoFrameBufferType", "i" },
        [ESPP_SERVICE_REQUEST_TAKE_SNAPSHOT] = { "TakeSnapshot", "i" },
+       [ESPP_SERVICE_REQUEST_SET_RENDER_TIME_OFFSET] = { "SetRenderTimeOffset", "il" },
        [ESPP_SERVICE_REQUEST_SET_CALLBACK] = { "SetCallback", "i" },
 };
 
index c1fcf8f0919d86a00c1db2625dd7631d01f34a27..96f5268953f691ec73f2f59c64e2b034065214b4 100644 (file)
@@ -56,6 +56,7 @@ typedef enum {
        ESPP_SERVICE_REQUEST_SET_LOW_LATENCY_MODE,
        ESPP_SERVICE_REQUEST_SET_DECODED_VIDEO_FRAME_BUFFER_TYPE,
        ESPP_SERVICE_REQUEST_TAKE_SNAPSHOT,
+       ESPP_SERVICE_REQUEST_SET_RENDER_TIME_OFFSET,
        ESPP_SERVICE_REQUEST_SET_CALLBACK,
        ESPP_SERVICE_REQUEST_NUM,
 } espp_service_request_e;
index 46993c32a5b670fc3c7b01035357a3bf3425da20..2acaf2b495bbe2ccb81366949d109f56f7b20137 100644 (file)
@@ -997,6 +997,31 @@ static void __handle_take_snapshot(handler_userdata_s *hdata, espp_service_data_
        result->ret = 0;
 }
 
+static void __handle_set_render_time_offset(handler_userdata_s *hdata, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
+{
+       int ret;
+       esplusplayer_stream_type stream_type;
+       int64_t time_offset_ms;
+
+       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, &stream_type, &time_offset_ms);
+       if (ret != 0)
+               return;
+
+       ret = esplusplayer_set_render_time_offset((esplusplayer_handle)hdata->espp, stream_type, time_offset_ms);
+       RET_IF(ret != ESPLUSPLAYER_ERROR_TYPE_NONE,
+               "failed to esplusplayer_set_render_time_offset(), ESPP[%p], stream_type[%d], time_offset_ms[%" PRId64 "]",
+               hdata->espp, stream_type, time_offset_ms);
+
+       LOG_INFO("fd[%d], ESPP[%p]: esplusplayer_set_render_time_offset() success, stream_type[%d], time_offset_ms[%" PRId64 "]",
+               hdata->fd, hdata->espp, stream_type, time_offset_ms);
+
+       result->ret = 0;
+}
+
 static void __ready_to_prepare_cb(const int type, void *user_data)
 {
        handler_userdata_s *hdata = (handler_userdata_s *)user_data;
@@ -1232,6 +1257,7 @@ static func_handler handlers[] = {
        [ESPP_SERVICE_REQUEST_SET_LOW_LATENCY_MODE] = __handle_set_low_latency_mode,
        [ESPP_SERVICE_REQUEST_SET_DECODED_VIDEO_FRAME_BUFFER_TYPE] = __handle_set_decoded_video_frame_buffer_type,
        [ESPP_SERVICE_REQUEST_TAKE_SNAPSHOT] = __handle_take_snapshot,
+       [ESPP_SERVICE_REQUEST_SET_RENDER_TIME_OFFSET] = __handle_set_render_time_offset,
        [ESPP_SERVICE_REQUEST_SET_CALLBACK] = __handle_set_callback,
 };