mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
aggregator: Add function to allow subclasses to set their own latency
For audiomixer this is one blocksize, for videoaggregator this should be the duration of one output frame.
This commit is contained in:
parent
27bcbf0a80
commit
06a4e80be9
4 changed files with 46 additions and 2 deletions
|
@ -243,6 +243,9 @@ struct _GstAggregatorPrivate
|
||||||
GstClockTime latency_min;
|
GstClockTime latency_min;
|
||||||
GstClockTime latency_max;
|
GstClockTime latency_max;
|
||||||
|
|
||||||
|
GstClockTime sub_latency_min;
|
||||||
|
GstClockTime sub_latency_max;
|
||||||
|
|
||||||
/* aggregate */
|
/* aggregate */
|
||||||
GstClockID aggregate_id;
|
GstClockID aggregate_id;
|
||||||
gint n_kicks;
|
gint n_kicks;
|
||||||
|
@ -1040,6 +1043,11 @@ gst_aggregator_get_latency (GstAggregator * self, gboolean * live,
|
||||||
min = self->priv->latency_min;
|
min = self->priv->latency_min;
|
||||||
max = self->priv->latency_max;
|
max = self->priv->latency_max;
|
||||||
|
|
||||||
|
min += self->priv->sub_latency_min;
|
||||||
|
if (GST_CLOCK_TIME_IS_VALID (max)
|
||||||
|
&& GST_CLOCK_TIME_IS_VALID (self->priv->sub_latency_max))
|
||||||
|
max += self->priv->sub_latency_max;
|
||||||
|
|
||||||
if (GST_CLOCK_TIME_IS_VALID (self->latency)) {
|
if (GST_CLOCK_TIME_IS_VALID (self->latency)) {
|
||||||
min += self->latency;
|
min += self->latency;
|
||||||
if (GST_CLOCK_TIME_IS_VALID (max))
|
if (GST_CLOCK_TIME_IS_VALID (max))
|
||||||
|
@ -1553,8 +1561,8 @@ gst_aggregator_init (GstAggregator * self, GstAggregatorClass * klass)
|
||||||
priv->tags_changed = FALSE;
|
priv->tags_changed = FALSE;
|
||||||
|
|
||||||
self->priv->latency_live = FALSE;
|
self->priv->latency_live = FALSE;
|
||||||
self->priv->latency_min = 0;
|
self->priv->latency_min = self->priv->sub_latency_min = 0;
|
||||||
self->priv->latency_max = GST_CLOCK_TIME_NONE;
|
self->priv->latency_max = self->priv->sub_latency_max = GST_CLOCK_TIME_NONE;
|
||||||
_reset_flow_values (self);
|
_reset_flow_values (self);
|
||||||
|
|
||||||
self->srcpad = gst_pad_new_from_template (pad_template, "src");
|
self->srcpad = gst_pad_new_from_template (pad_template, "src");
|
||||||
|
@ -1923,3 +1931,29 @@ gst_aggregator_merge_tags (GstAggregator * self,
|
||||||
self->priv->tags_changed = TRUE;
|
self->priv->tags_changed = TRUE;
|
||||||
GST_OBJECT_UNLOCK (self);
|
GST_OBJECT_UNLOCK (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_aggregator_set_latency:
|
||||||
|
* @self: a #GstAggregator
|
||||||
|
* @min_latency: minimum latency
|
||||||
|
* @max_latency: maximum latency
|
||||||
|
*
|
||||||
|
* Lets #GstAggregator sub-classes tell the baseclass what their internal
|
||||||
|
* latency is. Will also post a LATENCY message on the bus so the pipeline
|
||||||
|
* can reconfigure its global latency.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gst_aggregator_set_latency (GstAggregator * self,
|
||||||
|
GstClockTime min_latency, GstClockTime max_latency)
|
||||||
|
{
|
||||||
|
g_return_if_fail (GST_IS_AGGREGATOR (self));
|
||||||
|
g_return_if_fail (max_latency >= min_latency);
|
||||||
|
|
||||||
|
GST_OBJECT_LOCK (self);
|
||||||
|
self->priv->sub_latency_min = min_latency;
|
||||||
|
self->priv->sub_latency_max = max_latency;
|
||||||
|
GST_OBJECT_UNLOCK (self);
|
||||||
|
|
||||||
|
gst_element_post_message (GST_ELEMENT_CAST (self),
|
||||||
|
gst_message_new_latency (GST_OBJECT_CAST (self)));
|
||||||
|
}
|
||||||
|
|
|
@ -259,6 +259,10 @@ GstFlowReturn gst_aggregator_finish_buffer (GstAggregator
|
||||||
void gst_aggregator_set_src_caps (GstAggregator * agg,
|
void gst_aggregator_set_src_caps (GstAggregator * agg,
|
||||||
GstCaps * caps);
|
GstCaps * caps);
|
||||||
|
|
||||||
|
void gst_aggregator_set_latency (GstAggregator * self,
|
||||||
|
GstClockTime min_latency,
|
||||||
|
GstClockTime max_latency);
|
||||||
|
|
||||||
GType gst_aggregator_get_type(void);
|
GType gst_aggregator_get_type(void);
|
||||||
|
|
||||||
/* API that should eventually land in GstElement itself*/
|
/* API that should eventually land in GstElement itself*/
|
||||||
|
|
|
@ -597,6 +597,9 @@ gst_videoaggregator_src_setcaps (GstVideoAggregator * vagg, GstCaps * caps)
|
||||||
GST_VIDEO_AGGREGATOR_UNLOCK (vagg);
|
GST_VIDEO_AGGREGATOR_UNLOCK (vagg);
|
||||||
|
|
||||||
gst_aggregator_set_src_caps (agg, caps);
|
gst_aggregator_set_src_caps (agg, caps);
|
||||||
|
gst_aggregator_set_latency (agg, gst_util_uint64_scale (GST_SECOND,
|
||||||
|
GST_VIDEO_INFO_FPS_D (&info), GST_VIDEO_INFO_FPS_N (&info)),
|
||||||
|
GST_CLOCK_TIME_NONE);
|
||||||
|
|
||||||
GST_VIDEO_AGGREGATOR_LOCK (vagg);
|
GST_VIDEO_AGGREGATOR_LOCK (vagg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1378,6 +1378,9 @@ gst_audiomixer_aggregate (GstAggregator * agg, gboolean timeout)
|
||||||
|
|
||||||
if (audiomixer->send_caps) {
|
if (audiomixer->send_caps) {
|
||||||
gst_aggregator_set_src_caps (agg, audiomixer->current_caps);
|
gst_aggregator_set_src_caps (agg, audiomixer->current_caps);
|
||||||
|
gst_aggregator_set_latency (agg,
|
||||||
|
gst_util_uint64_scale (audiomixer->blocksize, GST_SECOND,
|
||||||
|
GST_AUDIO_INFO_RATE (&audiomixer->info)), GST_CLOCK_TIME_NONE);
|
||||||
|
|
||||||
if (agg->segment.rate > 0.0)
|
if (agg->segment.rate > 0.0)
|
||||||
agg->segment.position = agg->segment.start;
|
agg->segment.position = agg->segment.start;
|
||||||
|
|
Loading…
Reference in a new issue