gint old_numerator = G_MAXINT;
gint old_denominator = G_MAXINT;
gint counting = 0;
- GstTensorConfig config;
+ GstTensorsConfig in_configs;
GstClockTime base = 0;
+ guint i = 0;
walk = collect->data;
GstCaps *caps = gst_pad_get_current_caps (pad->pad);
GstStructure *s = gst_caps_get_structure (caps, 0);
- gst_tensor_config_from_structure (&config, s);
- g_assert (gst_tensor_config_validate (&config));
+ gst_tensors_config_from_structure (&in_configs, s);
+ g_assert (gst_tensors_config_validate (&in_configs));
- if (config.rate_d < old_denominator)
- old_denominator = config.rate_d;
- if (config.rate_n < old_numerator)
- old_numerator = config.rate_n;
+ if (in_configs.rate_d < old_denominator)
+ old_denominator = in_configs.rate_d;
+ if (in_configs.rate_n < old_numerator)
+ old_numerator = in_configs.rate_n;
gst_caps_unref (caps);
}
if (GST_IS_BUFFER (buf)) {
- mem = gst_buffer_get_memory (buf, 0);
- gst_buffer_append_memory (tensors_buf, mem);
+ guint n_mem = gst_buffer_n_memory (buf);
+
+ g_assert (n_mem == in_configs.info.num_tensors);
+ g_assert ((counting + n_mem) < NNS_TENSOR_SIZE_LIMIT);
+
+ for (i = 0; i < n_mem; ++i) {
+ mem = gst_buffer_get_memory (buf, i);
+ gst_buffer_append_memory (tensors_buf, mem);
+ configs->info.info[counting] = in_configs.info.info[i];
+ counting++;
+ }
if (sync.mode == SYNC_NOSYNC) {
gst_buffer_unref (buf);
}
isEOS = TRUE;
return isEOS;
}
-
- configs->info.info[counting] = config.info;
- counting++;
}
configs->rate_d = old_denominator;
};
/**
+ * @brief Default caps string for sink pad.
+ */
+#define CAPS_STRING_SINK GST_TENSOR_CAP_DEFAULT "; " GST_TENSORS_CAP_DEFAULT
+
+/**
* @brief the capabilities of the inputs and outputs.
* describe the real formats here.
*/
static GstStaticPadTemplate sink_templ = GST_STATIC_PAD_TEMPLATE ("sink_%u",
GST_PAD_SINK,
GST_PAD_REQUEST,
- GST_STATIC_CAPS (GST_TENSOR_CAP_DEFAULT)
+ GST_STATIC_CAPS (CAPS_STRING_SINK)
);
static gboolean gst_tensor_mux_handle_src_event (GstPad * pad,
const gchar * req_name, const GstCaps * caps)
{
GstPad *newpad;
+ GSList *walk = NULL;
GstTensorMux *tensor_mux;
gchar *name;
g_return_val_if_fail (GST_IS_TENSOR_MUX (element), NULL);
tensor_mux = GST_TENSOR_MUX (element);
+ walk = tensor_mux->collect->data;
- if (tensor_mux->tensors_config.info.num_tensors >= NNS_TENSOR_SIZE_LIMIT) {
- GST_ERROR_OBJECT (tensor_mux,
- "supposed max size is " NNS_TENSOR_SIZE_LIMIT_STR);
- g_assert (0);
- return NULL;
- }
-
- name =
- g_strdup_printf ("sink_%u", tensor_mux->tensors_config.info.num_tensors);
+ name = g_strdup_printf ("sink_%u", g_slist_length (walk));
newpad = gst_pad_new_from_template (templ, name);
g_free (name);
sizeof (GstTensorCollectPadData), NULL, TRUE);
tensormuxpad->pad = newpad;
gst_pad_set_element_private (newpad, tensormuxpad);
- tensor_mux->tensors_config.info.num_tensors++;
gst_element_add_pad (element, newpad);
} else {
GST_WARNING_OBJECT (tensor_mux, "failed to create request pad");
if (!tensor_mux->negotiated) {
GstCaps *newcaps;
+ if (GST_IS_BUFFER (tensors_buf)) {
+ tensor_mux->tensors_config.info.num_tensors =
+ gst_buffer_n_memory (tensors_buf);
+ }
+
g_assert (gst_tensors_config_validate (&tensor_mux->tensors_config));
newcaps = gst_tensors_caps_from_config (&tensor_mux->tensors_config);