[CodeClean] new header for mqtt and aitt accepted/tizen/unified/20220919.012623
authorJaeyun <jy1210.jung@samsung.com>
Thu, 15 Sep 2022 04:53:32 +0000 (13:53 +0900)
committerSangjung Woo <again4you@gmail.com>
Thu, 15 Sep 2022 05:22:36 +0000 (14:22 +0900)
Prepare connection handle, separate header files for mqtt and aitt.

Signed-off-by: Jaeyun <jy1210.jung@samsung.com>
src/libnnstreamer-edge/nnstreamer-edge-aitt.h [new file with mode: 0644]
src/libnnstreamer-edge/nnstreamer-edge-internal.h
src/libnnstreamer-edge/nnstreamer-edge-mqtt.h [new file with mode: 0644]

diff --git a/src/libnnstreamer-edge/nnstreamer-edge-aitt.h b/src/libnnstreamer-edge/nnstreamer-edge-aitt.h
new file mode 100644 (file)
index 0000000..44da6e5
--- /dev/null
@@ -0,0 +1,62 @@
+/* SPDX-License-Identifier: Apache-2.0 */
+/**
+ * Copyright (C) 2022 Samsung Electronics Co., Ltd. All Rights Reserved.
+ *
+ * @file   nnstreamer-edge-aitt.h
+ * @date   28 Mar 2022
+ * @brief  Common library to support communication among devices using aitt.
+ * @see    https://github.com/nnstreamer/nnstreamer
+ * @author Sangjung Woo <sangjung.woo@samsung.com>
+ * @bug    No known bugs except for NYI items
+ */
+
+#ifndef __NNSTREAMER_EDGE_AITT_H__
+#define __NNSTREAMER_EDGE_AITT_H__
+
+#include "nnstreamer-edge.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#if defined(ENABLE_AITT)
+/**
+ * @brief Create AITT handle and connect to AITT.
+ * @note This is internal function for AITT. You should call this with edge-handle lock.
+ */
+int nns_edge_aitt_connect (nns_edge_h edge_h);
+
+/**
+ * @brief Release the AITT handle.
+ * @note This is internal function for AITT. You should call this with edge-handle lock.
+ */
+int nns_edge_aitt_close (nns_edge_h edge_h);
+
+/**
+ * @brief Check whether aitt handle exists or not.
+ */
+int nns_edge_aitt_is_connected (nns_edge_h edge_h);
+
+/**
+ * @brief Publish raw data.
+ * @note This is internal function forAITT. You should call this with edge-handle lock.
+ */
+int nns_edge_aitt_publish (nns_edge_h edge_h, const void *data, const int length);
+
+/**
+ * @brief Subscribe a topic.
+ * @note This is internal function for AITT. You should call this with edge-handle lock.
+ */
+int nns_edge_aitt_subscribe (nns_edge_h edge_h);
+#else
+#define nns_edge_aitt_connect(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
+#define nns_edge_aitt_close(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
+#define nns_edge_aitt_publish(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
+#define nns_edge_aitt_subscribe(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
+#define nns_edge_aitt_is_connected(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
+#endif /* ENABLE_AITT */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __NNSTREAMER_EDGE_AITT_H__ */
index 9e0b01b6dd6c0f5492e4faf799285b4bc3816476..201994de6ca2fa369acf4c351f79ad0130534838 100644 (file)
@@ -20,10 +20,10 @@ extern "C" {
 
 #include "nnstreamer-edge.h"
 #include "nnstreamer-edge-metadata.h"
+#include "nnstreamer-edge-aitt.h"
+#include "nnstreamer-edge-mqtt.h"
 #include "nnstreamer-edge-queue.h"
 
-typedef void *nns_edge_broker_h;
-
 /**
  * @brief Internal data structure for raw data.
  */
@@ -77,101 +77,10 @@ typedef struct {
   nns_edge_queue_h send_queue;
   pthread_t send_thread;
 
-  /* MQTT */
-  nns_edge_broker_h broker_h;
+  /* MQTT or AITT handle */
+  void *broker_h;
 } nns_edge_handle_s;
 
-#if defined(ENABLE_MQTT)
-/**
- * @brief Connect to MQTT.
- * @note This is internal function for MQTT broker. You should call this with edge-handle lock.
- */
-int nns_edge_mqtt_connect (nns_edge_h edge_h, const char *topic);
-
-/**
- * @brief Close the connection to MQTT.
- * @note This is internal function for MQTT broker. You should call this with edge-handle lock.
- */
-int nns_edge_mqtt_close (nns_edge_h edge_h);
-
-/**
- * @brief Publish raw data.
- * @note This is internal function for MQTT broker. You should call this with edge-handle lock.
- */
-int nns_edge_mqtt_publish (nns_edge_h edge_h, const void *data, const int length);
-
-/**
- * @brief Subscribe a topic.
- * @note This is internal function for MQTT broker. You should call this with edge-handle lock.
- */
-int nns_edge_mqtt_subscribe (nns_edge_h edge_h);
-
-/**
- * @brief Check mqtt connection
- */
-bool nns_edge_mqtt_is_connected (nns_edge_h edge_h);
-
-/**
- * @brief Get message from mqtt broker.
- */
-int nns_edge_mqtt_get_message (nns_edge_h edge_h, char **msg);
-
-#else
-/**
- * @todo consider to change code style later.
- * If MQTT is disabled, nnstreamer does not include nnstreamer_edge_mqtt.c, and changing code style will make error as it is not used function now.
- *
- * static int nns_edge_mqtt_publish (nns_edge_h edge_h, const void *data, const int length)
- * {
- *   return NNS_EDGE_ERROR_NOT_SUPPORTED;
- * }
- */
-#define nns_edge_mqtt_connect(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
-#define nns_edge_mqtt_close(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
-#define nns_edge_mqtt_publish(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
-#define nns_edge_mqtt_subscribe(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
-#define nns_edge_mqtt_is_connected(...) (false)
-#define nns_edge_mqtt_get_message(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
-#endif
-
-#if defined(ENABLE_AITT)
-/**
- * @brief Create AITT handle and connect to AITT.
- * @note This is internal function for AITT. You should call this with edge-handle lock.
- */
-int nns_edge_aitt_connect (nns_edge_h edge_h);
-
-/**
- * @brief Release the AITT handle.
- * @note This is internal function for AITT. You should call this with edge-handle lock.
- */
-int nns_edge_aitt_close (nns_edge_h edge_h);
-
-/**
- * @brief Check whether aitt handle exists or not.
- */
-int
-nns_edge_aitt_is_connected (nns_edge_h edge_h);
-
-/**
- * @brief Publish raw data.
- * @note This is internal function forAITT. You should call this with edge-handle lock.
- */
-int nns_edge_aitt_publish (nns_edge_h edge_h, const void *data, const int length);
-
-/**
- * @brief Subscribe a topic.
- * @note This is internal function for AITT. You should call this with edge-handle lock.
- */
-int nns_edge_aitt_subscribe (nns_edge_h edge_h);
-#else
-#define nns_edge_aitt_connect(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
-#define nns_edge_aitt_close(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
-#define nns_edge_aitt_publish(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
-#define nns_edge_aitt_subscribe(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
-#define nns_edge_aitt_is_connected(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
-#endif
-
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
diff --git a/src/libnnstreamer-edge/nnstreamer-edge-mqtt.h b/src/libnnstreamer-edge/nnstreamer-edge-mqtt.h
new file mode 100644 (file)
index 0000000..1253d1e
--- /dev/null
@@ -0,0 +1,81 @@
+/* SPDX-License-Identifier: Apache-2.0 */
+/**
+ * Copyright (C) 2022 Samsung Electronics Co., Ltd. All Rights Reserved.
+ *
+ * @file   nnstreamer-edge-mqtt.h
+ * @date   11 May 2022
+ * @brief  Internal functions to support MQTT protocol (Paho Asynchronous MQTT C Client Library).
+ * @see    https://github.com/nnstreamer/nnstreamer
+ * @author Sangjung Woo <sangjung.woo@samsung.com>
+ * @bug    No known bugs except for NYI items
+ */
+
+#ifndef __NNSTREAMER_EDGE_MQTT_H__
+#define __NNSTREAMER_EDGE_MQTT_H__
+
+#include <stdbool.h>
+#include "nnstreamer-edge.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+typedef void *nns_edge_mqtt_h;
+
+#if defined(ENABLE_MQTT)
+/**
+ * @brief Connect to MQTT.
+ * @note This is internal function for MQTT broker. You should call this with edge-handle lock.
+ */
+int nns_edge_mqtt_connect (nns_edge_h edge_h, const char *topic);
+
+/**
+ * @brief Close the connection to MQTT.
+ * @note This is internal function for MQTT broker. You should call this with edge-handle lock.
+ */
+int nns_edge_mqtt_close (nns_edge_h edge_h);
+
+/**
+ * @brief Publish raw data.
+ * @note This is internal function for MQTT broker. You should call this with edge-handle lock.
+ */
+int nns_edge_mqtt_publish (nns_edge_h edge_h, const void *data, const int length);
+
+/**
+ * @brief Subscribe a topic.
+ * @note This is internal function for MQTT broker. You should call this with edge-handle lock.
+ */
+int nns_edge_mqtt_subscribe (nns_edge_h edge_h);
+
+/**
+ * @brief Check mqtt connection
+ */
+bool nns_edge_mqtt_is_connected (nns_edge_h edge_h);
+
+/**
+ * @brief Get message from mqtt broker.
+ */
+int nns_edge_mqtt_get_message (nns_edge_h edge_h, char **msg);
+
+#else
+/**
+ * @todo consider to change code style later.
+ * If MQTT is disabled, nnstreamer does not include nnstreamer_edge_mqtt.c, and changing code style will make error as it is not used function now.
+ *
+ * static int nns_edge_mqtt_publish (nns_edge_h edge_h, const void *data, const int length)
+ * {
+ *   return NNS_EDGE_ERROR_NOT_SUPPORTED;
+ * }
+ */
+#define nns_edge_mqtt_connect(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
+#define nns_edge_mqtt_close(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
+#define nns_edge_mqtt_publish(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
+#define nns_edge_mqtt_subscribe(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
+#define nns_edge_mqtt_is_connected(...) (false)
+#define nns_edge_mqtt_get_message(...) (NNS_EDGE_ERROR_NOT_SUPPORTED)
+#endif /* ENABLE_MQTT */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __NNSTREAMER_EDGE_MQTT_H__ */