Export edge data and event functions.
authorgichan2-jang <gichan2.jang@samsung.com>
Thu, 22 Aug 2024 04:33:12 +0000 (13:33 +0900)
committerjaeyun-jung <39614140+jaeyun-jung@users.noreply.github.com>
Fri, 23 Aug 2024 01:56:35 +0000 (10:56 +0900)
Export edge data and event functions for custom connections.

Signed-off-by: gichan2-jang <gichan2.jang@samsung.com>
debian/nnstreamer-edge-dev.install
include/nnstreamer-edge-data.h [new file with mode: 0644]
include/nnstreamer-edge-event.h [new file with mode: 0644]
include/nnstreamer-edge.h
packaging/nnstreamer-edge.spec
src/CMakeLists.txt
src/libnnstreamer-edge/nnstreamer-edge-data.c
src/libnnstreamer-edge/nnstreamer-edge-data.h [deleted file]
src/libnnstreamer-edge/nnstreamer-edge-event.h [deleted file]
src/libnnstreamer-edge/nnstreamer-edge-internal.c
src/libnnstreamer-edge/nnstreamer-edge-metadata.h

index ea4991da2e8ce064fd28936a03e45e9d1e28b59e..51e3b5452b546331cb2235cc71c46e706b7bcf0c 100644 (file)
@@ -1,4 +1,6 @@
 /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
diff --git a/include/nnstreamer-edge-data.h b/include/nnstreamer-edge-data.h
new file mode 100644 (file)
index 0000000..da0de33
--- /dev/null
@@ -0,0 +1,237 @@
+/* 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__ */
diff --git a/include/nnstreamer-edge-event.h b/include/nnstreamer-edge-event.h
new file mode 100644 (file)
index 0000000..5c719d6
--- /dev/null
@@ -0,0 +1,131 @@
+/* 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__ */
index 33257137c68c564cae8f564a11cda3796f851af0..3983ce6b2627bb7382906c5bf2111b8fddd6167c 100644 (file)
 #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).
@@ -46,16 +38,6 @@ typedef enum {
   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,
@@ -75,18 +57,6 @@ typedef enum {
   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
@@ -344,162 +314,6 @@ int nns_edge_set_info (nns_edge_h edge_h, const char *key, const char *value);
  */
 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.
index 58e00fdd0c1da6b35d4260d5ce4c4d8225b31703..3a1b1d4fb398fd905458f7950d8c4135479da781 100644 (file)
@@ -175,6 +175,8 @@ rm -rf %{buildroot}
 %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}
index 0ae6eae9bd9791285fe51acf507475712625d117..0afd47382612c8223369586ea13222679a5b7d72 100644 (file)
@@ -45,3 +45,5 @@ ENDIF()
 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})
index bebfa20666274514d77698e30f99ff3614dfe654..22c22c55399f6a5f948771277e64dc540deb80b2 100644 (file)
@@ -13,6 +13,7 @@
 #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)
 
diff --git a/src/libnnstreamer-edge/nnstreamer-edge-data.h b/src/libnnstreamer-edge/nnstreamer-edge-data.h
deleted file mode 100644 (file)
index 523c90b..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/* 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__ */
diff --git a/src/libnnstreamer-edge/nnstreamer-edge-event.h b/src/libnnstreamer-edge/nnstreamer-edge-event.h
deleted file mode 100644 (file)
index dd317c2..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/* 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__ */
index 1d9c43ba1dd6ad215da6b428fde3688be1604d14..d1ca77169a2b4b0fea339d225e0529f73f1cbd8f 100644 (file)
@@ -21,6 +21,7 @@
 #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"
 
index 5d9e3c329f5024de9a0331ad2762d45a75748c30..4b4c520944559660914c56568998e2e961bb8e4f 100644 (file)
@@ -14,7 +14,7 @@
 #ifndef __NNSTREAMER_EDGE_METADATA_H__
 #define __NNSTREAMER_EDGE_METADATA_H__
 
-#include "nnstreamer-edge.h"
+#include "nnstreamer-edge-data.h"
 
 #ifdef __cplusplus
 extern "C" {