Update to gstreamer-rs 0.18

This commit is contained in:
Sebastian Dröge 2022-01-22 12:12:03 +02:00
parent c05f2bca27
commit c221e9e870
9 changed files with 66 additions and 57 deletions

View file

@ -8,11 +8,11 @@ description = "NewTek NDI Plugin"
edition = "2018" edition = "2018"
[dependencies] [dependencies]
glib = "0.14" glib = "0.15"
gst = { package = "gstreamer", version = "0.17.4", features = ["v1_12"] } gst = { package = "gstreamer", version = "0.18", features = ["v1_12"] }
gst-base = { package = "gstreamer-base", version = "0.17" } gst-base = { package = "gstreamer-base", version = "0.18" }
gst-audio = { package = "gstreamer-audio", version = "0.17" } gst-audio = { package = "gstreamer-audio", version = "0.18" }
gst-video = { package = "gstreamer-video", version = "0.17", features = ["v1_12"] } gst-video = { package = "gstreamer-video", version = "0.18", features = ["v1_12"] }
byte-slice-cast = "1" byte-slice-cast = "1"
once_cell = "1.0" once_cell = "1.0"
byteorder = "1.0" byteorder = "1.0"

View file

@ -46,6 +46,8 @@ impl ObjectSubclass for DeviceProvider {
impl ObjectImpl for DeviceProvider {} impl ObjectImpl for DeviceProvider {}
impl GstObjectImpl for DeviceProvider {}
impl DeviceProviderImpl for DeviceProvider { impl DeviceProviderImpl for DeviceProvider {
fn metadata() -> Option<&'static gst::subclass::DeviceProviderMetadata> { fn metadata() -> Option<&'static gst::subclass::DeviceProviderMetadata> {
static METADATA: Lazy<gst::subclass::DeviceProviderMetadata> = Lazy::new(|| { static METADATA: Lazy<gst::subclass::DeviceProviderMetadata> = Lazy::new(|| {
@ -210,6 +212,8 @@ impl ObjectSubclass for Device {
impl ObjectImpl for Device {} impl ObjectImpl for Device {}
impl GstObjectImpl for Device {}
impl DeviceImpl for Device { impl DeviceImpl for Device {
fn create_element( fn create_element(
&self, &self,

View file

@ -20,61 +20,61 @@ use std::time;
use once_cell::sync::Lazy; 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)] #[repr(u32)]
#[genum(type_name = "GstNdiTimestampMode")] #[enum_type(name = "GstNdiTimestampMode")]
pub enum TimestampMode { 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, 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, ReceiveTimeTimestamp = 1,
#[genum(name = "NDI Timecode", nick = "timecode")] #[enum_value(name = "NDI Timecode", nick = "timecode")]
Timecode = 2, Timecode = 2,
#[genum(name = "NDI Timestamp", nick = "timestamp")] #[enum_value(name = "NDI Timestamp", nick = "timestamp")]
Timestamp = 3, Timestamp = 3,
#[genum(name = "Receive Time", nick = "receive-time")] #[enum_value(name = "Receive Time", nick = "receive-time")]
ReceiveTime = 4, 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)] #[repr(u32)]
#[genum(type_name = "GstNdiRecvColorFormat")] #[enum_type(name = "GstNdiRecvColorFormat")]
pub enum RecvColorFormat { pub enum RecvColorFormat {
#[genum(name = "BGRX or BGRA", nick = "bgrx-bgra")] #[enum_value(name = "BGRX or BGRA", nick = "bgrx-bgra")]
BgrxBgra = 0, BgrxBgra = 0,
#[genum(name = "UYVY or BGRA", nick = "uyvy-bgra")] #[enum_value(name = "UYVY or BGRA", nick = "uyvy-bgra")]
UyvyBgra = 1, UyvyBgra = 1,
#[genum(name = "RGBX or RGBA", nick = "rgbx-rgba")] #[enum_value(name = "RGBX or RGBA", nick = "rgbx-rgba")]
RgbxRgba = 2, RgbxRgba = 2,
#[genum(name = "UYVY or RGBA", nick = "uyvy-rgba")] #[enum_value(name = "UYVY or RGBA", nick = "uyvy-rgba")]
UyvyRgba = 3, UyvyRgba = 3,
#[genum(name = "Fastest", nick = "fastest")] #[enum_value(name = "Fastest", nick = "fastest")]
Fastest = 4, Fastest = 4,
#[genum(name = "Best", nick = "best")] #[enum_value(name = "Best", nick = "best")]
Best = 5, Best = 5,
#[cfg(feature = "advanced-sdk")] #[cfg(feature = "advanced-sdk")]
#[genum(name = "Compressed v1", nick = "compressed-v1")] #[enum_value(name = "Compressed v1", nick = "compressed-v1")]
CompressedV1 = 6, CompressedV1 = 6,
#[cfg(feature = "advanced-sdk")] #[cfg(feature = "advanced-sdk")]
#[genum(name = "Compressed v2", nick = "compressed-v2")] #[enum_value(name = "Compressed v2", nick = "compressed-v2")]
CompressedV2 = 7, CompressedV2 = 7,
#[cfg(feature = "advanced-sdk")] #[cfg(feature = "advanced-sdk")]
#[genum(name = "Compressed v3", nick = "compressed-v3")] #[enum_value(name = "Compressed v3", nick = "compressed-v3")]
CompressedV3 = 8, CompressedV3 = 8,
#[cfg(feature = "advanced-sdk")] #[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, CompressedV3WithAudio = 9,
#[cfg(feature = "advanced-sdk")] #[cfg(feature = "advanced-sdk")]
#[genum(name = "Compressed v4", nick = "compressed-v4")] #[enum_value(name = "Compressed v4", nick = "compressed-v4")]
CompressedV4 = 10, CompressedV4 = 10,
#[cfg(feature = "advanced-sdk")] #[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, CompressedV4WithAudio = 11,
#[cfg(feature = "advanced-sdk")] #[cfg(feature = "advanced-sdk")]
#[genum(name = "Compressed v5", nick = "compressed-v5")] #[enum_value(name = "Compressed v5", nick = "compressed-v5")]
CompressedV5 = 12, CompressedV5 = 12,
#[cfg(feature = "advanced-sdk")] #[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, CompressedV5WithAudio = 13,
} }

View file

@ -793,14 +793,14 @@ impl<'a> VideoFrame<'a> {
let picture_aspect_ratio = let picture_aspect_ratio =
frame.info().par() * gst::Fraction::new(frame.width() as i32, frame.height() as i32); frame.info().par() * gst::Fraction::new(frame.width() as i32, frame.height() as i32);
let picture_aspect_ratio = 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 { let ndi_frame = NDIlib_video_frame_v2_t {
xres: frame.width() as i32, xres: frame.width() as i32,
yres: frame.height() as i32, yres: frame.height() as i32,
FourCC: format, FourCC: format,
frame_rate_N: *frame.info().fps().numer(), frame_rate_N: frame.info().fps().numer(),
frame_rate_D: *frame.info().fps().denom(), frame_rate_D: frame.info().fps().denom(),
picture_aspect_ratio, picture_aspect_ratio,
frame_format_type, frame_format_type,
timecode, timecode,

View file

@ -64,7 +64,7 @@ impl ObjectSubclass for NdiSink {
impl ObjectImpl for NdiSink { impl ObjectImpl for NdiSink {
fn properties() -> &'static [glib::ParamSpec] { fn properties() -> &'static [glib::ParamSpec] {
static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| { static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| {
vec![glib::ParamSpec::new_string( vec![glib::ParamSpecString::new(
"ndi-name", "ndi-name",
"NDI Name", "NDI Name",
"NDI Name to use", "NDI Name to use",
@ -105,6 +105,8 @@ impl ObjectImpl for NdiSink {
} }
} }
impl GstObjectImpl for NdiSink {}
impl ElementImpl for NdiSink { impl ElementImpl for NdiSink {
fn metadata() -> Option<&'static gst::subclass::ElementMetadata> { fn metadata() -> Option<&'static gst::subclass::ElementMetadata> {
static ELEMENT_METADATA: Lazy<gst::subclass::ElementMetadata> = Lazy::new(|| { static ELEMENT_METADATA: Lazy<gst::subclass::ElementMetadata> = Lazy::new(|| {

View file

@ -62,6 +62,8 @@ impl ObjectImpl for NdiSinkCombiner {
} }
} }
impl GstObjectImpl for NdiSinkCombiner {}
impl ElementImpl for NdiSinkCombiner { impl ElementImpl for NdiSinkCombiner {
fn metadata() -> Option<&'static gst::subclass::ElementMetadata> { fn metadata() -> Option<&'static gst::subclass::ElementMetadata> {
static ELEMENT_METADATA: Lazy<gst::subclass::ElementMetadata> = Lazy::new(|| { static ELEMENT_METADATA: Lazy<gst::subclass::ElementMetadata> = Lazy::new(|| {
@ -259,10 +261,10 @@ impl AggregatorImpl for NdiSinkCombiner {
audio_info.rate() as u64 * audio_info.bpf() as u64, audio_info.rate() as u64 * audio_info.bpf() as u64,
) )
} else if let Some(ref video_info) = state.video_info { } 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( gst::ClockTime::SECOND.mul_div_floor(
*video_info.fps().denom() as u64, video_info.fps().denom() as u64,
*video_info.fps().numer() as u64, video_info.fps().numer() as u64,
) )
} else { } else {
gst::ClockTime::NONE gst::ClockTime::NONE
@ -564,12 +566,9 @@ impl AggregatorImpl for NdiSinkCombiner {
// 2 frames latency because we queue 1 frame and wait until audio // 2 frames latency because we queue 1 frame and wait until audio
// up to the end of that frame has arrived. // 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 gst::ClockTime::SECOND
.mul_div_floor( .mul_div_floor(2 * info.fps().denom() as u64, info.fps().numer() as u64)
2 * *info.fps().denom() as u64,
*info.fps().numer() as u64,
)
.unwrap_or(80 * gst::ClockTime::MSECOND) .unwrap_or(80 * gst::ClockTime::MSECOND)
} else { } else {
// let's assume 25fps and 2 frames latency // let's assume 25fps and 2 frames latency

View file

@ -105,28 +105,28 @@ impl ObjectImpl for NdiSrc {
fn properties() -> &'static [glib::ParamSpec] { fn properties() -> &'static [glib::ParamSpec] {
static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| { static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| {
vec![ vec![
glib::ParamSpec::new_string( glib::ParamSpecString::new(
"ndi-name", "ndi-name",
"NDI Name", "NDI Name",
"NDI stream name of the sender", "NDI stream name of the sender",
None, None,
glib::ParamFlags::READWRITE, glib::ParamFlags::READWRITE,
), ),
glib::ParamSpec::new_string( glib::ParamSpecString::new(
"url-address", "url-address",
"URL/Address", "URL/Address",
"URL/address and port of the sender, e.g. 127.0.0.1:5961", "URL/address and port of the sender, e.g. 127.0.0.1:5961",
None, None,
glib::ParamFlags::READWRITE, glib::ParamFlags::READWRITE,
), ),
glib::ParamSpec::new_string( glib::ParamSpecString::new(
"receiver-ndi-name", "receiver-ndi-name",
"Receiver NDI Name", "Receiver NDI Name",
"NDI stream name of this receiver", "NDI stream name of this receiver",
Some(&*DEFAULT_RECEIVER_NDI_NAME), Some(&*DEFAULT_RECEIVER_NDI_NAME),
glib::ParamFlags::READWRITE, glib::ParamFlags::READWRITE,
), ),
glib::ParamSpec::new_uint( glib::ParamSpecUInt::new(
"connect-timeout", "connect-timeout",
"Connect Timeout", "Connect Timeout",
"Connection timeout in ms", "Connection timeout in ms",
@ -135,7 +135,7 @@ impl ObjectImpl for NdiSrc {
10000, 10000,
glib::ParamFlags::READWRITE, glib::ParamFlags::READWRITE,
), ),
glib::ParamSpec::new_uint( glib::ParamSpecUInt::new(
"timeout", "timeout",
"Timeout", "Timeout",
"Receive timeout in ms", "Receive timeout in ms",
@ -144,7 +144,7 @@ impl ObjectImpl for NdiSrc {
5000, 5000,
glib::ParamFlags::READWRITE, glib::ParamFlags::READWRITE,
), ),
glib::ParamSpec::new_uint( glib::ParamSpecUInt::new(
"max-queue-length", "max-queue-length",
"Max Queue Length", "Max Queue Length",
"Maximum receive queue length", "Maximum receive queue length",
@ -153,7 +153,7 @@ impl ObjectImpl for NdiSrc {
10, 10,
glib::ParamFlags::READWRITE, glib::ParamFlags::READWRITE,
), ),
glib::ParamSpec::new_int( glib::ParamSpecInt::new(
"bandwidth", "bandwidth",
"Bandwidth", "Bandwidth",
"Bandwidth, -10 metadata-only, 10 audio-only, 100 highest", "Bandwidth, -10 metadata-only, 10 audio-only, 100 highest",
@ -162,7 +162,7 @@ impl ObjectImpl for NdiSrc {
100, 100,
glib::ParamFlags::READWRITE, glib::ParamFlags::READWRITE,
), ),
glib::ParamSpec::new_enum( glib::ParamSpecEnum::new(
"color-format", "color-format",
"Color Format", "Color Format",
"Receive color format", "Receive color format",
@ -170,7 +170,7 @@ impl ObjectImpl for NdiSrc {
RecvColorFormat::UyvyBgra as u32 as i32, RecvColorFormat::UyvyBgra as u32 as i32,
glib::ParamFlags::READWRITE, glib::ParamFlags::READWRITE,
), ),
glib::ParamSpec::new_enum( glib::ParamSpecEnum::new(
"timestamp-mode", "timestamp-mode",
"Timestamp Mode", "Timestamp Mode",
"Timestamp information to use for outgoing PTS", "Timestamp information to use for outgoing PTS",
@ -360,6 +360,8 @@ impl ObjectImpl for NdiSrc {
} }
} }
impl GstObjectImpl for NdiSrc {}
impl ElementImpl for NdiSrc { impl ElementImpl for NdiSrc {
fn metadata() -> Option<&'static gst::subclass::ElementMetadata> { fn metadata() -> Option<&'static gst::subclass::ElementMetadata> {
static ELEMENT_METADATA: Lazy<gst::subclass::ElementMetadata> = Lazy::new(|| { static ELEMENT_METADATA: Lazy<gst::subclass::ElementMetadata> = Lazy::new(|| {

View file

@ -65,6 +65,8 @@ impl ObjectImpl for NdiSrcDemux {
} }
} }
impl GstObjectImpl for NdiSrcDemux {}
impl ElementImpl for NdiSrcDemux { impl ElementImpl for NdiSrcDemux {
fn metadata() -> Option<&'static gst::subclass::ElementMetadata> { fn metadata() -> Option<&'static gst::subclass::ElementMetadata> {
static ELEMENT_METADATA: Lazy<gst::subclass::ElementMetadata> = Lazy::new(|| { static ELEMENT_METADATA: Lazy<gst::subclass::ElementMetadata> = Lazy::new(|| {
@ -188,7 +190,7 @@ impl NdiSrcDemux {
} }
} }
Ok(Some(ev)) std::ops::ControlFlow::Continue(gst::EventForeachAction::Keep)
}); });
state.audio_caps = Some(caps.clone()); 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()); state.video_caps = Some(caps.clone());

View file

@ -1070,8 +1070,8 @@ impl Receiver {
yres: video_frame.yres(), yres: video_frame.yres(),
fps_n: video_frame.frame_rate().0, fps_n: video_frame.frame_rate().0,
fps_d: video_frame.frame_rate().1, fps_d: video_frame.frame_rate().1,
par_n: *par.numer(), par_n: par.numer(),
par_d: *par.denom(), par_d: par.denom(),
interlace_mode, interlace_mode,
}); });
} }
@ -1108,8 +1108,8 @@ impl Receiver {
yres: video_frame.yres(), yres: video_frame.yres(),
fps_n: video_frame.frame_rate().0, fps_n: video_frame.frame_rate().0,
fps_d: video_frame.frame_rate().1, fps_d: video_frame.frame_rate().1,
par_n: *par.numer(), par_n: par.numer(),
par_d: *par.denom(), par_d: par.denom(),
interlace_mode, interlace_mode,
}); });
} }
@ -1146,8 +1146,8 @@ impl Receiver {
yres: video_frame.yres(), yres: video_frame.yres(),
fps_n: video_frame.frame_rate().0, fps_n: video_frame.frame_rate().0,
fps_d: video_frame.frame_rate().1, fps_d: video_frame.frame_rate().1,
par_n: *par.numer(), par_n: par.numer(),
par_d: *par.denom(), par_d: par.denom(),
interlace_mode, interlace_mode,
}); });
} }