diff --git a/integration_tests/src/tests/required_inputs.rs b/integration_tests/src/tests/required_inputs.rs index 855260dcb..c6a167027 100644 --- a/integration_tests/src/tests/required_inputs.rs +++ b/integration_tests/src/tests/required_inputs.rs @@ -420,6 +420,100 @@ pub fn required_audio_inputs_with_offset() -> Result<()> { Ok(()) } +/// Required inputs with some packets delayed and some dropped. Offset set to 1000ms. +/// +/// Countdown from 10 +/// - 1 seconds of silence +/// - 1 second of audio (from the start of the recording) +/// - 2 seconds of silence (cuts of part of "10" and "9" from countdown) +/// - remaining part of audio (2 seconds from previous step are missing) +#[test] +pub fn required_audio_inputs_with_offset_missing_data() -> Result<()> { + const OUTPUT_DUMP_FILE: &str = "required_audio_inputs_with_offset_missing_data_output.rtp"; + let instance = CompositorInstance::start(None); + let input_1_port = instance.get_port(); + let output_port = instance.get_port(); + + instance.send_request( + "output/output_1/register", + json!({ + "type": "rtp_stream", + "transport_protocol": "tcp_server", + "port": output_port, + "audio": { + "initial": { + "inputs": [ + { + "input_id": "input_1", + "volume": 1.0, + }, + ] + }, + "encoder": { + "type": "opus", + "channels": "stereo", + } + }, + }), + )?; + + instance.send_request( + "output/output_1/unregister", + json!({ + "schedule_time_ms": 10000, + }), + )?; + + let output_receiver = OutputReceiver::start(output_port, CommunicationProtocol::Tcp)?; + + instance.send_request( + "input/input_1/register", + json!({ + "type": "rtp_stream", + "transport_protocol": "tcp_server", + "port": input_1_port, + "audio": { + "decoder": "opus" + }, + "offset_ms": 1000, + "required": true, + }), + )?; + + let mut input_sender = PacketSender::new(CommunicationProtocol::Tcp, input_1_port)?; + let input_dump = input_dump_from_disk("countdown_audio.rtp")?; + let (input_first_part, input_second_part) = + split_rtp_packet_dump(input_dump, Duration::from_secs(1))?; + let (_dropped_2_seconds, input_second_part_2) = + split_rtp_packet_dump(input_second_part, Duration::from_secs(2))?; + + let input_handle = thread::spawn(move || { + input_sender.send(&input_first_part).unwrap(); + thread::sleep(Duration::from_secs(3)); + input_sender.send(&input_second_part_2).unwrap(); + }); + + instance.send_request("start", json!({}))?; + + input_handle.join().unwrap(); + let new_output_dump = output_receiver.wait_for_output()?; + + compare_audio_dumps( + OUTPUT_DUMP_FILE, + &new_output_dump, + AudioValidationConfig { + sampling_intervals: vec![ + Duration::from_millis(0)..Duration::from_millis(2000), + Duration::from_millis(2000)..Duration::from_millis(4000), + Duration::from_millis(6000)..Duration::from_millis(8000), + ], + ..Default::default() + }, + )?; + + Ok(()) +} + /// Optional inputs with some packets delayed in the middle /// No offset /// diff --git a/snapshot_tests/snapshots b/snapshot_tests/snapshots index 2a70986eb..243f38ace 160000 --- a/snapshot_tests/snapshots +++ b/snapshot_tests/snapshots @@ -1 +1 @@ -Subproject commit 2a70986eb1efb45160afffb4155b500dbb22a97d +Subproject commit 243f38ace6a87ba1c5bd113d3f94ea9cb929e79e