mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-11-26 05:21:00 +00:00
Update to gstreamer-rs 0.18
This commit is contained in:
parent
c05f2bca27
commit
c221e9e870
9 changed files with 66 additions and 57 deletions
10
Cargo.toml
10
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"
|
||||
|
|
|
@ -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<gst::subclass::DeviceProviderMetadata> = 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,
|
||||
|
|
46
src/lib.rs
46
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,
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -64,7 +64,7 @@ impl ObjectSubclass for NdiSink {
|
|||
impl ObjectImpl for NdiSink {
|
||||
fn properties() -> &'static [glib::ParamSpec] {
|
||||
static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = 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<gst::subclass::ElementMetadata> = Lazy::new(|| {
|
||||
|
|
|
@ -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<gst::subclass::ElementMetadata> = 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
|
||||
|
|
|
@ -105,28 +105,28 @@ impl ObjectImpl for NdiSrc {
|
|||
fn properties() -> &'static [glib::ParamSpec] {
|
||||
static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = 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<gst::subclass::ElementMetadata> = Lazy::new(|| {
|
||||
|
|
|
@ -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<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());
|
||||
|
@ -238,7 +240,7 @@ impl NdiSrcDemux {
|
|||
}
|
||||
}
|
||||
|
||||
Ok(Some(ev))
|
||||
std::ops::ControlFlow::Continue(gst::EventForeachAction::Keep)
|
||||
});
|
||||
|
||||
state.video_caps = Some(caps.clone());
|
||||
|
|
|
@ -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,
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue