Add new timestamp mode based on the receive time and timecode

In addition to the old one based on the receive time and timestamp.

Also make that new mode the default as it will usually give more
accurate results because the timestamp is just the send time while the
timecode is usually set by the sender based on the media timestamps.
This commit is contained in:
Sebastian Dröge 2021-02-25 11:31:32 +02:00
parent a02fe56871
commit 84e4fe7f59
4 changed files with 16 additions and 9 deletions

View file

@ -20,12 +20,14 @@ use once_cell::sync::Lazy;
#[repr(u32)]
#[genum(type_name = "GstNdiTimestampMode")]
pub enum TimestampMode {
#[genum(name = "Receive Time", nick = "receive-time")]
ReceiveTime = 0,
#[genum(name = "Receive Time / Timecode", nick = "receive-time-vs-timecode")]
ReceiveTimeTimecode = 0,
#[genum(name = "Receive Time / Timestamp", nick = "receive-time-vs-timestamp")]
ReceiveTimeTimestamp = 1,
#[genum(name = "NDI Timecode", nick = "timecode")]
Timecode = 1,
Timecode = 2,
#[genum(name = "NDI Timestamp", nick = "timestamp")]
Timestamp = 2,
Timestamp = 3,
}
fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {

View file

@ -39,7 +39,7 @@ impl Default for Settings {
connect_timeout: 10000,
timeout: 5000,
bandwidth: ndisys::NDIlib_recv_bandwidth_highest,
timestamp_mode: TimestampMode::ReceiveTime,
timestamp_mode: TimestampMode::ReceiveTimeTimecode,
}
}
}
@ -111,7 +111,7 @@ static PROPERTIES: [subclass::Property; 7] = [
"Timestamp Mode",
"Timestamp information to use for outgoing PTS",
TimestampMode::static_type(),
TimestampMode::ReceiveTime as i32,
TimestampMode::ReceiveTimeTimecode as i32,
glib::ParamFlags::READWRITE,
)
}),

View file

@ -40,7 +40,7 @@ impl Default for Settings {
connect_timeout: 10000,
timeout: 5000,
bandwidth: ndisys::NDIlib_recv_bandwidth_highest,
timestamp_mode: TimestampMode::ReceiveTime,
timestamp_mode: TimestampMode::ReceiveTimeTimecode,
}
}
}
@ -112,7 +112,7 @@ static PROPERTIES: [subclass::Property; 7] = [
"Timestamp Mode",
"Timestamp information to use for outgoing PTS",
TimestampMode::static_type(),
TimestampMode::ReceiveTime as i32,
TimestampMode::ReceiveTimeTimecode as i32,
glib::ParamFlags::READWRITE,
)
}),

View file

@ -812,7 +812,12 @@ impl<T: ReceiverType> Receiver<T> {
);
let (pts, duration) = match self.0.timestamp_mode {
TimestampMode::ReceiveTime => self.0.observations.process(
TimestampMode::ReceiveTimeTimecode => {
self.0
.observations
.process(self.0.cat, element, (timecode, receive_time), duration)
}
TimestampMode::ReceiveTimeTimestamp => self.0.observations.process(
self.0.cat,
element,
(timestamp, receive_time),