From 0911775142c5886d7bfb557facc0ce1e3a7dbba5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 30 Sep 2021 13:33:18 +0300 Subject: [PATCH] Set the discont flag on the first audio/video buffer --- src/receiver.rs | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/receiver.rs b/src/receiver.rs index dd901edb9..43cb77414 100644 --- a/src/receiver.rs +++ b/src/receiver.rs @@ -493,6 +493,8 @@ impl Receiver { } fn receive_thread(receiver: &Weak, recv: RecvInstance) { + let mut first_video_frame = true; + let mut first_audio_frame = true; let mut first_frame = true; let mut timer = time::Instant::now(); @@ -553,11 +555,31 @@ impl Receiver { } Ok(Some(Frame::Video(frame))) => { first_frame = false; - receiver.create_video_buffer_and_info(&element, frame) + let mut buffer = receiver.create_video_buffer_and_info(&element, frame); + if first_video_frame { + if let Ok(Buffer::Video(ref mut buffer, _)) = buffer { + buffer + .get_mut() + .unwrap() + .set_flags(gst::BufferFlags::DISCONT); + first_video_frame = false; + } + } + buffer } Ok(Some(Frame::Audio(frame))) => { first_frame = false; - receiver.create_audio_buffer_and_info(&element, frame) + let mut buffer = receiver.create_audio_buffer_and_info(&element, frame); + if first_audio_frame { + if let Ok(Buffer::Video(ref mut buffer, _)) = buffer { + buffer + .get_mut() + .unwrap() + .set_flags(gst::BufferFlags::DISCONT); + first_audio_frame = false; + } + } + buffer } Ok(Some(Frame::Metadata(frame))) => { if let Some(metadata) = frame.metadata() {