static gboolean gst_inter_audio_sink_query (GstBaseSink * sink, GstQuery * query) { GstInterAudioSink *interaudiosink = GST_INTER_AUDIO_SINK (sink); gboolean ret; GST_DEBUG_OBJECT (sink, "query"); switch (GST_QUERY_TYPE (query)) { case GST_QUERY_LATENCY:{ gboolean live, us_live; GstClockTime min_l, max_l; GST_DEBUG_OBJECT (sink, "latency query"); if ((ret = gst_base_sink_query_latency (GST_BASE_SINK_CAST (sink), &live, &us_live, &min_l, &max_l))) { GstClockTime base_latency, min_latency, max_latency; /* we and upstream are both live, adjust the min_latency */ if (live && us_live) { /* FIXME: The other side can change this value when it starts */ base_latency = interaudiosink->surface->audio_latency_time; /* we cannot go lower than the buffer size and the min peer latency */ min_latency = base_latency + min_l; /* the max latency is the max of the peer, we can delay an infinite * amount of time. */ max_latency = (max_l == -1) ? -1 : (base_latency + max_l); GST_DEBUG_OBJECT (sink, "peer min %" GST_TIME_FORMAT ", our min latency: %" GST_TIME_FORMAT, GST_TIME_ARGS (min_l), GST_TIME_ARGS (min_latency)); GST_DEBUG_OBJECT (sink, "peer max %" GST_TIME_FORMAT ", our max latency: %" GST_TIME_FORMAT, GST_TIME_ARGS (max_l), GST_TIME_ARGS (max_latency)); } else { GST_DEBUG_OBJECT (sink, "peer or we are not live, don't care about latency"); min_latency = min_l; max_latency = max_l; } gst_query_set_latency (query, live, min_latency, max_latency); } break; } default: ret = GST_BASE_SINK_CLASS (gst_inter_audio_sink_parent_class)->query (sink, query); break; } return ret; }
static gboolean gst_decklink_audio_sink_query (GstBaseSink * bsink, GstQuery * query) { GstDecklinkAudioSink *self = GST_DECKLINK_AUDIO_SINK (bsink); gboolean res = FALSE; switch (GST_QUERY_TYPE (query)) { case GST_QUERY_LATENCY: { gboolean live, us_live; GstClockTime min_l, max_l; GST_DEBUG_OBJECT (self, "latency query"); /* ask parent first, it will do an upstream query for us. */ if ((res = gst_base_sink_query_latency (GST_BASE_SINK_CAST (self), &live, &us_live, &min_l, &max_l))) { GstClockTime base_latency, min_latency, max_latency; /* we and upstream are both live, adjust the min_latency */ if (live && us_live) { GST_OBJECT_LOCK (self); if (!self->info.rate) { GST_OBJECT_UNLOCK (self); GST_DEBUG_OBJECT (self, "we are not negotiated, can't report latency yet"); res = FALSE; goto done; } base_latency = self->buffer_time * 1000; GST_OBJECT_UNLOCK (self); /* we cannot go lower than the buffer size and the min peer latency */ min_latency = base_latency + min_l; /* the max latency is the max of the peer, we can delay an infinite * amount of time. */ max_latency = (max_l == GST_CLOCK_TIME_NONE) ? GST_CLOCK_TIME_NONE : (base_latency + max_l); GST_DEBUG_OBJECT (self, "peer min %" GST_TIME_FORMAT ", our min latency: %" GST_TIME_FORMAT, GST_TIME_ARGS (min_l), GST_TIME_ARGS (min_latency)); GST_DEBUG_OBJECT (self, "peer max %" GST_TIME_FORMAT ", our max latency: %" GST_TIME_FORMAT, GST_TIME_ARGS (max_l), GST_TIME_ARGS (max_latency)); } else { GST_DEBUG_OBJECT (self, "peer or we are not live, don't care about latency"); min_latency = min_l; max_latency = max_l; } gst_query_set_latency (query, live, min_latency, max_latency); } break; } default: res = GST_BASE_SINK_CLASS (parent_class)->query (bsink, query); break; } done: return res; }