21 #define GST_CAT_DEFAULT gst_tensor_query_serversink_debug
23 #define DEFAULT_METALESS_FRAME_LIMIT 1
28 static GstStaticPadTemplate
sinktemplate = GST_STATIC_PAD_TEMPLATE (
"sink",
42 #define gst_tensor_query_serversink_parent_class parent_class
46 * element, GstStateChange transition);
48 guint prop_id,
const GValue * value, GParamSpec * pspec);
50 guint prop_id, GValue * value, GParamSpec * pspec);
64 GObjectClass *gobject_class;
65 GstElementClass *gstelement_class;
66 GstBaseSinkClass *gstbasesink_class;
68 gstbasesink_class = (GstBaseSinkClass *) klass;
69 gstelement_class = (GstElementClass *) gstbasesink_class;
70 gobject_class = (GObjectClass *) gstelement_class;
78 g_param_spec_enum (
"connect-type",
"Connect Type",
79 "The connection type",
81 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
82 g_object_class_install_property (gobject_class,
PROP_TIMEOUT,
83 g_param_spec_uint (
"timeout",
"Timeout",
84 "The timeout as seconds to maintain connection", 0,
86 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
87 g_object_class_install_property (gobject_class,
PROP_ID,
88 g_param_spec_uint (
"id",
"ID",
89 "ID for distinguishing query servers.", 0,
91 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
93 g_param_spec_int (
"limit",
"Limit",
94 "Limits of the number of the buffers that the server cannot handle. "
95 "e.g., If the received buffer does not have a GstMetaQuery, the server cannot handle the buffer.",
97 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
99 gst_element_class_add_pad_template (gstelement_class,
102 gst_element_class_set_static_metadata (gstelement_class,
103 "TensorQueryServerSink",
"Sink/Tensor/Query",
104 "Send tensor data as a server over the network",
105 "Samsung Electronics Co., Ltd.");
110 GST_DEBUG_CATEGORY_INIT (gst_tensor_query_serversink_debug,
111 "tensor_query_serversink", 0,
"Tensor Query Server Sink");
134 G_OBJECT_CLASS (parent_class)->finalize (
object);
169 static GstStateChangeReturn
171 GstStateChange transition)
174 GstBaseSink *bsink = GST_BASE_SINK (element);
175 GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
178 switch (transition) {
179 case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
181 nns_loge (
"Failed to change state from PAUSED to PLAYING.");
182 return GST_STATE_CHANGE_FAILURE;
185 caps = gst_pad_peer_query_caps (GST_BASE_SINK_PAD (bsink), NULL);
187 gst_caps_unref (caps);
189 case GST_STATE_CHANGE_READY_TO_PAUSED:
191 nns_loge (
"Failed to change state from READY to PAUSED.");
192 return GST_STATE_CHANGE_FAILURE;
199 ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
200 if (ret == GST_STATE_CHANGE_FAILURE) {
201 nns_loge (
"Failed to change state");
205 switch (transition) {
206 case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
221 const GValue * value, GParamSpec * pspec)
230 serversink->
timeout = g_value_get_uint (value);
233 serversink->
sink_id = g_value_get_uint (value);
239 G_OBJECT_WARN_INVALID_PROPERTY_ID (
object, prop_id, pspec);
249 GValue * value, GParamSpec * pspec)
258 g_value_set_uint (value, serversink->
timeout);
261 g_value_set_uint (value, serversink->
sink_id);
267 G_OBJECT_WARN_INVALID_PROPERTY_ID (
object, prop_id, pspec);
279 gchar *caps_str, *new_caps_str;
281 caps_str = gst_caps_to_string (caps);
283 new_caps_str = g_strdup_printf (
"@query_server_sink_caps@%s", caps_str);
306 nns_loge (
"Failed to send buffer to edge device in server sink.");
307 return GST_FLOW_ERROR;
310 nns_logw (
"Cannot get tensor query meta. Drop buffers!\n");
314 nns_logw (
"Cannot get tensor query meta. Stop the query server!\n"
315 "There are elements that are not available on the query server.\n"
316 "Please check available elements on the server."
317 "See: https://github.com/nnstreamer/nnstreamer/wiki/Available-elements-on-query-server");
318 return GST_FLOW_ERROR;