[SYNC_NOSYNC] = "nosync",
[SYNC_SLOWEST] = "slowest",
[SYNC_BASEPAD] = "basepad",
+ [SYNC_REFRESH] = "refresh",
[SYNC_END] = NULL
};
total = g_slist_length (collect->data);
- /** @todo update below with each sync mode */
- if (empty > 0 || empty == total)
- is_eos = TRUE;
+ switch (sync->mode) {
+ case SYNC_REFRESH:
+ if (empty == total)
+ is_eos = TRUE;
+ break;
+ default:
+ if (empty > 0)
+ is_eos = TRUE;
+ break;
+ }
return is_eos;
}
case SYNC_NOSYNC:
/* fall-through */
case SYNC_SLOWEST:
+ case SYNC_REFRESH:
if (*current_time < GST_BUFFER_PTS (buf))
*current_time = GST_BUFFER_PTS (buf);
break;
while (walk) {
gboolean configured = FALSE;
+ gboolean is_empty = FALSE;
data = (GstCollectData *) walk->data;
pad = (GstTensorCollectPadData *) data;
if (FALSE == _gst_tensor_time_sync_buffer_update (&buf, collect, data,
current_time, base_time, sync))
return FALSE;
+ is_empty = (buf == NULL);
break;
case SYNC_NOSYNC:
buf = gst_collect_pads_pop (collect, data);
+ is_empty = (buf == NULL);
+ break;
+ case SYNC_REFRESH:
+ buf = gst_collect_pads_pop (collect, data);
+ if (buf != NULL) {
+ if (pad->buffer != NULL) {
+ gst_buffer_unref (pad->buffer);
+ }
+ pad->buffer = gst_buffer_ref (buf);
+ } else {
+ if (pad->buffer == NULL) {
+ *is_eos = FALSE;
+ ml_logd ("Not the all buffers are arrived yet.");
+ return FALSE;
+ }
+ is_empty = TRUE;
+ buf = gst_buffer_ref (pad->buffer);
+ }
break;
default:
break;
}
gst_buffer_unref (buf);
- } else {
- empty_pad++;
}
+ if (is_empty)
+ empty_pad++;
}
configs->info.num_tensors = counting;
static gboolean gst_tensor_mux_sink_event (GstCollectPads * pads,
GstCollectData * data, GstEvent * event, GstTensorMux * tensor_mux);
static GstFlowReturn gst_tensor_mux_collected (GstCollectPads * pads,
- GstTensorMux * tesnor_mux);
+ GstTensorMux * tensor_mux);
+static GstFlowReturn gst_tensor_mux_do_clip (GstCollectPads * pads,
+ GstCollectData * data, GstBuffer * buffer, GstBuffer ** out,
+ GstTensorMux * tensor_mux);
static void gst_tensor_mux_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
gst_collect_pads_set_function (tensor_mux->collect,
(GstCollectPadsFunction) GST_DEBUG_FUNCPTR (gst_tensor_mux_collected),
tensor_mux);
+ gst_collect_pads_set_clip_function (tensor_mux->collect,
+ (GstCollectPadsClipFunction) GST_DEBUG_FUNCPTR (gst_tensor_mux_do_clip),
+ tensor_mux);
tensor_mux->silent = TRUE;
tensor_mux->sync.mode = SYNC_SLOWEST;
if (newpad) {
GstTensorCollectPadData *tensormuxpad;
+ gboolean locked, waiting;
+
+ locked = waiting = TRUE;
+
+ if (tensor_mux->sync.mode == SYNC_REFRESH) {
+ locked = waiting = FALSE;
+ }
tensormuxpad = (GstTensorCollectPadData *)
gst_collect_pads_add_pad (tensor_mux->collect, newpad,
- sizeof (GstTensorCollectPadData), NULL, TRUE);
+ sizeof (GstTensorCollectPadData), NULL, locked);
+
+ /* NOTE: if locked is TRUE, waiting flag is not effective */
+ gst_collect_pads_set_waiting (tensor_mux->collect,
+ (GstCollectData *) tensormuxpad, waiting);
tensormuxpad->pad = newpad;
gst_pad_set_element_private (newpad, tensormuxpad);
}
/**
+ * @brief set pads waiting property
+ */
+static void
+gst_tensor_mux_set_waiting (GstTensorMux * tensor_mux, gboolean waiting)
+{
+ if (tensor_mux->sync.mode == SYNC_REFRESH) {
+ GstCollectPads *pads = tensor_mux->collect;
+ GSList *walk = pads->data;
+
+ while (walk) {
+ gst_collect_pads_set_waiting (pads, walk->data, waiting);
+ walk = g_slist_next (walk);
+ }
+ }
+}
+
+/**
* @brief sink event vmethod
*/
static gboolean
case GST_EVENT_FLUSH_STOP:
tensor_mux->need_segment = TRUE;
break;
+ case GST_EVENT_EOS:
+ gst_tensor_mux_set_waiting (tensor_mux, FALSE);
+ break;
default:
break;
}
GstFlowReturn ret = GST_FLOW_OK;
GstBuffer *tensors_buf;
gboolean isEOS = FALSE;
+ gboolean buf_collected = FALSE;
GST_DEBUG_OBJECT (tensor_mux, " all pads are collected ");
return GST_FLOW_ERROR;
}
- if (!gst_tensor_mux_collect_buffer (tensor_mux, tensors_buf, &isEOS)) {
+ buf_collected =
+ gst_tensor_mux_collect_buffer (tensor_mux, tensors_buf, &isEOS);
+
+ gst_tensor_mux_set_waiting (tensor_mux, TRUE);
+
+ if (!buf_collected) {
if (isEOS) {
gst_pad_push_event (tensor_mux->srcpad, gst_event_new_eos ());
ret = GST_FLOW_EOS;
}
/**
+ * @brief Gst Clip Pads Function which is called right after a buffer is received for each pad.
+ */
+static GstFlowReturn
+gst_tensor_mux_do_clip (GstCollectPads * pads, GstCollectData * data,
+ GstBuffer * buffer, GstBuffer ** out, GstTensorMux * tensor_mux)
+{
+ gst_tensor_mux_set_waiting (tensor_mux, FALSE);
+ *out = buffer;
+ return GST_FLOW_OK;
+}
+
+/**
* @brief Ready --> Pasuse State Change
*/
static void