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
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;
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
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
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
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
* @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,
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
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
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);
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;
[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" },
};
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;
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;
[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,
};