mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-10-02 08:42:15 +00:00
84e4fe7f59
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.
69 lines
1.8 KiB
Rust
69 lines
1.8 KiB
Rust
use glib::prelude::*;
|
|
|
|
mod device_provider;
|
|
pub mod ndi;
|
|
mod ndiaudiosrc;
|
|
pub mod ndisys;
|
|
mod ndivideosrc;
|
|
pub mod receiver;
|
|
|
|
use crate::ndi::*;
|
|
use crate::ndisys::*;
|
|
use crate::receiver::*;
|
|
|
|
use std::collections::HashMap;
|
|
use std::time;
|
|
|
|
use once_cell::sync::Lazy;
|
|
|
|
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy, glib::GEnum)]
|
|
#[repr(u32)]
|
|
#[genum(type_name = "GstNdiTimestampMode")]
|
|
pub enum TimestampMode {
|
|
#[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 = 2,
|
|
#[genum(name = "NDI Timestamp", nick = "timestamp")]
|
|
Timestamp = 3,
|
|
}
|
|
|
|
fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
|
|
if !ndi::initialize() {
|
|
return Err(glib::glib_bool_error!("Cannot initialize NDI"));
|
|
}
|
|
|
|
ndivideosrc::register(plugin)?;
|
|
ndiaudiosrc::register(plugin)?;
|
|
device_provider::register(plugin)?;
|
|
Ok(())
|
|
}
|
|
|
|
static DEFAULT_RECEIVER_NDI_NAME: Lazy<String> = Lazy::new(|| {
|
|
format!(
|
|
"GStreamer NDI Source {}-{}",
|
|
env!("CARGO_PKG_VERSION"),
|
|
env!("COMMIT_ID")
|
|
)
|
|
});
|
|
|
|
#[cfg(feature = "reference-timestamps")]
|
|
static TIMECODE_CAPS: Lazy<gst::Caps> =
|
|
Lazy::new(|| gst::Caps::new_simple("timestamp/x-ndi-timecode", &[]));
|
|
#[cfg(feature = "reference-timestamps")]
|
|
static TIMESTAMP_CAPS: Lazy<gst::Caps> =
|
|
Lazy::new(|| gst::Caps::new_simple("timestamp/x-ndi-timestamp", &[]));
|
|
|
|
gst::gst_plugin_define!(
|
|
ndi,
|
|
env!("CARGO_PKG_DESCRIPTION"),
|
|
plugin_init,
|
|
concat!(env!("CARGO_PKG_VERSION"), "-", env!("COMMIT_ID")),
|
|
"LGPL",
|
|
env!("CARGO_PKG_NAME"),
|
|
env!("CARGO_PKG_NAME"),
|
|
env!("CARGO_PKG_REPOSITORY"),
|
|
env!("BUILD_REL_DATE")
|
|
);
|