ndisrc: receiver: Remove some code duplication

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1727>
This commit is contained in:
Sebastian Dröge 2024-08-16 17:51:26 +03:00 committed by GStreamer Marge Bot
parent f2658eb773
commit 84fef267b5

View file

@ -321,11 +321,16 @@ impl Receiver {
gst::debug!(CAT, obj = element, "No frame received yet, retry");
continue;
}
Ok(Some(Frame::Video(frame))) => {
Ok(Some(frame)) => {
if let Some(receive_time_gst) = element.current_running_time() {
let receive_time_real = (glib::real_time() as u64 * 1000).nseconds();
if matches!(frame, Frame::Video(_) | Frame::Audio(_)) {
first_frame = false;
}
match frame {
Frame::Video(frame) => {
let discont = first_video_frame;
first_video_frame = false;
@ -343,14 +348,8 @@ impl Receiver {
receive_time_gst,
receive_time_real,
})
} else {
Err(gst::FlowError::Flushing)
}
}
Ok(Some(Frame::Audio(frame))) => {
if let Some(receive_time_gst) = element.current_running_time() {
let receive_time_real = (glib::real_time() as u64 * 1000).nseconds();
first_frame = false;
Frame::Audio(frame) => {
let discont = first_audio_frame;
first_audio_frame = false;
@ -368,13 +367,8 @@ impl Receiver {
receive_time_gst,
receive_time_real,
})
} else {
Err(gst::FlowError::Flushing)
}
}
Ok(Some(Frame::Metadata(frame))) => {
if let Some(receive_time_gst) = element.current_running_time() {
let receive_time_real = (glib::real_time() as u64 * 1000).nseconds();
Frame::Metadata(frame) => {
gst::debug!(
CAT,
obj = element,
@ -387,6 +381,8 @@ impl Receiver {
receive_time_gst,
receive_time_real,
})
}
}
} else {
Err(gst::FlowError::Flushing)
}