From 57821cade40eaa99b4dc4e14679f00ed6e3ca575 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 19 Aug 2024 13:11:27 +0300 Subject: [PATCH] ndisrc: Only calculate timecode/timestamp mappings if necessary Part-of: --- net/ndi/src/ndisrc/imp.rs | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/net/ndi/src/ndisrc/imp.rs b/net/ndi/src/ndisrc/imp.rs index 6f3fdbfa1..e53ec768b 100644 --- a/net/ndi/src/ndisrc/imp.rs +++ b/net/ndi/src/ndisrc/imp.rs @@ -651,19 +651,33 @@ impl NdiSrc { receive_time_real, ); - let res_timestamp = state.observations_timestamp[idx].process( - self.obj().upcast_ref(), - timestamp, - receive_time_gst, - duration, - ); + let res_timestamp = if matches!( + state.timestamp_mode, + TimestampMode::ReceiveTimeTimestamp | TimestampMode::Auto + ) { + state.observations_timestamp[idx].process( + self.obj().upcast_ref(), + timestamp, + receive_time_gst, + duration, + ) + } else { + None + }; - let res_timecode = state.observations_timecode[idx].process( - self.obj().upcast_ref(), - Some(timecode), - receive_time_gst, - duration, - ); + let res_timecode = if matches!( + state.timestamp_mode, + TimestampMode::ReceiveTimeTimecode | TimestampMode::Auto + ) { + state.observations_timecode[idx].process( + self.obj().upcast_ref(), + Some(timecode), + receive_time_gst, + duration, + ) + } else { + None + }; let (pts, duration, discont) = match state.timestamp_mode { TimestampMode::ReceiveTimeTimecode => match res_timecode {