mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 03:35:21 +00:00
libs/gst/base/gstbasesink.c: Simplify latency query.
Original commit message from CVS: * libs/gst/base/gstbasesink.c: (gst_base_sink_query_latency), (gst_base_sink_event), (gst_base_sink_query), (gst_base_sink_change_state): Simplify latency query. When not synchronizing, we can report latency without querying the peer element.
This commit is contained in:
parent
e7f433f720
commit
af6e6cf1cc
2 changed files with 41 additions and 42 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2007-09-24 Wim Taymans <wim.taymans@gmail.com>
|
||||||
|
|
||||||
|
* libs/gst/base/gstbasesink.c: (gst_base_sink_query_latency),
|
||||||
|
(gst_base_sink_event), (gst_base_sink_query),
|
||||||
|
(gst_base_sink_change_state):
|
||||||
|
Simplify latency query.
|
||||||
|
When not synchronizing, we can report latency without querying the peer
|
||||||
|
element.
|
||||||
|
|
||||||
2007-09-24 Wim Taymans <wim.taymans@gmail.com>
|
2007-09-24 Wim Taymans <wim.taymans@gmail.com>
|
||||||
|
|
||||||
* gst/gstobject.h:
|
* gst/gstobject.h:
|
||||||
|
|
|
@ -833,37 +833,47 @@ gst_base_sink_query_latency (GstBaseSink * sink, gboolean * live,
|
||||||
gboolean * upstream_live, GstClockTime * min_latency,
|
gboolean * upstream_live, GstClockTime * min_latency,
|
||||||
GstClockTime * max_latency)
|
GstClockTime * max_latency)
|
||||||
{
|
{
|
||||||
gboolean l, us_live, res;
|
gboolean l, us_live, res, have_latency;
|
||||||
GstClockTime min, max;
|
GstClockTime min, max;
|
||||||
GstQuery *query;
|
GstQuery *query;
|
||||||
GstClockTime us_min, us_max;
|
GstClockTime us_min, us_max;
|
||||||
|
|
||||||
/* we are live when we sync to the clock */
|
/* we are live when we sync to the clock */
|
||||||
l = gst_base_sink_get_sync (sink);
|
GST_OBJECT_LOCK (sink);
|
||||||
|
l = sink->sync;
|
||||||
|
have_latency = sink->priv->have_latency;
|
||||||
|
GST_OBJECT_UNLOCK (sink);
|
||||||
|
|
||||||
/* assume no latency */
|
/* assume no latency */
|
||||||
min = 0;
|
min = 0;
|
||||||
max = -1;
|
max = -1;
|
||||||
us_live = FALSE;
|
us_live = FALSE;
|
||||||
|
res = TRUE;
|
||||||
|
|
||||||
query = gst_query_new_latency ();
|
/* we are live and we are prerolled, do upstream query to get the total
|
||||||
|
* picture */
|
||||||
|
if (l && have_latency) {
|
||||||
|
query = gst_query_new_latency ();
|
||||||
|
|
||||||
/* ask the peer for the latency */
|
/* ask the peer for the latency */
|
||||||
if (!(res = gst_base_sink_peer_query (sink, query)))
|
if (!(res = gst_base_sink_peer_query (sink, query)))
|
||||||
goto query_failed;
|
goto query_failed;
|
||||||
|
|
||||||
/* get upstream min and max latency */
|
/* get upstream min and max latency */
|
||||||
gst_query_parse_latency (query, &us_live, &us_min, &us_max);
|
gst_query_parse_latency (query, &us_live, &us_min, &us_max);
|
||||||
if (us_live) {
|
gst_query_unref (query);
|
||||||
/* upstream live, use its latency, subclasses should use these
|
|
||||||
* values to create the complete latency. */
|
if (us_live) {
|
||||||
min = us_min;
|
/* upstream live, use its latency, subclasses should use these
|
||||||
max = us_max;
|
* values to create the complete latency. */
|
||||||
|
min = us_min;
|
||||||
|
max = us_max;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (sink, "latency query: live: %d, upstream: %d, min %"
|
GST_DEBUG_OBJECT (sink, "latency query: live: %d, have_latency %d,"
|
||||||
GST_TIME_FORMAT ", max %" GST_TIME_FORMAT, l, us_live,
|
" upstream: %d, min %" GST_TIME_FORMAT ", max %" GST_TIME_FORMAT, l,
|
||||||
GST_TIME_ARGS (min), GST_TIME_ARGS (max));
|
have_latency, us_live, GST_TIME_ARGS (min), GST_TIME_ARGS (max));
|
||||||
|
|
||||||
if (live)
|
if (live)
|
||||||
*live = l;
|
*live = l;
|
||||||
|
@ -874,16 +884,14 @@ gst_base_sink_query_latency (GstBaseSink * sink, gboolean * live,
|
||||||
if (max_latency)
|
if (max_latency)
|
||||||
*max_latency = max;
|
*max_latency = max;
|
||||||
|
|
||||||
done:
|
|
||||||
gst_query_unref (query);
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
query_failed:
|
query_failed:
|
||||||
{
|
{
|
||||||
GST_DEBUG_OBJECT (sink, "latency query failed");
|
GST_DEBUG_OBJECT (sink, "latency query failed");
|
||||||
goto done;
|
gst_query_unref (query);
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2950,30 +2958,12 @@ gst_base_sink_query (GstElement * element, GstQuery * query)
|
||||||
break;
|
break;
|
||||||
case GST_QUERY_LATENCY:
|
case GST_QUERY_LATENCY:
|
||||||
{
|
{
|
||||||
gboolean live, us_live, have_latency;
|
gboolean live, us_live;
|
||||||
GstClockTime min, max;
|
GstClockTime min, max;
|
||||||
|
|
||||||
/* we need to be negotiated before we can report caps */
|
if ((res = gst_base_sink_query_latency (basesink, &live, &us_live, &min,
|
||||||
GST_OBJECT_LOCK (basesink);
|
&max))) {
|
||||||
have_latency = basesink->priv->have_latency;
|
gst_query_set_latency (query, live, min, max);
|
||||||
GST_OBJECT_UNLOCK (basesink);
|
|
||||||
|
|
||||||
if (!have_latency) {
|
|
||||||
GST_DEBUG_OBJECT (basesink, "not prerolled yet, can't report latency");
|
|
||||||
res = FALSE;
|
|
||||||
} else {
|
|
||||||
if ((res = gst_base_sink_query_latency (basesink, &live, &us_live, &min,
|
|
||||||
&max))) {
|
|
||||||
/* if we or the upstream elements are not live, we don't need latency
|
|
||||||
* compensation */
|
|
||||||
if (!live || !us_live) {
|
|
||||||
GST_DEBUG_OBJECT (basesink,
|
|
||||||
"no latency compensation, we %d, upstream %d", live, us_live);
|
|
||||||
min = 0;
|
|
||||||
max = -1;
|
|
||||||
}
|
|
||||||
gst_query_set_latency (query, live, min, max);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue