From dd144953322f025240e890299b99f10186c5e79c Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Wed, 6 May 2015 14:19:36 -0300 Subject: [PATCH] videoaggregator: refactor caps reconfigure to its own function Makes the aggregation code shorter and easier to read --- gst-libs/gst/video/gstvideoaggregator.c | 42 +++++++++++++++++-------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/gst-libs/gst/video/gstvideoaggregator.c b/gst-libs/gst/video/gstvideoaggregator.c index b86ee21874..25995062e2 100644 --- a/gst-libs/gst/video/gstvideoaggregator.c +++ b/gst-libs/gst/video/gstvideoaggregator.c @@ -1281,18 +1281,13 @@ gst_videoaggregator_get_next_time (GstAggregator * agg) } static GstFlowReturn -gst_videoaggregator_aggregate (GstAggregator * agg, gboolean timeout) +gst_videoaggregator_check_reconfigure (GstVideoAggregator * vagg, + gboolean timeout) { - GstVideoAggregator *vagg = GST_VIDEO_AGGREGATOR (agg); - GstClockTime output_start_time, output_end_time; - GstBuffer *outbuf = NULL; - GstFlowReturn flow_ret; - gint64 jitter; - - GST_VIDEO_AGGREGATOR_LOCK (vagg); + GstAggregator *agg = (GstAggregator *) vagg; if (GST_VIDEO_INFO_FORMAT (&vagg->info) == GST_VIDEO_FORMAT_UNKNOWN - || gst_pad_check_reconfigure (agg->srcpad)) { + || gst_pad_check_reconfigure (GST_AGGREGATOR_SRC_PAD (vagg))) { gboolean ret; ret = gst_videoaggregator_update_converters (vagg); @@ -1300,7 +1295,7 @@ gst_videoaggregator_aggregate (GstAggregator * agg, gboolean timeout) ret = gst_videoaggregator_update_src_caps (vagg); if (!ret) { - if (timeout && gst_pad_needs_reconfigure (agg->srcpad)) { + if (timeout && gst_pad_needs_reconfigure (GST_AGGREGATOR_SRC_PAD (vagg))) { guint64 frame_duration; gint fps_d, fps_n; @@ -1328,15 +1323,36 @@ gst_videoaggregator_aggregate (GstAggregator * agg, gboolean timeout) else agg->segment.position = 0; vagg->priv->nframes++; - GST_VIDEO_AGGREGATOR_UNLOCK (vagg); - return GST_FLOW_OK; + return GST_FLOW_NEEDS_DATA; } else { - GST_VIDEO_AGGREGATOR_UNLOCK (vagg); return GST_FLOW_NOT_NEGOTIATED; } } } + return GST_FLOW_OK; +} + +static GstFlowReturn +gst_videoaggregator_aggregate (GstAggregator * agg, gboolean timeout) +{ + GstVideoAggregator *vagg = GST_VIDEO_AGGREGATOR (agg); + GstClockTime output_start_time, output_end_time; + GstBuffer *outbuf = NULL; + GstFlowReturn flow_ret; + gint64 jitter; + + GST_VIDEO_AGGREGATOR_LOCK (vagg); + + flow_ret = gst_videoaggregator_check_reconfigure (vagg, timeout); + if (flow_ret == GST_FLOW_NEEDS_DATA) { + GST_VIDEO_AGGREGATOR_UNLOCK (vagg); + return GST_FLOW_OK; + } else if (flow_ret != GST_FLOW_OK) { + GST_VIDEO_AGGREGATOR_UNLOCK (vagg); + return flow_ret; + } + output_start_time = gst_videoaggregator_get_next_time (agg); if (GST_VIDEO_INFO_FPS_N (&vagg->info) == 0)