rtp: tests: add possibility to check duration of depayloaded buffers

.. and clarify an expect panic message.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1586>
This commit is contained in:
Tim-Philipp Müller 2024-05-27 16:33:44 +03:00 committed by GStreamer Marge Bot
parent 6b628485c5
commit 6597ec84eb

View file

@ -103,6 +103,8 @@ pub struct ExpectedBuffer {
pub pts: Option<gst::ClockTime>,
/// If not set then it is asserted that the depayloaded buffer also has no DTS.
pub dts: Option<gst::ClockTime>,
/// If set, the duration will be checked against the one on the depayloaded buffer
pub duration: Option<gst::ClockTime>,
/// If not set the size will not be checked.
pub size: Option<usize>,
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(),