Export edge data and event functions for custom connections.
Signed-off-by: gichan2-jang <gichan2.jang@samsung.com>
/usr/include/nnstreamer/nnstreamer-edge.h
/usr/include/nnstreamer/nnstreamer-edge-custom.h
+/usr/include/nnstreamer/nnstreamer-edge-data.h
+/usr/include/nnstreamer/nnstreamer-edge-event.h
/usr/lib/*/pkgconfig/nnstreamer-edge.pc
/usr/lib/*/libnnstreamer-edge.so
--- /dev/null
+/* SPDX-License-Identifier: Apache-2.0 */
+/**
+ * Copyright (C) 2022 Samsung Electronics Co., Ltd. All Rights Reserved.
+ *
+ * @file nnstreamer-edge-data.h
+ * @date 7 Sep 2022
+ * @brief Util functions for edge data.
+ * @see https://github.com/nnstreamer/nnstreamer
+ * @author Gichan Jang <gichan2.jang@samsung.com>
+ * @bug No known bugs except for NYI items
+ */
+
+#ifndef __NNSTREAMER_EDGE_DATA_H__
+#define __NNSTREAMER_EDGE_DATA_H__
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+typedef void *nns_edge_data_h;
+typedef uint64_t nns_size_t;
+typedef int64_t nns_ssize_t;
+
+/**
+ * @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().
+ * @param[out] data_h Handle of 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_OUT_OF_MEMORY Failed to allocate required memory.
+ * @retval #NNS_EDGE_ERROR_INVALID_PARAMETER Given parameter is invalid.
+ */
+int nns_edge_data_create (nns_edge_data_h *data_h);
+
+/**
+ * @brief Destroy nnstreamer edge data handle.
+ * @param[in] data_h Handle of 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.
+ */
+int nns_edge_data_destroy (nns_edge_data_h data_h);
+
+/**
+ * @brief Copy edge data and return new handle.
+ * @note Caller should release returned new edge data 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.
+ * @retval #NNS_EDGE_ERROR_NONE Successful.
+ * @retval #NNS_EDGE_ERROR_NOT_SUPPORTED Not supported.
+ * @retval #NNS_EDGE_ERROR_OUT_OF_MEMORY Failed to allocate required memory.
+ * @retval #NNS_EDGE_ERROR_INVALID_PARAMETER Given parameter is invalid.
+ */
+int nns_edge_data_copy (nns_edge_data_h data_h, nns_edge_data_h *new_data_h);
+
+/**
+ * @brief Add raw data into nnstreamer edge data.
+ * @note See NNS_EDGE_DATA_LIMIT, the maximum number of raw data in handle.
+ * @param[in] data_h The edge data handle.
+ * @param[in] data The raw data.
+ * @param[in] data_len The byte size of the data.
+ * @param[in] destroy_cb The callback for destroying the added 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.
+ */
+int nns_edge_data_add (nns_edge_data_h data_h, void *data, nns_size_t data_len, nns_edge_data_destroy_cb destroy_cb);
+
+/**
+ * @brief Remove raw data in edge data.
+ * @param[in] data_h The edge data handle.
+ * @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.
+ */
+int nns_edge_data_clear (nns_edge_data_h data_h);
+
+/**
+ * @brief Get the n'th edge data.
+ * @note DO NOT release returned data. You should copy the data to another buffer if the returned data is necessary.
+ * @param[in] data_h The edge data handle.
+ * @param[in] index The index of the data to get.
+ * @param[out] data The data in the data handle.
+ * @param[out] data_len The byte size of the 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.
+ */
+int nns_edge_data_get (nns_edge_data_h data_h, unsigned int index, void **data, nns_size_t *data_len);
+
+/**
+ * @brief Get the number of edge data in handle.
+ * @param[in] data_h The edge data handle.
+ * @param[out] count The number of the data in the data handle.
+ * @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.
+ */
+int nns_edge_data_get_count (nns_edge_data_h data_h, unsigned int *count);
+
+/**
+ * @brief Set the information of edge data.
+ * @note The param key is case-insensitive. If same key string already exists, it will replace old value.
+ * @param[in] data_h The edge data handle.
+ * @param[in] key A key of the information.
+ * @param[in] value The information to be set.
+ * @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.
+ */
+int nns_edge_data_set_info (nns_edge_data_h data_h, const char *key, const char *value);
+
+/**
+ * @brief Get the information of edge data.
+ * @note The param key is case-insensitive. Caller should release the returned value using free().
+ * @param[in] data_h The edge data handle.
+ * @param[in] key A key of the information.
+ * @param[in] value The information to get.
+ * @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.
+ */
+int nns_edge_data_get_info (nns_edge_data_h data_h, const char *key, char **value);
+
+/**
+ * @brief Clear information of edge data.
+ * @param[in] data_h The edge data handle.
+ * @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.
+ */
+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.
+ * @retval #NNS_EDGE_ERROR_NONE Successful.
+ * @retval #NNS_EDGE_ERROR_NOT_SUPPORTED Not supported.
+ * @retval #NNS_EDGE_ERROR_INVALID_PARAMETER Given parameter is invalid.
+ */
+int nns_edge_data_is_valid (nns_edge_data_h data_h);
+
+/**
+ * @brief Serialize metadata in edge data.
+ * @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.
+ * @return 0 on success, otherwise an 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_OUT_OF_MEMORY Failed to allocate required memory.
+ */
+int nns_edge_data_serialize_meta (nns_edge_data_h data_h, void **data, nns_size_t *data_len);
+
+/**
+ * @brief Deserialize metadata in edge data.
+ * @param[in] data_h The handle to the edge data.
+ * @param[out] data A pointer to deserialized meta data.
+ * @param[out] data_len Length of the deserialized meta 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.
+ */
+int nns_edge_data_deserialize_meta (nns_edge_data_h data_h, const void *data, const nns_size_t data_len);
+
+/**
+ * @brief Serialize entire edge data (meta data + raw data).
+ * @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_OUT_OF_MEMORY Failed to allocate required memory.
+ */
+int nns_edge_data_serialize (nns_edge_data_h data_h, void **data, nns_size_t *data_len);
+
+/**
+ * @brief Deserialize entire edge data (meta data + raw data).
+ * @param[in] data_h The handle to the edge data.
+ * @param[out] data A pointer to deserialized edge data.
+ * @param[out] data_len Length of the deserialized 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.
+ */
+int nns_edge_data_deserialize (nns_edge_data_h data_h, const void *data, const nns_size_t data_len);
+
+/**
+ * @brief Check given data is serialized buffer.
+ * @param[in] data A serialized edge data to check.
+ * @param[in] data_len 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. */
+int nns_edge_data_is_serialized (const void *data, const nns_size_t data_len);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __NNSTREAMER_EDGE_DATA_H__ */
--- /dev/null
+/* SPDX-License-Identifier: Apache-2.0 */
+/**
+ * Copyright (C) 2022 Samsung Electronics Co., Ltd. All Rights Reserved.
+ *
+ * @file nnstreamer-edge-event.h
+ * @date 7 Sep 2022
+ * @brief Util functions for nnstreamer edge event.
+ * @see https://github.com/nnstreamer/nnstreamer
+ * @author Gichan Jang <gichan2.jang@samsung.com>
+ * @bug No known bugs except for NYI items
+ */
+
+#ifndef __NNSTREAMER_EDGE_EVENT_H__
+#define __NNSTREAMER_EDGE_EVENT_H__
+
+#include "nnstreamer-edge-data.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+typedef void *nns_edge_event_h;
+
+typedef enum {
+ NNS_EDGE_EVENT_UNKNOWN = 0,
+ NNS_EDGE_EVENT_CAPABILITY,
+ NNS_EDGE_EVENT_NEW_DATA_RECEIVED,
+ NNS_EDGE_EVENT_CALLBACK_RELEASED,
+ NNS_EDGE_EVENT_CONNECTION_CLOSED,
+
+ NNS_EDGE_EVENT_CUSTOM = 0x01000000
+} nns_edge_event_e;
+
+/**
+ * @brief Callback for the nnstreamer edge event.
+ * @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 Get the nnstreamer edge event type.
+ * @param[in] event_h The edge event handle.
+ * @param[out] event The event type, value of @a nns_edge_event_e.
+ * @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.
+ */
+int nns_edge_event_get_type (nns_edge_event_h event_h, nns_edge_event_e *event);
+
+/**
+ * @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().
+ * @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.
+ * @retval #NNS_EDGE_ERROR_NONE Successful.
+ * @retval #NNS_EDGE_ERROR_NOT_SUPPORTED Not supported.
+ * @retval #NNS_EDGE_ERROR_INVALID_PARAMETER Given parameter is invalid
+ */
+int nns_edge_event_parse_new_data (nns_edge_event_h event_h, nns_edge_data_h *data_h);
+
+/**
+ * @brief Parse edge event (NNS_EDGE_EVENT_CAPABILITY) and get capability string.
+ * @note Caller should release returned string using free().
+ * @param[in] event_h The edge event handle.
+ * @param[out] capability Capability string.
+ * @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
+ */
+int nns_edge_event_parse_capability (nns_edge_event_h event_h, char **capability);
+
+/**
+ * @brief Util function to invoke event callback.
+ * @param[in] event_cb Callback for the nnstreamer edge event.
+ * @param[in] user_data The user's custom data given to callbacks.
+ * @param[in] data A pointer to event data.
+ * @param[in] data_len Length of the event data.
+ * @param[in] destroy_cb A callback function to free the event 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_OUT_OF_MEMORY Failed to allocate required memory.
+ */
+int nns_edge_event_invoke_callback (nns_edge_event_cb event_cb, void *user_data, nns_edge_event_e event, void *data, nns_size_t data_len, nns_edge_data_destroy_cb destroy_cb);
+
+/**
+ * @brief Create nnstreamer edge event.
+ * @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().
+ * @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_OUT_OF_MEMORY Failed to allocate required memory.
+ */
+int nns_edge_event_create (nns_edge_event_e event, nns_edge_event_h *event_h);
+
+/**
+ * @brief Destroy nnstreamer edge event.
+ * @param[in] event_h The handle of the event to be destroyed.
+ * @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. */
+int nns_edge_event_destroy (nns_edge_event_h event_h);
+
+/**
+ * @brief Set event data.
+ * @param[in] event_h The handle of edge event.
+ * @param[in] data A pointer to event data.
+ * @param[in] data_len Length of the event data.
+ * @param[in] destroy_cb A callback function to destroy the event 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. */
+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
+}
+#endif /* __cplusplus */
+#endif /* __NNSTREAMER_EDGE_EVENT_H__ */
#ifndef __NNSTREAMER_EDGE_H__
#define __NNSTREAMER_EDGE_H__
-#include <stdint.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
+#include "nnstreamer-edge-data.h"
+#include "nnstreamer-edge-event.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef void *nns_edge_h;
-typedef void *nns_edge_event_h;
-typedef void *nns_edge_data_h;
-typedef uint64_t nns_size_t;
-typedef int64_t nns_ssize_t;
-
-/**
- * @brief The maximum number of data instances that nnstreamer-edge data may have.
- */
-#define NNS_EDGE_DATA_LIMIT (256)
/**
* @brief Enumeration for the error codes of nnstreamer-edge (linux standard error, sync with tizen error code).
NNS_EDGE_ERROR_NOT_SUPPORTED = (NNS_EDGE_ERROR_UNKNOWN + 2),
} nns_edge_error_e;
-typedef enum {
- NNS_EDGE_EVENT_UNKNOWN = 0,
- NNS_EDGE_EVENT_CAPABILITY,
- NNS_EDGE_EVENT_NEW_DATA_RECEIVED,
- NNS_EDGE_EVENT_CALLBACK_RELEASED,
- NNS_EDGE_EVENT_CONNECTION_CLOSED,
-
- NNS_EDGE_EVENT_CUSTOM = 0x01000000
-} nns_edge_event_e;
-
typedef enum {
NNS_EDGE_CONNECT_TYPE_TCP = 0,
NNS_EDGE_CONNECT_TYPE_MQTT,
NNS_EDGE_NODE_TYPE_UNKNOWN,
} nns_edge_node_type_e;
-/**
- * @brief Callback for the nnstreamer edge event.
- * @note This callback will suspend data stream. Do not spend too much time in the callback.
- * @return User should return NNS_EDGE_ERROR_NONE if an event is successfully handled.
- */
-typedef int (*nns_edge_event_cb) (nns_edge_event_h event_h, void *user_data);
-
-/**
- * @brief Callback called when nnstreamer-edge data is released.
- */
-typedef void (*nns_edge_data_destroy_cb) (void *data);
-
/**
* @brief Create a handle representing an instance of edge-AI connection between a server and client (query) or a data publisher and scriber.
* @param[in] id Unique id in local network
*/
int nns_edge_get_info (nns_edge_h edge_h, const char *key, char **value);
-/**
- * @brief Get the nnstreamer edge event type.
- * @param[in] event_h The edge event handle.
- * @param[out] event The event type, value of @a nns_edge_event_e.
- * @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.
- */
-int nns_edge_event_get_type (nns_edge_event_h event_h, nns_edge_event_e *event);
-
-/**
- * @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().
- * @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.
- * @retval #NNS_EDGE_ERROR_NONE Successful.
- * @retval #NNS_EDGE_ERROR_NOT_SUPPORTED Not supported.
- * @retval #NNS_EDGE_ERROR_INVALID_PARAMETER Given parameter is invalid
- */
-int nns_edge_event_parse_new_data (nns_edge_event_h event_h, nns_edge_data_h *data_h);
-
-/**
- * @brief Parse edge event (NNS_EDGE_EVENT_CAPABILITY) and get capability string.
- * @note Caller should release returned string using free().
- * @param[in] event_h The edge event handle.
- * @param[out] capability Capability string.
- * @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
- */
-int nns_edge_event_parse_capability (nns_edge_event_h event_h, char **capability);
-
-/**
- * @brief Create a handle used for data transmission.
- * @note Caller should release returned edge data 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.
- * @retval #NNS_EDGE_ERROR_NOT_SUPPORTED Not supported.
- * @retval #NNS_EDGE_ERROR_OUT_OF_MEMORY Failed to allocate required memory.
- * @retval #NNS_EDGE_ERROR_INVALID_PARAMETER Given parameter is invalid.
- */
-int nns_edge_data_create (nns_edge_data_h *data_h);
-
-/**
- * @brief Destroy nnstreamer edge data handle.
- * @param[in] data_h Handle of 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.
- */
-int nns_edge_data_destroy (nns_edge_data_h data_h);
-
-/**
- * @brief Copy edge data and return new handle.
- * @note Caller should release returned new edge data 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.
- * @retval #NNS_EDGE_ERROR_NONE Successful.
- * @retval #NNS_EDGE_ERROR_NOT_SUPPORTED Not supported.
- * @retval #NNS_EDGE_ERROR_OUT_OF_MEMORY Failed to allocate required memory.
- * @retval #NNS_EDGE_ERROR_INVALID_PARAMETER Given parameter is invalid.
- */
-int nns_edge_data_copy (nns_edge_data_h data_h, nns_edge_data_h *new_data_h);
-
-/**
- * @brief Add raw data into nnstreamer edge data.
- * @note See NNS_EDGE_DATA_LIMIT, the maximum number of raw data in handle.
- * @param[in] data_h The edge data handle.
- * @param[in] data The raw data.
- * @param[in] data_len The byte size of the data.
- * @param[in] destroy_cb The callback for destroying the added 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.
- */
-int nns_edge_data_add (nns_edge_data_h data_h, void *data, nns_size_t data_len, nns_edge_data_destroy_cb destroy_cb);
-
-/**
- * @brief Remove raw data in edge data.
- * @param[in] data_h The edge data handle.
- * @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.
- */
-int nns_edge_data_clear (nns_edge_data_h data_h);
-
-/**
- * @brief Get the n'th edge data.
- * @note DO NOT release returned data. You should copy the data to another buffer if the returned data is necessary.
- * @param[in] data_h The edge data handle.
- * @param[in] index The index of the data to get.
- * @param[out] data The data in the data handle.
- * @param[out] data_len The byte size of the 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.
- */
-int nns_edge_data_get (nns_edge_data_h data_h, unsigned int index, void **data, nns_size_t *data_len);
-
-/**
- * @brief Get the number of edge data in handle.
- * @param[in] data_h The edge data handle.
- * @param[out] count The number of the data in the data handle.
- * @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.
- */
-int nns_edge_data_get_count (nns_edge_data_h data_h, unsigned int *count);
-
-/**
- * @brief Set the information of edge data.
- * @note The param key is case-insensitive. If same key string already exists, it will replace old value.
- * @param[in] data_h The edge data handle.
- * @param[in] key A key of the information.
- * @param[in] value The information to be set.
- * @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_OUT_OF_MEMORY Failed to allocate required memory.
- * @retval #NNS_EDGE_ERROR_INVALID_PARAMETER Given parameter is invalid.
- */
-int nns_edge_data_set_info (nns_edge_data_h data_h, const char *key, const char *value);
-
-/**
- * @brief Get the information of edge data.
- * @note The param key is case-insensitive. Caller should release the returned value using free().
- * @param[in] data_h The edge data handle.
- * @param[in] key A key of the information.
- * @param[in] value The information to get.
- * @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.
- */
-int nns_edge_data_get_info (nns_edge_data_h data_h, const char *key, char **value);
-
-/**
- * @brief Clear information of edge data.
- * @param[in] data_h The edge data handle.
- * @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.
- */
-int nns_edge_data_clear_info (nns_edge_data_h data_h);
-
/**
* @brief Get the version of nnstreamer-edge.
* @param[out] major MAJOR.minor.micro, won't set if it's null.
%files devel
%{_includedir}/nnstreamer/nnstreamer-edge.h
%{_includedir}/nnstreamer/nnstreamer-edge-custom.h
+%{_includedir}/nnstreamer/nnstreamer-edge-data.h
+%{_includedir}/nnstreamer/nnstreamer-edge-event.h
%{_libdir}/pkgconfig/nnstreamer-edge.pc
%if 0%{?unit_test}
INSTALL (TARGETS ${NNS_EDGE_LIB_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
INSTALL (FILES ${INCLUDE_DIR}/nnstreamer-edge.h DESTINATION ${INCLUDE_INSTALL_DIR})
INSTALL (FILES ${INCLUDE_DIR}/nnstreamer-edge-custom.h DESTINATION ${INCLUDE_INSTALL_DIR})
+INSTALL (FILES ${INCLUDE_DIR}/nnstreamer-edge-data.h DESTINATION ${INCLUDE_INSTALL_DIR})
+INSTALL (FILES ${INCLUDE_DIR}/nnstreamer-edge-event.h DESTINATION ${INCLUDE_INSTALL_DIR})
#include "nnstreamer-edge-data.h"
#include "nnstreamer-edge-log.h"
#include "nnstreamer-edge-util.h"
+#include "nnstreamer-edge-metadata.h"
#define NNS_EDGE_DATA_KEY (0xeddaedda)
+++ /dev/null
-/* SPDX-License-Identifier: Apache-2.0 */
-/**
- * Copyright (C) 2022 Samsung Electronics Co., Ltd. All Rights Reserved.
- *
- * @file nnstreamer-edge-data.h
- * @date 7 Sep 2022
- * @brief Util functions for edge data.
- * @see https://github.com/nnstreamer/nnstreamer
- * @author Gichan Jang <gichan2.jang@samsung.com>
- * @bug No known bugs except for NYI items
- * @note This file is internal header for nnstreamer edge utils. DO NOT export this file.
- */
-
-#ifndef __NNSTREAMER_EDGE_DATA_H__
-#define __NNSTREAMER_EDGE_DATA_H__
-
-#include "nnstreamer-edge.h"
-#include "nnstreamer-edge-metadata.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/**
- * @brief Internal wrapper function of the nns_edge_data_destroy() to avoid build warning of the incompatibe type casting. (See nns_edge_data_destroy_cb())
- */
-void nns_edge_data_release_handle (void *data);
-
-/**
- * @brief Validate edge data handle.
- * @note This is internal function, DO NOT export this.
- */
-int nns_edge_data_is_valid (nns_edge_data_h data_h);
-
-/**
- * @brief Serialize metadata in edge data.
- * @note This is internal function, DO NOT export this. Caller should release the returned value using free().
- */
-int nns_edge_data_serialize_meta (nns_edge_data_h data_h, void **data, nns_size_t *data_len);
-
-/**
- * @brief Deserialize metadata in edge data.
- * @note This is internal function, DO NOT export this.
- */
-int nns_edge_data_deserialize_meta (nns_edge_data_h data_h, const void *data, const nns_size_t data_len);
-
-/**
- * @brief Serialize entire edge data (meta data + raw data).
- * @note This is internal function, DO NOT export this. Caller should release the returned value using free().
- */
-int nns_edge_data_serialize (nns_edge_data_h data_h, void **data, nns_size_t *data_len);
-
-/**
- * @brief Deserialize entire edge data (meta data + raw data).
- * @note This is internal function, DO NOT export this.
- */
-int nns_edge_data_deserialize (nns_edge_data_h data_h, const void *data, const nns_size_t data_len);
-
-/**
- * @brief Check given data is serialized buffer.
- * @note This is internal function, DO NOT export this.
- */
-int nns_edge_data_is_serialized (const void *data, const nns_size_t data_len);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-#endif /* __NNSTREAMER_EDGE_DATA_H__ */
+++ /dev/null
-/* SPDX-License-Identifier: Apache-2.0 */
-/**
- * Copyright (C) 2022 Samsung Electronics Co., Ltd. All Rights Reserved.
- *
- * @file nnstreamer-edge-event.h
- * @date 7 Sep 2022
- * @brief Util functions for nnstreamer edge event.
- * @see https://github.com/nnstreamer/nnstreamer
- * @author Gichan Jang <gichan2.jang@samsung.com>
- * @bug No known bugs except for NYI items
- * @note This file is internal header for nnstreamer edge utils. DO NOT export this file.
- */
-
-#ifndef __NNSTREAMER_EDGE_EVENT_H__
-#define __NNSTREAMER_EDGE_EVENT_H__
-
-#include "nnstreamer-edge.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/**
- * @brief Internal util function to invoke event callback.
- */
-int nns_edge_event_invoke_callback (nns_edge_event_cb event_cb, void *user_data, nns_edge_event_e event, void *data, nns_size_t data_len, nns_edge_data_destroy_cb destroy_cb);
-
-/**
- * @brief Create nnstreamer edge event.
- * @note This is internal function for edge event.
- */
-int nns_edge_event_create (nns_edge_event_e event, nns_edge_event_h *event_h);
-
-/**
- * @brief Destroy nnstreamer edge event.
- * @note This is internal function for edge event.
- */
-int nns_edge_event_destroy (nns_edge_event_h event_h);
-
-/**
- * @brief Set event data.
- * @note This is internal function for edge event.
- */
-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
-}
-#endif /* __cplusplus */
-#endif /* __NNSTREAMER_EDGE_EVENT_H__ */
#include "nnstreamer-edge-util.h"
#include "nnstreamer-edge-queue.h"
#include "nnstreamer-edge-aitt.h"
+#include "nnstreamer-edge-metadata.h"
#include "nnstreamer-edge-mqtt.h"
#include "nnstreamer-edge-custom-impl.h"
#ifndef __NNSTREAMER_EDGE_METADATA_H__
#define __NNSTREAMER_EDGE_METADATA_H__
-#include "nnstreamer-edge.h"
+#include "nnstreamer-edge-data.h"
#ifdef __cplusplus
extern "C" {