1#![allow(unused_doc_comments)]
3
4#[allow(dead_code)]
10mod ndi;
11#[allow(dead_code)]
12mod ndisys;
13
14mod device_provider;
15
16#[cfg(feature = "sink")]
17mod ndisink;
18#[cfg(feature = "sink")]
19mod ndisinkcombiner;
20#[cfg(feature = "sink")]
21mod ndisinkmeta;
22
23mod ndisrc;
24mod ndisrcdemux;
25mod ndisrcmeta;
26
27mod ndi_cc_meta;
28
29#[cfg(feature = "doc")]
30use gst::prelude::*;
31
32use std::sync::LazyLock;
33
34#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy, glib::Enum, Default)]
35#[repr(u32)]
36#[enum_type(name = "GstNdiTimestampMode")]
37pub enum TimestampMode {
38 #[default]
39 #[enum_value(name = "Auto", nick = "auto")]
40 Auto = 0,
41 #[enum_value(name = "Receive Time / Timecode", nick = "receive-time-vs-timecode")]
42 ReceiveTimeTimecode = 1,
43 #[enum_value(name = "Receive Time / Timestamp", nick = "receive-time-vs-timestamp")]
44 ReceiveTimeTimestamp = 2,
45 #[enum_value(name = "NDI Timecode", nick = "timecode")]
46 Timecode = 3,
47 #[enum_value(name = "NDI Timestamp", nick = "timestamp")]
48 Timestamp = 4,
49 #[enum_value(name = "Receive Time", nick = "receive-time")]
50 ReceiveTime = 5,
51 #[enum_value(name = "Clocked", nick = "clocked")]
52 Clocked = 6,
53}
54
55#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy, glib::Enum)]
56#[repr(u32)]
57#[enum_type(name = "GstNdiRecvColorFormat")]
58pub enum RecvColorFormat {
59 #[enum_value(name = "BGRX or BGRA", nick = "bgrx-bgra")]
60 BgrxBgra = 0,
61 #[enum_value(name = "UYVY or BGRA", nick = "uyvy-bgra")]
62 UyvyBgra = 1,
63 #[enum_value(name = "RGBX or RGBA", nick = "rgbx-rgba")]
64 RgbxRgba = 2,
65 #[enum_value(name = "UYVY or RGBA", nick = "uyvy-rgba")]
66 UyvyRgba = 3,
67 #[enum_value(name = "Fastest", nick = "fastest")]
68 Fastest = 4,
69 #[enum_value(name = "Best", nick = "best")]
70 Best = 5,
71 #[cfg(feature = "advanced-sdk")]
72 #[enum_value(name = "Compressed v1", nick = "compressed-v1")]
73 CompressedV1 = 6,
74 #[cfg(feature = "advanced-sdk")]
75 #[enum_value(name = "Compressed v2", nick = "compressed-v2")]
76 CompressedV2 = 7,
77 #[cfg(feature = "advanced-sdk")]
78 #[enum_value(name = "Compressed v3", nick = "compressed-v3")]
79 CompressedV3 = 8,
80 #[cfg(feature = "advanced-sdk")]
81 #[enum_value(name = "Compressed v3 with audio", nick = "compressed-v3-with-audio")]
82 CompressedV3WithAudio = 9,
83 #[cfg(feature = "advanced-sdk")]
84 #[enum_value(name = "Compressed v4", nick = "compressed-v4")]
85 CompressedV4 = 10,
86 #[cfg(feature = "advanced-sdk")]
87 #[enum_value(name = "Compressed v4 with audio", nick = "compressed-v4-with-audio")]
88 CompressedV4WithAudio = 11,
89 #[cfg(feature = "advanced-sdk")]
90 #[enum_value(name = "Compressed v5", nick = "compressed-v5")]
91 CompressedV5 = 12,
92 #[cfg(feature = "advanced-sdk")]
93 #[enum_value(name = "Compressed v5 with audio", nick = "compressed-v5-with-audio")]
94 CompressedV5WithAudio = 13,
95}
96
97impl From<RecvColorFormat> for crate::ndisys::NDIlib_recv_color_format_e {
98 fn from(v: RecvColorFormat) -> Self {
99 use crate::ndisys::*;
100
101 match v {
102 RecvColorFormat::BgrxBgra => NDIlib_recv_color_format_BGRX_BGRA,
103 RecvColorFormat::UyvyBgra => NDIlib_recv_color_format_UYVY_BGRA,
104 RecvColorFormat::RgbxRgba => NDIlib_recv_color_format_RGBX_RGBA,
105 RecvColorFormat::UyvyRgba => NDIlib_recv_color_format_UYVY_RGBA,
106 RecvColorFormat::Fastest => NDIlib_recv_color_format_fastest,
107 RecvColorFormat::Best => NDIlib_recv_color_format_best,
108 #[cfg(feature = "advanced-sdk")]
109 RecvColorFormat::CompressedV1 => NDIlib_recv_color_format_ex_compressed,
110 #[cfg(feature = "advanced-sdk")]
111 RecvColorFormat::CompressedV2 => NDIlib_recv_color_format_ex_compressed_v2,
112 #[cfg(feature = "advanced-sdk")]
113 RecvColorFormat::CompressedV3 => NDIlib_recv_color_format_ex_compressed_v3,
114 #[cfg(feature = "advanced-sdk")]
115 RecvColorFormat::CompressedV3WithAudio => {
116 NDIlib_recv_color_format_ex_compressed_v3_with_audio
117 }
118 #[cfg(feature = "advanced-sdk")]
119 RecvColorFormat::CompressedV4 => NDIlib_recv_color_format_ex_compressed_v4,
120 #[cfg(feature = "advanced-sdk")]
121 RecvColorFormat::CompressedV4WithAudio => {
122 NDIlib_recv_color_format_ex_compressed_v4_with_audio
123 }
124 #[cfg(feature = "advanced-sdk")]
125 RecvColorFormat::CompressedV5 => NDIlib_recv_color_format_ex_compressed_v5,
126 #[cfg(feature = "advanced-sdk")]
127 RecvColorFormat::CompressedV5WithAudio => {
128 NDIlib_recv_color_format_ex_compressed_v5_with_audio
129 }
130 }
131 }
132}
133
134fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
135 #[cfg(feature = "doc")]
136 TimestampMode::static_type().mark_as_plugin_api(gst::PluginAPIFlags::empty());
137 #[cfg(feature = "doc")]
138 RecvColorFormat::static_type().mark_as_plugin_api(gst::PluginAPIFlags::empty());
139
140 device_provider::register(plugin)?;
141
142 ndisrc::register(plugin)?;
143 ndisrcdemux::register(plugin)?;
144
145 #[cfg(feature = "sink")]
146 {
147 ndisinkcombiner::register(plugin)?;
148 ndisink::register(plugin)?;
149 }
150
151 Ok(())
152}
153
154static TIMECODE_CAPS: LazyLock<gst::Caps> =
155 LazyLock::new(|| gst::Caps::new_empty_simple("timestamp/x-ndi-timecode"));
156static TIMESTAMP_CAPS: LazyLock<gst::Caps> =
157 LazyLock::new(|| gst::Caps::new_empty_simple("timestamp/x-ndi-timestamp"));
158
159gst::plugin_define!(
160 ndi,
161 env!("CARGO_PKG_DESCRIPTION"),
162 plugin_init,
163 concat!(env!("CARGO_PKG_VERSION"), "-", env!("COMMIT_ID")),
164 "MPL",
166 env!("CARGO_PKG_NAME"),
167 env!("CARGO_PKG_NAME"),
168 env!("CARGO_PKG_REPOSITORY"),
169 env!("BUILD_REL_DATE")
170);