rtp: tests: add possibility to make input live

.. for payloaders that behave differently with live
and non-live inputs (e.g. audio payloaders which by
default will pick different aggregation modes based
on that.

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 17:14:55 +03:00 committed by GStreamer Marge Bot
parent 6597ec84eb
commit 2b68920f82
3 changed files with 30 additions and 3 deletions

View file

@ -9,7 +9,7 @@
// SPDX-License-Identifier: MPL-2.0
use crate::klv::klv_utils::*;
use crate::tests::{run_test_pipeline_full, ExpectedBuffer, ExpectedPacket, Source};
use crate::tests::{run_test_pipeline_full, ExpectedBuffer, ExpectedPacket, Liveness, Source};
fn init() {
use std::sync::Once;
@ -129,6 +129,7 @@ fn test_klv_pay_depay() {
expected_pay,
expected_depay,
Some(expected_output_caps),
Liveness::NonLive,
);
}
@ -228,6 +229,7 @@ fn test_klv_pay_depay_fragmented() {
expected_pay,
expected_depay,
Some(expected_output_caps),
Liveness::NonLive,
);
}
@ -312,6 +314,7 @@ fn test_klv_pay_depay_with_packet_loss() {
expected_pay,
expected_depay,
Some(expected_output_caps),
Liveness::NonLive,
);
}
@ -434,6 +437,7 @@ fn test_klv_pay_depay_fragmented_with_packet_loss() {
expected_pay,
expected_depay,
Some(expected_output_caps),
Liveness::NonLive,
);
}

View file

@ -9,7 +9,7 @@
// SPDX-License-Identifier: MPL-2.0
use crate::tests::{
run_test_pipeline, run_test_pipeline_full, ExpectedBuffer, ExpectedPacket, Source,
run_test_pipeline, run_test_pipeline_full, ExpectedBuffer, ExpectedPacket, Liveness, Source,
};
use gst::prelude::*;
use gst_check::Harness;
@ -531,6 +531,7 @@ fn test_opus_pay_depay_multichannel() {
expected_pay,
expected_depay,
Some(expected_depay_caps),
Liveness::NonLive,
);
}

View file

@ -207,7 +207,21 @@ pub fn run_test_pipeline(
expected_pay: Vec<Vec<ExpectedPacket>>,
expected_depay: Vec<Vec<ExpectedBuffer>>,
) {
run_test_pipeline_full(src, pay, depay, expected_pay, expected_depay, None);
run_test_pipeline_full(
src,
pay,
depay,
expected_pay,
expected_depay,
None,
Liveness::NonLive,
);
}
#[derive(Debug, PartialEq)]
pub enum Liveness {
Live(i64),
NonLive,
}
pub fn run_test_pipeline_full(
@ -217,6 +231,7 @@ pub fn run_test_pipeline_full(
expected_pay: Vec<Vec<ExpectedPacket>>,
expected_depay: Vec<Vec<ExpectedBuffer>>,
expected_depay_caps: Option<gst::Caps>,
liveness: Liveness,
) {
let pipeline = Pipeline(gst::Pipeline::new());
@ -224,6 +239,7 @@ pub fn run_test_pipeline_full(
let src = match src {
Source::Bin(src) => {
assert_eq!(liveness, Liveness::NonLive);
let Ok(src) = gst::parse::bin_from_description_with_name(src, true, "rtptestsrc")
else {
return;
@ -233,9 +249,15 @@ pub fn run_test_pipeline_full(
}
Source::Buffers(caps, buffers) => {
let mut buffers = buffers.into_iter();
let (live, min_latency) = match liveness {
Liveness::NonLive => (false, -1i64),
Liveness::Live(min_latency) => (true, min_latency),
};
let appsrc = gst_app::AppSrc::builder()
.format(gst::Format::Time)
.caps(&caps)
.is_live(live)
.min_latency(min_latency)
.callbacks(
gst_app::AppSrcCallbacks::builder()
.need_data(move |appsrc, _offset| {