Always return 1 frame of latency except for timecode mode

This allows for some slack when receiving, as up to 1 frame difference between
receive times can easily happen because of capturing alone.

And return 5 frames maximum latency as that is the size of our internal
queue.
This commit is contained in:
Sebastian Dröge 2019-07-19 11:37:33 +03:00
parent fa9f788190
commit 5e5007091e
2 changed files with 22 additions and 6 deletions

View file

@ -457,14 +457,22 @@ impl BaseSrcImpl for NdiAudioSrc {
let settings = self.settings.lock().unwrap();
if state.current_latency.is_some() {
let latency = if settings.timestamp_mode == TimestampMode::Timestamp {
let min = if settings.timestamp_mode != TimestampMode::Timecode {
state.current_latency
} else {
0.into()
};
gst_debug!(self.cat, obj: element, "Returning latency {}", latency);
q.set(true, latency, gst::CLOCK_TIME_NONE);
let max = 5 * state.current_latency;
gst_debug!(
self.cat,
obj: element,
"Returning latency min {} max {}",
min,
max
);
q.set(true, min, max);
true
} else {
false

View file

@ -493,14 +493,22 @@ impl BaseSrcImpl for NdiVideoSrc {
let settings = self.settings.lock().unwrap();
if state.current_latency.is_some() {
let latency = if settings.timestamp_mode == TimestampMode::Timestamp {
let min = if settings.timestamp_mode != TimestampMode::Timecode {
state.current_latency
} else {
0.into()
};
gst_debug!(self.cat, obj: element, "Returning latency {}", latency);
q.set(true, latency, gst::CLOCK_TIME_NONE);
let max = 5 * state.current_latency;
gst_debug!(
self.cat,
obj: element,
"Returning latency min {} max {}",
min,
max
);
q.set(true, min, max);
true
} else {
false