Add API - espp_client_submit_eos_packet()
authorSangchul Lee <sc11.lee@samsung.com>
Fri, 12 May 2023 08:31:06 +0000 (17:31 +0900)
committer이상철/Tizen Platform Lab(SR)/삼성전자 <sc11.lee@samsung.com>
Mon, 15 May 2023 05:55:03 +0000 (14:55 +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 9b7ca431944b71000413474855c29bfcb36329be..2025588e5734f26feed86c9d69f1f9ea50faf8c2 100644 (file)
@@ -518,3 +518,20 @@ int espp_client_submit_packet(espp_h espp, espp_packet_s *packet, espp_submit_er
        return ESPP_CLIENT_ERROR_NONE;
 }
 
+int espp_client_submit_eos_packet(espp_h espp, espp_stream_type_e stream_type, espp_submit_error_e *error)
+{
+       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_submit_eos_packet(_espp, stream_type, error) != 0)
+               return ESPP_CLIENT_ERROR_INVALID_OPERATION;
+
+       LOG_INFO("espp[%p] stream_type[%d]", espp, stream_type);
+
+       return ESPP_CLIENT_ERROR_NONE;
+}
+
index 3ba70a4fcfcff2bf075a3e981a7fdb658792e247..4d77e4873c3c290e596beaa3f528ab33d031a072 100644 (file)
@@ -615,6 +615,22 @@ int espp_client_set_audio_mute(espp_h espp, bool mute);
  */
 int espp_client_submit_packet(espp_h espp, espp_packet_s *packet, espp_submit_error_e *error);
 
+/**
+ * @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[out] error       ESPP packet submit error (optional, this can be NULL)
+ * @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
+ * @see espp_ready_to_prepare_cb()
+ * @see espp_seek_done_cb()
+ * @see espp_buffer_status_cb()
+ */
+int espp_client_submit_eos_packet(espp_h espp, espp_stream_type_e stream_type, espp_submit_error_e *error);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index 0fc13aa21e51d40523d53fdc56f880172d27a0a6..a942232a7a735fc8a3a493e97782fe4daee56010 100644 (file)
@@ -89,6 +89,7 @@ int espp_service_client_socket_request_set_display_visible(espp_s *espp, bool vi
 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);
 
 /* event handler */
 gpointer espp_service_client_event_handler_thread_func(gpointer user_data);
index 5eaedd1c4ec23bb07e1e80b0f8a0a0f2c96823b6..881cacb52dfef7f1b919181b425c36039d907154 100644 (file)
@@ -697,3 +697,26 @@ int espp_service_client_socket_request_submit_packet(espp_s *espp, espp_packet_s
 
        return 0;
 }
+
+int espp_service_client_socket_request_submit_eos_packet(espp_s *espp, espp_stream_type_e stream_type, espp_submit_error_e *error)
+{
+       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_SUBMIT_EOS_PACKET);
+       FILL_SOCKET_MSG_PARAMS(data, ESPP_SERVICE_REQUEST_SUBMIT_EOS_PACKET, "stream_type", stream_type);
+       if (send_data(espp->fd, &data, &result) != 0)
+               return -1;
+
+       if (result.ret != 0 && error)
+               *error = result.ret;
+
+       RET_VAL_IF_SERVER_RESULT_ERROR(result, -1);
+
+       LOG_DEBUG("espp[%p], fd[%d]", espp, espp->fd);
+
+       return 0;
+}
index 928f69b553f44d2623feb272868499a5b14e7aa5..57023ba7ce14410e4ebabee45237b82b1e1981ca 100644 (file)
@@ -38,6 +38,7 @@ espp_service_ipc_data_s requests[] = {
        [ESPP_SERVICE_REQUEST_SET_DISPLAY_VISIBLE] = { "SetDisplayVisible", "b" },
        [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_CALLBACK] = { "SetCallback", "i" },
 };
 
index 315d258417b56b8843d963f56aaaa671567f18f6..a9742497d2e8b3cc4bb46cf653ea95613297a6c3 100644 (file)
@@ -47,6 +47,7 @@ typedef enum {
        ESPP_SERVICE_REQUEST_SET_DISPLAY_VISIBLE,
        ESPP_SERVICE_REQUEST_SET_AUDIO_MUTE,
        ESPP_SERVICE_REQUEST_SUBMIT_PACKET,
+       ESPP_SERVICE_REQUEST_SUBMIT_EOS_PACKET,
        ESPP_SERVICE_REQUEST_SET_CALLBACK,
 } espp_service_request_e;
 
index 0600a4872f75da26f3f17473f440d162badeef57..7e96c283fa2c91ddc3e4b8dc48926f0580208f46 100644 (file)
@@ -554,7 +554,7 @@ static void __handle_submit_packet(handler_userdata_s *hdata, espp_service_data_
        status = esplusplayer_submit_packet((esplusplayer_handle)hdata->espp, &es_packet);
        if (status != ESPLUSPLAYER_SUBMIT_STATUS_SUCCESS) {
                result->ret = status;
-               LOG_ERROR("failed to esplusplayer_submit_packet(), status:%d", status);
+               LOG_ERROR("failed to esplusplayer_submit_packet(), status[%d]", status);
                return;
        }
 
@@ -563,6 +563,28 @@ static void __handle_submit_packet(handler_userdata_s *hdata, espp_service_data_
        result->ret = 0;
 }
 
+static void __handle_submit_eos_packet(handler_userdata_s *hdata, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
+{
+       int ret;
+       esplusplayer_submit_status status;
+       esplusplayer_stream_type stream_type;
+
+       ret = espp_service_msg_parse_params(data->params, data->request, &stream_type);
+       if (ret != 0)
+               return;
+
+       status = esplusplayer_submit_eos_packet((esplusplayer_handle)hdata->espp, stream_type);
+       if (status != ESPLUSPLAYER_SUBMIT_STATUS_SUCCESS) {
+               result->ret = status;
+               LOG_ERROR("failed to esplusplayer_submit_eos_packet(), stream_type[%d], status[%d]", stream_type, status);
+               return;
+       }
+
+       LOG_INFO("fd[%d], ESPP[%p]: esplusplayer_submit_eos_packet() success, stream_type[%d]", hdata->fd, hdata->espp, stream_type);
+
+       result->ret = 0;
+}
+
 static void __ready_to_prepare_cb(const int type, void *user_data)
 {
        handler_userdata_s *hdata = (handler_userdata_s *)user_data;
@@ -748,6 +770,7 @@ static func_handler handlers[] = {
        [ESPP_SERVICE_REQUEST_SET_DISPLAY_VISIBLE] = __handle_set_display_visible,
        [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_CALLBACK] = __handle_set_callback,
 };