Init skelton of edgesrc and edgesink.
Signed-off-by: Yechan Choi <yechan9.choi@samsung.com>
--- /dev/null
+/* SPDX-License-Identifier: LGPL-2.1-only */
+/**
+ * Copyright (C) 2022 Samsung Electronics Co., Ltd.
+ *
+ * @file edge_common.c
+ * @date 01 Aug 2022
+ * @brief Common functions for edge sink and src
+ * @author Yechan Choi <yechan9.choi@samsung.com>
+ * @see http://github.com/nnstreamer/nnstreamer
+ * @bug No known bugs
+ *
+ */
--- /dev/null
+/* SPDX-License-Identifier: LGPL-2.1-only */
+/**
+ * Copyright (C) 2022 Samsung Electronics Co., Ltd.
+ *
+ * @file edge_common.h
+ * @date 01 Aug 2022
+ * @brief Common functions for edge sink and src
+ * @author Yechan Choi <yechan9.choi@samsung.com>
+ * @see http://github.com/nnstreamer/nnstreamer
+ * @bug No known bugs
+ *
+ */
+#ifndef __GST_EDGE_H__
+#define __GST_EDGE_H__
+
+G_BEGIN_DECLS
+#ifndef UNUSED
+#define UNUSED(expr) do { (void)(sizeof(x), 0); } while (0)
+#endif /* UNUSED */
+#ifndef GST_EDGE_PACKAGE
+#define GST_EDGE_PACKAGE "GStreamer Edge Plugins"
+#endif /* GST_EDGE_PACKAGE */
+#define GST_EDGE_ELEM_NAME_SINK "edgesink"
+#define GST_EDGE_ELEM_NAME_SRC "edgesrc"
+ G_END_DECLS
+#endif /* __GST_EDGE_H__ */
--- /dev/null
+/* SPDX-License-Identifier: LGPL-2.1-only */
+/**
+ * Copyright (C) 2022 Samsung Electronics Co., Ltd.
+ *
+ * @file edge_sink.h
+ * @date 02 Aug 2022
+ * @brief Register edge plugins
+ * @author Yechan Choi <yechan9.choi@samsung.com>
+ * @see http://github.com/nnstreamer/nnstreamer
+ * @bug No known bugs
+ *
+ */
+#include <gst/gst.h>
+
+#include "edge_common.h"
+#include "edge_sink.h"
+#include "edge_src.h"
+
+/**
+ * @brief The entry point of the Gstreamer Edge plugin
+ */
+static gboolean
+plugin_init (GstPlugin * plugin)
+{
+ if (!gst_element_register (plugin, GST_EDGE_ELEM_NAME_SINK, GST_RANK_NONE,
+ GST_TYPE_EDGESINK)) {
+ return FALSE;
+ }
+
+ if (!gst_element_register (plugin, GST_EDGE_ELEM_NAME_SRC, GST_RANK_NONE,
+ GST_TYPE_EDGESRC)) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+#ifndef PACKAGE
+#define PACKAGE GST_EDGE_PACKAGE
+#endif
+
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_VERSION_MINOR, edge,
+ "A collcetion of GStreamer plugins to support Edge",
+ plugin_init, VERSION, "LGPL", PACKAGE,
+ "https://github.com/nnstreamer/nnstreamer")
--- /dev/null
+/* SPDX-License-Identifier: LGPL-2.1-only */
+/**
+ * Copyright (C) 2022 Samsung Electronics Co., Ltd.
+ *
+ * @file edge_sink.h
+ * @date 01 Aug 2022
+ * @brief Publish incoming streams
+ * @author Yechan Choi <yechan9.choi@samsung.com>
+ * @see http://github.com/nnstreamer/nnstreamer
+ * @bug No known bugs
+ *
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "edge_sink.h"
+
+GST_DEBUG_CATEGORY_STATIC (gst_edgesink_debug);
+#define GST_CAT_DEFAULT gst_edgesink_debug
+
+/**
+ * @brief the capabilities of the inputs.
+ */
+static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS_ANY);
+
+enum
+{
+ PROP_0,
+
+ /** @todo define props */
+
+ PROP_LAST
+};
+
+#define gst_edgesink_parent_class parent_class
+G_DEFINE_TYPE (GstEdgeSink, gst_edgesink, GST_TYPE_BASE_SINK);
+
+static void gst_edgesink_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSepc * pspec);
+
+static void gst_edgesink_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
+
+static void gst_edgesink_finalize (GObject * object);
+
+static gboolean gst_edgesink_start (GstBaseSink * basesink);
+static GstFlowReturn gst_edgesink_render (GstBaseSink * basesink,
+ GstBuffer * buf);
+static gboolean gst_edgesink_set_caps (GstBaseSink * basesink, GstCaps * caps);
+
+/**
+ * @brief initialize the class
+ */
+static void
+gst_edgesink_class_init (GstEdgeSinkClass * klass)
+{
+ GObjectClass *gobject_class;
+ GstElementClass *gselement_class;
+ GstBaseSinkClass *gstbasesink_class;
+
+ gstbasesink_class = (GstBaseSinkClass *) klass;
+ gstelement_class = (GstElementClass *) gstbasesink_class;
+ gobject_class = (GObjectClass *) gstelement_class;
+
+ gobject_class->set_property = gst_edgesink_set_property;
+ gobject_class->get_property = gst_edgesink_get_property;
+ gobject_class->finalize = gst_edgesink_finalize;
+
+ /** @todo set props */
+
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&sinktemplate));
+
+ gst_element_class_set_static_metadata (gstelement_class,
+ "EdgeSink", "Sink/Edge",
+ "Publish incoming streams", "Samsung Electronics Co., Ltd.");
+
+ gstbasesink_class->start = gst_edgesink_start;
+ gstbasesink_class->render = gst_edgesink_render;
+ gstbasesink_class->set_caps = gst_edgesink_set_caps;
+
+ GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT,
+ GST_EDGE_ELEM_NAME_SINK, 0, "Edge sink");
+}
+
+/**
+ * @brief initialize the new element
+ */
+static void
+gst_edgesink_init (GstEdgeSink * sink)
+{
+ /** @todo set default value of props */
+}
+
+
+/**
+ * @brief finalize the object
+ */
+static void
+gst_edgesink_finalize (GObject * object)
+{
+ GstEdgeSink *self = GST_EDGESINK (object);
+ /** @todo finalize - free all pointer in element */
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+/**
+ * @brief set property
+ */
+static void
+gst_edgesink_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ GstEdgeSink *self = GST_EDGESINK (object);
+
+ switch (prop_id) {
+ /** @todo set prop */
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+/**
+ * @brief get property
+ */
+static void
+gst_edgesink_get_property (GObject * object, guint prop_id, GValue * value,
+ GParmSpec * pspec)
+{
+ GstEdgeSInk *self = GST_EDGESINK (object);
+
+ switch (prop_id) {
+ /** @todo props */
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+/**
+ * @brief start processing of edgesink
+ */
+static gboolean
+gst_edgesink_start (GstBaseSink * basesink)
+{
+ GstEdgeSink *sink = GST_EDGESINK (basesink);
+
+ /** @todo start */
+}
+
+/**
+ * @brief render buffer, send buffer
+ */
+static GstFlowReturn
+gst_edgesink_render (GstBaseSink * basesink, GstBuffer * buf)
+{
+ /** @todo render, send data */
+}
+
+/**
+ * @brief An implementation of the set_caps vmethod in GstBaseSinkClass
+ */
+static gboolean
+gst_edgesink_set_caps (GstBaseSink * basesink, GstCaps * caps)
+{
+ /** @todo set caps */
+}
--- /dev/null
+/* SPDX-License-Identifier: LGPL-2.1-only */
+/**
+ * Copyright (C) 2022 Samsung Electronics Co., Ltd.
+ *
+ * @file edge_sink.h
+ * @date 01 Aug 2022
+ * @brief Publish incoming streams
+ * @author Yechan Choi <yechan9.choi@samsung.com>
+ * @see http://github.com/nnstreamer/nnstreamer
+ * @bug No known bugs
+ *
+ */
+#ifndef __GST_EDGE_SINK_H__
+#define __GST_EDGE_SINK_H__
+
+#include <gst/gst.h>
+#include <gst/base/gstbasesink.h>
+
+G_BEGIN_DECLS
+#define GST_TYPE_EDGESINK \
+ (gst_edgesink_get_type())
+#define GST_EDGESINK(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_EDGESINK,GstEdgeSink))
+#define GST_EDGESINK_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_EDGESINK,GstEdgeSinkClass))
+#define GST_IS_EDGESINK(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_EDGESINK))
+#define GST_IS_EDGESINK_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_EDGESINK))
+#define GST_EDGESINK_CAST(obj) ((GstEdgeSink *)(obj))
+typedef struct _GstEdgeSink GstEdgeSink;
+typedef struct _GstEdgeSinkClass GstEdgeSinkClass;
+
+/**
+ * @brief GstEdgeSink data structure.
+ */
+struct _GstEdgeSink
+{
+ GstBaseSink element;
+
+};
+
+/**
+ * @brief GstEdgeSinkClass data structure.
+ */
+struct _GstEdgeSinkClass
+{
+ GstBaseSinkClass parent_class; /**<parent class */
+};
+
+GType gst_edgesink_get_type (void);
+
+G_END_DECLS
+#endif /* __GST_EDGE_SINK_H__ */
--- /dev/null
+/* SPDX-License-Identifier: LGPL-2.1-only */
+/**
+ * Copyright (C) 2022 Samsung Electronics Co., Ltd.
+ *
+ * @file edge_src.c
+ * @date 02 Aug 2022
+ * @brief Subscribe and push incoming data to the GStreamer pipeline
+ * @author Yechan Choi <yechan9.choi@samsung.com>
+ * @see http://github.com/nnstreamer/nnstreamer
+ * @bug No known bugs
+ *
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "edge_src.h"
+
+GST_DEBUG_CATEGORY_STATIC (gst_edgesrc_debug);
+#define GST_CAT_DEFAULT gst_edgesrc_debug
+
+/**
+ * @brief the capabilities of the outputs
+ */
+static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC, GST_PAD_ALWAYS, GST_STATIC_CAPS_ANY);
+
+/**
+ * @brief edgesrc properties
+ */
+enum
+{
+ PROP_0,
+
+ /** @todo define props */
+
+ PROP_LAST
+}
+
+#define gst_edgesrc_parent_class parent_class
+G_DEFINE_TYPE (GstEdgeSrc, gst_edgesrc, GST_TYPE_PUSH_SRC);
+
+static void gst_edgesrc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_edgesrc_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+static void gst_edgesrc_class_finalize (GObject * object);
+
+static GstStateChangeReturn gst_edgesrc_change_state (GstElement * element,
+ GstStateChange transition);
+
+static gboolean gst_edgesrc_start (GstBaseSrc * basesrc);
+static gboolean gst_edgesrc_stop (GstBaseSrc * basesrc);
+static GstCaps *gst_edgesrc_get_caps (GstBaseSrc * basesrc, GstCaps * filter);
+static void gst_edgesrc_get_times (GstBaseSrc * basesrc, GstBuffer * buffer,
+ GstClockTime * start, GstClockTime * end);
+static gboolean gst_edgesrc_is_seekable (GstBaseSrc * basesrc);
+static GstFlowReturn gst_edgesrc_create (GstBaseSrc * basesrc, guint64 offset,
+ guint size, GstBuffer ** buf);
+static gboolean gst_edgesrc_query (GstBaseSrc * basesrc, GstQuery * query);
+
+/**
+ * @brief initialize the class
+ */
+static void
+gst_edgesrc_class_init (GstEdgeSrcClass * klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
+ GstBaseSrcClass *gstbasesrc_class = GST_BASE_SRC_CLASS (klass);
+
+ gobject_class->set_property = gst_edgesrc_set_property;
+ gobject_class->get_property = gst_edgesrc_get_property;
+ gobject_class->finalize = gst_edgesrc_class_finalize;
+
+ /** @todo set props */
+
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&srctemplate));
+
+ gst_element_class_set_static_metadata (gelement_class,
+ "EdgeSrc", "Source/Edge",
+ "Subscribe and push incoming streams", "Samsung Electronics Co., Ltd.");
+
+ gstelement_class->change_state = gst_edgesrc_change_state;
+
+ gstbasesrc_class->start = gst_edgesrc_start;
+ gstbasesrc_class->stop = gst_edgesrc_stop;
+ gstbasesrc_class->get_caps = gst_edgesrc_get_caps;
+ gstbasesrc_class->get_times = gst_edgesrc_get_times;
+ gstbasesrc_class->is_seekable = gst_edgesrc_is_seekable;
+ gstbasesrc_class->create = gst_edgesrc_create;
+ gstbasesrc_class->query = gst_edgesrc_query;
+
+ GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT,
+ GST_EDGE_ELEM_NAME_SRC, 0, "Edge src");
+}
+
+/**
+ * @brief initialize edgesrc element
+ */
+static void
+gst_edgesrc_init (GstEdgeSrc * self)
+{
+ GstBaseSrc *basesrc = GST_BASE_SRC (self);
+
+ gst_base_src_set_format (basesrc, GST_FORMAT_TIME);
+ gst_base_src_set_async (basesrc, FALSE);
+
+ /** @todo set default value of props */
+}
+
+/**
+ * @brief set property
+ */
+static void
+gst_edgesrc_set_property (GObject * object, guint prop_id, const GValue * value,
+ GParamSpec * pspec)
+{
+ GstEdgeSrc *self = GST_EDGESRC (object);
+
+ switch (prod_id) {
+ /** @todo set prop */
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+/**
+ * @brief get property
+ */
+static void
+gst_edgesrc_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
+{
+ GstEdgeSrc *self = GST_EDGESRC (object);
+
+ switch (prop_id) {
+ /** @todo props */
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+/**
+ * @brief finalize the object
+ */
+static void
+gst_edgesrc_class_finalize (GObject * object)
+{
+ GstEdgeSrc *self = GST_EDGESRC (object);
+ /** @todo finalize - free all pointer in element */
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+/**
+ * @brief handle edgesrc's state change
+ */
+static GstStateChangeReturn
+gst_edgesrc_change_state (GstElement * element, GstStateChange transition)
+{
+ GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
+
+ GstEdgeSrc *self = GST_EDGESRC (element);
+
+ /** @todo handle transition */
+
+ ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
+
+ /** @todo handle transition */
+
+ return ret;
+}
+
+/**
+ * @brief start edgesrc, called when state changed null to ready
+ */
+static gboolean
+gst_edgesrc_start (GstBaseSrc * basesrc)
+{
+ GstEdgeSrc *self = GST_EDGESRC (basesrc);
+
+ /** @todo start */
+}
+
+/**
+ * @brief stop edgesrc, called when state changed ready to null
+ */
+static gboolean
+gst_edgesrc_stop (GstBaseSrc * basesrc)
+{
+ GstEdgeSrc *self = GST_EDGESRC (basesrc);
+
+ /** @todo stop */
+}
+
+/**
+ * @brief Get caps of subclass
+ */
+static GstCaps *
+gst_edgesrc_get_caps (GstBaseSrc * basesrc, GstCaps * filter)
+{
+ /** @todo get caps */
+}
+
+/**
+ * @brief Return the time information of the given buffer
+ */
+static void
+gst_edgesrc_get_times (GstBaseSrc * basesrc, GstBuffer * buffer,
+ GstClockTime * start, GstClockTime * end)
+{
+ /** @todo get times */
+}
+
+/**
+ * @brief Check if source supports seeking
+ */
+static gboolean
+gst_edgesrc_is_seekable (GstBaseSrc * basesrc)
+{
+ /** @todo is seekable */
+}
+
+/**
+ * @brief Create a buffer containing the subscribed data
+ */
+static GstFlowReturn
+gst_edgesrc_create (GstBaseSrc * basesrc, guint64 offset, guint size,
+ GstBuffer ** buf)
+{
+ GstEdgeSrc *self = GST_EDGESRC (basesrc);
+
+ /** @todo create */
+}
+
+/**
+ * @brief An implementation of the GstBaseSrc vmethod that handles queries
+ */
+static gboolean
+gst_edgesrc_query (GstBaseSrc * basesrc, GstQuery * query)
+{
+ /** @todo query */
+}
--- /dev/null
+/* SPDX-License-Identifier: LGPL-2.1-only */
+/**
+ * Copyright (C) 2022 Samsung Electronics Co., Ltd.
+ *
+ * @file edge_src.h
+ * @date 02 Aug 2022
+ * @brief Subscribe and push incoming data to the GStreamer pipeline
+ * @author Yechan Choi <yechan9.choi@samsung.com>
+ * @see http://github.com/nnstreamer/nnstreamer
+ * @bug No known bugs
+ *
+ */
+#ifndef __GST_EDGE_SRC_H__
+#define __GST_EDGE_SRC_H__
+
+#include <gst/base/gstbasesrc.h>
+
+G_BEGIN_DECLS
+#define GST_TYPE_EDGESRC \
+ (gst_edgesrc_get_type())
+#define GST_EDGESRC(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_EDGESRC,GstEdgeSrc))
+#define GST_EDGESRC_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_EDGESRC,GstEdgeSrcClass))
+#define GST_IS_EDGESRC(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_EDGESRC))
+#define GST_IS_EDGESRC_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_EDGESRC))
+#define GST_EDGESRC_CAST(obj) ((GstEdgeSrc *) (obj))
+typedef struct _GstEdgeSrc GstEdgeSrc;
+typedef struct _GstEdgeSrcClass GstEdgeSinkClass;
+
+/**
+ * @brief GstEdgeSrc data structure.
+ */
+struct _GstEdgeSrc
+{
+ GstBaseSrc element;
+}
+
+/**
+ * @brief GstEdgeSrcClass data structure.
+ */
+struct _GstEdgeSrcClass
+{
+ GstBaseSrcClass parent_class;
+}
+
+GType gst_edgesrc_get_type (void);
+
+G_END_DECLS
+#endif /* __GST_EDGE_SRC_H__ */
--- /dev/null
+edge_files = [
+ 'edge_common.c',
+ 'edge_elements.c',
+ 'edge_sink.c',
+ 'edge_src.c',
+]
+
+edge_srcs = []
+edge_dep = [
+ glib_dep,
+ gst_base_dep,
+ gst_dep,
+]
+
+foreach s : edge_files
+ edge_srcs += join_paths(meson.current_source_dir(), s)
+endforeach
+
+gstedge_shared = shared_library('gstedge',
+ edge_srcs,
+ dependencies: edge_dep,
+ install: true,
+ include_directories: include_directories('../nnstreamer/include'),
+ install_dir: plugins_install_dir
+)
+
+gstedge_dep = declare_dependency(
+ link_with: gstedge_shared,
+ dependencies: edge_dep,
+ include_directories: include_directories('.')
+)
+subdir('edge')
subdir('join')
if mqtt_support_is_available
subdir('mqtt')