if self.sync {
let mut all_with_time = true;
let mut min_ts = None;
+ let mut max_ts = None;
let mut min_sn = 0;
for (streamno, queue) in self.packets.iter().enumerate() {
if queue.is_empty() {
if !self.had_warning && self.packets.len() > 1 {
for q in self.packets.iter() {
- if q.len() > 64 {
+ if q.len() > 1024 {
self.had_warning = true;
- println!("Too many packets in one of the queues, synchronisation is not possible!");
+ println!("Too many packets ({}) in one of the queues, synchronisation is not possible!", q.len());
self.sync = false;
break;
}
min_ts = Some(millis);
min_sn = streamno;
}
+ if max_ts.is_none() || max_ts < Some(millis) {
+ max_ts = Some(millis);
+ }
} else {
all_with_time = false;
}
self.sync = false;
return self.get_last_packet();
}
+ if !self.had_warning {
+ const THR: u64 = 2000;
+ if let (Some(mints), Some(maxts)) = (min_ts, max_ts) {
+ if mints + THR < maxts {
+ println!("Queue times differ more than by {}s, synchronisation is not possible!", THR as f32 / 1000.0);
+ self.had_warning = true;
+ self.sync = false;
+ }
+ }
+ }
if min_ts.is_some() {
self.packets[min_sn].pop_front()
} else {