Register sub-plugins included in libgstmqtt. More...
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <gst/base/gstbasesink.h>
#include <MQTTAsync.h>
#include <nnstreamer_util.h>
#include "mqttsink.h"
#include "ntputil.h"
Go to the source code of this file.
Macros | |
#define | gst_mqtt_sink_parent_class parent_class |
#define | GST_CAT_DEFAULT gst_mqtt_sink_debug |
Enumerations | |
enum | { PROP_0, PROP_DEBUG, PROP_MQTT_CLIENT_ID, PROP_MQTT_HOST_ADDRESS, PROP_MQTT_HOST_PORT, PROP_MQTT_PUB_TOPIC, PROP_MQTT_PUB_WAIT_TIMEOUT, PROP_MQTT_OPT_CLEANSESSION, PROP_MQTT_OPT_KEEP_ALIVE_INTERVAL, PROP_NUM_BUFFERS, PROP_MAX_MSG_BUF_SIZE, PROP_MQTT_QOS, PROP_MQTT_NTP_SYNC, PROP_MQTT_NTP_SRVS, PROP_LAST } |
enum | { DEFAULT_DEBUG = FALSE, DEFAULT_NUM_BUFFERS = -1, DEFAULT_QOS = TRUE, DEFAULT_SYNC = FALSE, DEFAULT_MQTT_OPT_CLEANSESSION = TRUE, DEFAULT_MQTT_OPT_KEEP_ALIVE_INTERVAL = 60, DEFAULT_MQTT_DISCONNECT_TIMEOUT = G_TIME_SPAN_SECOND * 3, DEFAULT_MQTT_PUB_WAIT_TIMEOUT = 1, DEFAULT_MAX_MSG_BUF_SIZE = 0, DEFAULT_MQTT_QOS = 0, DEFAULT_MQTT_NTP_SYNC = FALSE, MAX_LEN_PROP_NTP_SRVS = 4096 } |
Functions | |
G_DEFINE_TYPE (GstMqttSink, gst_mqtt_sink, GST_TYPE_BASE_SINK) | |
GST_DEBUG_CATEGORY_STATIC (gst_mqtt_sink_debug) | |
static void | gst_mqtt_sink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) |
The setter for the mqttsink's properties. More... | |
static void | gst_mqtt_sink_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) |
The getter for the mqttsink's properties. More... | |
static void | gst_mqtt_sink_class_finalize (GObject *object) |
Finalize GstMqttSinkClass object. More... | |
static GstStateChangeReturn | gst_mqtt_sink_change_state (GstElement *element, GstStateChange transition) |
Handle mqttsink's state change. More... | |
static gboolean | gst_mqtt_sink_start (GstBaseSink *basesink) |
Start mqttsink, called when state changed null to ready. More... | |
static gboolean | gst_mqtt_sink_stop (GstBaseSink *basesink) |
Stop mqttsink, called when state changed ready to null. More... | |
static gboolean | gst_mqtt_sink_query (GstBaseSink *basesink, GstQuery *query) |
Perform queries on the element. More... | |
static GstFlowReturn | gst_mqtt_sink_render (GstBaseSink *basesink, GstBuffer *in_buf) |
The callback to process each buffer receiving on the sink pad. More... | |
static GstFlowReturn | gst_mqtt_sink_render_list (GstBaseSink *basesink, GstBufferList *list) |
The callback to process GstBufferList (instead of a single buffer) on the sink pad. More... | |
static gboolean | gst_mqtt_sink_event (GstBaseSink *basesink, GstEvent *event) |
Handle events arriving on the sink pad. More... | |
static gboolean | gst_mqtt_sink_set_caps (GstBaseSink *basesink, GstCaps *caps) |
An implementation of the set_caps vmethod in GstBaseSinkClass. More... | |
static gboolean | gst_mqtt_sink_get_debug (GstMqttSink *self) |
Getter for the 'debug' property. More... | |
static void | gst_mqtt_sink_set_debug (GstMqttSink *self, const gboolean flag) |
Setter for the 'debug' property. More... | |
static gchar * | gst_mqtt_sink_get_client_id (GstMqttSink *self) |
Getter for the 'client-id' property. More... | |
static void | gst_mqtt_sink_set_client_id (GstMqttSink *self, const gchar *id) |
Setter for the 'client-id' property. More... | |
static gchar * | gst_mqtt_sink_get_host_address (GstMqttSink *self) |
Getter for the 'host' property. More... | |
static void | gst_mqtt_sink_set_host_address (GstMqttSink *self, const gchar *addr) |
Setter for the 'host' property. More... | |
static gchar * | gst_mqtt_sink_get_host_port (GstMqttSink *self) |
Getter for the 'port' property. More... | |
static void | gst_mqtt_sink_set_host_port (GstMqttSink *self, const gchar *port) |
Setter for the 'port' property. More... | |
static gchar * | gst_mqtt_sink_get_pub_topic (GstMqttSink *self) |
Getter for the 'pub-topic' property. More... | |
static void | gst_mqtt_sink_set_pub_topic (GstMqttSink *self, const gchar *topic) |
Setter for the 'pub-topic' property. More... | |
static gulong | gst_mqtt_sink_get_pub_wait_timeout (GstMqttSink *self) |
Getter for the 'pub-wait-timeout' property. More... | |
static void | gst_mqtt_sink_set_pub_wait_timeout (GstMqttSink *self, const gulong to) |
Setter for the 'pub-wait-timeout' property. More... | |
static gboolean | gst_mqtt_sink_get_opt_cleansession (GstMqttSink *self) |
Getter for the 'cleansession' property. More... | |
static void | gst_mqtt_sink_set_opt_cleansession (GstMqttSink *self, const gboolean val) |
Setter for the 'cleansession' property. More... | |
static gint | gst_mqtt_sink_get_opt_keep_alive_interval (GstMqttSink *self) |
Getter for the 'keep-alive-interval' property. More... | |
static void | gst_mqtt_sink_set_opt_keep_alive_interval (GstMqttSink *self, const gint num) |
Setter for the 'keep-alive-interval' property. More... | |
static gsize | gst_mqtt_sink_get_max_msg_buf_size (GstMqttSink *self) |
Getter for the 'max-buffer-size' property. More... | |
static void | gst_mqtt_sink_set_max_msg_buf_size (GstMqttSink *self, const gsize size) |
Setter for the 'max-buffer-size' property. More... | |
static gint | gst_mqtt_sink_get_num_buffers (GstMqttSink *self) |
Getter for the 'num-buffers' property. More... | |
static void | gst_mqtt_sink_set_num_buffers (GstMqttSink *self, const gint num) |
Setter for the 'num-buffers' property. More... | |
static gint | gst_mqtt_sink_get_mqtt_qos (GstMqttSink *self) |
Getter for the 'mqtt-qos' property. More... | |
static void | gst_mqtt_sink_set_mqtt_qos (GstMqttSink *self, const gint qos) |
Setter for the 'mqtt-qos' property. More... | |
static gboolean | gst_mqtt_sink_get_mqtt_ntp_sync (GstMqttSink *self) |
Getter for the 'ntp-sync' property. More... | |
static void | gst_mqtt_sink_set_mqtt_ntp_sync (GstMqttSink *self, const gboolean flag) |
Setter for the 'ntp-sync' property. More... | |
static gchar * | gst_mqtt_sink_get_mqtt_ntp_srvs (GstMqttSink *self) |
Getter for the 'ntp-srvs' property. More... | |
static void | gst_mqtt_sink_set_mqtt_ntp_srvs (GstMqttSink *self, const gchar *pairs) |
Setter for the 'ntp-srvs' property. More... | |
static void | cb_mqtt_on_connect (void *context, MQTTAsync_successData *response) |
A callback function corresponding to MQTTAsync_connectOptions's onSuccess. This callback is invoked when the connection between this element and the broker is properly established. More... | |
static void | cb_mqtt_on_connect_failure (void *context, MQTTAsync_failureData *response) |
A callback function corresponding to MQTTAsync_connectOptions's onFailure. This callback is invoked when it is failed to connect to the broker. More... | |
static void | cb_mqtt_on_disconnect (void *context, MQTTAsync_successData *response) |
A callback function corresponding to MQTTAsync_disconnectOptions's onSuccess. Regardless of the MQTTAsync_disconnect function's result, the pipeline should be stopped after this callback. More... | |
static void | cb_mqtt_on_disconnect_failure (void *context, MQTTAsync_failureData *response) |
A callback function corresponding to MQTTAsync_disconnectOptions's onFailure. Regardless of the MQTTAsync_disconnect function's result, the pipeline should be stopped after this callback. More... | |
static void | cb_mqtt_on_delivery_complete (void *context, MQTTAsync_token token) |
A callback function to be given to the MQTTAsync_setCallbacks function. This callback is activated when mqtt-qos is higher then 0. More... | |
static void | cb_mqtt_on_connection_lost (void *context, char *cause) |
A callback function to be given to the MQTTAsync_setCallbacks function. When the connection between this element and the broker is broken, this callback will be invoked. More... | |
static int | cb_mqtt_on_message_arrived (void *context, char *topicName, int topicLen, MQTTAsync_message *message) |
A callback function to be given to the MQTTAsync_setCallbacks function. In the case of the publisher, this callback is not used. More... | |
static void | cb_mqtt_on_send_success (void *context, MQTTAsync_successData *response) |
A callback function corresponding to MQTTAsync_responseOptions's onSuccess. More... | |
static void | cb_mqtt_on_send_failure (void *context, MQTTAsync_failureData *response) |
A callback function corresponding to MQTTAsync_responseOptions's onFailure. More... | |
static void | gst_mqtt_sink_init (GstMqttSink *self) |
Initialize GstMqttSink object. More... | |
static void | gst_mqtt_sink_class_init (GstMqttSinkClass *klass) |
Initialize GstMqttSinkClass object. More... | |
static void | _put_timestamp_to_msg_buf_hdr (GstMqttSink *self, GstBuffer *gst_buf, GstMQTTMessageHdr *hdr) |
A utility function to set the timestamp information onto the given buffer. More... | |
static gboolean | _mqtt_set_msg_buf_hdr (GstBuffer *gst_buf, GstMQTTMessageHdr *hdr) |
A utility function to set the message header. More... | |
Variables | |
static GstStaticPadTemplate | sink_pad_template |
static guint8 | sink_client_id = 0 |
static const gchar | DEFAULT_MQTT_HOST_ADDRESS [] = "127.0.0.1" |
static const gchar | DEFAULT_MQTT_HOST_PORT [] = "1883" |
static const gchar | TAG_ERR_MQTTSINK [] = "ERROR: MQTTSink" |
static const gchar | DEFAULT_MQTT_CLIENT_ID [] = "$HOST_$PID_^[0-9][0-9]?$|^255$" |
static const gchar | DEFAULT_MQTT_CLIENT_ID_FORMAT [] = "%s_%u_sink%u" |
static const gchar | DEFAULT_MQTT_PUB_TOPIC [] = "$client-id/topic" |
static const gchar | DEFAULT_MQTT_PUB_TOPIC_FORMAT [] = "%s/topic" |
static const gchar | DEFAULT_MQTT_NTP_SERVERS [] = "pool.ntp.org:123" |
Register sub-plugins included in libgstmqtt.
Publish incoming data streams as a MQTT topic.
Copyright (C) 2021 Wook Song wook1 6.so ng@sa msun g.com
Copyright (C) 2021 Wook Song wook1 6.so ng@sa msun g.com
Definition in file mqttsink.c.
#define GST_CAT_DEFAULT gst_mqtt_sink_debug |
Definition at line 42 of file mqttsink.c.
#define gst_mqtt_sink_parent_class parent_class |
Definition at line 38 of file mqttsink.c.
anonymous enum |
Definition at line 65 of file mqttsink.c.
anonymous enum |
Definition at line 44 of file mqttsink.c.
|
static |
A utility function to set the message header.
Definition at line 725 of file mqttsink.c.
|
static |
A utility function to set the timestamp information onto the given buffer.
Definition at line 688 of file mqttsink.c.
|
static |
A callback function corresponding to MQTTAsync_connectOptions's onSuccess. This callback is invoked when the connection between this element and the broker is properly established.
Callback function definitions
Definition at line 1267 of file mqttsink.c.
|
static |
A callback function corresponding to MQTTAsync_connectOptions's onFailure. This callback is invoked when it is failed to connect to the broker.
Definition at line 1285 of file mqttsink.c.
|
static |
A callback function to be given to the MQTTAsync_setCallbacks function. When the connection between this element and the broker is broken, this callback will be invoked.
Definition at line 1351 of file mqttsink.c.
|
static |
A callback function to be given to the MQTTAsync_setCallbacks function. This callback is activated when mqtt-qos
is higher then 0.
Definition at line 1336 of file mqttsink.c.
|
static |
A callback function corresponding to MQTTAsync_disconnectOptions's onSuccess. Regardless of the MQTTAsync_disconnect function's result, the pipeline should be stopped after this callback.
Definition at line 1303 of file mqttsink.c.
|
static |
A callback function corresponding to MQTTAsync_disconnectOptions's onFailure. Regardless of the MQTTAsync_disconnect function's result, the pipeline should be stopped after this callback.
Definition at line 1320 of file mqttsink.c.
|
static |
A callback function to be given to the MQTTAsync_setCallbacks function. In the case of the publisher, this callback is not used.
Definition at line 1368 of file mqttsink.c.
|
static |
A callback function corresponding to MQTTAsync_responseOptions's onFailure.
Definition at line 1404 of file mqttsink.c.
|
static |
A callback function corresponding to MQTTAsync_responseOptions's onSuccess.
Definition at line 1384 of file mqttsink.c.
G_DEFINE_TYPE | ( | GstMqttSink | , |
gst_mqtt_sink | , | ||
GST_TYPE_BASE_SINK | |||
) |
GST_DEBUG_CATEGORY_STATIC | ( | gst_mqtt_sink_debug | ) |
|
static |
Handle mqttsink's state change.
Definition at line 491 of file mqttsink.c.
|
static |
Finalize GstMqttSinkClass object.
Definition at line 454 of file mqttsink.c.
|
static |
Initialize GstMqttSinkClass object.
Definition at line 229 of file mqttsink.c.
|
static |
Handle events arriving on the sink pad.
Definition at line 898 of file mqttsink.c.
|
static |
Getter for the 'client-id' property.
Definition at line 976 of file mqttsink.c.
|
static |
Getter for the 'debug' property.
Definition at line 958 of file mqttsink.c.
|
static |
Getter for the 'host' property.
Definition at line 995 of file mqttsink.c.
|
static |
Getter for the 'port' property.
Definition at line 1017 of file mqttsink.c.
|
static |
Getter for the 'max-buffer-size' property.
Definition at line 1109 of file mqttsink.c.
|
static |
Getter for the 'ntp-srvs' property.
Definition at line 1185 of file mqttsink.c.
|
static |
Getter for the 'ntp-sync' property.
Definition at line 1167 of file mqttsink.c.
|
static |
Getter for the 'mqtt-qos' property.
Definition at line 1149 of file mqttsink.c.
|
static |
Getter for the 'num-buffers' property.
Definition at line 1127 of file mqttsink.c.
|
static |
Getter for the 'cleansession' property.
Definition at line 1055 of file mqttsink.c.
|
static |
Getter for the 'keep-alive-interval' property.
Definition at line 1091 of file mqttsink.c.
|
static |
The getter for the mqttsink's properties.
Definition at line 399 of file mqttsink.c.
|
static |
Getter for the 'pub-topic' property.
Definition at line 1036 of file mqttsink.c.
|
static |
Getter for the 'pub-wait-timeout' property.
Definition at line 1073 of file mqttsink.c.
|
static |
Initialize GstMqttSink object.
init MQTT related variables
init private variables
init mqttsink properties
init basesink properties
Definition at line 171 of file mqttsink.c.
|
static |
Perform queries on the element.
Definition at line 661 of file mqttsink.c.
|
static |
The callback to process each buffer receiving on the sink pad.
Allocate a message buffer
Definition at line 751 of file mqttsink.c.
|
static |
The callback to process GstBufferList (instead of a single buffer) on the sink pad.
Definition at line 877 of file mqttsink.c.
|
static |
An implementation of the set_caps vmethod in GstBaseSinkClass.
Definition at line 924 of file mqttsink.c.
|
static |
Setter for the 'client-id' property.
Definition at line 985 of file mqttsink.c.
|
static |
Setter for the 'debug' property.
Definition at line 967 of file mqttsink.c.
|
static |
Setter for the 'host' property.
Definition at line 1004 of file mqttsink.c.
|
static |
Setter for the 'port' property.
Definition at line 1026 of file mqttsink.c.
|
static |
Setter for the 'max-buffer-size' property.
Definition at line 1118 of file mqttsink.c.
|
static |
Setter for the 'ntp-srvs' property.
Definition at line 1194 of file mqttsink.c.
|
static |
Setter for the 'ntp-sync' property.
Definition at line 1176 of file mqttsink.c.
|
static |
Setter for the 'mqtt-qos' property.
Definition at line 1158 of file mqttsink.c.
|
static |
Setter for the 'num-buffers' property.
Definition at line 1140 of file mqttsink.c.
|
static |
Setter for the 'cleansession' property.
Definition at line 1064 of file mqttsink.c.
|
static |
Setter for the 'keep-alive-interval' property.
Definition at line 1100 of file mqttsink.c.
|
static |
The setter for the mqttsink's properties.
Function prototype declarations
Definition at line 344 of file mqttsink.c.
|
static |
Setter for the 'pub-topic' property.
Definition at line 1045 of file mqttsink.c.
|
static |
Setter for the 'pub-wait-timeout' property.
Definition at line 1082 of file mqttsink.c.
|
static |
Start mqttsink, called when state changed null to ready.
Definition at line 554 of file mqttsink.c.
|
static |
Stop mqttsink, called when state changed ready to null.
Definition at line 623 of file mqttsink.c.
|
static |
Definition at line 85 of file mqttsink.c.
|
static |
Definition at line 86 of file mqttsink.c.
|
static |
Definition at line 82 of file mqttsink.c.
|
static |
Definition at line 83 of file mqttsink.c.
|
static |
Definition at line 89 of file mqttsink.c.
|
static |
Definition at line 87 of file mqttsink.c.
|
static |
Definition at line 88 of file mqttsink.c.
|
static |
Definition at line 81 of file mqttsink.c.
|
static |
Definition at line 35 of file mqttsink.c.
|
static |
Definition at line 84 of file mqttsink.c.