return ESPP_CLIENT_ERROR_NONE;
}
+int espp_client_set_ready_to_seek_cb(espp_h espp, espp_ready_to_seek_cb callback, void *user_data)
+{
+ espp_s *_espp = (espp_s *)espp;
+ g_autoptr(GMutexLocker) locker = NULL;
+ g_autoptr(GMutexLocker) cb_locker = NULL;
+
+ RET_VAL_IF(!espp, ESPP_CLIENT_ERROR_INVALID_PARAMETER, "espp is NULL");
+ RET_VAL_IF(!callback, ESPP_CLIENT_ERROR_INVALID_PARAMETER, "callback is NULL");
+
+ locker = g_mutex_locker_new(&_espp->mutex);
+
+ if (espp_service_client_socket_request_set_callback(_espp, ESPP_SERVICE_EVENT_CB_READY_TO_SEEK, (void *)callback, user_data) != 0)
+ return ESPP_CLIENT_ERROR_INVALID_OPERATION;
+
+ cb_locker = g_mutex_locker_new(&_espp->cb_mutex);
+ LOG_WARNING_IF_CALLBACK_EXISTS(_espp->ready_to_seek_cb);
+
+ _espp->ready_to_seek_cb.callback = callback;
+ _espp->ready_to_seek_cb.user_data = user_data;
+
+ LOG_INFO("espp[%p] callback[%p] user_data[%p]", espp, callback, user_data);
+
+ return ESPP_CLIENT_ERROR_NONE;
+}
+
int espp_client_set_seek_done_cb(espp_h espp, espp_seek_done_cb callback, void *user_data)
{
espp_s *_espp = (espp_s *)espp;
} espp_packet_s;
/**
- * @brief Called when when the ESPP service client handle is prepared to receive es packets after calling espp_client_prepare_async().
+ * @brief Called when when the ESPP service client handle is prepared to receive ESPP packets after calling espp_client_prepare_async().
* @param[in] stream_type The stream type
* @param[in] user_data The user data passed from the callback registration function
* @see espp_client_set_ready_to_prepare_cb()
+ * @see espp_client_submit_packet()
*/
typedef void (*espp_ready_to_prepare_cb)(espp_stream_type_e stream_type, void *user_data);
* @param[in] result The result (@c true = success, @c false = failure)
* @param[in] user_data The user data passed from the callback registration function
* @see espp_client_set_prepare_async_done_cb()
+ * @see espp_client_submit_packet()
*/
typedef void (*espp_prepare_async_done_cb)(bool result, void *user_data);
+/**
+ * @brief Called when the ESPP service client handle is prepared to receive ESPP packets after calling espp_client_seek().
+ * @param[in] stream_type The stream type
+ * @param[in] time_ms The seek time in milliseconds
+ * @param[in] user_data The user data passed from the callback registration function
+ * @see espp_client_set_ready_to_seek_cb()
+ * @see espp_client_seek()
+ * @see espp_client_submit_packet()
+ */
+typedef void (*espp_ready_to_seek_cb)(espp_stream_type_e stream_type, uint64_t time_ms, void *user_data);
+
/**
* @brief Called when the seek operation of the ESPP service client handle has been finished.
* @param[in] user_data The user data passed from the callback registration function
* @see espp_client_set_seek_done_cb()
+ * @see espp_client_seek()
+ * @see espp_client_submit_packet()
*/
typedef void (*espp_seek_done_cb)(void *user_data);
typedef void (*espp_resource_conflicted_cb)(void *user_data);
/**
- * @brief Sets a callback function to be invoked when the ESPP service client handle is prepared to receive es packets after calling espp_client_prepare_async().
+ * @brief Sets a callback function to be invoked when the ESPP service client handle is prepared to receive ESPP packets after calling espp_client_prepare_async().
* @param[in] espp ESPP service client handle
* @param[in] callback Callback function pointer
* @param[in] user_data The user data to be passed to the callback function
* @retval #ESPP_CLIENT_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #ESPP_CLIENT_ERROR_INVALID_OPERATION Invalid operation
* @post espp_ready_to_prepare_cb() will be invoked.
+ * @see espp_client_prepare_async()
+ * @see espp_client_submit_packet()
*/
int espp_client_set_ready_to_prepare_cb(espp_h espp, espp_ready_to_prepare_cb callback, void *user_data);
* @retval #ESPP_CLIENT_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #ESPP_CLIENT_ERROR_INVALID_OPERATION Invalid operation
* @post espp_prepare_async_done_cb() will be invoked.
+ * @see espp_client_submit_packet()
*/
int espp_client_set_prepare_async_done_cb(espp_h espp, espp_prepare_async_done_cb callback, void *user_data);
+/**
+ * @brief Sets a callback function to be invoked when the ESPP service client handle is prepared to receive ESPP packets after calling espp_client_seek().
+ * @param[in] espp ESPP service client handle
+ * @param[in] callback Callback function pointer
+ * @param[in] user_data The user data to be passed to the callback function
+ * @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 #ESPP_STATE_NONE or #ESPP_STATE_IDLE.
+ * @post espp_ready_to_seek_cb() will be invoked.
+ * @see espp_client_seek()
+ * @see espp_client_submit_packet()
+ */
+int espp_client_set_ready_to_seek_cb(espp_h espp, espp_ready_to_seek_cb callback, void *user_data);
+
/**
* @brief Sets a callback function to be invoked when the seek operation of the ESPP service client handle has been finished.
* @param[in] espp ESPP service client handle
* @retval #ESPP_CLIENT_ERROR_INVALID_OPERATION Invalid operation
* @post espp_seek_done_cb() will be invoked.
* @see espp_client_seek()
+ * @see espp_client_submit_packet()
*/
int espp_client_set_seek_done_cb(espp_h espp, espp_seek_done_cb callback, void *user_data);
* @retval #ESPP_CLIENT_ERROR_NONE Successful
* @retval #ESPP_CLIENT_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #ESPP_CLIENT_ERROR_INVALID_OPERATION Invalid operation
- * @pre This function must be called after espp_ready_to_prepare_cb() or espp_seek_done_cb() is invoked.
+ * @pre This function must be called after espp_ready_to_prepare_cb() or espp_ready_to_seek_cb() is invoked.
* @see espp_ready_to_prepare_cb()
- * @see espp_seek_done_cb()
+ * @see espp_ready_to_seek_cb()
* @see espp_buffer_status_cb()
*/
int espp_client_submit_packet(espp_h espp, espp_packet_s *packet, espp_submit_error_e *error);
* @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_ready_to_seek_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);
result->ret = 0;
}
+static void __handle_event_cb_ready_to_seek(espp_s *espp, espp_service_data_from_server_s *data, espp_service_data_from_client_s *result)
+{
+ int ret;
+ espp_stream_type_e stream_type;
+ uint64_t time_ms;
+
+ ASSERT(espp);
+ ASSERT(data);
+ ASSERT(result);
+
+ ret = espp_service_client_msg_parse_params(data->params, data->event, &stream_type, &time_ms);
+ if (ret != 0)
+ return;
+
+ LOG_INFO("cb params[stream_type:%d, time_ms:%" PRIu64 "]", stream_type, time_ms);
+
+ if (espp->ready_to_seek_cb.callback) {
+ LOG_DEBUG(">>> callback[%p] user_data[%p]", espp->ready_to_seek_cb.callback, espp->ready_to_seek_cb.user_data);
+ ((espp_ready_to_seek_cb)(espp->ready_to_seek_cb.callback))(stream_type, time_ms, espp->ready_to_seek_cb.user_data);
+ LOG_DEBUG("<<< end of the callback");
+ }
+
+ result->ret = 0;
+}
+
static void __handle_event_cb_seek_done(espp_s *espp, espp_service_data_from_server_s *data, espp_service_data_from_client_s *result)
{
ASSERT(espp);
[ESPP_SERVICE_EVENT_MSG] = __handle_event_msg,
[ESPP_SERVICE_EVENT_CB_READY_TO_PREPARE] = __handle_event_cb_ready_to_prepare,
[ESPP_SERVICE_EVENT_CB_PREPARE_ASYNC_DONE] = __handle_event_cb_prepare_async_done,
+ [ESPP_SERVICE_EVENT_CB_READY_TO_SEEK] = __handle_event_cb_ready_to_seek,
[ESPP_SERVICE_EVENT_CB_SEEK_DONE] = __handle_event_cb_seek_done,
[ESPP_SERVICE_EVENT_CB_EOS] = __handle_event_cb_eos,
[ESPP_SERVICE_EVENT_CB_BUFFER_STATUS] = __handle_event_cb_buffer_status,
espp_callback_s ready_to_prepare_cb;
espp_callback_s prepare_async_done_cb;
+ espp_callback_s ready_to_seek_cb;
espp_callback_s seek_done_cb;
espp_callback_s eos_cb;
espp_callback_s buffer_status_cb;
[ESPP_SERVICE_EVENT_MSG] = { "Message", "s" },
[ESPP_SERVICE_EVENT_CB_READY_TO_PREPARE] = { "ReadyToPrepareCB", "i" },
[ESPP_SERVICE_EVENT_CB_PREPARE_ASYNC_DONE] = { "PrepareAsyncDoneCB", "b" },
+ [ESPP_SERVICE_EVENT_CB_READY_TO_SEEK] = { "ReadyToSeekCB", "ik" },
[ESPP_SERVICE_EVENT_CB_SEEK_DONE] = { "SeekDoneCB", NULL },
[ESPP_SERVICE_EVENT_CB_EOS] = { "EosCB", NULL },
[ESPP_SERVICE_EVENT_CB_BUFFER_STATUS] = { "BufferStatusCB", "ii" },
ESPP_SERVICE_EVENT_MSG,
ESPP_SERVICE_EVENT_CB_READY_TO_PREPARE,
ESPP_SERVICE_EVENT_CB_PREPARE_ASYNC_DONE,
+ ESPP_SERVICE_EVENT_CB_READY_TO_SEEK,
ESPP_SERVICE_EVENT_CB_SEEK_DONE,
ESPP_SERVICE_EVENT_CB_EOS,
ESPP_SERVICE_EVENT_CB_BUFFER_STATUS,
espp_service_send_data(tbs->event_fd, &data);
}
+static void __ready_to_seek_cb(const int type, uint64_t time_ms, void *user_data)
+{
+ handler_userdata_s *hdata = (handler_userdata_s *)user_data;
+ tb_data_s *tbs;
+ espp_service_data_from_server_s data;
+
+ ASSERT(hdata);
+ ASSERT(hdata->svc);
+ ASSERT(hdata->fd >= 0);
+
+ LOG_DEBUG("type[%d], fd[%d], ESPP[%p]", type, hdata->fd, hdata->espp);
+
+ RET_IF(!(tbs = g_hash_table_lookup(hdata->svc->fd_table, hdata->key)), "failed to g_hash_table_lookup(), key[%s]", hdata->key);
+
+ LOG_DEBUG("event_fd[%d], ESPP[%p]", tbs->event_fd, tbs->espp);
+
+ FILL_SOCKET_MSG_EVENT(data, ESPP_SERVICE_EVENT_CB_READY_TO_SEEK);
+ FILL_SOCKET_MSG_PARAMS(data, ESPP_SERVICE_EVENT_CB_READY_TO_SEEK,
+ "type", type, "time_ms", time_ms);
+
+ espp_service_send_data(tbs->event_fd, &data);
+}
+
static void __seek_done_cb(void *user_data)
{
handler_userdata_s *hdata = (handler_userdata_s *)user_data;
static cb_intf_s cb_setters[] = {
[ESPP_SERVICE_EVENT_CB_READY_TO_PREPARE] = { (set_cb_func)esplusplayer_set_ready_to_prepare_cb, __ready_to_prepare_cb},
[ESPP_SERVICE_EVENT_CB_PREPARE_ASYNC_DONE] = { (set_cb_func)esplusplayer_set_prepare_async_done_cb, __prepare_async_done_cb},
+ [ESPP_SERVICE_EVENT_CB_READY_TO_SEEK] = { (set_cb_func)esplusplayer_set_ready_to_seek_cb, __ready_to_seek_cb},
[ESPP_SERVICE_EVENT_CB_SEEK_DONE] = { (set_cb_func)esplusplayer_set_seek_done_cb, __seek_done_cb},
[ESPP_SERVICE_EVENT_CB_EOS] = { (set_cb_func)esplusplayer_set_eos_cb, __eos_cb},
[ESPP_SERVICE_EVENT_CB_BUFFER_STATUS] = { (set_cb_func)esplusplayer_set_buffer_status_cb, __buffer_status_cb},