Protocols are enum. Use enum-param, not int or string.
With this, users can use both numbers and enum-strings.
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
#define TCP_DEFAULT_SINK_PORT 3000
#define TCP_DEFAULT_SRC_PORT 3001
#define DEFAULT_SILENT TRUE
-#define DEFAULT_PROTOCOL "tcp"
GST_DEBUG_CATEGORY_STATIC (gst_tensor_query_client_debug);
#define GST_CAT_DEFAULT gst_tensor_query_client_debug
g_param_spec_boolean ("silent", "Silent", "Produce verbose output",
DEFAULT_SILENT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_PROTOCOL,
- g_param_spec_string ("protocol", "Protocol",
- "A protocol option for tensor query.",
- DEFAULT_PROTOCOL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_param_spec_enum ("protocol", "Protocol",
+ "The network protocol to establish connections between client and server.",
+ GST_TYPE_QUERY_PROTOCOL, DEFAULT_PROTOCOL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_OPERATION,
g_param_spec_string ("operation", "Operation",
"The main operation of the host.",
/* init properties */
self->silent = DEFAULT_SILENT;
- self->protocol = _TENSOR_QUERY_PROTOCOL_TCP;
+ self->protocol = DEFAULT_PROTOCOL;
self->sink_conn = NULL;
self->sink_host = g_strdup (TCP_DEFAULT_HOST);
self->sink_port = TCP_DEFAULT_SINK_PORT;
self->src_port = g_value_get_uint (value);
break;
case PROP_PROTOCOL:
- if (g_ascii_strcasecmp (g_value_get_string (value), "tcp") == 0)
- self->protocol = _TENSOR_QUERY_PROTOCOL_TCP;
+ {
+ /** @todo expand when other protocols are ready */
+ TensorQueryProtocol protocol = g_value_get_enum (value);
+ if (protocol == _TENSOR_QUERY_PROTOCOL_TCP)
+ self->protocol = protocol;
+ }
break;
case PROP_OPERATION:
if (!g_value_get_string (value)) {
g_value_set_uint (value, self->src_port);
break;
case PROP_PROTOCOL:
- switch (self->protocol) {
- case _TENSOR_QUERY_PROTOCOL_TCP:
- g_value_set_string (value, "tcp");
- break;
- default:
- break;
- }
+ g_value_set_enum (value, self->protocol);
break;
case PROP_OPERATION:
g_value_set_string (value, self->operation);
return buffer;
}
+
+/**
+ * @brief register GEnumValue array for query protocol property handling
+ */
+GType
+gst_tensor_query_protocol_get_type (void)
+{
+ static GType protocol = 0;
+ if (protocol == 0) {
+ static GEnumValue protocols[] = {
+ {_TENSOR_QUERY_PROTOCOL_TCP, "TCP",
+ "Raw TCP protocol. Directly sending stream frames via TCP connections."},
+ {_TENSOR_QUERY_PROTOCOL_UDP, "UDP",
+ "Raw UDP protocol. Directly sending stream frames via UDP connections."},
+ {_TENSOR_QUERY_PROTOCOL_MQTT, "MQTT", "Connect with MQTT brokers."},
+ {0, NULL, NULL},
+ };
+ protocol = g_enum_register_static ("tensor_query_protocol", protocols);
+ }
+
+ return protocol;
+}
_TENSOR_QUERY_PROTOCOL_END
} TensorQueryProtocol;
+#define DEFAULT_HOST "localhost"
+#define DEFAULT_PROTOCOL (_TENSOR_QUERY_PROTOCOL_TCP)
+#define GST_TYPE_QUERY_PROTOCOL (gst_tensor_query_protocol_get_type ())
+/**
+ * @brief register GEnumValue array for query protocol property handling
+ */
+GType
+gst_tensor_query_protocol_get_type (void);
+
/**
* @brief Structures for tensor query commands.
*/
GST_DEBUG_CATEGORY_STATIC (gst_tensor_query_serversink_debug);
#define GST_CAT_DEFAULT gst_tensor_query_serversink_debug
-#define DEFAULT_HOST "localhost"
#define DEFAULT_PORT_SINK 3000
-#define DEFAULT_PROTOCOL _TENSOR_QUERY_PROTOCOL_TCP
#define DEFAULT_METALESS_FRAME_LIMIT 1
/**
65535, DEFAULT_PORT_SINK,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_PROTOCOL,
- g_param_spec_int ("protocol", "Protocol",
- "The network protocol to establish connection", 0,
- _TENSOR_QUERY_PROTOCOL_END, DEFAULT_PROTOCOL,
+ g_param_spec_enum ("protocol", "Protocol",
+ "The network protocol to establish connection",
+ GST_TYPE_QUERY_PROTOCOL, DEFAULT_PROTOCOL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_TIMEOUT,
g_param_spec_uint ("timeout", "Timeout",
serversink->port = g_value_get_uint (value);
break;
case PROP_PROTOCOL:
- serversink->protocol = g_value_get_int (value);
+ serversink->protocol = g_value_get_enum (value);
break;
case PROP_TIMEOUT:
serversink->timeout = g_value_get_uint (value);
g_value_set_uint (value, serversink->port);
break;
case PROP_PROTOCOL:
- g_value_set_int (value, serversink->protocol);
+ g_value_set_enum (value, serversink->protocol);
break;
case PROP_TIMEOUT:
g_value_set_uint (value, serversink->timeout);
GST_DEBUG_CATEGORY_STATIC (gst_tensor_query_serversrc_debug);
#define GST_CAT_DEFAULT gst_tensor_query_serversrc_debug
-#define DEFAULT_HOST "localhost"
#define DEFAULT_PORT_SRC 3001
-#define DEFAULT_PROTOCOL _TENSOR_QUERY_PROTOCOL_TCP
#define DEFAULT_IS_LIVE TRUE
/**
* @brief the capabilities of the outputs
"The port to listen to (0=random available port)", 0,
65535, DEFAULT_PORT_SRC, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_PROTOCOL,
- g_param_spec_int ("protocol", "Protocol",
- "The network protocol to establish connection", 0,
- _TENSOR_QUERY_PROTOCOL_END, DEFAULT_PROTOCOL,
+ g_param_spec_enum ("protocol", "Protocol",
+ "The network protocol to establish connections between client and server.",
+ GST_TYPE_QUERY_PROTOCOL, DEFAULT_PROTOCOL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_TIMEOUT,
g_param_spec_uint ("timeout", "Timeout",
serversrc->port = g_value_get_uint (value);
break;
case PROP_PROTOCOL:
- serversrc->protocol = g_value_get_int (value);
+ serversrc->protocol = g_value_get_enum (value);
break;
case PROP_TIMEOUT:
serversrc->timeout = g_value_get_uint (value);
g_value_set_uint (value, serversrc->port);
break;
case PROP_PROTOCOL:
- g_value_set_int (value, serversrc->protocol);
+ g_value_set_enum (value, serversrc->protocol);
break;
case PROP_TIMEOUT:
g_value_set_uint (value, serversrc->timeout);