[sensor] Add MQTT common header
authorSangjung Woo <sangjung.woo@samsung.com>
Thu, 1 Jul 2021 09:47:09 +0000 (18:47 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Thu, 2 Sep 2021 08:37:17 +0000 (17:37 +0900)
To communicate with GstMQTT element, this patch adds the
GstMQTTMessageHdr structure. The original file is located in
gst/mqtt/mqttcommon.h of the NNStreamer repo. To remove glib dependency,
this version uses fixed-width integer types (i.e. stdint.h) instead of
GLib types.

Signed-off-by: Sangjung Woo <sangjung.woo@samsung.com>
src/libsensor/mqttcommon.h [new file with mode: 0644]

diff --git a/src/libsensor/mqttcommon.h b/src/libsensor/mqttcommon.h
new file mode 100644 (file)
index 0000000..7765dc3
--- /dev/null
@@ -0,0 +1,42 @@
+/* SPDX-License-Identifier: Apache-2.0 */
+/**
+ * @file    mqttcommon.h
+ * @date    08 Mar 2021
+ * @brief   Common macros and utility functions for GStreamer MQTT plugins
+ * @see     https://github.com/nnstreamer/nnstreamer
+ * @see     https://github.com/nnstreamer/nnstreamer-edge
+ * @author  Wook Song <wook16.song@samsung.com>
+ *          Sangjung Woo <sangjung.woo@samsung.com>
+ * @bug     No known bugs except for NYI items
+ * @note    To remove glib dependency, this file uses fixed width integer types (i.e. stdint.h) instead of GLib types.
+ */
+#ifndef __EDGE_MQTT_COMMON_H__
+#define __EDGE_MQTT_COMMON_H__
+
+#include <stdint.h>
+
+#define GST_MQTT_MAX_NUM_MEMS         16
+#define GST_MQTT_LEN_MSG_HDR          1024
+#define GST_MQTT_MAX_LEN_GST_CPAS_STR 512
+
+#define GST_US_TO_NS_MULTIPLIER 1000
+
+typedef struct _GstMQTTMessageHdr {
+  union {
+    struct {
+      uint32_t num_mems;
+      uint64_t size_mems[GST_MQTT_MAX_NUM_MEMS];
+
+      int64_t base_time_epoch;
+      int64_t sent_time_epoch;
+     
+      uint64_t duration;
+      uint64_t dts;
+      uint64_t pts;
+      char gst_caps_str[GST_MQTT_MAX_LEN_GST_CPAS_STR];
+    };
+    uint8_t _reserved_hdr[GST_MQTT_LEN_MSG_HDR];
+  };
+} GstMQTTMessageHdr;
+
+#endif /* __EDGE_MQTT_COMMON_H__ */