Code clean, update tags and API description.
Signed-off-by: Jaeyun Jung <jy1210.jung@samsung.com>
* @brief The maximum number of data instances that nnstreamer-edge data may have.
*/
#define NNS_EDGE_DATA_LIMIT (256)
+
/**
* @brief Callback called when nnstreamer-edge data is released.
*/
typedef void (*nns_edge_data_destroy_cb) (void *data);
-
/**
* @brief Create a handle used for data transmission.
- * @note Caller should release returned edge data using nns_edge_data_destroy().
+ * @remarks If the function succeeds, @a data_h should be released using nns_edge_data_destroy().
* @param[out] data_h Handle of edge data.
* @return 0 on success. Otherwise a negative error value.
* @retval #NNS_EDGE_ERROR_NONE Successful.
*/
int nns_edge_data_destroy (nns_edge_data_h data_h);
+/**
+ * @brief Destroy nnstreamer edge data handle.
+ * @details This is wrapper function of nns_edge_data_destroy() to avoid build warning of the incompatibe type casting.
+ * @param[in] data The pointer to the edge data handle to be released.
+ * @retval #NNS_EDGE_ERROR_NONE Successful.
+ * @retval #NNS_EDGE_ERROR_NOT_SUPPORTED Not supported.
+ * @retval #NNS_EDGE_ERROR_INVALID_PARAMETER Given parameter is invalid.
+ */
+void nns_edge_data_release_handle (void *data);
+
/**
* @brief Copy edge data and return new handle.
- * @note Caller should release returned new edge data using nns_edge_data_destroy().
+ * @remarks If the function succeeds, @a new_data_h should be released using nns_edge_data_destroy().
* @param[in] data_h The edge data to be copied.
* @param[out] new_data_h A destination handle of edge data.
* @return 0 on success. Otherwise a negative error value.
/**
* @brief Get the information of edge data.
- * @note The param key is case-insensitive. Caller should release the returned value using free().
+ * @remarks If the function succeeds, @a value should be released using free().
+ * @note The param key is case-insensitive.
* @param[in] data_h The edge data handle.
* @param[in] key A key of the information.
* @param[in] value The information to get.
*/
int nns_edge_data_clear_info (nns_edge_data_h data_h);
-/**
- * @brief Release the edge data handle. This function releases the memory allocated for the edge data handle.
- * @param[in] data The pointer to the edge data handle to be released.
- * @retval #NNS_EDGE_ERROR_NONE Successful.
- * @retval #NNS_EDGE_ERROR_NOT_SUPPORTED Not supported.
- * @retval #NNS_EDGE_ERROR_INVALID_PARAMETER Given parameter is invalid.
- */
-void nns_edge_data_release_handle (void *data);
-
/**
* @brief Validate edge data handle.
* @param[in] data_h The edge data handle.
/**
* @brief Serialize metadata in edge data.
+ * @remarks If the function succeeds, @a data should be released using free().
* @param[in] data_h The handle to the edge data.
* @param[out] data A pointer to store the serialized meta data.
* @param[out] data_len A pointer to store the length of the serialized meta data.
/**
* @brief Serialize entire edge data (meta data + raw data).
+ * @remarks If the function succeeds, @a data should be released using free().
* @param[in] data_h The handle to the edge data.
* @param[out] data A pointer to store the serialized edge data.
* @param[out] data_len A pointer to store the length of the serialized edge data.
* @return 0 on success. Otherwise a negative error value.
* @retval #NNS_EDGE_ERROR_NONE Successful.
* @retval #NNS_EDGE_ERROR_NOT_SUPPORTED Not supported.
- * @retval #NNS_EDGE_ERROR_INVALID_PARAMETER Given parameter is invalid. */
+ * @retval #NNS_EDGE_ERROR_INVALID_PARAMETER Given parameter is invalid.
+ */
int nns_edge_data_is_serialized (const void *data, const nns_size_t data_len);
#ifdef __cplusplus
typedef void *nns_edge_event_h;
+/**
+ * @brief Enumeration for the event type of nnstreamer-edge.
+ */
typedef enum {
NNS_EDGE_EVENT_UNKNOWN = 0,
NNS_EDGE_EVENT_CAPABILITY,
/**
* @brief Callback for the nnstreamer edge event.
+ * @note This callback will suspend data stream. Do not spend too much time in the callback.
* @param[in] event_h The edge event handle.
* @param[in] user_data The user's custom data given to callbacks.
- * @note This callback will suspend data stream. Do not spend too much time in the callback.
* @return 0 on success. Otherwise a negative error value.
- * @retval #NNS_EDGE_ERROR_NONE Successful.
- * @retval #NNS_EDGE_ERROR_NOT_SUPPORTED Not supported.
- * @retval #NNS_EDGE_ERROR_INVALID_PARAMETER Given parameter is invalid. */
+ */
typedef int (*nns_edge_event_cb) (nns_edge_event_h event_h, void *user_data);
/**
/**
* @brief Parse edge event (NNS_EDGE_EVENT_NEW_DATA_RECEIVED) and get received data.
- * @note Caller should release returned edge data using nns_edge_data_destroy().
+ * @remarks If the function succeeds, @a data_h should be released using nns_edge_data_destroy().
* @param[in] event_h The edge event handle.
* @param[out] data_h Handle of received data.
* @return 0 on success. Otherwise a negative error value.
/**
* @brief Parse edge event (NNS_EDGE_EVENT_CAPABILITY) and get capability string.
- * @note Caller should release returned string using free().
+ * @remarks If the function succeeds, @a capability should be released using free().
* @param[in] event_h The edge event handle.
* @param[out] capability Capability string.
* @return 0 on success. Otherwise a negative error value.
/**
* @brief Create nnstreamer edge event.
+ * @remarks If the function succeeds, @a event_h should be released using nns_edge_event_destroy().
* @param[in] event Edge event type.
- * @param[out] event_h The handle of the created edge event. It should be released using nns_edge_event_destroy().
+ * @param[out] event_h The handle of the created edge event.
* @return 0 on success. Otherwise a negative error value.
* @retval #NNS_EDGE_ERROR_NONE Successful.
* @retval #NNS_EDGE_ERROR_NOT_SUPPORTED Not supported.
* @return 0 on success. Otherwise a negative error value.
* @retval #NNS_EDGE_ERROR_NONE Successful.
* @retval #NNS_EDGE_ERROR_NOT_SUPPORTED Not supported.
- * @retval #NNS_EDGE_ERROR_INVALID_PARAMETER Given parameter is invalid. */
+ * @retval #NNS_EDGE_ERROR_INVALID_PARAMETER Given parameter is invalid.
+ */
int nns_edge_event_destroy (nns_edge_event_h event_h);
/**
* @return 0 on success. Otherwise a negative error value.
* @retval #NNS_EDGE_ERROR_NONE Successful.
* @retval #NNS_EDGE_ERROR_NOT_SUPPORTED Not supported.
- * @retval #NNS_EDGE_ERROR_INVALID_PARAMETER Given parameter is invalid. */
+ * @retval #NNS_EDGE_ERROR_INVALID_PARAMETER Given parameter is invalid.
+ */
int nns_edge_event_set_data (nns_edge_event_h event_h, void *data, nns_size_t data_len, nns_edge_data_destroy_cb destroy_cb);
#ifdef __cplusplus
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
+
#include "nnstreamer-edge-data.h"
#include "nnstreamer-edge-event.h"
NNS_EDGE_ERROR_NOT_SUPPORTED = (NNS_EDGE_ERROR_UNKNOWN + 2),
} nns_edge_error_e;
+/**
+ * @brief Enumeration for the connection type of nnstreamer-edge.
+ */
typedef enum {
NNS_EDGE_CONNECT_TYPE_TCP = 0,
NNS_EDGE_CONNECT_TYPE_MQTT,
NNS_EDGE_CONNECT_TYPE_UNKNOWN
} nns_edge_connect_type_e;
+/**
+ * @brief Enumeration for the node type of nnstreamer-edge.
+ */
typedef enum {
NNS_EDGE_NODE_TYPE_QUERY_CLIENT = 0,
NNS_EDGE_NODE_TYPE_QUERY_SERVER,
/**
* @brief Create a handle representing an instance of edge-AI connection between a server and client (query) or a data publisher and scriber.
+ * @remarks If the function succeeds, @a edge_h should be released using nns_edge_release_handle().
* @param[in] id Unique id in local network
* @param[in] connect_type Value of @a nns_edge_connect_type_e. Connection type between edge nodes.
* @param[in] node_type Value of @a nns_edge_node_type_e. The node type of edge connection.
- * @param[out] edge_h The edge handle. If the function succeeds, @a edge_h should be released using nns_edge_release_handle().
+ * @param[out] edge_h The edge handle.
* @return 0 on success. Otherwise a negative error value.
* @retval #NNS_EDGE_ERROR_NONE Successful.
* @retval #NNS_EDGE_ERROR_NOT_SUPPORTED Not supported.
/**
* @brief Create edge custom handle.
+ * @remarks If the function succeeds, @a edge_h should be released using nns_edge_release_handle().
* @param[in] id Unique id in local network
* @param[in] lib_path The library path implementing the custom connection.
* @param[in] node_type Value of @a nns_edge_node_type_e. The node type of edge connection.
- * @param[out] edge_h The edge handle. If the function succeeds, @a edge_h should be released using nns_edge_release_handle().
+ * @param[out] edge_h The edge handle.
* @return 0 on success. Otherwise a negative error value.
* @retval #NNS_EDGE_ERROR_NONE Successful.
* @retval #NNS_EDGE_ERROR_NOT_SUPPORTED Not supported.
/**
* @brief Get nnstreamer edge info.
- * @note The param key is case-insensitive. Caller should release returned string using free().
+ * @remarks If the function succeeds, @a value should be released using free().
+ * @note The param key is case-insensitive.
* @param[in] edge_h The edge handle.
* @param[in] key Identifiers to determine which value to get.
* @param[out] value The values that match the key.
#ifndef __NNSTREAMER_EDGE_QUEUE_H__
#define __NNSTREAMER_EDGE_QUEUE_H__
-#include <stdbool.h>
-#include "nnstreamer-edge.h"
+#include "nnstreamer-edge-data.h"
#ifdef __cplusplus
extern "C" {
} nns_edge_queue_leak_e;
/**
- * @brief Create queue.
+ * @brief Create queue. Default length limit is 0 (unlimited).
+ * @remarks If the function succeeds, @a handle should be released using nns_edge_queue_destroy().
* @param[out] handle Newly created handle.
* @return 0 on success. Otherwise a negative error value.
* @retval #NNS_EDGE_ERROR_NONE Successful.
* @return 0 on success. Otherwise a negative error value.
* @retval #NNS_EDGE_ERROR_NONE Successful.
* @retval #NNS_EDGE_ERROR_INVALID_PARAMETER Given parameter is invalid.
- * @retval #NNS_EDGE_ERROR_IO
+ * @retval #NNS_EDGE_ERROR_IO Failed to get data.
*/
int nns_edge_queue_pop (nns_edge_queue_h handle, void **data, nns_size_t *size);
* @return 0 on success. Otherwise a negative error value.
* @retval #NNS_EDGE_ERROR_NONE Successful.
* @retval #NNS_EDGE_ERROR_INVALID_PARAMETER Given parameter is invalid.
- * @retval #NNS_EDGE_ERROR_IO
+ * @retval #NNS_EDGE_ERROR_IO Failed to get data.
*/
int nns_edge_queue_wait_pop (nns_edge_queue_h handle, unsigned int timeout, void **data, nns_size_t *size);
/**
* @brief Stop waiting for new data and clear all data in the queue.
+ * @details When this function is called, nns_edge_queue_wait_pop() will stop the waiting.
* @param[in] handle The queue handle.
* @return 0 on success. Otherwise a negative error value.
* @retval #NNS_EDGE_ERROR_NONE Successful.
* @retval #NNS_EDGE_ERROR_INVALID_PARAMETER Given parameter is invalid.
- * @note When this function is called, nns_edge_queue_wait_pop will stop the waiting.
*/
int nns_edge_queue_clear (nns_edge_queue_h handle);