Add function - prepare_async()
authorSangchul Lee <sc11.lee@samsung.com>
Mon, 24 Apr 2023 02:27:42 +0000 (11:27 +0900)
committer이상철/Tizen Platform Lab(SR)/삼성전자 <sc11.lee@samsung.com>
Wed, 26 Apr 2023 05:43:33 +0000 (14:43 +0900)
[Version] 0.1.3

Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
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_common.c
src/common/espp_service_common.h
src/daemon/espp_service_handler.c

index 73062d84bede336c508600811dae6f3ad5abb47f..539b66afa43bc98cc1284c4ab7c8d1916c350717 100644 (file)
@@ -1,6 +1,6 @@
 Name:       espp-service
 Summary:    ESPP service package which contains client lib. and daemon binary
-Version:    0.1.2
+Version:    0.1.3
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index 1ccda19277627177ee53ef45e1567ed918177427..634e38336444a1ad1dd21c33eea278324f69c5f0 100644 (file)
@@ -130,6 +130,23 @@ int espp_client_stop(espp_h espp)
        return ESPP_CLIENT_ERROR_NONE;
 }
 
+int espp_client_prepare_async(espp_h espp)
+{
+       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_prepare_async(_espp) != 0)
+               return ESPP_CLIENT_ERROR_INVALID_OPERATION;
+
+       LOG_INFO("espp[%p]", espp);
+
+       return ESPP_CLIENT_ERROR_NONE;
+}
+
 int espp_client_set_audio_stream_info(espp_h espp, espp_audio_stream_info_s *info)
 {
        espp_s *_espp = (espp_s *)espp;
index 81cc8f2110ef8d9224848404d61b42adcd847c99..08f3c58c88edf5cbf6b961e8d350ecace57afb25 100644 (file)
@@ -122,7 +122,7 @@ typedef struct {
 int espp_client_create(espp_h *espp);
 
 /**
- * @brief Destroys the espp.
+ * @brief Destroys the ESPP service client handle.
  * @param[in] espp    ESPP service client handle
  * @return @c 0 on success,
  *         otherwise a negative error value
@@ -134,7 +134,7 @@ int espp_client_create(espp_h *espp);
 int espp_client_destroy(espp_h espp);
 
 /**
- * @brief Opens the espp.
+ * @brief Opens the ESPP service client handle.
  * @param[in] espp    ESPP service client handle
  * @return @c 0 on success,
  *         otherwise a negative error value
@@ -148,7 +148,7 @@ int espp_client_destroy(espp_h espp);
 int espp_client_open(espp_h espp);
 
 /**
- * @brief Closes the espp.
+ * @brief Closes the ESPP service client handle.
  * @param[in] espp    ESPP service client handle
  * @return @c 0 on success,
  *         otherwise a negative error value
@@ -161,7 +161,7 @@ int espp_client_open(espp_h espp);
 int espp_client_close(espp_h espp);
 
 /**
- * @brief Starts the espp.
+ * @brief Starts the ESPP service client handle.
  * @param[in] espp    ESPP service client handle
  * @return @c 0 on success,
  *         otherwise a negative error value
@@ -169,12 +169,15 @@ int espp_client_close(espp_h espp);
  * @retval #ESPP_CLIENT_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #ESPP_CLIENT_ERROR_INVALID_OPERATION Invalid operation
  * @see espp_client_create()
+ * @see espp_client_set_audio_stream_info()
+ * @see espp_client_set_video_stream_info()
+ * @see espp_client_prepare_async()
  * @see espp_client_stop()
  */
 int espp_client_start(espp_h espp);
 
 /**
- * @brief Stops the espp.
+ * @brief Stops the ESPP service client handle.
  * @remarks espp_client_close() must be called after this handle is stopped.
  * @param[in] espp    ESPP service client handle
  * @return @c 0 on success,
@@ -188,7 +191,22 @@ int espp_client_start(espp_h espp);
 int espp_client_stop(espp_h espp);
 
 /**
- * @brief Sets the audio stream information.
+ * @brief Prepares the ESPP service client handle asynchronously.
+ * @param[in] espp    ESPP service client handle
+ * @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
+ * @post espp_client_prepare_async_done_cb() will be called when the preparation is finished.
+ * @see espp_client_set_audio_stream_info()
+ * @see espp_client_set_video_stream_info()
+ * @see espp_client_start()
+ */
+int espp_client_prepare_async(espp_h espp);
+
+/**
+ * @brief Sets the audio stream information to the ESPP service client handle.
  * @remarks This function must be called before calling the espp_client_prepare_async().
  * @param[in] espp    ESPP service client handle
  * @param[in] info    Audio stream information structure pointer
@@ -203,7 +221,7 @@ int espp_client_stop(espp_h espp);
 int espp_client_set_audio_stream_info(espp_h espp, espp_audio_stream_info_s *info);
 
 /**
- * @brief Sets the video stream information.
+ * @brief Sets the video stream information to the ESPP service client handle.
  * @remarks This function must be called before calling the espp_client_prepare_async().
  * @param[in] espp    ESPP service client handle
  * @param[in] info    Video stream information structure pointer
index 62f811a90cb8f0d94a7d254aa537c4dea98b3fdf..6900e716cda8a2da66075cd7dbed5ae55abe8bfe 100644 (file)
@@ -43,6 +43,7 @@ int espp_service_client_socket_request_open(espp_s *espp);
 int espp_service_client_socket_request_close(espp_s *espp);
 int espp_service_client_socket_request_start(espp_s *espp);
 int espp_service_client_socket_request_stop(espp_s *espp);
+int espp_service_client_socket_request_prepare_async(espp_s *espp);
 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);
 
index ce6d041807a3132dd5d8765251e5f232de3dc39b..e2798552f46313b9db7fb31acae08c509c727ac5 100644 (file)
@@ -264,6 +264,25 @@ int espp_service_client_socket_request_stop(espp_s *espp)
        return 0;
 }
 
+int espp_service_client_socket_request_prepare_async(espp_s *espp)
+{
+       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_PREPARE_ASYNC);
+       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_audio_stream_info(espp_s *espp, espp_audio_stream_info_s *info)
 {
        espp_service_data_from_client_s data;
index 54c756ca8e6cd14a4e4d90129cee0469f11b26c7..fab1c804f4b1cab7fc09991d35500611681a4e1a 100644 (file)
@@ -23,6 +23,7 @@ espp_service_request_s requests[] = { /* str, param_formats - 'b':bool, 'i':int,
        [ESPP_SERVICE_REQUEST_CLOSE] = { "Close", NULL },
        [ESPP_SERVICE_REQUEST_START] = { "Start", NULL },
        [ESPP_SERVICE_REQUEST_STOP] = { "Stop", NULL },
+       [ESPP_SERVICE_REQUEST_PREPARE_ASYNC] = { "PrepareAsync", NULL },
        [ESPP_SERVICE_REQUEST_SET_AUDIO_STREAM_INFO] = { "SetAudioStreamInfo", "suiuuu" },
        [ESPP_SERVICE_REQUEST_SET_VIDEO_STREAM_INFO] = { "SetVideoStreamInfo", "suiuuuuuu" },
 };
index f6708284523e725ad35d908a74671a2a873b63cd..9f42a667c42cad3aa59b1f863b9d04ebabd83982 100644 (file)
@@ -128,6 +128,7 @@ typedef enum {
        ESPP_SERVICE_REQUEST_CLOSE,
        ESPP_SERVICE_REQUEST_START,
        ESPP_SERVICE_REQUEST_STOP,
+       ESPP_SERVICE_REQUEST_PREPARE_ASYNC,
        ESPP_SERVICE_REQUEST_SET_AUDIO_STREAM_INFO,
        ESPP_SERVICE_REQUEST_SET_VIDEO_STREAM_INFO,
 } espp_service_request_e;
index 4dc78a769a0d0ad7e1ce8a50554318e2fc6f6900..9e75398b8f4c2c99bfa5538a59cb1ea019417f98 100644 (file)
@@ -154,6 +154,28 @@ static void __handle_stop(espp_service_s *svc, int fd, espp_service_data_from_cl
        result->ret = 0;
 }
 
+static void __handle_prepare_async(espp_service_s *svc, int fd, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
+{
+       int ret;
+       esplusplayer_handle espp;
+
+       ASSERT(svc);
+       ASSERT(fd >= 0);
+       ASSERT(data);
+       ASSERT(result);
+
+       result->ret = -1;
+
+       RET_IF(!(espp = g_hash_table_lookup(svc->espp_handles, GINT_TO_POINTER(fd))), "failed to g_hash_table_lookup(), fd[%d]", fd);
+
+       ret = esplusplayer_prepare_async(espp);
+       RET_IF(ret != ESPLUSPLAYER_ERROR_TYPE_NONE, "failed to esplusplayer_prepare_async(), ESPP[%p]", espp);
+
+       LOG_INFO("fd[%d], ESPP[%p]: esplusplayer_prepare_async() success", fd, espp);
+
+       result->ret = 0;
+}
+
 static void __handle_set_audio_stream_info(espp_service_s *svc, int fd, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
 {
        int ret;
@@ -220,6 +242,7 @@ static func_handler handlers[] = {
        [ESPP_SERVICE_REQUEST_CLOSE] = __handle_close,
        [ESPP_SERVICE_REQUEST_START] = __handle_start,
        [ESPP_SERVICE_REQUEST_STOP] = __handle_stop,
+       [ESPP_SERVICE_REQUEST_PREPARE_ASYNC] = __handle_prepare_async,
        [ESPP_SERVICE_REQUEST_SET_AUDIO_STREAM_INFO] = __handle_set_audio_stream_info,
        [ESPP_SERVICE_REQUEST_SET_VIDEO_STREAM_INFO] = __handle_set_video_stream_info,
 };