2020-01-16 08:27:50 +00:00
|
|
|
mod device_provider;
|
2019-07-11 17:35:43 +00:00
|
|
|
pub mod ndi;
|
2021-02-25 19:00:33 +00:00
|
|
|
#[cfg(feature = "sink")]
|
|
|
|
mod ndisink;
|
|
|
|
#[cfg(feature = "sink")]
|
|
|
|
mod ndisinkcombiner;
|
|
|
|
#[cfg(feature = "sink")]
|
|
|
|
pub mod ndisinkmeta;
|
2021-09-29 10:45:04 +00:00
|
|
|
mod ndisrc;
|
|
|
|
mod ndisrcdemux;
|
|
|
|
pub mod ndisrcmeta;
|
2019-07-15 16:43:22 +00:00
|
|
|
pub mod ndisys;
|
2019-07-17 16:10:20 +00:00
|
|
|
pub mod receiver;
|
2018-06-25 08:38:45 +00:00
|
|
|
|
2019-07-23 11:20:56 +00:00
|
|
|
use crate::ndi::*;
|
|
|
|
use crate::ndisys::*;
|
|
|
|
use crate::receiver::*;
|
2018-06-25 08:38:45 +00:00
|
|
|
|
2019-07-17 07:40:26 +00:00
|
|
|
use std::time;
|
2018-08-14 14:47:58 +00:00
|
|
|
|
2021-02-23 10:29:04 +00:00
|
|
|
use once_cell::sync::Lazy;
|
|
|
|
|
2022-01-22 10:12:03 +00:00
|
|
|
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy, glib::Enum)]
|
2019-07-16 14:43:03 +00:00
|
|
|
#[repr(u32)]
|
2022-01-22 10:12:03 +00:00
|
|
|
#[enum_type(name = "GstNdiTimestampMode")]
|
2019-07-16 14:43:03 +00:00
|
|
|
pub enum TimestampMode {
|
2022-06-07 09:47:21 +00:00
|
|
|
#[enum_value(name = "Auto", nick = "auto")]
|
|
|
|
Auto = 0,
|
2022-01-22 10:12:03 +00:00
|
|
|
#[enum_value(name = "Receive Time / Timecode", nick = "receive-time-vs-timecode")]
|
2022-06-07 09:47:21 +00:00
|
|
|
ReceiveTimeTimecode = 1,
|
2022-01-22 10:12:03 +00:00
|
|
|
#[enum_value(name = "Receive Time / Timestamp", nick = "receive-time-vs-timestamp")]
|
2022-06-07 09:47:21 +00:00
|
|
|
ReceiveTimeTimestamp = 2,
|
2022-01-22 10:12:03 +00:00
|
|
|
#[enum_value(name = "NDI Timecode", nick = "timecode")]
|
2022-06-07 09:47:21 +00:00
|
|
|
Timecode = 3,
|
2022-01-22 10:12:03 +00:00
|
|
|
#[enum_value(name = "NDI Timestamp", nick = "timestamp")]
|
2022-06-07 09:47:21 +00:00
|
|
|
Timestamp = 4,
|
2022-01-22 10:12:03 +00:00
|
|
|
#[enum_value(name = "Receive Time", nick = "receive-time")]
|
2022-06-07 09:47:21 +00:00
|
|
|
ReceiveTime = 5,
|
2019-07-16 14:43:03 +00:00
|
|
|
}
|
|
|
|
|
2022-01-22 10:12:03 +00:00
|
|
|
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy, glib::Enum)]
|
2021-10-01 07:17:57 +00:00
|
|
|
#[repr(u32)]
|
2022-01-22 10:12:03 +00:00
|
|
|
#[enum_type(name = "GstNdiRecvColorFormat")]
|
2021-10-01 07:17:57 +00:00
|
|
|
pub enum RecvColorFormat {
|
2022-01-22 10:12:03 +00:00
|
|
|
#[enum_value(name = "BGRX or BGRA", nick = "bgrx-bgra")]
|
2021-10-01 07:17:57 +00:00
|
|
|
BgrxBgra = 0,
|
2022-01-22 10:12:03 +00:00
|
|
|
#[enum_value(name = "UYVY or BGRA", nick = "uyvy-bgra")]
|
2021-10-01 07:17:57 +00:00
|
|
|
UyvyBgra = 1,
|
2022-01-22 10:12:03 +00:00
|
|
|
#[enum_value(name = "RGBX or RGBA", nick = "rgbx-rgba")]
|
2021-10-01 07:17:57 +00:00
|
|
|
RgbxRgba = 2,
|
2022-01-22 10:12:03 +00:00
|
|
|
#[enum_value(name = "UYVY or RGBA", nick = "uyvy-rgba")]
|
2021-10-01 07:17:57 +00:00
|
|
|
UyvyRgba = 3,
|
2022-01-22 10:12:03 +00:00
|
|
|
#[enum_value(name = "Fastest", nick = "fastest")]
|
2021-10-01 07:17:57 +00:00
|
|
|
Fastest = 4,
|
2022-01-22 10:12:03 +00:00
|
|
|
#[enum_value(name = "Best", nick = "best")]
|
2021-10-01 07:17:57 +00:00
|
|
|
Best = 5,
|
2021-10-01 09:47:43 +00:00
|
|
|
#[cfg(feature = "advanced-sdk")]
|
2022-01-22 10:12:03 +00:00
|
|
|
#[enum_value(name = "Compressed v1", nick = "compressed-v1")]
|
2021-10-01 09:47:43 +00:00
|
|
|
CompressedV1 = 6,
|
|
|
|
#[cfg(feature = "advanced-sdk")]
|
2022-01-22 10:12:03 +00:00
|
|
|
#[enum_value(name = "Compressed v2", nick = "compressed-v2")]
|
2021-10-01 09:47:43 +00:00
|
|
|
CompressedV2 = 7,
|
|
|
|
#[cfg(feature = "advanced-sdk")]
|
2022-01-22 10:12:03 +00:00
|
|
|
#[enum_value(name = "Compressed v3", nick = "compressed-v3")]
|
2021-10-01 09:47:43 +00:00
|
|
|
CompressedV3 = 8,
|
|
|
|
#[cfg(feature = "advanced-sdk")]
|
2022-01-22 10:12:03 +00:00
|
|
|
#[enum_value(name = "Compressed v3 with audio", nick = "compressed-v3-with-audio")]
|
2021-10-01 09:47:43 +00:00
|
|
|
CompressedV3WithAudio = 9,
|
|
|
|
#[cfg(feature = "advanced-sdk")]
|
2022-01-22 10:12:03 +00:00
|
|
|
#[enum_value(name = "Compressed v4", nick = "compressed-v4")]
|
2021-10-01 09:47:43 +00:00
|
|
|
CompressedV4 = 10,
|
|
|
|
#[cfg(feature = "advanced-sdk")]
|
2022-01-22 10:12:03 +00:00
|
|
|
#[enum_value(name = "Compressed v4 with audio", nick = "compressed-v4-with-audio")]
|
2021-10-01 09:47:43 +00:00
|
|
|
CompressedV4WithAudio = 11,
|
|
|
|
#[cfg(feature = "advanced-sdk")]
|
2022-01-22 10:12:03 +00:00
|
|
|
#[enum_value(name = "Compressed v5", nick = "compressed-v5")]
|
2021-10-01 09:47:43 +00:00
|
|
|
CompressedV5 = 12,
|
|
|
|
#[cfg(feature = "advanced-sdk")]
|
2022-01-22 10:12:03 +00:00
|
|
|
#[enum_value(name = "Compressed v5 with audio", nick = "compressed-v5-with-audio")]
|
2021-10-01 09:47:43 +00:00
|
|
|
CompressedV5WithAudio = 13,
|
2021-10-01 07:17:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl From<RecvColorFormat> for NDIlib_recv_color_format_e {
|
|
|
|
fn from(v: RecvColorFormat) -> Self {
|
|
|
|
match v {
|
|
|
|
RecvColorFormat::BgrxBgra => NDIlib_recv_color_format_BGRX_BGRA,
|
|
|
|
RecvColorFormat::UyvyBgra => NDIlib_recv_color_format_UYVY_BGRA,
|
|
|
|
RecvColorFormat::RgbxRgba => NDIlib_recv_color_format_RGBX_RGBA,
|
|
|
|
RecvColorFormat::UyvyRgba => NDIlib_recv_color_format_UYVY_RGBA,
|
|
|
|
RecvColorFormat::Fastest => NDIlib_recv_color_format_fastest,
|
|
|
|
RecvColorFormat::Best => NDIlib_recv_color_format_best,
|
2021-10-01 09:47:43 +00:00
|
|
|
#[cfg(feature = "advanced-sdk")]
|
|
|
|
RecvColorFormat::CompressedV1 => NDIlib_recv_color_format_ex_compressed,
|
|
|
|
#[cfg(feature = "advanced-sdk")]
|
|
|
|
RecvColorFormat::CompressedV2 => NDIlib_recv_color_format_ex_compressed_v2,
|
|
|
|
#[cfg(feature = "advanced-sdk")]
|
|
|
|
RecvColorFormat::CompressedV3 => NDIlib_recv_color_format_ex_compressed_v3,
|
|
|
|
#[cfg(feature = "advanced-sdk")]
|
|
|
|
RecvColorFormat::CompressedV3WithAudio => {
|
|
|
|
NDIlib_recv_color_format_ex_compressed_v3_with_audio
|
|
|
|
}
|
|
|
|
#[cfg(feature = "advanced-sdk")]
|
|
|
|
RecvColorFormat::CompressedV4 => NDIlib_recv_color_format_ex_compressed_v4,
|
|
|
|
#[cfg(feature = "advanced-sdk")]
|
|
|
|
RecvColorFormat::CompressedV4WithAudio => {
|
|
|
|
NDIlib_recv_color_format_ex_compressed_v4_with_audio
|
|
|
|
}
|
|
|
|
#[cfg(feature = "advanced-sdk")]
|
|
|
|
RecvColorFormat::CompressedV5 => NDIlib_recv_color_format_ex_compressed_v5,
|
|
|
|
#[cfg(feature = "advanced-sdk")]
|
|
|
|
RecvColorFormat::CompressedV5WithAudio => {
|
|
|
|
NDIlib_recv_color_format_ex_compressed_v5_with_audio
|
|
|
|
}
|
2021-10-01 07:17:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-11 16:47:03 +00:00
|
|
|
fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
|
2019-07-11 18:56:30 +00:00
|
|
|
if !ndi::initialize() {
|
2021-09-13 09:26:56 +00:00
|
|
|
return Err(glib::bool_error!("Cannot initialize NDI"));
|
2019-07-11 18:56:30 +00:00
|
|
|
}
|
|
|
|
|
2021-02-25 19:00:33 +00:00
|
|
|
device_provider::register(plugin)?;
|
|
|
|
|
2021-09-29 10:45:04 +00:00
|
|
|
ndisrc::register(plugin)?;
|
|
|
|
ndisrcdemux::register(plugin)?;
|
|
|
|
|
2021-02-25 19:00:33 +00:00
|
|
|
#[cfg(feature = "sink")]
|
|
|
|
{
|
|
|
|
ndisinkcombiner::register(plugin)?;
|
|
|
|
ndisink::register(plugin)?;
|
|
|
|
}
|
2018-12-11 16:47:03 +00:00
|
|
|
Ok(())
|
2018-04-09 05:53:04 +00:00
|
|
|
}
|
|
|
|
|
2021-02-23 10:29:04 +00:00
|
|
|
static DEFAULT_RECEIVER_NDI_NAME: Lazy<String> = Lazy::new(|| {
|
|
|
|
format!(
|
|
|
|
"GStreamer NDI Source {}-{}",
|
|
|
|
env!("CARGO_PKG_VERSION"),
|
|
|
|
env!("COMMIT_ID")
|
|
|
|
)
|
|
|
|
});
|
2019-07-16 13:03:15 +00:00
|
|
|
|
2019-07-22 06:12:04 +00:00
|
|
|
#[cfg(feature = "reference-timestamps")]
|
2021-02-23 10:29:04 +00:00
|
|
|
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", &[]));
|
2018-08-14 13:45:13 +00:00
|
|
|
|
2021-09-13 09:26:56 +00:00
|
|
|
gst::plugin_define!(
|
2019-06-25 16:20:50 +00:00
|
|
|
ndi,
|
2019-07-09 14:51:57 +00:00
|
|
|
env!("CARGO_PKG_DESCRIPTION"),
|
2018-06-27 09:56:11 +00:00
|
|
|
plugin_init,
|
2019-07-09 14:51:57 +00:00
|
|
|
concat!(env!("CARGO_PKG_VERSION"), "-", env!("COMMIT_ID")),
|
2018-12-11 16:47:03 +00:00
|
|
|
"LGPL",
|
2019-07-09 14:51:57 +00:00
|
|
|
env!("CARGO_PKG_NAME"),
|
|
|
|
env!("CARGO_PKG_NAME"),
|
|
|
|
env!("CARGO_PKG_REPOSITORY"),
|
|
|
|
env!("BUILD_REL_DATE")
|
2018-06-27 09:56:11 +00:00
|
|
|
);
|