diff --git a/Cargo.toml b/Cargo.toml index bb64db63..95447083 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,11 +8,11 @@ description = "NewTek NDI Plugin" edition = "2018" [dependencies] -glib = "0.14" -gst = { package = "gstreamer", version = "0.17.4", features = ["v1_12"] } -gst-base = { package = "gstreamer-base", version = "0.17" } -gst-audio = { package = "gstreamer-audio", version = "0.17" } -gst-video = { package = "gstreamer-video", version = "0.17", features = ["v1_12"] } +glib = "0.15" +gst = { package = "gstreamer", version = "0.18", features = ["v1_12"] } +gst-base = { package = "gstreamer-base", version = "0.18" } +gst-audio = { package = "gstreamer-audio", version = "0.18" } +gst-video = { package = "gstreamer-video", version = "0.18", features = ["v1_12"] } byte-slice-cast = "1" once_cell = "1.0" byteorder = "1.0" diff --git a/src/device_provider/imp.rs b/src/device_provider/imp.rs index 956a531b..8484511e 100644 --- a/src/device_provider/imp.rs +++ b/src/device_provider/imp.rs @@ -46,6 +46,8 @@ impl ObjectSubclass for DeviceProvider { impl ObjectImpl for DeviceProvider {} +impl GstObjectImpl for DeviceProvider {} + impl DeviceProviderImpl for DeviceProvider { fn metadata() -> Option<&'static gst::subclass::DeviceProviderMetadata> { static METADATA: Lazy = Lazy::new(|| { @@ -210,6 +212,8 @@ impl ObjectSubclass for Device { impl ObjectImpl for Device {} +impl GstObjectImpl for Device {} + impl DeviceImpl for Device { fn create_element( &self, diff --git a/src/lib.rs b/src/lib.rs index 2c4302d7..dfdabf29 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,61 +20,61 @@ use std::time; use once_cell::sync::Lazy; -#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy, glib::GEnum)] +#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy, glib::Enum)] #[repr(u32)] -#[genum(type_name = "GstNdiTimestampMode")] +#[enum_type(name = "GstNdiTimestampMode")] pub enum TimestampMode { - #[genum(name = "Receive Time / Timecode", nick = "receive-time-vs-timecode")] + #[enum_value(name = "Receive Time / Timecode", nick = "receive-time-vs-timecode")] ReceiveTimeTimecode = 0, - #[genum(name = "Receive Time / Timestamp", nick = "receive-time-vs-timestamp")] + #[enum_value(name = "Receive Time / Timestamp", nick = "receive-time-vs-timestamp")] ReceiveTimeTimestamp = 1, - #[genum(name = "NDI Timecode", nick = "timecode")] + #[enum_value(name = "NDI Timecode", nick = "timecode")] Timecode = 2, - #[genum(name = "NDI Timestamp", nick = "timestamp")] + #[enum_value(name = "NDI Timestamp", nick = "timestamp")] Timestamp = 3, - #[genum(name = "Receive Time", nick = "receive-time")] + #[enum_value(name = "Receive Time", nick = "receive-time")] ReceiveTime = 4, } -#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy, glib::GEnum)] +#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy, glib::Enum)] #[repr(u32)] -#[genum(type_name = "GstNdiRecvColorFormat")] +#[enum_type(name = "GstNdiRecvColorFormat")] pub enum RecvColorFormat { - #[genum(name = "BGRX or BGRA", nick = "bgrx-bgra")] + #[enum_value(name = "BGRX or BGRA", nick = "bgrx-bgra")] BgrxBgra = 0, - #[genum(name = "UYVY or BGRA", nick = "uyvy-bgra")] + #[enum_value(name = "UYVY or BGRA", nick = "uyvy-bgra")] UyvyBgra = 1, - #[genum(name = "RGBX or RGBA", nick = "rgbx-rgba")] + #[enum_value(name = "RGBX or RGBA", nick = "rgbx-rgba")] RgbxRgba = 2, - #[genum(name = "UYVY or RGBA", nick = "uyvy-rgba")] + #[enum_value(name = "UYVY or RGBA", nick = "uyvy-rgba")] UyvyRgba = 3, - #[genum(name = "Fastest", nick = "fastest")] + #[enum_value(name = "Fastest", nick = "fastest")] Fastest = 4, - #[genum(name = "Best", nick = "best")] + #[enum_value(name = "Best", nick = "best")] Best = 5, #[cfg(feature = "advanced-sdk")] - #[genum(name = "Compressed v1", nick = "compressed-v1")] + #[enum_value(name = "Compressed v1", nick = "compressed-v1")] CompressedV1 = 6, #[cfg(feature = "advanced-sdk")] - #[genum(name = "Compressed v2", nick = "compressed-v2")] + #[enum_value(name = "Compressed v2", nick = "compressed-v2")] CompressedV2 = 7, #[cfg(feature = "advanced-sdk")] - #[genum(name = "Compressed v3", nick = "compressed-v3")] + #[enum_value(name = "Compressed v3", nick = "compressed-v3")] CompressedV3 = 8, #[cfg(feature = "advanced-sdk")] - #[genum(name = "Compressed v3 with audio", nick = "compressed-v3-with-audio")] + #[enum_value(name = "Compressed v3 with audio", nick = "compressed-v3-with-audio")] CompressedV3WithAudio = 9, #[cfg(feature = "advanced-sdk")] - #[genum(name = "Compressed v4", nick = "compressed-v4")] + #[enum_value(name = "Compressed v4", nick = "compressed-v4")] CompressedV4 = 10, #[cfg(feature = "advanced-sdk")] - #[genum(name = "Compressed v4 with audio", nick = "compressed-v4-with-audio")] + #[enum_value(name = "Compressed v4 with audio", nick = "compressed-v4-with-audio")] CompressedV4WithAudio = 11, #[cfg(feature = "advanced-sdk")] - #[genum(name = "Compressed v5", nick = "compressed-v5")] + #[enum_value(name = "Compressed v5", nick = "compressed-v5")] CompressedV5 = 12, #[cfg(feature = "advanced-sdk")] - #[genum(name = "Compressed v5 with audio", nick = "compressed-v5-with-audio")] + #[enum_value(name = "Compressed v5 with audio", nick = "compressed-v5-with-audio")] CompressedV5WithAudio = 13, } diff --git a/src/ndi.rs b/src/ndi.rs index a12e03c8..24507b88 100644 --- a/src/ndi.rs +++ b/src/ndi.rs @@ -793,14 +793,14 @@ impl<'a> VideoFrame<'a> { let picture_aspect_ratio = frame.info().par() * gst::Fraction::new(frame.width() as i32, frame.height() as i32); let picture_aspect_ratio = - *picture_aspect_ratio.numer() as f32 / *picture_aspect_ratio.denom() as f32; + picture_aspect_ratio.numer() as f32 / picture_aspect_ratio.denom() as f32; let ndi_frame = NDIlib_video_frame_v2_t { xres: frame.width() as i32, yres: frame.height() as i32, FourCC: format, - frame_rate_N: *frame.info().fps().numer(), - frame_rate_D: *frame.info().fps().denom(), + frame_rate_N: frame.info().fps().numer(), + frame_rate_D: frame.info().fps().denom(), picture_aspect_ratio, frame_format_type, timecode, diff --git a/src/ndisink/imp.rs b/src/ndisink/imp.rs index 417da0fe..86c31032 100644 --- a/src/ndisink/imp.rs +++ b/src/ndisink/imp.rs @@ -64,7 +64,7 @@ impl ObjectSubclass for NdiSink { impl ObjectImpl for NdiSink { fn properties() -> &'static [glib::ParamSpec] { static PROPERTIES: Lazy> = Lazy::new(|| { - vec![glib::ParamSpec::new_string( + vec![glib::ParamSpecString::new( "ndi-name", "NDI Name", "NDI Name to use", @@ -105,6 +105,8 @@ impl ObjectImpl for NdiSink { } } +impl GstObjectImpl for NdiSink {} + impl ElementImpl for NdiSink { fn metadata() -> Option<&'static gst::subclass::ElementMetadata> { static ELEMENT_METADATA: Lazy = Lazy::new(|| { diff --git a/src/ndisinkcombiner/imp.rs b/src/ndisinkcombiner/imp.rs index 4e1a1659..20fd8816 100644 --- a/src/ndisinkcombiner/imp.rs +++ b/src/ndisinkcombiner/imp.rs @@ -62,6 +62,8 @@ impl ObjectImpl for NdiSinkCombiner { } } +impl GstObjectImpl for NdiSinkCombiner {} + impl ElementImpl for NdiSinkCombiner { fn metadata() -> Option<&'static gst::subclass::ElementMetadata> { static ELEMENT_METADATA: Lazy = Lazy::new(|| { @@ -259,10 +261,10 @@ impl AggregatorImpl for NdiSinkCombiner { audio_info.rate() as u64 * audio_info.bpf() as u64, ) } else if let Some(ref video_info) = state.video_info { - if *video_info.fps().numer() > 0 { + if video_info.fps().numer() > 0 { gst::ClockTime::SECOND.mul_div_floor( - *video_info.fps().denom() as u64, - *video_info.fps().numer() as u64, + video_info.fps().denom() as u64, + video_info.fps().numer() as u64, ) } else { gst::ClockTime::NONE @@ -564,12 +566,9 @@ impl AggregatorImpl for NdiSinkCombiner { // 2 frames latency because we queue 1 frame and wait until audio // up to the end of that frame has arrived. - let latency = if *info.fps().numer() > 0 { + let latency = if info.fps().numer() > 0 { gst::ClockTime::SECOND - .mul_div_floor( - 2 * *info.fps().denom() as u64, - *info.fps().numer() as u64, - ) + .mul_div_floor(2 * info.fps().denom() as u64, info.fps().numer() as u64) .unwrap_or(80 * gst::ClockTime::MSECOND) } else { // let's assume 25fps and 2 frames latency diff --git a/src/ndisrc/imp.rs b/src/ndisrc/imp.rs index 3d1200f2..8bed052a 100644 --- a/src/ndisrc/imp.rs +++ b/src/ndisrc/imp.rs @@ -105,28 +105,28 @@ impl ObjectImpl for NdiSrc { fn properties() -> &'static [glib::ParamSpec] { static PROPERTIES: Lazy> = Lazy::new(|| { vec![ - glib::ParamSpec::new_string( + glib::ParamSpecString::new( "ndi-name", "NDI Name", "NDI stream name of the sender", None, glib::ParamFlags::READWRITE, ), - glib::ParamSpec::new_string( + glib::ParamSpecString::new( "url-address", "URL/Address", "URL/address and port of the sender, e.g. 127.0.0.1:5961", None, glib::ParamFlags::READWRITE, ), - glib::ParamSpec::new_string( + glib::ParamSpecString::new( "receiver-ndi-name", "Receiver NDI Name", "NDI stream name of this receiver", Some(&*DEFAULT_RECEIVER_NDI_NAME), glib::ParamFlags::READWRITE, ), - glib::ParamSpec::new_uint( + glib::ParamSpecUInt::new( "connect-timeout", "Connect Timeout", "Connection timeout in ms", @@ -135,7 +135,7 @@ impl ObjectImpl for NdiSrc { 10000, glib::ParamFlags::READWRITE, ), - glib::ParamSpec::new_uint( + glib::ParamSpecUInt::new( "timeout", "Timeout", "Receive timeout in ms", @@ -144,7 +144,7 @@ impl ObjectImpl for NdiSrc { 5000, glib::ParamFlags::READWRITE, ), - glib::ParamSpec::new_uint( + glib::ParamSpecUInt::new( "max-queue-length", "Max Queue Length", "Maximum receive queue length", @@ -153,7 +153,7 @@ impl ObjectImpl for NdiSrc { 10, glib::ParamFlags::READWRITE, ), - glib::ParamSpec::new_int( + glib::ParamSpecInt::new( "bandwidth", "Bandwidth", "Bandwidth, -10 metadata-only, 10 audio-only, 100 highest", @@ -162,7 +162,7 @@ impl ObjectImpl for NdiSrc { 100, glib::ParamFlags::READWRITE, ), - glib::ParamSpec::new_enum( + glib::ParamSpecEnum::new( "color-format", "Color Format", "Receive color format", @@ -170,7 +170,7 @@ impl ObjectImpl for NdiSrc { RecvColorFormat::UyvyBgra as u32 as i32, glib::ParamFlags::READWRITE, ), - glib::ParamSpec::new_enum( + glib::ParamSpecEnum::new( "timestamp-mode", "Timestamp Mode", "Timestamp information to use for outgoing PTS", @@ -360,6 +360,8 @@ impl ObjectImpl for NdiSrc { } } +impl GstObjectImpl for NdiSrc {} + impl ElementImpl for NdiSrc { fn metadata() -> Option<&'static gst::subclass::ElementMetadata> { static ELEMENT_METADATA: Lazy = Lazy::new(|| { diff --git a/src/ndisrcdemux/imp.rs b/src/ndisrcdemux/imp.rs index 9cf8180c..67b38d79 100644 --- a/src/ndisrcdemux/imp.rs +++ b/src/ndisrcdemux/imp.rs @@ -65,6 +65,8 @@ impl ObjectImpl for NdiSrcDemux { } } +impl GstObjectImpl for NdiSrcDemux {} + impl ElementImpl for NdiSrcDemux { fn metadata() -> Option<&'static gst::subclass::ElementMetadata> { static ELEMENT_METADATA: Lazy = Lazy::new(|| { @@ -188,7 +190,7 @@ impl NdiSrcDemux { } } - Ok(Some(ev)) + std::ops::ControlFlow::Continue(gst::EventForeachAction::Keep) }); state.audio_caps = Some(caps.clone()); @@ -238,7 +240,7 @@ impl NdiSrcDemux { } } - Ok(Some(ev)) + std::ops::ControlFlow::Continue(gst::EventForeachAction::Keep) }); state.video_caps = Some(caps.clone()); diff --git a/src/receiver.rs b/src/receiver.rs index d44eea25..6098f4c1 100644 --- a/src/receiver.rs +++ b/src/receiver.rs @@ -1070,8 +1070,8 @@ impl Receiver { yres: video_frame.yres(), fps_n: video_frame.frame_rate().0, fps_d: video_frame.frame_rate().1, - par_n: *par.numer(), - par_d: *par.denom(), + par_n: par.numer(), + par_d: par.denom(), interlace_mode, }); } @@ -1108,8 +1108,8 @@ impl Receiver { yres: video_frame.yres(), fps_n: video_frame.frame_rate().0, fps_d: video_frame.frame_rate().1, - par_n: *par.numer(), - par_d: *par.denom(), + par_n: par.numer(), + par_d: par.denom(), interlace_mode, }); } @@ -1146,8 +1146,8 @@ impl Receiver { yres: video_frame.yres(), fps_n: video_frame.frame_rate().0, fps_d: video_frame.frame_rate().1, - par_n: *par.numer(), - par_d: *par.denom(), + par_n: par.numer(), + par_d: par.denom(), interlace_mode, }); }