Add API - espp_client_set_buffer_size()
authorSangchul Lee <sc11.lee@samsung.com>
Fri, 12 May 2023 09:08:49 +0000 (18:08 +0900)
committer이상철/Tizen Platform Lab(SR)/삼성전자 <sc11.lee@samsung.com>
Mon, 15 May 2023 05:55:03 +0000 (14:55 +0900)
[Version] 0.1.11

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 2025588e5734f26feed86c9d69f1f9ea50faf8c2..21f6757a58f120192c22bca12836cfe06238b5a4 100644 (file)
@@ -535,3 +535,19 @@ int espp_client_submit_eos_packet(espp_h espp, espp_stream_type_e stream_type, e
        return ESPP_CLIENT_ERROR_NONE;
 }
 
+int espp_client_set_buffer_size(espp_h espp, espp_buffer_size_type_e size_type, uint64_t size)
+{
+       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_buffer_size(_espp, size_type, size) != 0)
+               return ESPP_CLIENT_ERROR_INVALID_OPERATION;
+
+       LOG_INFO("espp[%p] size_type[%d] size[%" PRIu64 "]", espp, size_type, size);
+
+       return ESPP_CLIENT_ERROR_NONE;
+}
index 4d77e4873c3c290e596beaa3f528ab33d031a072..062b2e7fc108cbd92ba16ce7c462f2e31eee6eb9 100644 (file)
@@ -133,6 +133,20 @@ typedef enum {
        ESPP_BUFFER_STATUS_OVERRUN,    /**< Overrun */
 } espp_buffer_status_e;
 
+/**
+ * @brief  Enumerations for buffer size type
+ */
+typedef enum {
+  ESPP_BUFFER_SIZE_TYPE_AUDIO_MAX_TIME,            /**< The maximum amount of data for audio (in ms) */
+  ESPP_BUFFER_SIZE_TYPE_VIDEO_MAX_TIME,            /**< The maximum amount of data for video (in ms) */
+  ESPP_BUFFER_SIZE_TYPE_AUDIO_MIN_TIME_THRESHOLD,  /**< Emit underrun when queued bytes drops below the percent of the audio max time (in %) */
+  ESPP_BUFFER_SIZE_TYPE_VIDEO_MIN_TIME_THRESHOLD,  /**< Emit underrun when queued bytes drops below the percent of the video max time (in %) */
+  ESPP_BUFFER_SIZE_TYPE_AUDIO_MAX_BYTE,            /**< The maximum amount of data for audio (in bytes) */
+  ESPP_BUFFER_SIZE_TYPE_VIDEO_MAX_BYTE,            /**< The maximum amount of data for video (in bytes) */
+  ESPP_BUFFER_SIZE_TYPE_AUDIO_MIN_BYTE_THRESHOLD,  /**< Emit underrun when queued bytes drops below the percent of the audio max bytes size (in %) */
+  ESPP_BUFFER_SIZE_TYPE_VIDEO_MIN_BYTE_THRESHOLD,  /**< Emit underrun when queued bytes drops below the percent of the video max bytes size (in %) */
+} espp_buffer_size_type_e;
+
 /**
  * @brief Enumerations for the submit error
  */
@@ -618,7 +632,7 @@ int espp_client_submit_packet(espp_h espp, espp_packet_s *packet, espp_submit_er
 /**
  * @brief Generates EoS(End of Stream) packet and submits it.
  * @param[in] espp         ESPP service client handle
- * @param[in] stream_type  The stream type that reaches EoS.
+ * @param[in] stream_type  The stream type that reaches EoS
  * @param[out] error       ESPP packet submit error (optional, this can be NULL)
  * @return @c 0 on success,
  *         otherwise a negative error value
@@ -631,6 +645,21 @@ int espp_client_submit_packet(espp_h espp, espp_packet_s *packet, espp_submit_er
  */
 int espp_client_submit_eos_packet(espp_h espp, espp_stream_type_e stream_type, espp_submit_error_e *error);
 
+/**
+ * @brief Sets buffer size.
+ * @param[in] espp    ESPP service client handle
+ * @param[in] type    The buffer size type to be set
+ * @param[in] size    The size of the selected buffer type
+ * @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_open()
+ */
+int espp_client_set_buffer_size(espp_h espp, espp_buffer_size_type_e size_type, uint64_t size);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index a942232a7a735fc8a3a493e97782fe4daee56010..1932711d079807c770b60f8b6f0b75cd6997068a 100644 (file)
@@ -90,6 +90,7 @@ int espp_service_client_socket_request_set_audio_mute(espp_s *espp, bool mute);
 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);
+int espp_service_client_socket_request_set_buffer_size(espp_s *espp, espp_buffer_size_type_e size_type, uint64_t size);
 
 /* event handler */
 gpointer espp_service_client_event_handler_thread_func(gpointer user_data);
index 881cacb52dfef7f1b919181b425c36039d907154..1bc8e175eed8c484c7bf5920fef538fcba60ac69 100644 (file)
@@ -720,3 +720,24 @@ int espp_service_client_socket_request_submit_eos_packet(espp_s *espp, espp_stre
 
        return 0;
 }
+
+int espp_service_client_socket_request_set_buffer_size(espp_s *espp, espp_buffer_size_type_e size_type, uint64_t size)
+{
+       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_BUFFER_SIZE);
+       FILL_SOCKET_MSG_PARAMS(data, ESPP_SERVICE_REQUEST_SET_BUFFER_SIZE,
+               "size_type", size_type, "size", size);
+       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 57023ba7ce14410e4ebabee45237b82b1e1981ca..d5f40c5c39fe17f84c89bcf706560a2dd79b38c9 100644 (file)
@@ -39,6 +39,7 @@ espp_service_ipc_data_s requests[] = {
        [ESPP_SERVICE_REQUEST_SET_AUDIO_MUTE] = { "SetAudioMute", "b" },
        [ESPP_SERVICE_REQUEST_SUBMIT_PACKET] = { "SubmitPacket", "iukku" },
        [ESPP_SERVICE_REQUEST_SUBMIT_EOS_PACKET] = { "SubmitEosPacket", "i" },
+       [ESPP_SERVICE_REQUEST_SET_BUFFER_SIZE] = { "SetBufferSize", "ik" },
        [ESPP_SERVICE_REQUEST_SET_CALLBACK] = { "SetCallback", "i" },
 };
 
index a9742497d2e8b3cc4bb46cf653ea95613297a6c3..6a6773d06071e09fb0508b61aca2a5f5742cc72c 100644 (file)
@@ -48,6 +48,7 @@ typedef enum {
        ESPP_SERVICE_REQUEST_SET_AUDIO_MUTE,
        ESPP_SERVICE_REQUEST_SUBMIT_PACKET,
        ESPP_SERVICE_REQUEST_SUBMIT_EOS_PACKET,
+       ESPP_SERVICE_REQUEST_SET_BUFFER_SIZE,
        ESPP_SERVICE_REQUEST_SET_CALLBACK,
 } espp_service_request_e;
 
index 7e96c283fa2c91ddc3e4b8dc48926f0580208f46..602b242a7b6bcfd3dfc2e71cae73af563b33a5a8 100644 (file)
@@ -585,6 +585,27 @@ static void __handle_submit_eos_packet(handler_userdata_s *hdata, espp_service_d
        result->ret = 0;
 }
 
+static void __handle_set_buffer_size(handler_userdata_s *hdata, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
+{
+       int ret;
+       esplusplayer_buffer_option option;
+       uint64_t size;
+
+       ret = espp_service_msg_parse_params(data->params, data->request,
+               &option, &size);
+       if (ret != 0)
+               return;
+
+       ret = esplusplayer_set_buffer_size((esplusplayer_handle)hdata->espp, option, size);
+       RET_IF(ret != ESPLUSPLAYER_ERROR_TYPE_NONE, "failed to esplusplayer_set_buffer_size(), ESPP[%p], option[%d], size[%" PRIu64 "]",
+               hdata->espp, option, size);
+
+       LOG_INFO("fd[%d], ESPP[%p]: esplusplayer_set_buffer_size() success, option[%d], size[%" PRIu64 "]",
+               hdata->fd, hdata->espp, option, size);
+
+       result->ret = 0;
+}
+
 static void __ready_to_prepare_cb(const int type, void *user_data)
 {
        handler_userdata_s *hdata = (handler_userdata_s *)user_data;
@@ -771,6 +792,7 @@ static func_handler handlers[] = {
        [ESPP_SERVICE_REQUEST_SET_AUDIO_MUTE] = __handle_set_audio_mute,
        [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,
        [ESPP_SERVICE_REQUEST_SET_CALLBACK] = __handle_set_callback,
 };