GST_STATIC_CAPS (GST_TENSOR_CAP_DEFAULT)
);
-static void gst_tensor_merge_finalize (GObject * object);
-
static gboolean gst_tensor_merge_handle_src_event (GstPad * pad,
GstObject * parent, GstEvent * event);
static GstPad *gst_tensor_merge_request_new_pad (GstElement * element,
const GValue * value, GParamSpec * pspec);
static void gst_tensor_merge_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
+static void gst_tensor_merge_finalize (GObject * object);
#define gst_tensor_merge_parent_class parent_class
G_DEFINE_TYPE (GstTensorMerge, gst_tensor_merge, GST_TYPE_ELEMENT);
GstTensorMerge *tensor_merge;
tensor_merge = GST_TENSOR_MERGE (object);
- if (tensor_merge->collect)
+ if (tensor_merge->collect) {
gst_object_unref (tensor_merge->collect);
+ tensor_merge->collect = NULL;
+ }
+
+ if (tensor_merge->option) {
+ g_free (tensor_merge->option);
+ tensor_merge->option = NULL;
+ }
+
G_OBJECT_CLASS (parent_class)->finalize (object);
}
/**
* @brief Compare dts & pts time and find earliest
* @param tensor_merge tensor merger
- * @param old previous merge pad data
- * @param new current merge pad data
+ * @param old_data previous merge pad data
+ * @param new_data current merge pad data
* @return if > 0, new is earlier than old
*/
static gint
gst_tensor_merge_compare_pads (GstTensorMerge * tensor_merge,
- GstTensorMergePadData * old, GstTensorMergePadData * new)
+ GstTensorMergePadData * old_data, GstTensorMergePadData * new_data)
{
guint64 oldtime, newtime;
- if (old == NULL || old->buffer == NULL)
+ if (old_data == NULL)
return 1;
- if (new == NULL || new->buffer == NULL)
+ if (new_data == NULL)
return -1;
- if (GST_CLOCK_TIME_IS_VALID (old->dts_timestamp) &&
- GST_CLOCK_TIME_IS_VALID (new->dts_timestamp)) {
- oldtime = old->dts_timestamp;
- newtime = new->dts_timestamp;
+ if (GST_CLOCK_TIME_IS_VALID (old_data->dts_timestamp) &&
+ GST_CLOCK_TIME_IS_VALID (new_data->dts_timestamp)) {
+ oldtime = old_data->dts_timestamp;
+ newtime = new_data->dts_timestamp;
} else {
- oldtime = old->pts_timestamp;
- newtime = new->pts_timestamp;
+ oldtime = old_data->pts_timestamp;
+ newtime = new_data->pts_timestamp;
}
if (!GST_CLOCK_TIME_IS_VALID (oldtime))
gst_caps_unref (caps);
walk = g_slist_next (walk);
+
GstBuffer *buf = NULL;
buf = gst_collect_pads_pop (tensor_merge->collect, data);
- if (buf && GST_BUFFER_PTS_IS_VALID (buf)) {
- pad->pts_timestamp =
- gst_segment_to_running_time (&data->segment, GST_FORMAT_TIME,
- GST_BUFFER_PTS (buf));
- } else {
- pad->pts_timestamp = GST_CLOCK_TIME_NONE;
- }
- if (buf && GST_BUFFER_DTS_IS_VALID (buf)) {
- pad->dts_timestamp =
- gst_segment_to_running_time (&data->segment, GST_FORMAT_TIME,
- GST_BUFFER_DTS (buf));
- } else {
- pad->dts_timestamp = GST_CLOCK_TIME_NONE;
- }
- pad->buffer = buf;
if (GST_IS_BUFFER (buf)) {
+ if (GST_BUFFER_PTS_IS_VALID (buf)) {
+ pad->pts_timestamp =
+ gst_segment_to_running_time (&data->segment, GST_FORMAT_TIME,
+ GST_BUFFER_PTS (buf));
+ } else {
+ pad->pts_timestamp = GST_CLOCK_TIME_NONE;
+ }
+ if (GST_BUFFER_DTS_IS_VALID (buf)) {
+ pad->dts_timestamp =
+ gst_segment_to_running_time (&data->segment, GST_FORMAT_TIME,
+ GST_BUFFER_DTS (buf));
+ } else {
+ pad->dts_timestamp = GST_CLOCK_TIME_NONE;
+ }
+
mem = gst_buffer_get_memory (buf, 0);
gst_buffer_append_memory (tensors_buf, mem);
- if (pad->buffer != NULL) {
- if (gst_tensor_merge_compare_pads (tensor_merge, bestpad, pad) > 0) {
- bestpad = pad;
- *pts_time = bestpad->pts_timestamp;
- *dts_time = bestpad->dts_timestamp;
- }
+ if (gst_tensor_merge_compare_pads (tensor_merge, bestpad, pad) > 0) {
+ bestpad = pad;
+ *pts_time = bestpad->pts_timestamp;
+ *dts_time = bestpad->dts_timestamp;
}
gst_buffer_unref (buf);
tensors_buf = gst_buffer_new ();
g_assert (tensors_buf != NULL);
- tensor_buf = gst_buffer_new ();
- g_assert (tensor_buf != NULL);
-
isEOS =
gst_tensor_merge_collect_buffer (tensor_merge, tensors_buf, &pts_time,
&dts_time);
if (isEOS) {
- gst_buffer_unref (tensors_buf);
- gst_buffer_unref (tensor_buf);
-
gst_pad_push_event (tensor_merge->srcpad, gst_event_new_eos ());
ret = GST_FLOW_EOS;
goto beach;
if (gst_merge_tensors_config (tensor_merge, &tensor_merge->tensors_config,
&config)) {
-
g_assert (gst_tensor_config_validate (&config));
newcaps = gst_tensor_caps_from_config (&config);
} else {
tensor_merge->need_segment = FALSE;
}
-
/* TODO : Should handle Properly. This is just for the temperaly usage */
- mem = gst_buffer_get_memory_range (tensors_buf, 0, -1);
+ mem = gst_buffer_get_all_memory (tensors_buf);
+
+ tensor_buf = gst_buffer_new ();
+ g_assert (tensor_buf != NULL);
+
gst_buffer_append_memory (tensor_buf, mem);
gst_buffer_copy_into (tensor_buf, tensors_buf, GST_BUFFER_COPY_TIMESTAMPS, 0,
-1);
- gst_buffer_unref (tensors_buf);
-
ret = gst_pad_push (tensor_merge->srcpad, tensor_buf);
if (ret != GST_FLOW_OK) {
GST_WARNING_OBJECT (tensor_merge, "pushed outbuf, result = %s",
/* fall-through, returns result */
}
beach:
+ gst_buffer_unref (tensors_buf);
return ret;
nego_error:
{
+ gst_buffer_unref (tensors_buf);
GST_WARNING_OBJECT (tensor_merge, "failed to set caps");
GST_ELEMENT_ERROR (tensor_merge, CORE, NEGOTIATION, (NULL), (NULL));
return GST_FLOW_NOT_NEGOTIATED;
GST_STATIC_CAPS (GST_TENSOR_CAP_DEFAULT)
);
-static void gst_tensor_mux_finalize (GObject * object);
-
static gboolean gst_tensor_mux_handle_src_event (GstPad * pad,
GstObject * parent, GstEvent * event);
static GstPad *gst_tensor_mux_request_new_pad (GstElement * element,
const GValue * value, GParamSpec * pspec);
static void gst_tensor_mux_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
+static void gst_tensor_mux_finalize (GObject * object);
#define gst_tensor_mux_parent_class parent_class
G_DEFINE_TYPE (GstTensorMux, gst_tensor_mux, GST_TYPE_ELEMENT);
GstTensorMux *tensor_mux;
tensor_mux = GST_TENSOR_MUX (object);
- if (tensor_mux->collect)
+ if (tensor_mux->collect) {
gst_object_unref (tensor_mux->collect);
+ tensor_mux->collect = NULL;
+ }
+
G_OBJECT_CLASS (parent_class)->finalize (object);
}
/**
* @brief Compare dts & pts time and find earliest
* @param tensor_mux tensor muxer
- * @param old previous mux pad data
- * @param new current mux pad data
+ * @param old_data previous mux pad data
+ * @param new_data current mux pad data
* @return if > 0, new is earlier than old
*/
static gint
gst_tensor_mux_compare_pads (GstTensorMux * tensor_mux,
- GstTensorMuxPadData * old, GstTensorMuxPadData * new)
+ GstTensorMuxPadData * old_data, GstTensorMuxPadData * new_data)
{
guint64 oldtime, newtime;
- if (old == NULL || old->buffer == NULL)
+ if (old_data == NULL)
return 1;
- if (new == NULL || new->buffer == NULL)
+ if (new_data == NULL)
return -1;
- if (GST_CLOCK_TIME_IS_VALID (old->dts_timestamp) &&
- GST_CLOCK_TIME_IS_VALID (new->dts_timestamp)) {
- oldtime = old->dts_timestamp;
- newtime = new->dts_timestamp;
+ if (GST_CLOCK_TIME_IS_VALID (old_data->dts_timestamp) &&
+ GST_CLOCK_TIME_IS_VALID (new_data->dts_timestamp)) {
+ oldtime = old_data->dts_timestamp;
+ newtime = new_data->dts_timestamp;
} else {
- oldtime = old->pts_timestamp;
- newtime = new->pts_timestamp;
+ oldtime = old_data->pts_timestamp;
+ newtime = new_data->pts_timestamp;
}
if (!GST_CLOCK_TIME_IS_VALID (oldtime))
gst_caps_unref (caps);
walk = g_slist_next (walk);
+
GstBuffer *buf = NULL;
buf = gst_collect_pads_pop (tensor_mux->collect, data);
- if (buf && GST_BUFFER_PTS_IS_VALID (buf)) {
- pad->pts_timestamp =
- gst_segment_to_running_time (&data->segment, GST_FORMAT_TIME,
- GST_BUFFER_PTS (buf));
- } else {
- pad->pts_timestamp = GST_CLOCK_TIME_NONE;
- }
- if (buf && GST_BUFFER_DTS_IS_VALID (buf)) {
- pad->dts_timestamp =
- gst_segment_to_running_time (&data->segment, GST_FORMAT_TIME,
- GST_BUFFER_DTS (buf));
- } else {
- pad->dts_timestamp = GST_CLOCK_TIME_NONE;
- }
- pad->buffer = buf;
if (GST_IS_BUFFER (buf)) {
+ if (GST_BUFFER_PTS_IS_VALID (buf)) {
+ pad->pts_timestamp =
+ gst_segment_to_running_time (&data->segment, GST_FORMAT_TIME,
+ GST_BUFFER_PTS (buf));
+ } else {
+ pad->pts_timestamp = GST_CLOCK_TIME_NONE;
+ }
+ if (GST_BUFFER_DTS_IS_VALID (buf)) {
+ pad->dts_timestamp =
+ gst_segment_to_running_time (&data->segment, GST_FORMAT_TIME,
+ GST_BUFFER_DTS (buf));
+ } else {
+ pad->dts_timestamp = GST_CLOCK_TIME_NONE;
+ }
+
mem = gst_buffer_get_memory (buf, 0);
gst_buffer_append_memory (tensors_buf, mem);
- if (pad->buffer != NULL) {
- if (gst_tensor_mux_compare_pads (tensor_mux, bestpad, pad) > 0) {
- bestpad = pad;
- *pts_time = bestpad->pts_timestamp;
- *dts_time = bestpad->dts_timestamp;
- }
+ if (gst_tensor_mux_compare_pads (tensor_mux, bestpad, pad) > 0) {
+ bestpad = pad;
+ *pts_time = bestpad->pts_timestamp;
+ *dts_time = bestpad->dts_timestamp;
}
gst_buffer_unref (buf);
tensors_buf = gst_buffer_new ();
g_assert (tensors_buf);
+
isEOS =
gst_tensor_mux_collect_buffer (tensor_mux, tensors_buf, &pts_time,
&dts_time);
return ret;
nego_error:
{
+ gst_buffer_unref (tensors_buf);
GST_WARNING_OBJECT (tensor_mux, "failed to set caps");
GST_ELEMENT_ERROR (tensor_mux, CORE, NEGOTIATION, (NULL), (NULL));
return GST_FLOW_NOT_NEGOTIATED;