Name: espp-service
Summary: ESPP service package which contains client lib. and daemon binary
-Version: 0.1.9
+Version: 0.1.10
Release: 0
Group: Multimedia/Libraries
License: Apache-2.0
return ESPP_CLIENT_ERROR_NONE;
}
+int espp_client_set_buffer_status_cb(espp_h espp, espp_buffer_status_cb callback, void *user_data)
+{
+ espp_s *_espp = (espp_s *)espp;
+ g_autoptr(GMutexLocker) 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_BUFFER_STATUS, (void *)callback, user_data) != 0)
+ return ESPP_CLIENT_ERROR_INVALID_OPERATION;
+
+ LOG_WARNING_IF_CALLBACK_EXISTS(_espp->buffer_status_cb);
+
+ _espp->buffer_status_cb.callback = callback;
+ _espp->buffer_status_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_resource_conflicted_cb(espp_h espp, espp_resource_conflicted_cb callback, void *user_data)
{
espp_s *_espp = (espp_s *)espp;
ESPP_DISPLAY_MODE_DST_ROI, /**< Destination RoI */
} espp_display_mode_e;
+/**
+ * @brief Enumerations for the buffer status
+ */
+typedef enum {
+ ESPP_BUFFER_STATUS_UNDERRUN, /**< Underrun */
+ ESPP_BUFFER_STATUS_OVERRUN, /**< Overrun */
+} espp_buffer_status_e;
+
/**
* @brief Enumerations for the submit error
*/
*/
typedef void (*espp_eos_cb)(void *user_data);
+/**
+ * @brief Called when the buffer of the ESPP service client handle faces underrun or overrun condition.
+ * @param[in] stream_type The stream type
+ * @param[in] buffer_status The buffer status
+ * @param[in] user_data The user data passed from the callback registration function
+ * @see espp_client_set_buffer_status_cb()
+ */
+typedef void (*espp_buffer_status_cb)(espp_stream_type_e stream_type, espp_buffer_status_e buffer_status, void *user_data);
+
/**
* @brief Called when a H/W resource of the ESPP service client handle has been conflicted.
* @param[in] user_data The user data passed from the callback registration function
*/
int espp_client_set_eos_cb(espp_h espp, espp_eos_cb callback, void *user_data);
+/**
+ * @brief Sets a callback function to be invoked when the buffer of the ESPP service client handle faces underrun or overflow condition.
+ * @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
+ * @post espp_buffer_status_cb() will be invoked.
+ */
+int espp_client_set_buffer_status_cb(espp_h espp, espp_buffer_status_cb callback, void *user_data);
+
/**
* @brief Sets a callback function to be invoked when when a H/W resource of the ESPP service client handle has been conflicted.
* @param[in] espp ESPP service client handle
* @retval #ESPP_CLIENT_ERROR_NONE Successful
* @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.
+ * @pre This function must be called after espp_ready_to_prepare_cb() or espp_seek_done_cb() is invoked.
* @see espp_ready_to_prepare_cb()
+ * @see espp_seek_done_cb()
+ * @see espp_buffer_status_cb()
*/
int espp_client_submit_packet(espp_h espp, espp_packet_s *packet, espp_submit_error_e *error);
result->ret = 0;
}
+static void __handle_event_cb_buffer_status(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;
+ espp_buffer_status_e buffer_status;
+
+ ASSERT(espp);
+ ASSERT(data);
+ ASSERT(result);
+
+ result->ret = -1;
+
+ ret = espp_service_client_msg_parse_params(data->params, data->event, &stream_type, &buffer_status);
+ if (ret != 0)
+ return;
+
+ LOG_INFO("cb params[stream_type:%d, buffer_status:%d]", stream_type, buffer_status);
+
+ if (espp->buffer_status_cb.callback) {
+ LOG_DEBUG(">>> callback[%p] user_data[%p]", espp->buffer_status_cb.callback, espp->buffer_status_cb.user_data);
+ ((espp_buffer_status_cb)(espp->buffer_status_cb.callback))(stream_type, buffer_status, espp->buffer_status_cb.user_data);
+ LOG_DEBUG("<<< end of the callback");
+ }
+
+ result->ret = 0;
+}
+
static func_handler handlers[] = {
[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_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,
};
static void __func_handler(espp_s *espp, espp_service_data_from_server_s *data, espp_service_data_from_client_s *result)
espp_callback_s prepare_async_done_cb;
espp_callback_s seek_done_cb;
espp_callback_s eos_cb;
+ espp_callback_s buffer_status_cb;
espp_callback_s resource_conflicted_cb;
} espp_s;
[ESPP_SERVICE_EVENT_CB_PREPARE_ASYNC_DONE] = { "PrepareAsyncDoneCB", "b" },
[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_CB_RESOURCE_CONFLICTED] = { "PrepareAsyncDoneCB", NULL },
};
ESPP_SERVICE_EVENT_CB_PREPARE_ASYNC_DONE,
ESPP_SERVICE_EVENT_CB_SEEK_DONE,
ESPP_SERVICE_EVENT_CB_EOS,
+ ESPP_SERVICE_EVENT_CB_BUFFER_STATUS,
ESPP_SERVICE_EVENT_CB_RESOURCE_CONFLICTED,
} espp_service_event_e;
espp_service_send_data(tbs->event_fd, &data);
}
+static void __buffer_status_cb(const int stream_type, const int buffer_status, 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("stream_type[%d], buffer_status[%d], fd[%d], ESPP[%p]", stream_type, buffer_status, 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_BUFFER_STATUS);
+ FILL_SOCKET_MSG_PARAMS(data, ESPP_SERVICE_EVENT_CB_BUFFER_STATUS,
+ "stream_type", stream_type, "buffer_status", buffer_status);
+ espp_service_send_data(tbs->event_fd, &data);
+}
+
static void __resource_conflicted_cb(void *user_data)
{
handler_userdata_s *hdata = (handler_userdata_s *)user_data;
[ESPP_SERVICE_EVENT_CB_PREPARE_ASYNC_DONE] = { (set_cb_func)esplusplayer_set_prepare_async_done_cb, __prepare_async_done_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},
[ESPP_SERVICE_EVENT_CB_RESOURCE_CONFLICTED] = { (set_cb_func)esplusplayer_set_resource_conflicted_cb, __resource_conflicted_cb},
};