From 6597ec84eba70e91d15922f4c263e16fe14032ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Mon, 27 May 2024 16:33:44 +0300 Subject: [PATCH] rtp: tests: add possibility to check duration of depayloaded buffers .. and clarify an expect panic message. Part-of: --- net/rtp/src/tests.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/net/rtp/src/tests.rs b/net/rtp/src/tests.rs index 3fb705e4..3bb66e49 100644 --- a/net/rtp/src/tests.rs +++ b/net/rtp/src/tests.rs @@ -103,6 +103,8 @@ pub struct ExpectedBuffer { pub pts: Option, /// If not set then it is asserted that the depayloaded buffer also has no DTS. pub dts: Option, + /// If set, the duration will be checked against the one on the depayloaded buffer + pub duration: Option, /// If not set the size will not be checked. pub size: Option, pub flags: gst::BufferFlags, @@ -115,12 +117,14 @@ impl ExpectedBuffer { /// /// * pts: None /// * dts: None + /// * duration: None /// * size: None => not checked /// * flags: gst::BufferFlags::empty() pub fn builder() -> ExpectedBufferBuilder { ExpectedBufferBuilder(ExpectedBuffer { pts: None, dts: None, + duration: None, size: None, flags: gst::BufferFlags::empty(), }) @@ -145,6 +149,11 @@ impl ExpectedBufferBuilder { self } + pub fn duration(mut self, duration: gst::ClockTime) -> Self { + self.0.duration = Some(duration); + self + } + pub fn size(mut self, size: usize) -> Self { self.0.size = Some(size); self @@ -282,7 +291,7 @@ pub fn run_test_pipeline_full( .lock() .unwrap() .next() - .expect("Expected packets?!"); + .expect("Not enough expected packets?!"); let drop_count = expected_packets .iter() @@ -574,6 +583,18 @@ pub fn run_test_pipeline_full( expected_buffer.pts.display(), ); + if let Some(expected_duration) = expected_buffer.duration { + assert_eq!( + buffer.duration(), + Some(expected_duration), + "Buffer {} of payload buffer list {} has unexpected duration {:?} instead of {:?}", + j, + i, + buffer.duration(), + expected_duration, + ); + } + if let Some(expected_size) = expected_buffer.size { assert_eq!( buffer.size(),