Update for GLib/GStreamer API changes

And clean up a lot of related property/caps/structure code.
This commit is contained in:
Sebastian Dröge 2021-11-06 09:34:10 +02:00
parent c99b7785f9
commit d9bda62a47
79 changed files with 799 additions and 912 deletions

View file

@ -209,21 +209,18 @@ impl ElementImpl for AudioEcho {
fn pad_templates() -> &'static [gst::PadTemplate] { fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| { static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
let caps = gst::Caps::new_simple( let caps = gst::Caps::builder("audio/x-raw")
"audio/x-raw", .field(
&[ "format",
( gst::List::new([
"format", gst_audio::AUDIO_FORMAT_F32.to_str(),
&gst::List::new(&[ gst_audio::AUDIO_FORMAT_F64.to_str(),
&gst_audio::AUDIO_FORMAT_F32.to_str(), ]),
&gst_audio::AUDIO_FORMAT_F64.to_str(), )
]), .field("rate", gst::IntRange::new(0, i32::MAX))
), .field("channels", gst::IntRange::new(0, i32::MAX))
("rate", &gst::IntRange::<i32>::new(0, i32::MAX)), .field("layout", "interleaved")
("channels", &gst::IntRange::<i32>::new(0, i32::MAX)), .build();
("layout", &"interleaved"),
],
);
let src_pad_template = gst::PadTemplate::new( let src_pad_template = gst::PadTemplate::new(
"src", "src",
gst::PadDirection::Src, gst::PadDirection::Src,

View file

@ -25,7 +25,7 @@ use gst::{gst_debug, gst_error, gst_info, gst_log};
use std::mem; use std::mem;
use std::sync::Mutex; use std::sync::Mutex;
use std::{i32, u64}; use std::u64;
use byte_slice_cast::*; use byte_slice_cast::*;
@ -1887,15 +1887,12 @@ impl ElementImpl for AudioLoudNorm {
fn pad_templates() -> &'static [gst::PadTemplate] { fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| { static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
let caps = gst::Caps::new_simple( let caps = gst::Caps::builder("audio/x-raw")
"audio/x-raw", .field("format", gst_audio::AUDIO_FORMAT_F64.to_str())
&[ .field("rate", 192_000i32)
("format", &gst_audio::AUDIO_FORMAT_F64.to_str()), .field("channels", gst::IntRange::new(1, std::i32::MAX))
("rate", &192_000i32), .field("layout", "interleaved")
("channels", &gst::IntRange::<i32>::new(1, std::i32::MAX)), .build();
("layout", &"interleaved"),
],
);
let src_pad_template = gst::PadTemplate::new( let src_pad_template = gst::PadTemplate::new(
"src", "src",
gst::PadDirection::Src, gst::PadDirection::Src,

View file

@ -225,15 +225,12 @@ impl ElementImpl for AudioRNNoise {
fn pad_templates() -> &'static [gst::PadTemplate] { fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| { static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
let caps = gst::Caps::new_simple( let caps = gst::Caps::builder("audio/x-raw")
"audio/x-raw", .field("format", gst_audio::AUDIO_FORMAT_F32.to_str())
&[ .field("rate", 48000)
("format", &gst_audio::AUDIO_FORMAT_F32.to_str()), .field("channels", gst::IntRange::new(1, std::i32::MAX))
("rate", &48000), .field("layout", "interleaved")
("channels", &gst::IntRange::<i32>::new(1, std::i32::MAX)), .build();
("layout", &"interleaved"),
],
);
let src_pad_template = gst::PadTemplate::new( let src_pad_template = gst::PadTemplate::new(
"src", "src",
gst::PadDirection::Src, gst::PadDirection::Src,

View file

@ -256,21 +256,18 @@ impl ElementImpl for EbuR128Level {
let caps = gst::Caps::builder("audio/x-raw") let caps = gst::Caps::builder("audio/x-raw")
.field( .field(
"format", "format",
&gst::List::new(&[ gst::List::new([
&gst_audio::AUDIO_FORMAT_S16.to_str(), gst_audio::AUDIO_FORMAT_S16.to_str(),
&gst_audio::AUDIO_FORMAT_S32.to_str(), gst_audio::AUDIO_FORMAT_S32.to_str(),
&gst_audio::AUDIO_FORMAT_F32.to_str(), gst_audio::AUDIO_FORMAT_F32.to_str(),
&gst_audio::AUDIO_FORMAT_F64.to_str(), gst_audio::AUDIO_FORMAT_F64.to_str(),
]), ]),
) )
.field( .field("layout", gst::List::new(["interleaved", "non-interleaved"]))
"layout",
&gst::List::new(&[&"interleaved", &"non-interleaved"]),
)
// Limit from ebur128 // Limit from ebur128
.field("rate", &gst::IntRange::<i32>::new(1, 2_822_400)) .field("rate", gst::IntRange::new(1i32, 2_822_400))
// Limit from ebur128 // Limit from ebur128
.field("channels", &gst::IntRange::<i32>::new(1, 64)) .field("channels", gst::IntRange::new(1i32, 64))
.build(); .build();
let src_pad_template = gst::PadTemplate::new( let src_pad_template = gst::PadTemplate::new(
"src", "src",
@ -499,9 +496,9 @@ impl BaseTransformImpl for EbuR128Level {
let stream_time = segment.as_ref().and_then(|s| s.to_stream_time(timestamp)); let stream_time = segment.as_ref().and_then(|s| s.to_stream_time(timestamp));
let mut s = gst::Structure::builder("ebur128-level") let mut s = gst::Structure::builder("ebur128-level")
.field("timestamp", &timestamp) .field("timestamp", timestamp)
.field("running-time", &running_time) .field("running-time", running_time)
.field("stream-time", &stream_time) .field("stream-time", stream_time)
.build(); .build();
if state.ebur128.mode().contains(ebur128::Mode::M) { if state.ebur128.mode().contains(ebur128::Mode::M) {
@ -568,7 +565,7 @@ impl BaseTransformImpl for EbuR128Level {
.collect::<Result<Vec<_>, _>>(); .collect::<Result<Vec<_>, _>>();
match peaks { match peaks {
Ok(peaks) => s.set("sample-peak", &gst::Array::from_owned(peaks)), Ok(peaks) => s.set("sample-peak", gst::Array::from(peaks)),
Err(err) => { Err(err) => {
gst_error!(CAT, obj: element, "Failed to get sample peaks: {}", err) gst_error!(CAT, obj: element, "Failed to get sample peaks: {}", err)
} }
@ -581,7 +578,7 @@ impl BaseTransformImpl for EbuR128Level {
.collect::<Result<Vec<_>, _>>(); .collect::<Result<Vec<_>, _>>();
match peaks { match peaks {
Ok(peaks) => s.set("true-peak", &gst::Array::from_owned(peaks)), Ok(peaks) => s.set("true-peak", gst::Array::from(peaks)),
Err(err) => { Err(err) => {
gst_error!(CAT, obj: element, "Failed to get true peaks: {}", err) gst_error!(CAT, obj: element, "Failed to get true peaks: {}", err)
} }

View file

@ -75,7 +75,7 @@ fn run_test(
.downcast::<gst_app::AppSink>() .downcast::<gst_app::AppSink>()
.unwrap(); .unwrap();
sink.set_property("sync", &false).unwrap(); sink.set_property("sync", false).unwrap();
let caps = gst_audio::AudioInfo::builder(gst_audio::AUDIO_FORMAT_F64, 192_000, channels) let caps = gst_audio::AudioInfo::builder(gst_audio::AUDIO_FORMAT_F64, 192_000, channels)
.build() .build()
.unwrap() .unwrap()

View file

@ -137,10 +137,10 @@ fn run_test(layout: gst_audio::AudioLayout, format: gst_audio::AudioFormat) {
let _global_loudness = s.get::<f64>("global-loudness").unwrap(); let _global_loudness = s.get::<f64>("global-loudness").unwrap();
let _relative_threshold = s.get::<f64>("relative-threshold").unwrap(); let _relative_threshold = s.get::<f64>("relative-threshold").unwrap();
let _loudness_range = s.get::<f64>("loudness-range").unwrap(); let _loudness_range = s.get::<f64>("loudness-range").unwrap();
let sample_peak = s.get::<gst::Array>("sample-peak").unwrap(); let sample_peak = s.get::<gst::ArrayRef>("sample-peak").unwrap();
assert_eq!(sample_peak.as_slice().len(), 2); assert_eq!(sample_peak.as_slice().len(), 2);
assert_eq!(sample_peak.as_slice()[0].type_(), glib::Type::F64); assert_eq!(sample_peak.as_slice()[0].type_(), glib::Type::F64);
let true_peak = s.get::<gst::Array>("true-peak").unwrap(); let true_peak = s.get::<gst::ArrayRef>("true-peak").unwrap();
assert_eq!(true_peak.as_slice().len(), 2); assert_eq!(true_peak.as_slice().len(), 2);
assert_eq!(true_peak.as_slice()[0].type_(), glib::Type::F64); assert_eq!(true_peak.as_slice()[0].type_(), glib::Type::F64);
} }

View file

@ -64,7 +64,9 @@ impl ElementImpl for ClaxonDec {
fn pad_templates() -> &'static [gst::PadTemplate] { fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| { static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
let sink_caps = gst::Caps::new_simple("audio/x-flac", &[("framed", &true)]); let sink_caps = gst::Caps::builder("audio/x-flac")
.field("framed", true)
.build();
let sink_pad_template = gst::PadTemplate::new( let sink_pad_template = gst::PadTemplate::new(
"sink", "sink",
gst::PadDirection::Sink, gst::PadDirection::Sink,
@ -73,23 +75,20 @@ impl ElementImpl for ClaxonDec {
) )
.unwrap(); .unwrap();
let src_caps = gst::Caps::new_simple( let src_caps = gst::Caps::builder("audio/x-raw")
"audio/x-raw", .field(
&[ "format",
( gst::List::new([
"format", gst_audio::AudioFormat::S8.to_str(),
&gst::List::new(&[ gst_audio::AUDIO_FORMAT_S16.to_str(),
&gst_audio::AudioFormat::S8.to_str(), gst_audio::AUDIO_FORMAT_S2432.to_str(),
&gst_audio::AUDIO_FORMAT_S16.to_str(), gst_audio::AUDIO_FORMAT_S32.to_str(),
&gst_audio::AUDIO_FORMAT_S2432.to_str(), ]),
&gst_audio::AUDIO_FORMAT_S32.to_str(), )
]), .field("rate", gst::IntRange::new(1i32, 655_350))
), .field("channels", gst::IntRange::new(1i32, 8))
("rate", &gst::IntRange::<i32>::new(1, 655_350)), .field("layout", "interleaved")
("channels", &gst::IntRange::<i32>::new(1, 8)), .build();
("layout", &"interleaved"),
],
);
let src_pad_template = gst::PadTemplate::new( let src_pad_template = gst::PadTemplate::new(
"src", "src",
gst::PadDirection::Src, gst::PadDirection::Src,
@ -124,7 +123,7 @@ impl AudioDecoderImpl for ClaxonDec {
let mut audio_info: Option<gst_audio::AudioInfo> = None; let mut audio_info: Option<gst_audio::AudioInfo> = None;
let s = caps.structure(0).unwrap(); let s = caps.structure(0).unwrap();
if let Ok(Some(streamheaders)) = s.get_optional::<gst::Array>("streamheader") { if let Ok(Some(streamheaders)) = s.get_optional::<gst::ArrayRef>("streamheader") {
let streamheaders = streamheaders.as_slice(); let streamheaders = streamheaders.as_slice();
if streamheaders.len() < 2 { if streamheaders.len() < 2 {

View file

@ -30,10 +30,10 @@ fn test_mono_s16() {
assert_eq!( assert_eq!(
caps, caps,
gst::Caps::builder("audio/x-raw") gst::Caps::builder("audio/x-raw")
.field("format", &gst_audio::AUDIO_FORMAT_S16.to_str()) .field("format", gst_audio::AUDIO_FORMAT_S16.to_str())
.field("rate", &44_100i32) .field("rate", 44_100i32)
.field("channels", &1i32) .field("channels", 1i32)
.field("layout", &"interleaved") .field("layout", "interleaved")
.build() .build()
); );
} }
@ -50,11 +50,11 @@ fn test_stereo_s32() {
assert_eq!( assert_eq!(
caps, caps,
gst::Caps::builder("audio/x-raw") gst::Caps::builder("audio/x-raw")
.field("format", &gst_audio::AUDIO_FORMAT_S2432.to_str()) .field("format", gst_audio::AUDIO_FORMAT_S2432.to_str())
.field("rate", &44_100i32) .field("rate", 44_100i32)
.field("channels", &2i32) .field("channels", 2i32)
.field("layout", &"interleaved") .field("layout", "interleaved")
.field("channel-mask", &gst::Bitmask::new(0x3)) .field("channel-mask", gst::Bitmask::new(0x3))
.build() .build()
); );
} }
@ -74,7 +74,7 @@ fn do_test(data: &'static [u8], packet_sizes: &[usize], decoded_samples: &[usize
h.play(); h.play();
let caps = gst::Caps::builder("audio/x-flac") let caps = gst::Caps::builder("audio/x-flac")
.field("framed", &true) .field("framed", true)
.build(); .build();
h.set_src_caps(caps); h.set_src_caps(caps);

View file

@ -464,15 +464,12 @@ impl ElementImpl for CsoundFilter {
fn pad_templates() -> &'static [gst::PadTemplate] { fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| { static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
let caps = gst::Caps::new_simple( let caps = gst::Caps::builder("audio/x-raw")
"audio/x-raw", .field("format", gst_audio::AUDIO_FORMAT_F64.to_str())
&[ .field("rate", gst::IntRange::new(1, i32::MAX))
("format", &gst_audio::AUDIO_FORMAT_F64.to_str()), .field("channels", gst::IntRange::new(1, i32::MAX))
("rate", &gst::IntRange::<i32>::new(1, i32::MAX)), .field("layout", "interleaved")
("channels", &gst::IntRange::<i32>::new(1, i32::MAX)), .build();
("layout", &"interleaved"),
],
);
let src_pad_template = gst::PadTemplate::new( let src_pad_template = gst::PadTemplate::new(
"src", "src",
gst::PadDirection::Src, gst::PadDirection::Src,

View file

@ -99,15 +99,12 @@ fn csound_filter_eos() {
let num_channels = 1; let num_channels = 1;
let sr: i32 = 44_100; let sr: i32 = 44_100;
let caps = gst::Caps::new_simple( let caps = gst::Caps::builder("audio/x-raw")
"audio/x-raw", .field("format", gst_audio::AUDIO_FORMAT_F64.to_str())
&[ .field("rate", sr)
("format", &gst_audio::AUDIO_FORMAT_F64.to_str()), .field("channels", num_channels)
("rate", &sr), .field("layout", "interleaved")
("channels", &num_channels), .build();
("layout", &"interleaved"),
],
);
let mut h = build_harness( let mut h = build_harness(
caps.clone(), caps.clone(),
@ -212,15 +209,12 @@ fn csound_filter_underflow() {
let num_channels = 1; let num_channels = 1;
let sr: i32 = 44_100; let sr: i32 = 44_100;
let caps = gst::Caps::new_simple( let caps = gst::Caps::builder("audio/x-raw")
"audio/x-raw", .field("format", gst_audio::AUDIO_FORMAT_F64.to_str())
&[ .field("rate", sr)
("format", &gst_audio::AUDIO_FORMAT_F64.to_str()), .field("channels", num_channels)
("rate", &sr), .field("layout", "interleaved")
("channels", &num_channels), .build();
("layout", &"interleaved"),
],
);
let mut h = build_harness( let mut h = build_harness(
caps.clone(), caps.clone(),
@ -294,27 +288,21 @@ fn csound_filter_caps_negotiation() {
let ochannels = 1; let ochannels = 1;
let sr: i32 = 44_100; let sr: i32 = 44_100;
let src_caps = gst::Caps::new_simple( let src_caps = gst::Caps::builder("audio/x-raw")
"audio/x-raw", .field("format", gst_audio::AUDIO_FORMAT_F64.to_str())
&[ .field("rate", sr)
("format", &gst_audio::AUDIO_FORMAT_F64.to_str()), .field("channels", ichannels)
("rate", &sr), .field("layout", "interleaved")
("channels", &ichannels), .build();
("layout", &"interleaved"),
],
);
// Define the output caps which would be fixated // Define the output caps which would be fixated
// at the end of the caps negotiation // at the end of the caps negotiation
let sink_caps = gst::Caps::new_simple( let sink_caps = gst::Caps::builder("audio/x-raw")
"audio/x-raw", .field("format", gst_audio::AUDIO_FORMAT_F64.to_str())
&[ .field("rate", gst::IntRange::new(1i32, 48000))
("format", &gst_audio::AUDIO_FORMAT_F64.to_str()), .field("channels", gst::IntRange::new(1i32, 2))
("rate", &gst::IntRange::<i32>::new(1, 48000)), .field("layout", "interleaved")
("channels", &gst::IntRange::<i32>::new(1, 2)), .build();
("layout", &"interleaved"),
],
);
// build the harness setting its src and sink caps, // build the harness setting its src and sink caps,
// also passing the csd score to the filter element // also passing the csd score to the filter element
@ -349,15 +337,12 @@ fn csound_filter_caps_negotiation() {
.expect("pad has no caps"); .expect("pad has no caps");
// our expected caps at the harness sinkpad // our expected caps at the harness sinkpad
let expected_caps = gst::Caps::new_simple( let expected_caps = gst::Caps::builder("audio/x-raw")
"audio/x-raw", .field("format", gst_audio::AUDIO_FORMAT_F64.to_str())
&[ .field("rate", 44_100i32)
("format", &gst_audio::AUDIO_FORMAT_F64.to_str()), .field("channels", ochannels)
("rate", &44_100i32), .field("layout", "interleaved")
("channels", &ochannels), .build();
("layout", &"interleaved"),
],
);
assert_eq!(harness_sink_caps, expected_caps); assert_eq!(harness_sink_caps, expected_caps);
} }
@ -373,27 +358,21 @@ fn csound_filter_caps_negotiation_fail() {
let ichannels = 2; let ichannels = 2;
let ochannels = 1; let ochannels = 1;
let src_caps = gst::Caps::new_simple( let src_caps = gst::Caps::builder("audio/x-raw")
"audio/x-raw", .field("format", gst_audio::AUDIO_FORMAT_F64.to_str())
&[ .field("rate", 44_100i32)
("format", &gst_audio::AUDIO_FORMAT_F64.to_str()), .field("channels", ichannels)
("rate", &44_100i32), .field("layout", "interleaved")
("channels", &ichannels), .build();
("layout", &"interleaved"),
],
);
// instead of having a range for channels/rate fields // instead of having a range for channels/rate fields
// we fixate them to 2 and 48_000 respectively, which would cause the negotiation error // we fixate them to 2 and 48_000 respectively, which would cause the negotiation error
let sink_caps = gst::Caps::new_simple( let sink_caps = gst::Caps::builder("audio/x-raw")
"audio/x-raw", .field("format", gst_audio::AUDIO_FORMAT_F64.to_str())
&[ .field("rate", 48_000i32)
("format", &gst_audio::AUDIO_FORMAT_F64.to_str()), .field("channels", ichannels)
("rate", &48_000i32), .field("layout", "interleaved")
("channels", &ichannels), .build();
("layout", &"interleaved"),
],
);
let mut h = build_harness( let mut h = build_harness(
src_caps, src_caps,

View file

@ -71,7 +71,7 @@ impl ElementImpl for LewtonDec {
fn pad_templates() -> &'static [gst::PadTemplate] { fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| { static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
let sink_caps = gst::Caps::new_simple("audio/x-vorbis", &[]); let sink_caps = gst::Caps::builder("audio/x-vorbis").build();
let sink_pad_template = gst::PadTemplate::new( let sink_pad_template = gst::PadTemplate::new(
"sink", "sink",
gst::PadDirection::Sink, gst::PadDirection::Sink,
@ -80,15 +80,12 @@ impl ElementImpl for LewtonDec {
) )
.unwrap(); .unwrap();
let src_caps = gst::Caps::new_simple( let src_caps = gst::Caps::builder("audio/x-raw")
"audio/x-raw", .field("format", gst_audio::AUDIO_FORMAT_F32.to_str())
&[ .field("rate", gst::IntRange::new(1, std::i32::MAX))
("format", &gst_audio::AUDIO_FORMAT_F32.to_str()), .field("channels", gst::IntRange::new(1i32, 255))
("rate", &gst::IntRange::<i32>::new(1, std::i32::MAX)), .field("layout", "interleaved")
("channels", &gst::IntRange::<i32>::new(1, 255)), .build();
("layout", &"interleaved"),
],
);
let src_pad_template = gst::PadTemplate::new( let src_pad_template = gst::PadTemplate::new(
"src", "src",
gst::PadDirection::Src, gst::PadDirection::Src,
@ -139,7 +136,7 @@ impl AudioDecoderImpl for LewtonDec {
let mut state = state_guard.as_mut().unwrap(); let mut state = state_guard.as_mut().unwrap();
let s = caps.structure(0).unwrap(); let s = caps.structure(0).unwrap();
if let Ok(Some(streamheaders)) = s.get_optional::<gst::Array>("streamheader") { if let Ok(Some(streamheaders)) = s.get_optional::<gst::ArrayRef>("streamheader") {
let streamheaders = streamheaders.as_slice(); let streamheaders = streamheaders.as_slice();
if streamheaders.len() < 3 { if streamheaders.len() < 3 {
gst_debug!( gst_debug!(

View file

@ -52,10 +52,10 @@ fn run_test(inline_headers: bool) {
let caps = gst::Caps::builder("audio/x-vorbis") let caps = gst::Caps::builder("audio/x-vorbis")
.field( .field(
"streamheader", "streamheader",
&gst::Array::new(&[ gst::Array::new([
&gst::Buffer::from_slice(&data[0..packet_offsets[0]]), gst::Buffer::from_slice(&data[0..packet_offsets[0]]),
&gst::Buffer::from_slice(&data[packet_offsets[0]..packet_offsets[1]]), gst::Buffer::from_slice(&data[packet_offsets[0]..packet_offsets[1]]),
&gst::Buffer::from_slice(&data[packet_offsets[1]..packet_offsets[2]]), gst::Buffer::from_slice(&data[packet_offsets[1]..packet_offsets[2]]),
]), ]),
) )
.build(); .build();
@ -92,10 +92,10 @@ fn run_test(inline_headers: bool) {
assert_eq!( assert_eq!(
caps, caps,
gst::Caps::builder("audio/x-raw") gst::Caps::builder("audio/x-raw")
.field("format", &gst_audio::AUDIO_FORMAT_F32.to_str()) .field("format", gst_audio::AUDIO_FORMAT_F32.to_str())
.field("rate", &44_100i32) .field("rate", 44_100i32)
.field("channels", &1i32) .field("channels", 1i32)
.field("layout", &"interleaved") .field("layout", "interleaved")
.build() .build()
); );
} }

View file

@ -109,8 +109,8 @@ fn main() -> Result<(), Box<dyn Error>> {
.set_property("location", &out_loc) .set_property("location", &out_loc)
.expect("Failed to set location property"); .expect("Failed to set location property");
decrypter.set_property("receiver-key", &glib::Bytes::from_owned(receiver.private.0))?; decrypter.set_property("receiver-key", glib::Bytes::from_owned(receiver.private.0))?;
decrypter.set_property("sender-key", &glib::Bytes::from_owned(sender.public))?; decrypter.set_property("sender-key", glib::Bytes::from_owned(sender.public))?;
let pipeline = gst::Pipeline::new(Some("test-pipeline")); let pipeline = gst::Pipeline::new(Some("test-pipeline"));
pipeline pipeline

View file

@ -108,8 +108,8 @@ fn main() -> Result<(), Box<dyn Error>> {
.set_property("location", &out_loc) .set_property("location", &out_loc)
.expect("Failed to set location property"); .expect("Failed to set location property");
encrypter.set_property("receiver-key", &glib::Bytes::from_owned(receiver.public))?; encrypter.set_property("receiver-key", glib::Bytes::from_owned(receiver.public))?;
encrypter.set_property("sender-key", &glib::Bytes::from_owned(sender.private.0))?; encrypter.set_property("sender-key", glib::Bytes::from_owned(sender.private.0))?;
let pipeline = gst::Pipeline::new(Some("test-pipeline")); let pipeline = gst::Pipeline::new(Some("test-pipeline"));
pipeline pipeline

View file

@ -42,13 +42,13 @@ fn typefind_register(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
"sodium_encrypted_typefind", "sodium_encrypted_typefind",
gst::Rank::None, gst::Rank::None,
None, None,
Some(&Caps::new_simple("application/x-sodium-encrypted", &[])), Some(&Caps::builder("application/x-sodium-encrypted").build()),
|typefind| { |typefind| {
if let Some(data) = typefind.peek(0, TYPEFIND_HEADER_SIZE as u32) { if let Some(data) = typefind.peek(0, TYPEFIND_HEADER_SIZE as u32) {
if data == TYPEFIND_HEADER { if data == TYPEFIND_HEADER {
typefind.suggest( typefind.suggest(
TypeFindProbability::Maximum, TypeFindProbability::Maximum,
&Caps::new_simple("application/x-sodium-encrypted", &[]), &Caps::builder("application/x-sodium-encrypted").build(),
); );
} }
} }

View file

@ -166,7 +166,7 @@ fn test_pull_range() {
let filesrc = gst::ElementFactory::make("filesrc", None).unwrap(); let filesrc = gst::ElementFactory::make("filesrc", None).unwrap();
filesrc filesrc
.set_property("location", &input_path.to_str().unwrap()) .set_property("location", input_path.to_str().unwrap())
.expect("failed to set property"); .expect("failed to set property");
let dec = gst::ElementFactory::make("sodiumdecrypter", None).unwrap(); let dec = gst::ElementFactory::make("sodiumdecrypter", None).unwrap();

View file

@ -78,7 +78,7 @@ fn encrypt_file() {
.expect("failed to set property"); .expect("failed to set property");
enc.set_property("receiver-key", &*RECEIVER_PUBLIC) enc.set_property("receiver-key", &*RECEIVER_PUBLIC)
.expect("failed to set property"); .expect("failed to set property");
enc.set_property("block-size", &1024u32) enc.set_property("block-size", 1024u32)
.expect("failed to set property"); .expect("failed to set property");
let mut h = gst_check::Harness::with_element(&enc, None, None); let mut h = gst_check::Harness::with_element(&enc, None, None);

View file

@ -66,8 +66,8 @@ fn main() {
for i in 0..n_streams { for i in 0..n_streams {
let sink = let sink =
gst::ElementFactory::make("fakesink", Some(format!("sink-{}", i).as_str())).unwrap(); gst::ElementFactory::make("fakesink", Some(format!("sink-{}", i).as_str())).unwrap();
sink.set_property("sync", &false).unwrap(); sink.set_property("sync", false).unwrap();
sink.set_property("async", &false).unwrap(); sink.set_property("async", false).unwrap();
let counter_clone = Arc::clone(&counter); let counter_clone = Arc::clone(&counter);
sink.static_pad("sink").unwrap().add_probe( sink.static_pad("sink").unwrap().add_probe(
@ -83,11 +83,9 @@ fn main() {
let source = let source =
gst::ElementFactory::make("udpsrc", Some(format!("source-{}", i).as_str())) gst::ElementFactory::make("udpsrc", Some(format!("source-{}", i).as_str()))
.unwrap(); .unwrap();
source.set_property("port", 40000i32 + i as i32).unwrap();
source source
.set_property("port", &(40000i32 + (i as i32))) .set_property("retrieve-sender-address", false)
.unwrap();
source
.set_property("retrieve-sender-address", &false)
.unwrap(); .unwrap();
source source
@ -96,13 +94,11 @@ fn main() {
let source = let source =
gst::ElementFactory::make("ts-udpsrc", Some(format!("source-{}", i).as_str())) gst::ElementFactory::make("ts-udpsrc", Some(format!("source-{}", i).as_str()))
.unwrap(); .unwrap();
source.set_property("port", 40000i32 + i as i32).unwrap();
source source
.set_property("port", &(40000i32 + (i as i32))) .set_property("context", format!("context-{}", (i as u32) % n_groups))
.unwrap(); .unwrap();
source source.set_property("context-wait", wait).unwrap();
.set_property("context", &format!("context-{}", (i as u32) % n_groups))
.unwrap();
source.set_property("context-wait", &wait).unwrap();
source source
} }
@ -112,8 +108,8 @@ fn main() {
Some(format!("source-{}", i).as_str()), Some(format!("source-{}", i).as_str()),
) )
.unwrap(); .unwrap();
source.set_property("host", &"127.0.0.1").unwrap(); source.set_property("host", "127.0.0.1").unwrap();
source.set_property("port", &40000i32).unwrap(); source.set_property("port", 40000i32).unwrap();
source source
} }
@ -123,12 +119,12 @@ fn main() {
Some(format!("source-{}", i).as_str()), Some(format!("source-{}", i).as_str()),
) )
.unwrap(); .unwrap();
source.set_property("host", &"127.0.0.1").unwrap(); source.set_property("host", "127.0.0.1").unwrap();
source.set_property("port", &40000i32).unwrap(); source.set_property("port", 40000i32).unwrap();
source source
.set_property("context", &format!("context-{}", (i as u32) % n_groups)) .set_property("context", format!("context-{}", (i as u32) % n_groups))
.unwrap(); .unwrap();
source.set_property("context-wait", &wait).unwrap(); source.set_property("context-wait", wait).unwrap();
source source
} }
@ -139,10 +135,10 @@ fn main() {
) )
.unwrap(); .unwrap();
source source
.set_property("samplesperbuffer", &((wait as i32) * 8000 / 1000)) .set_property("samplesperbuffer", (wait as i32) * 8000 / 1000)
.unwrap(); .unwrap();
sink.set_property("sync", &true).unwrap(); sink.set_property("sync", true).unwrap();
source source
} }
@ -151,12 +147,12 @@ fn main() {
gst::ElementFactory::make("ts-tonesrc", Some(format!("source-{}", i).as_str())) gst::ElementFactory::make("ts-tonesrc", Some(format!("source-{}", i).as_str()))
.unwrap(); .unwrap();
source source
.set_property("samples-per-buffer", &((wait as u32) * 8000 / 1000)) .set_property("samples-per-buffer", (wait as u32) * 8000 / 1000)
.unwrap(); .unwrap();
source source
.set_property("context", &format!("context-{}", (i as u32) % n_groups)) .set_property("context", format!("context-{}", (i as u32) % n_groups))
.unwrap(); .unwrap();
source.set_property("context-wait", &wait).unwrap(); source.set_property("context-wait", wait).unwrap();
source source
} }

View file

@ -706,15 +706,12 @@ impl SrcHandler {
let n_packets = gap - latency.nseconds() / spacing.nseconds(); let n_packets = gap - latency.nseconds() / spacing.nseconds();
if do_lost { if do_lost {
let s = gst::Structure::new( let s = gst::Structure::builder("GstRTPPacketLost")
"GstRTPPacketLost", .field("seqnum", lost_seqnum as u32)
&[ .field("timestamp", last_popped_pts + spacing)
("seqnum", &(lost_seqnum as u32)), .field("duration", (n_packets * spacing).nseconds())
("timestamp", &(last_popped_pts + spacing)), .field("retry", 0)
("duration", &(n_packets * spacing).nseconds()), .build();
("retry", &0),
],
);
events.push(gst::event::CustomDownstream::new(s)); events.push(gst::event::CustomDownstream::new(s));
} }
@ -736,15 +733,12 @@ impl SrcHandler {
state.last_popped_pts = Some(timestamp); state.last_popped_pts = Some(timestamp);
if do_lost { if do_lost {
let s = gst::Structure::new( let s = gst::Structure::builder("GstRTPPacketLost")
"GstRTPPacketLost", .field("seqnum", lost_seqnum as u32)
&[ .field("timestamp", timestamp)
("seqnum", &(lost_seqnum as u32)), .field("duration", duration.nseconds())
("timestamp", &timestamp), .field("retry", 0)
("duration", &duration.nseconds()), .build();
("retry", &0),
],
);
events.push(gst::event::CustomDownstream::new(s)); events.push(gst::event::CustomDownstream::new(s));
} }
@ -1503,14 +1497,11 @@ impl ObjectImpl for JitterBuffer {
} }
"stats" => { "stats" => {
let state = self.state.lock().unwrap(); let state = self.state.lock().unwrap();
let s = gst::Structure::new( let s = gst::Structure::builder("application/x-rtp-jitterbuffer-stats")
"application/x-rtp-jitterbuffer-stats", .field("num-pushed", state.stats.num_pushed)
&[ .field("num-lost", state.stats.num_lost)
("num-pushed", &state.stats.num_pushed), .field("num-late", state.stats.num_late)
("num-lost", &state.stats.num_lost), .build();
("num-late", &state.stats.num_late),
],
);
s.to_value() s.to_value()
} }
"context" => { "context" => {

View file

@ -33,12 +33,12 @@ fn push() {
let mut h = gst_check::Harness::new("ts-appsrc"); let mut h = gst_check::Harness::new("ts-appsrc");
let caps = gst::Caps::new_simple("foo/bar", &[]); let caps = gst::Caps::builder("foo/bar").build();
{ {
let appsrc = h.element().unwrap(); let appsrc = h.element().unwrap();
appsrc.set_property("caps", &caps).unwrap(); appsrc.set_property("caps", &caps).unwrap();
appsrc.set_property("do-timestamp", &true).unwrap(); appsrc.set_property("do-timestamp", true).unwrap();
appsrc.set_property("context", &"appsrc-push").unwrap(); appsrc.set_property("context", "appsrc-push").unwrap();
} }
h.play(); h.play();
@ -99,12 +99,12 @@ fn pause_regular() {
let mut h = gst_check::Harness::new("ts-appsrc"); let mut h = gst_check::Harness::new("ts-appsrc");
let caps = gst::Caps::new_simple("foo/bar", &[]); let caps = gst::Caps::builder("foo/bar").build();
{ {
let appsrc = h.element().unwrap(); let appsrc = h.element().unwrap();
appsrc.set_property("caps", &caps).unwrap(); appsrc.set_property("caps", &caps).unwrap();
appsrc.set_property("do-timestamp", &true).unwrap(); appsrc.set_property("do-timestamp", true).unwrap();
appsrc.set_property("context", &"appsrc-pause").unwrap(); appsrc.set_property("context", "appsrc-pause").unwrap();
} }
h.play(); h.play();
@ -169,12 +169,12 @@ fn flush_regular() {
let mut h = gst_check::Harness::new("ts-appsrc"); let mut h = gst_check::Harness::new("ts-appsrc");
let caps = gst::Caps::new_simple("foo/bar", &[]); let caps = gst::Caps::builder("foo/bar").build();
{ {
let appsrc = h.element().unwrap(); let appsrc = h.element().unwrap();
appsrc.set_property("caps", &caps).unwrap(); appsrc.set_property("caps", &caps).unwrap();
appsrc.set_property("do-timestamp", &true).unwrap(); appsrc.set_property("do-timestamp", true).unwrap();
appsrc.set_property("context", &"appsrc-flush").unwrap(); appsrc.set_property("context", "appsrc-flush").unwrap();
} }
h.play(); h.play();
@ -228,13 +228,13 @@ fn pause_flush() {
let mut h = gst_check::Harness::new("ts-appsrc"); let mut h = gst_check::Harness::new("ts-appsrc");
let caps = gst::Caps::new_simple("foo/bar", &[]); let caps = gst::Caps::builder("foo/bar").build();
{ {
let appsrc = h.element().unwrap(); let appsrc = h.element().unwrap();
appsrc.set_property("caps", &caps).unwrap(); appsrc.set_property("caps", &caps).unwrap();
appsrc.set_property("do-timestamp", &true).unwrap(); appsrc.set_property("do-timestamp", true).unwrap();
appsrc appsrc
.set_property("context", &"appsrc-pause_flush") .set_property("context", "appsrc-pause_flush")
.unwrap(); .unwrap();
} }

View file

@ -51,24 +51,24 @@ fn jb_pipeline() {
let pipeline = gst::Pipeline::new(None); let pipeline = gst::Pipeline::new(None);
let src = gst::ElementFactory::make("audiotestsrc", Some("audiotestsrc")).unwrap(); let src = gst::ElementFactory::make("audiotestsrc", Some("audiotestsrc")).unwrap();
src.set_property("is-live", &true).unwrap(); src.set_property("is-live", true).unwrap();
src.set_property("num-buffers", &BUFFER_NB).unwrap(); src.set_property("num-buffers", BUFFER_NB).unwrap();
let enc = gst::ElementFactory::make("alawenc", Some("alawenc")).unwrap(); let enc = gst::ElementFactory::make("alawenc", Some("alawenc")).unwrap();
let pay = gst::ElementFactory::make("rtppcmapay", Some("rtppcmapay")).unwrap(); let pay = gst::ElementFactory::make("rtppcmapay", Some("rtppcmapay")).unwrap();
let jb = gst::ElementFactory::make("ts-jitterbuffer", Some("ts-jitterbuffer")).unwrap(); let jb = gst::ElementFactory::make("ts-jitterbuffer", Some("ts-jitterbuffer")).unwrap();
jb.set_property("context", &"jb_pipeline").unwrap(); jb.set_property("context", "jb_pipeline").unwrap();
jb.set_property("context-wait", &CONTEXT_WAIT).unwrap(); jb.set_property("context-wait", CONTEXT_WAIT).unwrap();
jb.set_property("latency", &LATENCY).unwrap(); jb.set_property("latency", LATENCY).unwrap();
let depay = gst::ElementFactory::make("rtppcmadepay", Some("rtppcmadepay")).unwrap(); let depay = gst::ElementFactory::make("rtppcmadepay", Some("rtppcmadepay")).unwrap();
let dec = gst::ElementFactory::make("alawdec", Some("alawdec")).unwrap(); let dec = gst::ElementFactory::make("alawdec", Some("alawdec")).unwrap();
let sink = gst::ElementFactory::make("appsink", Some("appsink")).unwrap(); let sink = gst::ElementFactory::make("appsink", Some("appsink")).unwrap();
sink.set_property("sync", &false).unwrap(); sink.set_property("sync", false).unwrap();
sink.set_property("async", &false).unwrap(); sink.set_property("async", false).unwrap();
sink.set_property("emit-signals", &true).unwrap(); sink.set_property("emit-signals", true).unwrap();
pipeline pipeline
.add_many(&[&src, &enc, &pay, &jb, &depay, &dec, &sink]) .add_many(&[&src, &enc, &pay, &jb, &depay, &dec, &sink])
@ -115,30 +115,30 @@ fn jb_ts_pipeline() {
let pipeline = gst::Pipeline::new(None); let pipeline = gst::Pipeline::new(None);
let src = gst::ElementFactory::make("audiotestsrc", Some("audiotestsrc")).unwrap(); let src = gst::ElementFactory::make("audiotestsrc", Some("audiotestsrc")).unwrap();
src.set_property("is-live", &true).unwrap(); src.set_property("is-live", true).unwrap();
src.set_property("num-buffers", &BUFFER_NB).unwrap(); src.set_property("num-buffers", BUFFER_NB).unwrap();
let queue = gst::ElementFactory::make("ts-queue", Some("ts-queue")).unwrap(); let queue = gst::ElementFactory::make("ts-queue", Some("ts-queue")).unwrap();
queue queue
.set_property("context", &"jb_ts_pipeline_queue") .set_property("context", "jb_ts_pipeline_queue")
.unwrap(); .unwrap();
queue.set_property("context-wait", &CONTEXT_WAIT).unwrap(); queue.set_property("context-wait", CONTEXT_WAIT).unwrap();
let enc = gst::ElementFactory::make("alawenc", Some("alawenc")).unwrap(); let enc = gst::ElementFactory::make("alawenc", Some("alawenc")).unwrap();
let pay = gst::ElementFactory::make("rtppcmapay", Some("rtppcmapay")).unwrap(); let pay = gst::ElementFactory::make("rtppcmapay", Some("rtppcmapay")).unwrap();
let jb = gst::ElementFactory::make("ts-jitterbuffer", Some("ts-jitterbuffer")).unwrap(); let jb = gst::ElementFactory::make("ts-jitterbuffer", Some("ts-jitterbuffer")).unwrap();
jb.set_property("context", &"jb_ts_pipeline").unwrap(); jb.set_property("context", "jb_ts_pipeline").unwrap();
jb.set_property("context-wait", &CONTEXT_WAIT).unwrap(); jb.set_property("context-wait", CONTEXT_WAIT).unwrap();
jb.set_property("latency", &LATENCY).unwrap(); jb.set_property("latency", LATENCY).unwrap();
let depay = gst::ElementFactory::make("rtppcmadepay", Some("rtppcmadepay")).unwrap(); let depay = gst::ElementFactory::make("rtppcmadepay", Some("rtppcmadepay")).unwrap();
let dec = gst::ElementFactory::make("alawdec", Some("alawdec")).unwrap(); let dec = gst::ElementFactory::make("alawdec", Some("alawdec")).unwrap();
let sink = gst::ElementFactory::make("appsink", Some("appsink")).unwrap(); let sink = gst::ElementFactory::make("appsink", Some("appsink")).unwrap();
sink.set_property("sync", &false).unwrap(); sink.set_property("sync", false).unwrap();
sink.set_property("async", &false).unwrap(); sink.set_property("async", false).unwrap();
sink.set_property("emit-signals", &true).unwrap(); sink.set_property("emit-signals", true).unwrap();
pipeline pipeline
.add_many(&[&src, &queue, &enc, &pay, &jb, &depay, &dec, &sink]) .add_many(&[&src, &queue, &enc, &pay, &jb, &depay, &dec, &sink])

View file

@ -970,10 +970,10 @@ fn src_tsqueue_sink_nominal() {
let ts_queue = gst::ElementFactory::make("ts-queue", Some("ts-queue")).unwrap(); let ts_queue = gst::ElementFactory::make("ts-queue", Some("ts-queue")).unwrap();
ts_queue ts_queue
.set_property("context", &format!("{}_queue", name)) .set_property("context", format!("{}_queue", name))
.unwrap(); .unwrap();
ts_queue ts_queue
.set_property("context-wait", &(THROTTLING_DURATION.as_millis() as u32)) .set_property("context-wait", THROTTLING_DURATION.as_millis() as u32)
.unwrap(); .unwrap();
let (pipeline, src_element, _sink_element, receiver) = setup(name, Some(ts_queue), None); let (pipeline, src_element, _sink_element, receiver) = setup(name, Some(ts_queue), None);
@ -1001,18 +1001,18 @@ fn src_tsproxy_sink_nominal() {
let ts_proxy_sink = gst::ElementFactory::make("ts-proxysink", Some("ts-proxysink")).unwrap(); let ts_proxy_sink = gst::ElementFactory::make("ts-proxysink", Some("ts-proxysink")).unwrap();
ts_proxy_sink ts_proxy_sink
.set_property("proxy-context", &format!("{}_proxy_context", name)) .set_property("proxy-context", format!("{}_proxy_context", name))
.unwrap(); .unwrap();
let ts_proxy_src = gst::ElementFactory::make("ts-proxysrc", Some("ts-proxysrc")).unwrap(); let ts_proxy_src = gst::ElementFactory::make("ts-proxysrc", Some("ts-proxysrc")).unwrap();
ts_proxy_src ts_proxy_src
.set_property("proxy-context", &format!("{}_proxy_context", name)) .set_property("proxy-context", format!("{}_proxy_context", name))
.unwrap(); .unwrap();
ts_proxy_src ts_proxy_src
.set_property("context", &format!("{}_context", name)) .set_property("context", format!("{}_context", name))
.unwrap(); .unwrap();
ts_proxy_src ts_proxy_src
.set_property("context-wait", &(THROTTLING_DURATION.as_millis() as u32)) .set_property("context-wait", THROTTLING_DURATION.as_millis() as u32)
.unwrap(); .unwrap();
let (pipeline, src_element, _sink_element, receiver) = let (pipeline, src_element, _sink_element, receiver) =

View file

@ -63,24 +63,23 @@ fn multiple_contexts_queue() {
for i in 0..SRC_NB { for i in 0..SRC_NB {
let src = let src =
gst::ElementFactory::make("ts-udpsrc", Some(format!("src-{}", i).as_str())).unwrap(); gst::ElementFactory::make("ts-udpsrc", Some(format!("src-{}", i).as_str())).unwrap();
src.set_property("context", &format!("context-{}", (i as u32) % CONTEXT_NB)) src.set_property("context", format!("context-{}", (i as u32) % CONTEXT_NB))
.unwrap();
src.set_property("context-wait", &CONTEXT_WAIT).unwrap();
src.set_property("port", &((FIRST_PORT + i) as i32))
.unwrap(); .unwrap();
src.set_property("context-wait", CONTEXT_WAIT).unwrap();
src.set_property("port", (FIRST_PORT + i) as i32).unwrap();
let queue = let queue =
gst::ElementFactory::make("ts-queue", Some(format!("queue-{}", i).as_str())).unwrap(); gst::ElementFactory::make("ts-queue", Some(format!("queue-{}", i).as_str())).unwrap();
queue queue
.set_property("context", &format!("context-{}", (i as u32) % CONTEXT_NB)) .set_property("context", format!("context-{}", (i as u32) % CONTEXT_NB))
.unwrap(); .unwrap();
queue.set_property("context-wait", &CONTEXT_WAIT).unwrap(); queue.set_property("context-wait", CONTEXT_WAIT).unwrap();
let sink = let sink =
gst::ElementFactory::make("appsink", Some(format!("sink-{}", i).as_str())).unwrap(); gst::ElementFactory::make("appsink", Some(format!("sink-{}", i).as_str())).unwrap();
sink.set_property("sync", &false).unwrap(); sink.set_property("sync", false).unwrap();
sink.set_property("async", &false).unwrap(); sink.set_property("async", false).unwrap();
sink.set_property("emit-signals", &true).unwrap(); sink.set_property("emit-signals", true).unwrap();
pipeline.add_many(&[&src, &queue, &sink]).unwrap(); pipeline.add_many(&[&src, &queue, &sink]).unwrap();
gst::Element::link_many(&[&src, &queue, &sink]).unwrap(); gst::Element::link_many(&[&src, &queue, &sink]).unwrap();
@ -205,11 +204,10 @@ fn multiple_contexts_proxy() {
Some(format!("src-{}", pipeline_index).as_str()), Some(format!("src-{}", pipeline_index).as_str()),
) )
.unwrap(); .unwrap();
src.set_property("context", &format!("context-{}", (i as u32) % CONTEXT_NB)) src.set_property("context", format!("context-{}", (i as u32) % CONTEXT_NB))
.unwrap();
src.set_property("context-wait", &CONTEXT_WAIT).unwrap();
src.set_property("port", &((FIRST_PORT + i) as i32))
.unwrap(); .unwrap();
src.set_property("context-wait", CONTEXT_WAIT).unwrap();
src.set_property("port", (FIRST_PORT + i) as i32).unwrap();
let proxysink = gst::ElementFactory::make( let proxysink = gst::ElementFactory::make(
"ts-proxysink", "ts-proxysink",
@ -217,7 +215,7 @@ fn multiple_contexts_proxy() {
) )
.unwrap(); .unwrap();
proxysink proxysink
.set_property("proxy-context", &format!("proxy-{}", pipeline_index)) .set_property("proxy-context", format!("proxy-{}", pipeline_index))
.unwrap(); .unwrap();
let proxysrc = gst::ElementFactory::make( let proxysrc = gst::ElementFactory::make(
"ts-proxysrc", "ts-proxysrc",
@ -231,15 +229,15 @@ fn multiple_contexts_proxy() {
) )
.unwrap(); .unwrap();
proxysrc proxysrc
.set_property("proxy-context", &format!("proxy-{}", pipeline_index)) .set_property("proxy-context", format!("proxy-{}", pipeline_index))
.unwrap(); .unwrap();
let sink = let sink =
gst::ElementFactory::make("appsink", Some(format!("sink-{}", pipeline_index).as_str())) gst::ElementFactory::make("appsink", Some(format!("sink-{}", pipeline_index).as_str()))
.unwrap(); .unwrap();
sink.set_property("sync", &false).unwrap(); sink.set_property("sync", false).unwrap();
sink.set_property("async", &false).unwrap(); sink.set_property("async", false).unwrap();
sink.set_property("emit-signals", &true).unwrap(); sink.set_property("emit-signals", true).unwrap();
pipeline pipeline
.add_many(&[&src, &proxysink, &proxysrc, &sink]) .add_many(&[&src, &proxysink, &proxysrc, &sink])
@ -348,11 +346,11 @@ fn eos() {
let l = glib::MainLoop::new(None, false); let l = glib::MainLoop::new(None, false);
let pipeline = gst::Pipeline::new(None); let pipeline = gst::Pipeline::new(None);
let caps = gst::Caps::new_simple("foo/bar", &[]); let caps = gst::Caps::builder("foo/bar").build();
let src = gst::ElementFactory::make("ts-appsrc", Some("src-eos")).unwrap(); let src = gst::ElementFactory::make("ts-appsrc", Some("src-eos")).unwrap();
src.set_property("caps", &caps).unwrap(); src.set_property("caps", &caps).unwrap();
src.set_property("do-timestamp", &true).unwrap(); src.set_property("do-timestamp", true).unwrap();
src.set_property("context", &CONTEXT).unwrap(); src.set_property("context", &CONTEXT).unwrap();
let queue = gst::ElementFactory::make("ts-queue", Some("queue-eos")).unwrap(); let queue = gst::ElementFactory::make("ts-queue", Some("queue-eos")).unwrap();
@ -363,10 +361,10 @@ fn eos() {
pipeline.add_many(&[&src, &queue, &appsink]).unwrap(); pipeline.add_many(&[&src, &queue, &appsink]).unwrap();
gst::Element::link_many(&[&src, &queue, &appsink]).unwrap(); gst::Element::link_many(&[&src, &queue, &appsink]).unwrap();
appsink.set_property("sync", &false).unwrap(); appsink.set_property("sync", false).unwrap();
appsink.set_property("async", &false).unwrap(); appsink.set_property("async", false).unwrap();
appsink.set_property("emit-signals", &true).unwrap(); appsink.set_property("emit-signals", true).unwrap();
let (sample_notifier, sample_notif_rcv) = mpsc::channel(); let (sample_notifier, sample_notif_rcv) = mpsc::channel();
let (eos_notifier, eos_notif_rcv) = mpsc::channel(); let (eos_notifier, eos_notif_rcv) = mpsc::channel();
let appsink = appsink.dynamic_cast::<gst_app::AppSink>().unwrap(); let appsink = appsink.dynamic_cast::<gst_app::AppSink>().unwrap();
@ -486,22 +484,22 @@ fn premature_shutdown() {
let l = glib::MainLoop::new(None, false); let l = glib::MainLoop::new(None, false);
let pipeline = gst::Pipeline::new(None); let pipeline = gst::Pipeline::new(None);
let caps = gst::Caps::new_simple("foo/bar", &[]); let caps = gst::Caps::builder("foo/bar").build();
let src = gst::ElementFactory::make("ts-appsrc", Some("src-ps")).unwrap(); let src = gst::ElementFactory::make("ts-appsrc", Some("src-ps")).unwrap();
src.set_property("caps", &caps).unwrap(); src.set_property("caps", &caps).unwrap();
src.set_property("do-timestamp", &true).unwrap(); src.set_property("do-timestamp", true).unwrap();
src.set_property("context", &"appsrc-context").unwrap(); src.set_property("context", "appsrc-context").unwrap();
src.set_property("context-wait", &APPSRC_CONTEXT_WAIT) src.set_property("context-wait", APPSRC_CONTEXT_WAIT)
.unwrap(); .unwrap();
let queue = gst::ElementFactory::make("ts-queue", Some("queue-ps")).unwrap(); let queue = gst::ElementFactory::make("ts-queue", Some("queue-ps")).unwrap();
queue.set_property("context", &"queue-context").unwrap(); queue.set_property("context", "queue-context").unwrap();
queue queue
.set_property("context-wait", &QUEUE_CONTEXT_WAIT) .set_property("context-wait", QUEUE_CONTEXT_WAIT)
.unwrap(); .unwrap();
queue queue
.set_property("max-size-buffers", &QUEUE_ITEMS_CAPACITY) .set_property("max-size-buffers", QUEUE_ITEMS_CAPACITY)
.unwrap(); .unwrap();
let appsink = gst::ElementFactory::make("appsink", Some("sink-ps")).unwrap(); let appsink = gst::ElementFactory::make("appsink", Some("sink-ps")).unwrap();
@ -509,9 +507,9 @@ fn premature_shutdown() {
pipeline.add_many(&[&src, &queue, &appsink]).unwrap(); pipeline.add_many(&[&src, &queue, &appsink]).unwrap();
gst::Element::link_many(&[&src, &queue, &appsink]).unwrap(); gst::Element::link_many(&[&src, &queue, &appsink]).unwrap();
appsink.set_property("emit-signals", &true).unwrap(); appsink.set_property("emit-signals", true).unwrap();
appsink.set_property("sync", &false).unwrap(); appsink.set_property("sync", false).unwrap();
appsink.set_property("async", &false).unwrap(); appsink.set_property("async", false).unwrap();
let (appsink_sender, appsink_receiver) = mpsc::channel(); let (appsink_sender, appsink_receiver) = mpsc::channel();

View file

@ -45,11 +45,11 @@ fn test_push() {
fakesrc.link(&proxysink).unwrap(); fakesrc.link(&proxysink).unwrap();
proxysrc.link(&appsink).unwrap(); proxysrc.link(&appsink).unwrap();
fakesrc.set_property("num-buffers", &3i32).unwrap(); fakesrc.set_property("num-buffers", 3i32).unwrap();
proxysink.set_property("proxy-context", &"test1").unwrap(); proxysink.set_property("proxy-context", "test1").unwrap();
proxysrc.set_property("proxy-context", &"test1").unwrap(); proxysrc.set_property("proxy-context", "test1").unwrap();
appsink.set_property("emit-signals", &true).unwrap(); appsink.set_property("emit-signals", true).unwrap();
let samples = Arc::new(Mutex::new(Vec::new())); let samples = Arc::new(Mutex::new(Vec::new()));
@ -117,8 +117,8 @@ fn test_from_pipeline_to_pipeline() {
pipe_2.add_many(&[&pxsrc, &fakesink]).unwrap(); pipe_2.add_many(&[&pxsrc, &fakesink]).unwrap();
pxsrc.link(&fakesink).unwrap(); pxsrc.link(&fakesink).unwrap();
pxsink.set_property("proxy-context", &"test2").unwrap(); pxsink.set_property("proxy-context", "test2").unwrap();
pxsrc.set_property("proxy-context", &"test2").unwrap(); pxsrc.set_property("proxy-context", "test2").unwrap();
pipe_1.set_state(gst::State::Paused).unwrap(); pipe_1.set_state(gst::State::Paused).unwrap();
pipe_2.set_state(gst::State::Paused).unwrap(); pipe_2.set_state(gst::State::Paused).unwrap();
@ -149,11 +149,11 @@ fn test_from_pipeline_to_pipeline_and_back() {
pipe_2.add_many(&[&pxsrc_2, &pxsink_2]).unwrap(); pipe_2.add_many(&[&pxsrc_2, &pxsink_2]).unwrap();
pxsrc_2.link(&pxsink_2).unwrap(); pxsrc_2.link(&pxsink_2).unwrap();
pxsrc_1.set_property("proxy-context", &"test3").unwrap(); pxsrc_1.set_property("proxy-context", "test3").unwrap();
pxsink_2.set_property("proxy-context", &"test3").unwrap(); pxsink_2.set_property("proxy-context", "test3").unwrap();
pxsrc_2.set_property("proxy-context", &"test4").unwrap(); pxsrc_2.set_property("proxy-context", "test4").unwrap();
pxsink_1.set_property("proxy-context", &"test4").unwrap(); pxsink_1.set_property("proxy-context", "test4").unwrap();
pipe_1.set_state(gst::State::Paused).unwrap(); pipe_1.set_state(gst::State::Paused).unwrap();
pipe_2.set_state(gst::State::Paused).unwrap(); pipe_2.set_state(gst::State::Paused).unwrap();

View file

@ -42,9 +42,9 @@ fn test_push() {
fakesrc.link(&queue).unwrap(); fakesrc.link(&queue).unwrap();
queue.link(&appsink).unwrap(); queue.link(&appsink).unwrap();
fakesrc.set_property("num-buffers", &3i32).unwrap(); fakesrc.set_property("num-buffers", 3i32).unwrap();
appsink.set_property("emit-signals", &true).unwrap(); appsink.set_property("emit-signals", true).unwrap();
let samples = Arc::new(Mutex::new(Vec::new())); let samples = Arc::new(Mutex::new(Vec::new()));

View file

@ -56,17 +56,17 @@ fn test_push() {
let tcpclientsrc = gst::ElementFactory::make("ts-tcpclientsrc", None).unwrap(); let tcpclientsrc = gst::ElementFactory::make("ts-tcpclientsrc", None).unwrap();
let appsink = gst::ElementFactory::make("appsink", None).unwrap(); let appsink = gst::ElementFactory::make("appsink", None).unwrap();
appsink.set_property("sync", &false).unwrap(); appsink.set_property("sync", false).unwrap();
appsink.set_property("async", &false).unwrap(); appsink.set_property("async", false).unwrap();
pipeline.add_many(&[&tcpclientsrc, &appsink]).unwrap(); pipeline.add_many(&[&tcpclientsrc, &appsink]).unwrap();
tcpclientsrc.link(&appsink).unwrap(); tcpclientsrc.link(&appsink).unwrap();
let caps = gst::Caps::new_simple("foo/bar", &[]); let caps = gst::Caps::builder("foo/bar").build();
tcpclientsrc.set_property("caps", &caps).unwrap(); tcpclientsrc.set_property("caps", &caps).unwrap();
tcpclientsrc.set_property("port", &5000i32).unwrap(); tcpclientsrc.set_property("port", 5000i32).unwrap();
appsink.set_property("emit-signals", &true).unwrap(); appsink.set_property("emit-signals", true).unwrap();
let samples = Arc::new(Mutex::new(Vec::new())); let samples = Arc::new(Mutex::new(Vec::new()));

View file

@ -99,7 +99,7 @@ fn test_client_management() {
/* The client properties is writable too */ /* The client properties is writable too */
udpsink udpsink
.set_property("clients", &"127.0.0.1:5004,192.168.1.1:57") .set_property("clients", "127.0.0.1:5004,192.168.1.1:57")
.unwrap(); .unwrap();
let clients = udpsink let clients = udpsink
.property("clients") .property("clients")
@ -125,7 +125,7 @@ fn test_chain() {
h.set_src_caps_str("foo/bar"); h.set_src_caps_str("foo/bar");
{ {
let udpsink = h.element().unwrap(); let udpsink = h.element().unwrap();
udpsink.set_property("clients", &"127.0.0.1:5005").unwrap(); udpsink.set_property("clients", "127.0.0.1:5005").unwrap();
} }
thread::spawn(move || { thread::spawn(move || {

View file

@ -35,12 +35,12 @@ fn test_push() {
let mut h = gst_check::Harness::new("ts-udpsrc"); let mut h = gst_check::Harness::new("ts-udpsrc");
let caps = gst::Caps::new_simple("foo/bar", &[]); let caps = gst::Caps::builder("foo/bar").build();
{ {
let udpsrc = h.element().unwrap(); let udpsrc = h.element().unwrap();
udpsrc.set_property("caps", &caps).unwrap(); udpsrc.set_property("caps", &caps).unwrap();
udpsrc.set_property("port", &5000i32).unwrap(); udpsrc.set_property("port", 5000i32).unwrap();
udpsrc.set_property("context", &"test-push").unwrap(); udpsrc.set_property("context", "test-push").unwrap();
} }
h.play(); h.play();
@ -105,10 +105,8 @@ fn test_socket_reuse() {
{ {
let udpsrc = ts_src_h.element().unwrap(); let udpsrc = ts_src_h.element().unwrap();
udpsrc.set_property("port", &6000i32).unwrap(); udpsrc.set_property("port", 6000i32).unwrap();
udpsrc udpsrc.set_property("context", "test-socket-reuse").unwrap();
.set_property("context", &"test-socket-reuse")
.unwrap();
} }
ts_src_h.play(); ts_src_h.play();
@ -122,18 +120,16 @@ fn test_socket_reuse() {
let udpsink = sink_h.element().unwrap(); let udpsink = sink_h.element().unwrap();
udpsink.set_property("socket", &socket).unwrap(); udpsink.set_property("socket", &socket).unwrap();
udpsink.set_property("host", &"127.0.0.1").unwrap(); udpsink.set_property("host", "127.0.0.1").unwrap();
udpsink.set_property("port", &6001i32).unwrap(); udpsink.set_property("port", 6001i32).unwrap();
} }
sink_h.play(); sink_h.play();
sink_h.set_src_caps_str("application/test"); sink_h.set_src_caps_str("application/test");
{ {
let udpsrc = ts_src_h2.element().unwrap(); let udpsrc = ts_src_h2.element().unwrap();
udpsrc.set_property("port", &6001i32).unwrap(); udpsrc.set_property("port", 6001i32).unwrap();
udpsrc udpsrc.set_property("context", "test-socket-reuse").unwrap();
.set_property("context", &"test-socket-reuse")
.unwrap();
} }
ts_src_h2.play(); ts_src_h2.play();

View file

@ -429,11 +429,11 @@ impl ReqwestHttpSrc {
headers.append(field.clone(), value); headers.append(field.clone(), value);
}; };
if let Ok(values) = value.get::<gst::Array>() { if let Ok(values) = value.get::<gst::ArrayRef>() {
for value in values.as_slice() { for value in values.as_slice() {
append_header(&field, value); append_header(&field, value);
} }
} else if let Ok(values) = value.get::<gst::List>() { } else if let Ok(values) = value.get::<gst::ListRef>() {
for value in values.as_slice() { for value in values.as_slice() {
append_header(&field, value); append_header(&field, value);
} }
@ -552,7 +552,7 @@ impl ReqwestHttpSrc {
.and_then(|s| s.parse::<i32>().ok()) .and_then(|s| s.parse::<i32>().ok())
.map(|icy_metaint| { .map(|icy_metaint| {
gst::Caps::builder("application/x-icy") gst::Caps::builder("application/x-icy")
.field("metadata-interval", &icy_metaint) .field("metadata-interval", icy_metaint)
.build() .build()
}); });
@ -578,10 +578,10 @@ impl ReqwestHttpSrc {
caps = Some( caps = Some(
gst::Caps::builder("audio/x-unaligned-raw") gst::Caps::builder("audio/x-unaligned-raw")
.field("format", &"S16BE") .field("format", "S16BE")
.field("layout", &"interleaved") .field("layout", "interleaved")
.field("channels", &channels) .field("channels", channels)
.field("rate", &rate) .field("rate", rate)
.build(), .build(),
); );
} }

View file

@ -142,7 +142,7 @@ impl Harness {
}); });
let local_addr = futures::executor::block_on(local_addr_receiver).unwrap(); let local_addr = futures::executor::block_on(local_addr_receiver).unwrap();
src.set_property("location", &format!("http://{}/", local_addr)) src.set_property("location", format!("http://{}/", local_addr))
.unwrap(); .unwrap();
// Let the test setup anything needed on the HTTP source now // Let the test setup anything needed on the HTTP source now
@ -410,10 +410,10 @@ fn test_basic_request_inverted_defaults() {
Response::new(Body::from("Hello World")) Response::new(Body::from("Hello World"))
}, },
|src| { |src| {
src.set_property("keep-alive", &false).unwrap(); src.set_property("keep-alive", false).unwrap();
src.set_property("compress", &true).unwrap(); src.set_property("compress", true).unwrap();
src.set_property("iradio-mode", &false).unwrap(); src.set_property("iradio-mode", false).unwrap();
src.set_property("user-agent", &"test user-agent").unwrap(); src.set_property("user-agent", "test user-agent").unwrap();
}, },
); );
@ -485,10 +485,10 @@ fn test_extra_headers() {
src.set_property( src.set_property(
"extra-headers", "extra-headers",
&gst::Structure::builder("headers") &gst::Structure::builder("headers")
.field("foo", &"bar") .field("foo", "bar")
.field("baz", &1i32) .field("baz", 1i32)
.field("list", &gst::List::new(&[&1i32, &2i32])) .field("list", gst::List::new([1i32, 2i32]))
.field("array", &gst::Array::new(&[&1i32, &2i32])) .field("array", gst::Array::new([1i32, 2i32]))
.build(), .build(),
) )
.unwrap(); .unwrap();
@ -650,8 +650,8 @@ fn test_iradio_mode() {
assert_eq!( assert_eq!(
caps, caps,
gst::Caps::builder("application/x-icy") gst::Caps::builder("application/x-icy")
.field("metadata-interval", &8192i32) .field("metadata-interval", 8192i32)
.field("content-type", &"audio/mpeg; rate=44100") .field("content-type", "audio/mpeg; rate=44100")
.build() .build()
); );
@ -726,10 +726,10 @@ fn test_audio_l16() {
assert_eq!( assert_eq!(
caps, caps,
gst::Caps::builder("audio/x-unaligned-raw") gst::Caps::builder("audio/x-unaligned-raw")
.field("format", &"S16BE") .field("format", "S16BE")
.field("layout", &"interleaved") .field("layout", "interleaved")
.field("channels", &2i32) .field("channels", 2i32)
.field("rate", &48_000i32) .field("rate", 48_000i32)
.build() .build()
); );
} }
@ -760,8 +760,8 @@ fn test_authorization() {
} }
}, },
|src| { |src| {
src.set_property("user-id", &"user").unwrap(); src.set_property("user-id", "user").unwrap();
src.set_property("user-pw", &"password").unwrap(); src.set_property("user-pw", "password").unwrap();
}, },
); );
@ -860,7 +860,7 @@ fn test_network_error() {
let mut h = Harness::new( let mut h = Harness::new(
|_req| unreachable!(), |_req| unreachable!(),
|src| { |src| {
src.set_property("location", &"http://0.0.0.0:0").unwrap(); src.set_property("location", "http://0.0.0.0:0").unwrap();
}, },
); );

View file

@ -441,7 +441,7 @@ impl Transcriber {
); );
let caps = gst::Caps::builder("text/x-raw") let caps = gst::Caps::builder("text/x-raw")
.field("format", &"utf8") .field("format", "utf8")
.build(); .build();
events.push( events.push(
gst::event::Caps::builder(&caps) gst::event::Caps::builder(&caps)
@ -1275,7 +1275,7 @@ impl ElementImpl for Transcriber {
fn pad_templates() -> &'static [gst::PadTemplate] { fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| { static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
let src_caps = gst::Caps::builder("text/x-raw") let src_caps = gst::Caps::builder("text/x-raw")
.field("format", &"utf8") .field("format", "utf8")
.build(); .build();
let src_pad_template = gst::PadTemplate::new( let src_pad_template = gst::PadTemplate::new(
"src", "src",
@ -1286,9 +1286,9 @@ impl ElementImpl for Transcriber {
.unwrap(); .unwrap();
let sink_caps = gst::Caps::builder("audio/x-raw") let sink_caps = gst::Caps::builder("audio/x-raw")
.field("format", &"S16LE") .field("format", "S16LE")
.field("rate", &gst::IntRange::<i32>::new(8000, 48000)) .field("rate", gst::IntRange::new(8000i32, 48000))
.field("channels", &1) .field("channels", 1)
.build(); .build();
let sink_pad_template = gst::PadTemplate::new( let sink_pad_template = gst::PadTemplate::new(
"sink", "sink",

View file

@ -89,10 +89,11 @@ fn test_parse() {
match ev.view() { match ev.view() {
EventView::Caps(ev) => { EventView::Caps(ev) => {
assert!(ev.caps().is_strictly_equal(&gst::Caps::new_simple( assert!(ev.caps().is_strictly_equal(
"application/x-json", &gst::Caps::builder("application/x-json")
&[("format", &"test")] .field("format", "test")
))); .build()
));
} }
_ => (), _ => (),
} }

View file

@ -192,7 +192,7 @@ impl ObjectImpl for RegEx {
"commands" => { "commands" => {
let mut state = self.state.lock().unwrap(); let mut state = self.state.lock().unwrap();
state.commands = vec![]; state.commands = vec![];
let commands: gst::Array = value.get().expect("type checked upstream"); let commands = value.get::<gst::ArrayRef>().expect("type checked upstream");
for command in commands.as_slice() { for command in commands.as_slice() {
let s = match command let s = match command
.get::<Option<gst::Structure>>() .get::<Option<gst::Structure>>()
@ -258,16 +258,16 @@ impl ObjectImpl for RegEx {
match command.operation { match command.operation {
Operation::ReplaceAll(ref replacement) => { Operation::ReplaceAll(ref replacement) => {
commands.push( commands.push(
gst::Structure::new( gst::Structure::builder("replace-all")
"replace-all", .field("pattern", &command.pattern)
&[("pattern", &command.pattern), ("replacement", &replacement)], .field("replacement", replacement)
) .build()
.to_send_value(), .to_send_value(),
); );
} }
} }
} }
gst::Array::from_owned(commands).to_value() gst::Array::from(commands).to_value()
} }
_ => unimplemented!(), _ => unimplemented!(),
} }
@ -293,7 +293,7 @@ impl ElementImpl for RegEx {
fn pad_templates() -> &'static [gst::PadTemplate] { fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| { static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
let caps = gst::Caps::builder("text/x-raw") let caps = gst::Caps::builder("text/x-raw")
.field("format", &"utf8") .field("format", "utf8")
.build(); .build();
let src_pad_template = gst::PadTemplate::new( let src_pad_template = gst::PadTemplate::new(
"src", "src",

View file

@ -40,12 +40,12 @@ fn test_replace_all() {
{ {
let regex = h.element().expect("Could not create regex"); let regex = h.element().expect("Could not create regex");
let command = gst::Structure::new( let command = gst::Structure::builder("replace-all")
"replace-all", .field("pattern", "crap")
&[("pattern", &"crap"), ("replacement", &"trap")], .field("replacement", "trap")
); .build();
let commands = gst::Array::from_owned(vec![command.to_send_value()]); let commands = gst::Array::from(vec![command.to_send_value()]);
regex.set_property("commands", &commands).unwrap(); regex.set_property("commands", &commands).unwrap();
} }

View file

@ -632,7 +632,7 @@ impl ElementImpl for TextWrap {
fn pad_templates() -> &'static [gst::PadTemplate] { fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| { static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
let caps = gst::Caps::builder("text/x-raw") let caps = gst::Caps::builder("text/x-raw")
.field("format", &"utf8") .field("format", "utf8")
.build(); .build();
let src_pad_template = gst::PadTemplate::new( let src_pad_template = gst::PadTemplate::new(
"src", "src",

View file

@ -39,7 +39,7 @@ fn test_columns() {
{ {
let wrap = h.element().expect("Could not create textwrap"); let wrap = h.element().expect("Could not create textwrap");
wrap.set_property("columns", &5u32).unwrap(); wrap.set_property("columns", 5u32).unwrap();
} }
h.set_src_caps_str("text/x-raw, format=utf8"); h.set_src_caps_str("text/x-raw, format=utf8");
@ -77,8 +77,8 @@ fn test_lines() {
{ {
let wrap = h.element().expect("Could not create textwrap"); let wrap = h.element().expect("Could not create textwrap");
wrap.set_property("columns", &5u32).unwrap(); wrap.set_property("columns", 5u32).unwrap();
wrap.set_property("lines", &2u32).unwrap(); wrap.set_property("lines", 2u32).unwrap();
} }
h.set_src_caps_str("text/x-raw, format=utf8"); h.set_src_caps_str("text/x-raw, format=utf8");

View file

@ -64,7 +64,7 @@ impl ObjectSubclass for ProgressBin {
// Create the progressreport element. // Create the progressreport element.
let progress = gst::ElementFactory::make("progressreport", Some("progress")).unwrap(); let progress = gst::ElementFactory::make("progressreport", Some("progress")).unwrap();
// Don't let progressreport print to stdout itself // Don't let progressreport print to stdout itself
progress.set_property("silent", &true).unwrap(); progress.set_property("silent", true).unwrap();
// Return an instance of our struct // Return an instance of our struct
Self { Self {

View file

@ -205,27 +205,24 @@ impl ElementImpl for Rgb2Gray {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| { static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
// On the src pad, we can produce BGRx and GRAY8 of any // On the src pad, we can produce BGRx and GRAY8 of any
// width/height and with any framerate // width/height and with any framerate
let caps = gst::Caps::new_simple( let caps = gst::Caps::builder("video/x-raw")
"video/x-raw", .field(
&[ "format",
( gst::List::new([
"format", gst_video::VideoFormat::Bgrx.to_str(),
&gst::List::new(&[ gst_video::VideoFormat::Gray8.to_str(),
&gst_video::VideoFormat::Bgrx.to_str(), ]),
&gst_video::VideoFormat::Gray8.to_str(), )
]), .field("width", gst::IntRange::new(0, i32::MAX))
.field("height", gst::IntRange::new(0, i32::MAX))
.field(
"framerate",
gst::FractionRange::new(
gst::Fraction::new(0, 1),
gst::Fraction::new(i32::MAX, 1),
), ),
("width", &gst::IntRange::<i32>::new(0, i32::MAX)), )
("height", &gst::IntRange::<i32>::new(0, i32::MAX)), .build();
(
"framerate",
&gst::FractionRange::new(
gst::Fraction::new(0, 1),
gst::Fraction::new(i32::MAX, 1),
),
),
],
);
// The src pad template must be named "src" for basetransform // The src pad template must be named "src" for basetransform
// and specific a pad that is always there // and specific a pad that is always there
let src_pad_template = gst::PadTemplate::new( let src_pad_template = gst::PadTemplate::new(
@ -238,21 +235,18 @@ impl ElementImpl for Rgb2Gray {
// On the sink pad, we can accept BGRx of any // On the sink pad, we can accept BGRx of any
// width/height and with any framerate // width/height and with any framerate
let caps = gst::Caps::new_simple( let caps = gst::Caps::builder("video/x-raw")
"video/x-raw", .field("format", gst_video::VideoFormat::Bgrx.to_str())
&[ .field("width", gst::IntRange::new(0, i32::MAX))
("format", &gst_video::VideoFormat::Bgrx.to_str()), .field("height", gst::IntRange::new(0, i32::MAX))
("width", &gst::IntRange::<i32>::new(0, i32::MAX)), .field(
("height", &gst::IntRange::<i32>::new(0, i32::MAX)), "framerate",
( gst::FractionRange::new(
"framerate", gst::Fraction::new(0, 1),
&gst::FractionRange::new( gst::Fraction::new(i32::MAX, 1),
gst::Fraction::new(0, 1),
gst::Fraction::new(i32::MAX, 1),
),
), ),
], )
); .build();
// The sink pad template must be named "sink" for basetransform // The sink pad template must be named "sink" for basetransform
// and specific a pad that is always there // and specific a pad that is always there
let sink_pad_template = gst::PadTemplate::new( let sink_pad_template = gst::PadTemplate::new(

View file

@ -360,21 +360,18 @@ impl ElementImpl for SineSrc {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| { static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
// On the src pad, we can produce F32/F64 with any sample rate // On the src pad, we can produce F32/F64 with any sample rate
// and any number of channels // and any number of channels
let caps = gst::Caps::new_simple( let caps = gst::Caps::builder("audio/x-raw")
"audio/x-raw", .field(
&[ "format",
( gst::List::new([
"format", gst_audio::AUDIO_FORMAT_F32.to_str(),
&gst::List::new(&[ gst_audio::AUDIO_FORMAT_F64.to_str(),
&gst_audio::AUDIO_FORMAT_F32.to_str(), ]),
&gst_audio::AUDIO_FORMAT_F64.to_str(), )
]), .field("layout", "interleaved")
), .field("rate", gst::IntRange::new(1, i32::MAX))
("layout", &"interleaved"), .field("channels", gst::IntRange::new(1, i32::MAX))
("rate", &gst::IntRange::<i32>::new(1, i32::MAX)), .build();
("channels", &gst::IntRange::<i32>::new(1, i32::MAX)),
],
);
// The src pad template must be named "src" for basesrc // The src pad template must be named "src" for basesrc
// and specific a pad that is always there // and specific a pad that is always there
let src_pad_template = gst::PadTemplate::new( let src_pad_template = gst::PadTemplate::new(

View file

@ -340,27 +340,24 @@ To be able to declare what kinds of pads an element can create (they are not nec
In our case we only have always pads, one sink pad called “sink”, on which we can only accept RGB (BGRx to be exact) data with any width/height/framerate and one source pad called “src”, on which we will produce either RGB (BGRx) data or GRAY8 (8-bit grayscale) data. We do this by adding the following code to the class_init function. In our case we only have always pads, one sink pad called “sink”, on which we can only accept RGB (BGRx to be exact) data with any width/height/framerate and one source pad called “src”, on which we will produce either RGB (BGRx) data or GRAY8 (8-bit grayscale) data. We do this by adding the following code to the class_init function.
```rust ```rust
let caps = gst::Caps::new_simple( let caps = gst::Caps::builder("video/x-raw")
"video/x-raw", .field(
&[ "format",
( gst::List::new([
"format", gst_video::VideoFormat::Bgrx.to_str(),
&gst::List::new(&[ gst_video::VideoFormat::Gray8.to_str(),
&gst_video::VideoFormat::Bgrx.to_str(), ]),
&gst_video::VideoFormat::Gray8.to_str(), )
]), .field("width", gst::IntRange::new(0, i32::MAX))
.field("height", gst::IntRange::new(0, i32::MAX))
.field(
"framerate",
gst::FractionRange::new(
gst::Fraction::new(0, 1),
gst::Fraction::new(i32::MAX, 1),
), ),
("width", &gst::IntRange::<i32>::new(0, i32::MAX)), )
("height", &gst::IntRange::<i32>::new(0, i32::MAX)), .build();
(
"framerate",
&gst::FractionRange::new(
gst::Fraction::new(0, 1),
gst::Fraction::new(i32::MAX, 1),
),
),
],
);
let src_pad_template = gst::PadTemplate::new( let src_pad_template = gst::PadTemplate::new(
"src", "src",
gst::PadDirection::Src, gst::PadDirection::Src,
@ -371,21 +368,18 @@ In our case we only have always pads, one sink pad called “sink”, on which w
klass.add_pad_template(src_pad_template); klass.add_pad_template(src_pad_template);
let caps = gst::Caps::new_simple( let caps = gst::Caps::builder("video/x-raw")
"video/x-raw", .field("format", gst_video::VideoFormat::Bgrx.to_str())
&[ .field("width", gst::IntRange::new(0, i32::MAX))
("format", &gst_video::VideoFormat::Bgrx.to_str()), .field("height", gst::IntRange:::new(0, i32::MAX))
("width", &gst::IntRange::<i32>::new(0, i32::MAX)), .field(
("height", &gst::IntRange::<i32>::new(0, i32::MAX)), "framerate",
( gst::FractionRange::new(
"framerate", gst::Fraction::new(0, 1),
&gst::FractionRange::new( gst::Fraction::new(i32::MAX, 1),
gst::Fraction::new(0, 1),
gst::Fraction::new(i32::MAX, 1),
),
), ),
], )
); .build();
let sink_pad_template = gst::PadTemplate::new( let sink_pad_template = gst::PadTemplate::new(
"sink", "sink",
gst::PadDirection::Sink, gst::PadDirection::Sink,

View file

@ -139,21 +139,18 @@ impl ObjectSubclass for SineSrc {
// On the src pad, we can produce F32/F64 with any sample rate // On the src pad, we can produce F32/F64 with any sample rate
// and any number of channels // and any number of channels
let caps = gst::Caps::new_simple( let caps = gst::Caps::builder("audio/x-raw")
"audio/x-raw", .field(
&[ "format",
( gst::List::new([
"format", gst_audio::AUDIO_FORMAT_F32.to_str(),
&gst::List::new(&[ gst_audio::AUDIO_FORMAT_F64.to_str(),
&gst_audio::AUDIO_FORMAT_F32.to_str(), ]),
&gst_audio::AUDIO_FORMAT_F64.to_str(), )
]), .field("layout", "interleaved")
), .field("rate", gst::IntRange::new(1, i32::MAX))
("layout", &"interleaved"), .field("channels", gst::IntRange::new(1, i32::MAX))
("rate", &gst::IntRange::<i32>::new(1, i32::MAX)), .build();
("channels", &gst::IntRange::<i32>::new(1, i32::MAX)),
],
);
// The src pad template must be named "src" for basesrc // The src pad template must be named "src" for basesrc
// and specific a pad that is always there // and specific a pad that is always there
let src_pad_template = gst::PadTemplate::new( let src_pad_template = gst::PadTemplate::new(

View file

@ -42,7 +42,7 @@ fn create_pipeline() -> (gst::Pipeline, gst::Pad, gst::Element, gtk::Widget) {
let fallbackswitch = gst::ElementFactory::make("fallbackswitch", None).unwrap(); let fallbackswitch = gst::ElementFactory::make("fallbackswitch", None).unwrap();
fallbackswitch fallbackswitch
.set_property("timeout", &gst::ClockTime::SECOND) .set_property("timeout", gst::ClockTime::SECOND)
.unwrap(); .unwrap();
let decodebin = gst::ElementFactory::make("decodebin", None).unwrap(); let decodebin = gst::ElementFactory::make("decodebin", None).unwrap();

View file

@ -58,9 +58,9 @@ impl Default for Stats {
impl Stats { impl Stats {
fn to_structure(&self) -> gst::Structure { fn to_structure(&self) -> gst::Structure {
gst::Structure::builder("application/x-fallbacksrc-stats") gst::Structure::builder("application/x-fallbacksrc-stats")
.field("num-retry", &self.num_retry) .field("num-retry", self.num_retry)
.field("last-retry-reason", &self.last_retry_reason) .field("last-retry-reason", self.last_retry_reason)
.field("buffering-percent", &self.buffering_percent) .field("buffering-percent", self.buffering_percent)
.build() .build()
} }
} }
@ -833,10 +833,10 @@ impl FallbackSrc {
.get::<&str>() .get::<&str>()
.expect("Wrong type returned from update-uri signal"); .expect("Wrong type returned from update-uri signal");
source.set_property("uri", &uri).unwrap(); source.set_property("uri", uri).unwrap();
source.set_property("use-buffering", &true).unwrap(); source.set_property("use-buffering", true).unwrap();
source source
.set_property("buffer-duration", &buffer_duration) .set_property("buffer-duration", buffer_duration)
.unwrap(); .unwrap();
source source
@ -846,7 +846,7 @@ impl FallbackSrc {
// Handle any async state changes internally, they don't affect the pipeline because we // Handle any async state changes internally, they don't affect the pipeline because we
// convert everything to a live stream // convert everything to a live stream
source.set_property("async-handling", &true).unwrap(); source.set_property("async-handling", true).unwrap();
// Don't let the bin handle state changes of the source. We want to do it manually to catch // Don't let the bin handle state changes of the source. We want to do it manually to catch
// possible errors and retry, without causing the whole bin state change to fail // possible errors and retry, without causing the whole bin state change to fail
source.set_locked_state(true); source.set_locked_state(true);
@ -897,7 +897,7 @@ impl FallbackSrc {
audiotestsrc audiotestsrc
.set_property_from_str("wave", "silence") .set_property_from_str("wave", "silence")
.unwrap(); .unwrap();
audiotestsrc.set_property("is-live", &true).unwrap(); audiotestsrc.set_property("is-live", true).unwrap();
let srcpad = audiotestsrc.static_pad("src").unwrap(); let srcpad = audiotestsrc.static_pad("src").unwrap();
input input
@ -931,7 +931,7 @@ impl FallbackSrc {
let clocksync = gst::ElementFactory::make("clocksync", None) let clocksync = gst::ElementFactory::make("clocksync", None)
.or_else(|_| -> Result<_, glib::BoolError> { .or_else(|_| -> Result<_, glib::BoolError> {
let identity = gst::ElementFactory::make("identity", None)?; let identity = gst::ElementFactory::make("identity", None)?;
identity.set_property("sync", &true).unwrap(); identity.set_property("sync", true).unwrap();
Ok(identity) Ok(identity)
}) })
.expect("No clocksync or identity found"); .expect("No clocksync or identity found");
@ -960,12 +960,12 @@ impl FallbackSrc {
let src = FallbackSrc::from_instance(&element); let src = FallbackSrc::from_instance(&element);
src.handle_switch_active_pad_change(&element); src.handle_switch_active_pad_change(&element);
}); });
switch.set_property("timeout", &timeout.nseconds()).unwrap(); switch.set_property("timeout", timeout.nseconds()).unwrap();
switch switch
.set_property("min-upstream-latency", &min_latency.nseconds()) .set_property("min-upstream-latency", min_latency.nseconds())
.unwrap(); .unwrap();
switch switch
.set_property("immediate-fallback", &immediate_fallback) .set_property("immediate-fallback", immediate_fallback)
.unwrap(); .unwrap();
gst::Element::link_pads(&fallback_input, Some("src"), &switch, Some("fallback_sink")) gst::Element::link_pads(&fallback_input, Some("src"), &switch, Some("fallback_sink"))
@ -1341,7 +1341,7 @@ impl FallbackSrc {
gst_debug!(CAT, "image stream, inserting imagefreeze"); gst_debug!(CAT, "image stream, inserting imagefreeze");
element.add(&imagefreeze).unwrap(); element.add(&imagefreeze).unwrap();
imagefreeze.set_property("is-live", &true).unwrap(); imagefreeze.set_property("is-live", true).unwrap();
if imagefreeze.sync_state_with_parent().is_err() { if imagefreeze.sync_state_with_parent().is_err() {
gst_error!(CAT, obj: element, "imagefreeze failed to change state",); gst_error!(CAT, obj: element, "imagefreeze failed to change state",);
return Err(gst::error_msg!( return Err(gst::error_msg!(

View file

@ -303,7 +303,7 @@ impl VideoFallbackSource {
.or_else(|_| -> Result<_, glib::BoolError> { .or_else(|_| -> Result<_, glib::BoolError> {
let identity = let identity =
gst::ElementFactory::make("identity", Some("fallback_clocksync"))?; gst::ElementFactory::make("identity", Some("fallback_clocksync"))?;
identity.set_property("sync", &true).unwrap(); identity.set_property("sync", true).unwrap();
Ok(identity) Ok(identity)
}) })
.expect("No clocksync or identity found"); .expect("No clocksync or identity found");
@ -341,7 +341,7 @@ impl VideoFallbackSource {
]) ])
.unwrap(); .unwrap();
if imagefreeze.set_property("is-live", &true).is_err() { if imagefreeze.set_property("is-live", true).is_err() {
gst_error!( gst_error!(
CAT, CAT,
obj: element, obj: element,
@ -425,7 +425,7 @@ impl VideoFallbackSource {
videotestsrc videotestsrc
.set_property_from_str("pattern", "black") .set_property_from_str("pattern", "black")
.unwrap(); .unwrap();
videotestsrc.set_property("is-live", &true).unwrap(); videotestsrc.set_property("is-live", true).unwrap();
videotestsrc.static_pad("src").unwrap() videotestsrc.static_pad("src").unwrap()
} }

View file

@ -1134,10 +1134,10 @@ impl AggregatorImpl for FallbackSwitch {
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) = pad_state.video_info { } else if let Some(ref video_info) = pad_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

View file

@ -371,30 +371,30 @@ fn setup_pipeline(with_live_fallback: Option<bool>) -> Pipeline {
.unwrap() .unwrap()
.downcast::<gst_app::AppSrc>() .downcast::<gst_app::AppSrc>()
.unwrap(); .unwrap();
src.set_property("is-live", &true).unwrap(); src.set_property("is-live", true).unwrap();
src.set_property("format", &gst::Format::Time).unwrap(); src.set_property("format", gst::Format::Time).unwrap();
src.set_property("min-latency", &(10i64)).unwrap(); src.set_property("min-latency", 10i64).unwrap();
src.set_property( src.set_property(
"caps", "caps",
&gst::Caps::builder("video/x-raw") &gst::Caps::builder("video/x-raw")
.field("format", &"ARGB") .field("format", "ARGB")
.field("width", &320) .field("width", 320)
.field("height", &240) .field("height", 240)
.field("framerate", &gst::Fraction::new(1, 1)) .field("framerate", gst::Fraction::new(1, 1))
.build(), .build(),
) )
.unwrap(); .unwrap();
let switch = gst::ElementFactory::make("fallbackswitch", Some("switch")).unwrap(); let switch = gst::ElementFactory::make("fallbackswitch", Some("switch")).unwrap();
switch switch
.set_property("timeout", &(3 * gst::ClockTime::SECOND)) .set_property("timeout", 3 * gst::ClockTime::SECOND)
.unwrap(); .unwrap();
let sink = gst::ElementFactory::make("appsink", Some("sink")) let sink = gst::ElementFactory::make("appsink", Some("sink"))
.unwrap() .unwrap()
.downcast::<gst_app::AppSink>() .downcast::<gst_app::AppSink>()
.unwrap(); .unwrap();
sink.set_property("sync", &false).unwrap(); sink.set_property("sync", false).unwrap();
let queue = gst::ElementFactory::make("queue", None).unwrap(); let queue = gst::ElementFactory::make("queue", None).unwrap();
@ -410,19 +410,19 @@ fn setup_pipeline(with_live_fallback: Option<bool>) -> Pipeline {
.unwrap() .unwrap()
.downcast::<gst_app::AppSrc>() .downcast::<gst_app::AppSrc>()
.unwrap(); .unwrap();
fallback_src.set_property("is-live", &live).unwrap(); fallback_src.set_property("is-live", live).unwrap();
fallback_src fallback_src
.set_property("format", &gst::Format::Time) .set_property("format", gst::Format::Time)
.unwrap(); .unwrap();
fallback_src.set_property("min-latency", &(10i64)).unwrap(); fallback_src.set_property("min-latency", 10i64).unwrap();
fallback_src fallback_src
.set_property( .set_property(
"caps", "caps",
&gst::Caps::builder("video/x-raw") &gst::Caps::builder("video/x-raw")
.field("format", &"ARGB") .field("format", "ARGB")
.field("width", &160) .field("width", 160)
.field("height", &120) .field("height", 120)
.field("framerate", &gst::Fraction::new(1, 1)) .field("framerate", gst::Fraction::new(1, 1))
.build(), .build(),
) )
.unwrap(); .unwrap();

View file

@ -33,12 +33,12 @@ fn create_pipeline() -> (
let pipeline = gst::Pipeline::new(None); let pipeline = gst::Pipeline::new(None);
let video_src = gst::ElementFactory::make("videotestsrc", None).unwrap(); let video_src = gst::ElementFactory::make("videotestsrc", None).unwrap();
video_src.set_property("is-live", &true).unwrap(); video_src.set_property("is-live", true).unwrap();
video_src.set_property_from_str("pattern", "ball").unwrap(); video_src.set_property_from_str("pattern", "ball").unwrap();
let timeoverlay = gst::ElementFactory::make("timeoverlay", None).unwrap(); let timeoverlay = gst::ElementFactory::make("timeoverlay", None).unwrap();
timeoverlay timeoverlay
.set_property("font-desc", &"Monospace 20") .set_property("font-desc", "Monospace 20")
.unwrap(); .unwrap();
let video_tee = gst::ElementFactory::make("tee", None).unwrap(); let video_tee = gst::ElementFactory::make("tee", None).unwrap();
@ -62,12 +62,12 @@ fn create_pipeline() -> (
}; };
let video_enc = gst::ElementFactory::make("x264enc", None).unwrap(); let video_enc = gst::ElementFactory::make("x264enc", None).unwrap();
video_enc.set_property("rc-lookahead", &10i32).unwrap(); video_enc.set_property("rc-lookahead", 10i32).unwrap();
video_enc.set_property("key-int-max", &30u32).unwrap(); video_enc.set_property("key-int-max", 30u32).unwrap();
let video_parse = gst::ElementFactory::make("h264parse", None).unwrap(); let video_parse = gst::ElementFactory::make("h264parse", None).unwrap();
let audio_src = gst::ElementFactory::make("audiotestsrc", None).unwrap(); let audio_src = gst::ElementFactory::make("audiotestsrc", None).unwrap();
audio_src.set_property("is-live", &true).unwrap(); audio_src.set_property("is-live", true).unwrap();
audio_src.set_property_from_str("wave", "ticks").unwrap(); audio_src.set_property_from_str("wave", "ticks").unwrap();
let audio_tee = gst::ElementFactory::make("tee", None).unwrap(); let audio_tee = gst::ElementFactory::make("tee", None).unwrap();
@ -90,11 +90,9 @@ fn create_pipeline() -> (
let mux = gst::ElementFactory::make("mp4mux", None).unwrap(); let mux = gst::ElementFactory::make("mp4mux", None).unwrap();
let file_sink = gst::ElementFactory::make("filesink", None).unwrap(); let file_sink = gst::ElementFactory::make("filesink", None).unwrap();
file_sink file_sink.set_property("location", "recording.mp4").unwrap();
.set_property("location", &"recording.mp4") file_sink.set_property("async", false).unwrap();
.unwrap(); file_sink.set_property("sync", false).unwrap();
file_sink.set_property("async", &false).unwrap();
file_sink.set_property("sync", &false).unwrap();
pipeline pipeline
.add_many(&[ .add_many(&[
@ -262,7 +260,7 @@ fn create_ui(app: &gtk::Application) {
.unwrap() .unwrap()
.get::<bool>() .get::<bool>()
.unwrap(); .unwrap();
togglerecord.set_property("record", &recording).unwrap(); togglerecord.set_property("record", recording).unwrap();
button.set_label(if recording { "Stop" } else { "Record" }); button.set_label(if recording { "Stop" } else { "Record" });
}); });

View file

@ -232,8 +232,8 @@ impl HandleData for gst::Buffer {
} else if let Some(ref video_info) = state.video_info { } else if let Some(ref video_info) = state.video_info {
if video_info.fps() != 0.into() { if video_info.fps() != 0.into() {
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

View file

@ -53,7 +53,7 @@ fn setup_sender_receiver(
thread::JoinHandle<()>, thread::JoinHandle<()>,
) { ) {
let fakesink = gst::ElementFactory::make("fakesink", None).unwrap(); let fakesink = gst::ElementFactory::make("fakesink", None).unwrap();
fakesink.set_property("async", &false).unwrap(); fakesink.set_property("async", false).unwrap();
pipeline.add(&fakesink).unwrap(); pipeline.add(&fakesink).unwrap();
let main_stream = pad == "src"; let main_stream = pad == "src";
@ -111,17 +111,17 @@ fn setup_sender_receiver(
assert!(sinkpad.send_event(gst::event::StreamStart::new("test"))); assert!(sinkpad.send_event(gst::event::StreamStart::new("test")));
let caps = if main_stream { let caps = if main_stream {
gst::Caps::builder("video/x-raw") gst::Caps::builder("video/x-raw")
.field("format", &"ARGB") .field("format", "ARGB")
.field("width", &320i32) .field("width", 320i32)
.field("height", &240i32) .field("height", 240i32)
.field("framerate", &gst::Fraction::new(50, 1)) .field("framerate", gst::Fraction::new(50, 1))
.build() .build()
} else { } else {
gst::Caps::builder("audio/x-raw") gst::Caps::builder("audio/x-raw")
.field("format", &"U8") .field("format", "U8")
.field("layout", &"interleaved") .field("layout", "interleaved")
.field("rate", &8000i32) .field("rate", 8000i32)
.field("channels", &1i32) .field("channels", 1i32)
.build() .build()
}; };
assert!(sinkpad.send_event(gst::event::Caps::new(&caps))); assert!(sinkpad.send_event(gst::event::Caps::new(&caps)));
@ -298,7 +298,7 @@ fn test_one_stream_open() {
pipeline.set_state(gst::State::Playing).unwrap(); pipeline.set_state(gst::State::Playing).unwrap();
togglerecord.set_property("record", &true).unwrap(); togglerecord.set_property("record", true).unwrap();
sender_input.send(SendData::Buffers(10)).unwrap(); sender_input.send(SendData::Buffers(10)).unwrap();
drop(sender_input); drop(sender_input);
@ -330,7 +330,7 @@ fn test_one_stream_gaps_open() {
pipeline.set_state(gst::State::Playing).unwrap(); pipeline.set_state(gst::State::Playing).unwrap();
togglerecord.set_property("record", &true).unwrap(); togglerecord.set_property("record", true).unwrap();
sender_input.send(SendData::Buffers(5)).unwrap(); sender_input.send(SendData::Buffers(5)).unwrap();
sender_input.send(SendData::Gaps(5)).unwrap(); sender_input.send(SendData::Gaps(5)).unwrap();
drop(sender_input); drop(sender_input);
@ -365,7 +365,7 @@ fn test_one_stream_close_open() {
sender_input.send(SendData::Buffers(10)).unwrap(); sender_input.send(SendData::Buffers(10)).unwrap();
receiver_input_done.recv().unwrap(); receiver_input_done.recv().unwrap();
togglerecord.set_property("record", &true).unwrap(); togglerecord.set_property("record", true).unwrap();
sender_input.send(SendData::Buffers(10)).unwrap(); sender_input.send(SendData::Buffers(10)).unwrap();
drop(sender_input); drop(sender_input);
@ -397,10 +397,10 @@ fn test_one_stream_open_close() {
pipeline.set_state(gst::State::Playing).unwrap(); pipeline.set_state(gst::State::Playing).unwrap();
togglerecord.set_property("record", &true).unwrap(); togglerecord.set_property("record", true).unwrap();
sender_input.send(SendData::Buffers(10)).unwrap(); sender_input.send(SendData::Buffers(10)).unwrap();
receiver_input_done.recv().unwrap(); receiver_input_done.recv().unwrap();
togglerecord.set_property("record", &false).unwrap(); togglerecord.set_property("record", false).unwrap();
sender_input.send(SendData::Buffers(10)).unwrap(); sender_input.send(SendData::Buffers(10)).unwrap();
drop(sender_input); drop(sender_input);
@ -432,13 +432,13 @@ fn test_one_stream_open_close_open() {
pipeline.set_state(gst::State::Playing).unwrap(); pipeline.set_state(gst::State::Playing).unwrap();
togglerecord.set_property("record", &true).unwrap(); togglerecord.set_property("record", true).unwrap();
sender_input.send(SendData::Buffers(10)).unwrap(); sender_input.send(SendData::Buffers(10)).unwrap();
receiver_input_done.recv().unwrap(); receiver_input_done.recv().unwrap();
togglerecord.set_property("record", &false).unwrap(); togglerecord.set_property("record", false).unwrap();
sender_input.send(SendData::Buffers(10)).unwrap(); sender_input.send(SendData::Buffers(10)).unwrap();
receiver_input_done.recv().unwrap(); receiver_input_done.recv().unwrap();
togglerecord.set_property("record", &true).unwrap(); togglerecord.set_property("record", true).unwrap();
sender_input.send(SendData::Buffers(10)).unwrap(); sender_input.send(SendData::Buffers(10)).unwrap();
drop(sender_input); drop(sender_input);
@ -478,7 +478,7 @@ fn test_two_stream_open() {
pipeline.set_state(gst::State::Playing).unwrap(); pipeline.set_state(gst::State::Playing).unwrap();
togglerecord.set_property("record", &true).unwrap(); togglerecord.set_property("record", true).unwrap();
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
sender_input_2.send(SendData::Buffers(11)).unwrap(); sender_input_2.send(SendData::Buffers(11)).unwrap();
@ -536,7 +536,7 @@ fn test_two_stream_open_shift() {
pipeline.set_state(gst::State::Playing).unwrap(); pipeline.set_state(gst::State::Playing).unwrap();
togglerecord.set_property("record", &true).unwrap(); togglerecord.set_property("record", true).unwrap();
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
sender_input_2.send(SendData::Buffers(11)).unwrap(); sender_input_2.send(SendData::Buffers(11)).unwrap();
@ -599,7 +599,7 @@ fn test_two_stream_open_shift_main() {
pipeline.set_state(gst::State::Playing).unwrap(); pipeline.set_state(gst::State::Playing).unwrap();
togglerecord.set_property("record", &true).unwrap(); togglerecord.set_property("record", true).unwrap();
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
sender_input_2.send(SendData::Buffers(12)).unwrap(); sender_input_2.send(SendData::Buffers(12)).unwrap();
@ -676,7 +676,7 @@ fn test_two_stream_open_close() {
pipeline.set_state(gst::State::Playing).unwrap(); pipeline.set_state(gst::State::Playing).unwrap();
togglerecord.set_property("record", &true).unwrap(); togglerecord.set_property("record", true).unwrap();
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
sender_input_2.send(SendData::Buffers(11)).unwrap(); sender_input_2.send(SendData::Buffers(11)).unwrap();
@ -686,7 +686,7 @@ fn test_two_stream_open_close() {
// Stop recording and push new buffers to sender 1, which will advance // Stop recording and push new buffers to sender 1, which will advance
// it and release the 11th buffer of sender 2 above // it and release the 11th buffer of sender 2 above
togglerecord.set_property("record", &false).unwrap(); togglerecord.set_property("record", false).unwrap();
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
receiver_input_done_2.recv().unwrap(); receiver_input_done_2.recv().unwrap();
@ -745,7 +745,7 @@ fn test_two_stream_close_open() {
pipeline.set_state(gst::State::Playing).unwrap(); pipeline.set_state(gst::State::Playing).unwrap();
togglerecord.set_property("record", &false).unwrap(); togglerecord.set_property("record", false).unwrap();
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
sender_input_2.send(SendData::Buffers(11)).unwrap(); sender_input_2.send(SendData::Buffers(11)).unwrap();
@ -755,7 +755,7 @@ fn test_two_stream_close_open() {
// Start recording and push new buffers to sender 1, which will advance // Start recording and push new buffers to sender 1, which will advance
// it and release the 11th buffer of sender 2 above // it and release the 11th buffer of sender 2 above
togglerecord.set_property("record", &true).unwrap(); togglerecord.set_property("record", true).unwrap();
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
receiver_input_done_2.recv().unwrap(); receiver_input_done_2.recv().unwrap();
@ -814,7 +814,7 @@ fn test_two_stream_open_close_open() {
pipeline.set_state(gst::State::Playing).unwrap(); pipeline.set_state(gst::State::Playing).unwrap();
togglerecord.set_property("record", &true).unwrap(); togglerecord.set_property("record", true).unwrap();
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
sender_input_2.send(SendData::Buffers(11)).unwrap(); sender_input_2.send(SendData::Buffers(11)).unwrap();
@ -824,7 +824,7 @@ fn test_two_stream_open_close_open() {
// Stop recording and push new buffers to sender 1, which will advance // Stop recording and push new buffers to sender 1, which will advance
// it and release the 11th buffer of sender 2 above // it and release the 11th buffer of sender 2 above
togglerecord.set_property("record", &false).unwrap(); togglerecord.set_property("record", false).unwrap();
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
receiver_input_done_2.recv().unwrap(); receiver_input_done_2.recv().unwrap();
@ -840,7 +840,7 @@ fn test_two_stream_open_close_open() {
sender_input_2.send(SendData::Buffers(1)).unwrap(); sender_input_2.send(SendData::Buffers(1)).unwrap();
// Start recording again and send another set of buffers to both senders // Start recording again and send another set of buffers to both senders
togglerecord.set_property("record", &true).unwrap(); togglerecord.set_property("record", true).unwrap();
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
sender_input_2.send(SendData::Buffers(10)).unwrap(); sender_input_2.send(SendData::Buffers(10)).unwrap();
receiver_input_done_1.recv().unwrap(); receiver_input_done_1.recv().unwrap();
@ -908,7 +908,7 @@ fn test_two_stream_open_close_open_gaps() {
pipeline.set_state(gst::State::Playing).unwrap(); pipeline.set_state(gst::State::Playing).unwrap();
togglerecord.set_property("record", &true).unwrap(); togglerecord.set_property("record", true).unwrap();
sender_input_1.send(SendData::Buffers(3)).unwrap(); sender_input_1.send(SendData::Buffers(3)).unwrap();
sender_input_1.send(SendData::Gaps(3)).unwrap(); sender_input_1.send(SendData::Gaps(3)).unwrap();
@ -922,7 +922,7 @@ fn test_two_stream_open_close_open_gaps() {
// Stop recording and push new buffers to sender 1, which will advance // Stop recording and push new buffers to sender 1, which will advance
// it and release the 11th buffer of sender 2 above // it and release the 11th buffer of sender 2 above
togglerecord.set_property("record", &false).unwrap(); togglerecord.set_property("record", false).unwrap();
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
receiver_input_done_2.recv().unwrap(); receiver_input_done_2.recv().unwrap();
@ -940,7 +940,7 @@ fn test_two_stream_open_close_open_gaps() {
sender_input_2.send(SendData::Gaps(1)).unwrap(); sender_input_2.send(SendData::Gaps(1)).unwrap();
// Start recording again and send another set of buffers to both senders // Start recording again and send another set of buffers to both senders
togglerecord.set_property("record", &true).unwrap(); togglerecord.set_property("record", true).unwrap();
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
sender_input_2.send(SendData::Buffers(10)).unwrap(); sender_input_2.send(SendData::Buffers(10)).unwrap();
receiver_input_done_1.recv().unwrap(); receiver_input_done_1.recv().unwrap();
@ -1008,7 +1008,7 @@ fn test_two_stream_close_open_close_delta() {
pipeline.set_state(gst::State::Playing).unwrap(); pipeline.set_state(gst::State::Playing).unwrap();
togglerecord.set_property("record", &false).unwrap(); togglerecord.set_property("record", false).unwrap();
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
sender_input_2.send(SendData::Buffers(11)).unwrap(); sender_input_2.send(SendData::Buffers(11)).unwrap();
@ -1019,7 +1019,7 @@ fn test_two_stream_close_open_close_delta() {
// Start recording and push new buffers to sender 1. The first one is a delta frame, // Start recording and push new buffers to sender 1. The first one is a delta frame,
// so will be dropped, and as such the next frame of sender 2 will also be dropped // so will be dropped, and as such the next frame of sender 2 will also be dropped
// Sender 2 is empty now // Sender 2 is empty now
togglerecord.set_property("record", &true).unwrap(); togglerecord.set_property("record", true).unwrap();
sender_input_1.send(SendData::BuffersDelta(1)).unwrap(); sender_input_1.send(SendData::BuffersDelta(1)).unwrap();
sender_input_1.send(SendData::Buffers(9)).unwrap(); sender_input_1.send(SendData::Buffers(9)).unwrap();
receiver_input_done_2.recv().unwrap(); receiver_input_done_2.recv().unwrap();
@ -1039,7 +1039,7 @@ fn test_two_stream_close_open_close_delta() {
// Stop recording again and send another set of buffers to both senders // Stop recording again and send another set of buffers to both senders
// The first one is a delta frame, so we only actually stop recording // The first one is a delta frame, so we only actually stop recording
// after recording another frame // after recording another frame
togglerecord.set_property("record", &false).unwrap(); togglerecord.set_property("record", false).unwrap();
sender_input_1.send(SendData::BuffersDelta(1)).unwrap(); sender_input_1.send(SendData::BuffersDelta(1)).unwrap();
sender_input_1.send(SendData::Buffers(9)).unwrap(); sender_input_1.send(SendData::Buffers(9)).unwrap();
sender_input_2.send(SendData::Buffers(10)).unwrap(); sender_input_2.send(SendData::Buffers(10)).unwrap();
@ -1099,7 +1099,7 @@ fn test_three_stream_open_close_open() {
pipeline.set_state(gst::State::Playing).unwrap(); pipeline.set_state(gst::State::Playing).unwrap();
togglerecord.set_property("record", &true).unwrap(); togglerecord.set_property("record", true).unwrap();
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
sender_input_2.send(SendData::Buffers(11)).unwrap(); sender_input_2.send(SendData::Buffers(11)).unwrap();
@ -1110,7 +1110,7 @@ fn test_three_stream_open_close_open() {
// Stop recording and push new buffers to sender 1, which will advance // Stop recording and push new buffers to sender 1, which will advance
// it and release the 11th buffer of sender 2/3 above // it and release the 11th buffer of sender 2/3 above
togglerecord.set_property("record", &false).unwrap(); togglerecord.set_property("record", false).unwrap();
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
receiver_input_done_2.recv().unwrap(); receiver_input_done_2.recv().unwrap();
@ -1130,7 +1130,7 @@ fn test_three_stream_open_close_open() {
sender_input_2.send(SendData::Buffers(1)).unwrap(); sender_input_2.send(SendData::Buffers(1)).unwrap();
// Start recording again and send another set of buffers to both senders // Start recording again and send another set of buffers to both senders
togglerecord.set_property("record", &true).unwrap(); togglerecord.set_property("record", true).unwrap();
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
sender_input_2.send(SendData::Buffers(10)).unwrap(); sender_input_2.send(SendData::Buffers(10)).unwrap();
sender_input_3.send(SendData::Buffers(5)).unwrap(); sender_input_3.send(SendData::Buffers(5)).unwrap();
@ -1221,7 +1221,7 @@ fn test_two_stream_main_eos() {
pipeline.set_state(gst::State::Playing).unwrap(); pipeline.set_state(gst::State::Playing).unwrap();
togglerecord.set_property("record", &true).unwrap(); togglerecord.set_property("record", true).unwrap();
// Send 10 buffers to main stream first // Send 10 buffers to main stream first
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
@ -1304,7 +1304,7 @@ fn test_two_stream_secondary_eos_first() {
pipeline.set_state(gst::State::Playing).unwrap(); pipeline.set_state(gst::State::Playing).unwrap();
togglerecord.set_property("record", &true).unwrap(); togglerecord.set_property("record", true).unwrap();
// Send 10 buffers to main stream first // Send 10 buffers to main stream first
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
@ -1382,7 +1382,7 @@ fn test_three_stream_main_eos() {
pipeline.set_state(gst::State::Playing).unwrap(); pipeline.set_state(gst::State::Playing).unwrap();
togglerecord.set_property("record", &true).unwrap(); togglerecord.set_property("record", true).unwrap();
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
sender_input_2.send(SendData::Buffers(9)).unwrap(); sender_input_2.send(SendData::Buffers(9)).unwrap();
@ -1495,7 +1495,7 @@ fn test_three_stream_main_and_second_eos() {
pipeline.set_state(gst::State::Playing).unwrap(); pipeline.set_state(gst::State::Playing).unwrap();
togglerecord.set_property("record", &true).unwrap(); togglerecord.set_property("record", true).unwrap();
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
sender_input_2.send(SendData::Buffers(9)).unwrap(); sender_input_2.send(SendData::Buffers(9)).unwrap();
@ -1608,7 +1608,7 @@ fn test_three_stream_secondary_eos_first() {
pipeline.set_state(gst::State::Playing).unwrap(); pipeline.set_state(gst::State::Playing).unwrap();
togglerecord.set_property("record", &true).unwrap(); togglerecord.set_property("record", true).unwrap();
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
sender_input_2.send(SendData::Buffers(9)).unwrap(); sender_input_2.send(SendData::Buffers(9)).unwrap();

View file

@ -54,7 +54,9 @@ impl ElementImpl for CdgDec {
fn pad_templates() -> &'static [gst::PadTemplate] { fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| { static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
let sink_caps = gst::Caps::new_simple("video/x-cdg", &[("parsed", &true)]); let sink_caps = gst::Caps::builder("video/x-cdg")
.field("parsed", true)
.build();
let sink_pad_template = gst::PadTemplate::new( let sink_pad_template = gst::PadTemplate::new(
"sink", "sink",
gst::PadDirection::Sink, gst::PadDirection::Sink,
@ -63,15 +65,12 @@ impl ElementImpl for CdgDec {
) )
.unwrap(); .unwrap();
let src_caps = gst::Caps::new_simple( let src_caps = gst::Caps::builder("video/x-raw")
"video/x-raw", .field("format", gst_video::VideoFormat::Rgba.to_str())
&[ .field("width", CDG_WIDTH as i32)
("format", &gst_video::VideoFormat::Rgba.to_str()), .field("height", CDG_HEIGHT as i32)
("width", &(CDG_WIDTH as i32)), .field("framerate", gst::Fraction::new(0, 1))
("height", &(CDG_HEIGHT as i32)), .build();
("framerate", &gst::Fraction::new(0, 1)),
],
);
let src_pad_template = gst::PadTemplate::new( let src_pad_template = gst::PadTemplate::new(
"src", "src",
gst::PadDirection::Src, gst::PadDirection::Src,

View file

@ -60,7 +60,7 @@ impl ElementImpl for CdgParse {
fn pad_templates() -> &'static [gst::PadTemplate] { fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| { static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
let sink_caps = gst::Caps::new_simple("video/x-cdg", &[]); let sink_caps = gst::Caps::builder("video/x-cdg").build();
let sink_pad_template = gst::PadTemplate::new( let sink_pad_template = gst::PadTemplate::new(
"sink", "sink",
gst::PadDirection::Sink, gst::PadDirection::Sink,
@ -69,15 +69,12 @@ impl ElementImpl for CdgParse {
) )
.unwrap(); .unwrap();
let src_caps = gst::Caps::new_simple( let src_caps = gst::Caps::builder("video/x-cdg")
"video/x-cdg", .field("width", CDG_WIDTH as i32)
&[ .field("height", CDG_HEIGHT as i32)
("width", &(CDG_WIDTH as i32)), .field("framerate", gst::Fraction::new(0, 1))
("height", &(CDG_HEIGHT as i32)), .field("parsed", true)
("framerate", &gst::Fraction::new(0, 1)), .build();
("parsed", &true),
],
);
let src_pad_template = gst::PadTemplate::new( let src_pad_template = gst::PadTemplate::new(
"src", "src",
gst::PadDirection::Src, gst::PadDirection::Src,
@ -136,15 +133,12 @@ impl BaseParseImpl for CdgParse {
let pad = element.src_pad(); let pad = element.src_pad();
if pad.current_caps().is_none() { if pad.current_caps().is_none() {
// Set src pad caps // Set src pad caps
let src_caps = gst::Caps::new_simple( let src_caps = gst::Caps::builder("video/x-cdg")
"video/x-cdg", .field("width", CDG_WIDTH as i32)
&[ .field("height", CDG_HEIGHT as i32)
("width", &(CDG_WIDTH as i32)), .field("framerate", gst::Fraction::new(0, 1))
("height", &(CDG_HEIGHT as i32)), .field("parsed", true)
("framerate", &gst::Fraction::new(0, 1)), .build();
("parsed", &true),
],
);
pad.push_event(gst::event::Caps::new(&src_caps)); pad.push_event(gst::event::Caps::new(&src_caps));
} }

View file

@ -77,12 +77,12 @@ pub fn register(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
"cdg_typefind", "cdg_typefind",
gst::Rank::None, gst::Rank::None,
Some("cdg"), Some("cdg"),
Some(&Caps::new_simple("video/x-cdg", &[])), Some(&Caps::builder("video/x-cdg").build()),
|mut typefind| { |mut typefind| {
let proba = compute_probability(&mut typefind); let proba = compute_probability(&mut typefind);
if proba != gst::TypeFindProbability::None { if proba != gst::TypeFindProbability::None {
typefind.suggest(proba, &Caps::new_simple("video/x-cdg", &[])); typefind.suggest(proba, &Caps::builder("video/x-cdg").build());
} }
}, },
) )

View file

@ -37,7 +37,7 @@ fn test_cdgdec() {
// Ensure we are in push mode so 'blocksize' prop is used // Ensure we are in push mode so 'blocksize' prop is used
let filesrc = gst::ElementFactory::make("pushfilesrc", None).unwrap(); let filesrc = gst::ElementFactory::make("pushfilesrc", None).unwrap();
filesrc filesrc
.set_property("location", &input_path.to_str().unwrap()) .set_property("location", input_path.to_str().unwrap())
.expect("failed to set 'location' property"); .expect("failed to set 'location' property");
{ {
let child_proxy = filesrc.dynamic_cast_ref::<gst::ChildProxy>().unwrap(); let child_proxy = filesrc.dynamic_cast_ref::<gst::ChildProxy>().unwrap();

View file

@ -315,7 +315,7 @@ impl ElementImpl for CCDetect {
{ {
let caps = caps.get_mut().unwrap(); let caps = caps.get_mut().unwrap();
let s = gst::Structure::builder("closedcaption/x-cea-708") let s = gst::Structure::builder("closedcaption/x-cea-708")
.field("format", &gst::List::new(&[&"cc_data", &"cdp"])) .field("format", gst::List::new(["cc_data", "cdp"]))
.build(); .build();
caps.append_structure(s); caps.append_structure(s);
} }

View file

@ -938,7 +938,7 @@ impl Cea608ToJson {
EventView::Caps(..) => { EventView::Caps(..) => {
// We send our own caps downstream // We send our own caps downstream
let caps = gst::Caps::builder("application/x-json") let caps = gst::Caps::builder("application/x-json")
.field("format", &"cea608") .field("format", "cea608")
.build(); .build();
self.srcpad.push_event(gst::event::Caps::new(&caps)) self.srcpad.push_event(gst::event::Caps::new(&caps))
} }
@ -1084,7 +1084,7 @@ impl ElementImpl for Cea608ToJson {
.unwrap(); .unwrap();
let caps = gst::Caps::builder("closedcaption/x-cea-608") let caps = gst::Caps::builder("closedcaption/x-cea-608")
.field("format", &"raw") .field("format", "raw")
.build(); .build();
let sink_pad_template = gst::PadTemplate::new( let sink_pad_template = gst::PadTemplate::new(

View file

@ -309,7 +309,7 @@ impl Cea608ToTt {
} else if s.name() == "text/x-raw" { } else if s.name() == "text/x-raw" {
state.format = Some(Format::Raw); state.format = Some(Format::Raw);
gst::Caps::builder("text/x-raw") gst::Caps::builder("text/x-raw")
.field("format", &"utf8") .field("format", "utf8")
.build() .build()
} else { } else {
unreachable!(); unreachable!();
@ -453,7 +453,7 @@ impl ElementImpl for Cea608ToTt {
// Raw timed text // Raw timed text
let s = gst::Structure::builder("text/x-raw") let s = gst::Structure::builder("text/x-raw")
.field("format", &"utf8") .field("format", "utf8")
.build(); .build();
caps.append_structure(s); caps.append_structure(s);
} }
@ -467,7 +467,7 @@ impl ElementImpl for Cea608ToTt {
.unwrap(); .unwrap();
let caps = gst::Caps::builder("closedcaption/x-cea-608") let caps = gst::Caps::builder("closedcaption/x-cea-608")
.field("format", &"raw") .field("format", "raw")
.build(); .build();
let sink_pad_template = gst::PadTemplate::new( let sink_pad_template = gst::PadTemplate::new(

View file

@ -157,11 +157,11 @@ impl MccEnc {
); );
} }
if *framerate.denom() == 1 { if framerate.denom() == 1 {
let _ = write!(buffer, "Time Code Rate={}\r\n", *framerate.numer()); let _ = write!(buffer, "Time Code Rate={}\r\n", framerate.numer());
} else { } else {
assert_eq!(*framerate.denom(), 1001); assert_eq!(framerate.denom(), 1001);
let _ = write!(buffer, "Time Code Rate={}DF\r\n", *framerate.numer() / 1000); let _ = write!(buffer, "Time Code Rate={}DF\r\n", framerate.numer() / 1000);
} }
let _ = write!(buffer, "\r\n"); let _ = write!(buffer, "\r\n");
@ -388,9 +388,9 @@ impl MccEnc {
.field( .field(
"version", "version",
if framerate == gst::Fraction::new(60000, 1001) { if framerate == gst::Fraction::new(60000, 1001) {
&2i32 2i32
} else { } else {
&1i32 1i32
}, },
) )
.build(); .build();
@ -579,24 +579,24 @@ impl ElementImpl for MccEnc {
{ {
let caps = caps.get_mut().unwrap(); let caps = caps.get_mut().unwrap();
let framerates = gst::List::new(&[ let framerates = gst::List::new([
&gst::Fraction::new(24, 1), gst::Fraction::new(24, 1),
&gst::Fraction::new(25, 1), gst::Fraction::new(25, 1),
&gst::Fraction::new(30000, 1001), gst::Fraction::new(30000, 1001),
&gst::Fraction::new(30, 1), gst::Fraction::new(30, 1),
&gst::Fraction::new(50, 1), gst::Fraction::new(50, 1),
&gst::Fraction::new(60000, 1001), gst::Fraction::new(60000, 1001),
&gst::Fraction::new(60, 1), gst::Fraction::new(60, 1),
]); ]);
let s = gst::Structure::builder("closedcaption/x-cea-708") let s = gst::Structure::builder("closedcaption/x-cea-708")
.field("format", &"cdp") .field("format", "cdp")
.field("framerate", &framerates) .field("framerate", &framerates)
.build(); .build();
caps.append_structure(s); caps.append_structure(s);
let s = gst::Structure::builder("closedcaption/x-cea-608") let s = gst::Structure::builder("closedcaption/x-cea-608")
.field("format", &"s334-1a") .field("format", "s334-1a")
.field("framerate", &framerates) .field("framerate", &framerates)
.build(); .build();
caps.append_structure(s); caps.append_structure(s);

View file

@ -273,8 +273,7 @@ impl State {
} }
buffer.set_duration( buffer.set_duration(
gst::ClockTime::SECOND gst::ClockTime::SECOND.mul_div_ceil(framerate.denom() as u64, framerate.numer() as u64),
.mul_div_ceil(*framerate.denom() as u64, *framerate.numer() as u64),
); );
} }
@ -310,12 +309,12 @@ impl State {
let caps = match format { let caps = match format {
Format::Cea708Cdp => gst::Caps::builder("closedcaption/x-cea-708") Format::Cea708Cdp => gst::Caps::builder("closedcaption/x-cea-708")
.field("format", &"cdp") .field("format", "cdp")
.field("framerate", &framerate) .field("framerate", framerate)
.build(), .build(),
Format::Cea608 => gst::Caps::builder("closedcaption/x-cea-608") Format::Cea608 => gst::Caps::builder("closedcaption/x-cea-608")
.field("format", &"s334-1a") .field("format", "s334-1a")
.field("framerate", &framerate) .field("framerate", framerate)
.build(), .build(),
}; };
@ -1226,14 +1225,14 @@ impl ElementImpl for MccParse {
); );
let s = gst::Structure::builder("closedcaption/x-cea-708") let s = gst::Structure::builder("closedcaption/x-cea-708")
.field("format", &"cdp") .field("format", "cdp")
.field("framerate", &framerate) .field("framerate", framerate)
.build(); .build();
caps.append_structure(s); caps.append_structure(s);
let s = gst::Structure::builder("closedcaption/x-cea-608") let s = gst::Structure::builder("closedcaption/x-cea-608")
.field("format", &"s334-1a") .field("format", "s334-1a")
.field("framerate", &framerate) .field("framerate", framerate)
.build(); .build();
caps.append_structure(s); caps.append_structure(s);
} }
@ -1246,7 +1245,7 @@ impl ElementImpl for MccParse {
.unwrap(); .unwrap();
let caps = gst::Caps::builder("application/x-mcc") let caps = gst::Caps::builder("application/x-mcc")
.field("version", &gst::List::new(&[&1i32, &2i32])) .field("version", gst::List::new([1i32, 2i32]))
.build(); .build();
let sink_pad_template = gst::PadTemplate::new( let sink_pad_template = gst::PadTemplate::new(
"sink", "sink",

View file

@ -195,8 +195,8 @@ impl State {
let framerate = self.framerate.unwrap(); let framerate = self.framerate.unwrap();
let dur = gst::ClockTime::SECOND.mul_div_floor( let dur = gst::ClockTime::SECOND.mul_div_floor(
self.internal_buffer.len() as u64 * *framerate.denom() as u64, self.internal_buffer.len() as u64 * framerate.denom() as u64,
*framerate.numer() as u64, framerate.numer() as u64,
); );
buf_mut.set_duration(dur); buf_mut.set_duration(dur);
@ -409,10 +409,10 @@ impl ElementImpl for SccEnc {
fn pad_templates() -> &'static [gst::PadTemplate] { fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| { static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
let framerates = let framerates =
gst::List::new(&[&gst::Fraction::new(30000, 1001), &gst::Fraction::new(30, 1)]); gst::List::new([gst::Fraction::new(30000, 1001), gst::Fraction::new(30, 1)]);
let caps = gst::Caps::builder("closedcaption/x-cea-608") let caps = gst::Caps::builder("closedcaption/x-cea-608")
.field("format", &"raw") .field("format", "raw")
.field("framerate", &framerates) .field("framerate", framerates)
.build(); .build();
let sink_pad_template = gst::PadTemplate::new( let sink_pad_template = gst::PadTemplate::new(
"sink", "sink",

View file

@ -225,8 +225,7 @@ impl State {
buffer.set_pts(self.last_position); buffer.set_pts(self.last_position);
buffer.set_duration( buffer.set_duration(
gst::ClockTime::SECOND gst::ClockTime::SECOND.mul_div_ceil(framerate.denom() as u64, framerate.numer() as u64),
.mul_div_ceil(*framerate.denom() as u64, *framerate.numer() as u64),
); );
} }
@ -260,8 +259,8 @@ impl State {
self.framerate = Some(framerate); self.framerate = Some(framerate);
let caps = gst::Caps::builder("closedcaption/x-cea-608") let caps = gst::Caps::builder("closedcaption/x-cea-608")
.field("format", &"raw") .field("format", "raw")
.field("framerate", &framerate) .field("framerate", framerate)
.build(); .build();
self.framerate = Some(framerate); self.framerate = Some(framerate);
@ -1093,13 +1092,10 @@ impl ElementImpl for SccParse {
fn pad_templates() -> &'static [gst::PadTemplate] { fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| { static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
let caps = gst::Caps::builder("closedcaption/x-cea-608") let caps = gst::Caps::builder("closedcaption/x-cea-608")
.field("format", &"raw") .field("format", "raw")
.field( .field(
"framerate", "framerate",
&gst::List::new(&[ gst::List::new([gst::Fraction::new(30000, 1001), gst::Fraction::new(30, 1)]),
&gst::Fraction::new(30000, 1001),
&gst::Fraction::new(30, 1),
]),
) )
.build(); .build();
let src_pad_template = gst::PadTemplate::new( let src_pad_template = gst::PadTemplate::new(

View file

@ -67,7 +67,7 @@ impl Default for Settings {
fn default() -> Self { fn default() -> Self {
Self { Self {
cc_caps: gst::Caps::builder("closedcaption/x-cea-608") cc_caps: gst::Caps::builder("closedcaption/x-cea-608")
.field("format", &"raw") .field("format", "raw")
.build(), .build(),
passthrough: DEFAULT_PASSTHROUGH, passthrough: DEFAULT_PASSTHROUGH,
latency: DEFAULT_LATENCY, latency: DEFAULT_LATENCY,
@ -139,16 +139,16 @@ impl TranscriberBin {
state state
.transcriber_queue .transcriber_queue
.set_property("max-size-buffers", &0u32) .set_property("max-size-buffers", 0u32)
.unwrap(); .unwrap();
state state
.transcriber_queue .transcriber_queue
.set_property("max-size-time", &0u64) .set_property("max-size-time", 0u64)
.unwrap(); .unwrap();
state.internal_bin.add(&state.transcription_bin)?; state.internal_bin.add(&state.transcription_bin)?;
state.textwrap.set_property("lines", &2u32).unwrap(); state.textwrap.set_property("lines", 2u32).unwrap();
state.transcription_bin.set_locked_state(true); state.transcription_bin.set_locked_state(true);
@ -208,7 +208,7 @@ impl TranscriberBin {
state state
.cccombiner .cccombiner
.set_property("latency", &(100 * gst::ClockTime::MSECOND)) .set_property("latency", 100 * gst::ClockTime::MSECOND)
.unwrap(); .unwrap();
self.audio_sinkpad self.audio_sinkpad
@ -239,15 +239,15 @@ impl TranscriberBin {
let max_size_time = settings.latency + settings.accumulate_time; let max_size_time = settings.latency + settings.accumulate_time;
for queue in &[&state.audio_queue_passthrough, &state.video_queue] { for queue in &[&state.audio_queue_passthrough, &state.video_queue] {
queue.set_property("max-size-bytes", &0u32).unwrap(); queue.set_property("max-size-bytes", 0u32).unwrap();
queue.set_property("max-size-buffers", &0u32).unwrap(); queue.set_property("max-size-buffers", 0u32).unwrap();
queue.set_property("max-size-time", &max_size_time).unwrap(); queue.set_property("max-size-time", max_size_time).unwrap();
} }
let latency_ms = settings.latency.mseconds() as u32; let latency_ms = settings.latency.mseconds() as u32;
state state
.transcriber .transcriber
.set_property("latency", &latency_ms) .set_property("latency", latency_ms)
.unwrap(); .unwrap();
if !settings.passthrough { if !settings.passthrough {
@ -349,19 +349,19 @@ impl TranscriberBin {
gst_debug!(CAT, obj: element, "setting CC mode {:?}", mode); gst_debug!(CAT, obj: element, "setting CC mode {:?}", mode);
state.tttocea608.set_property("mode", &mode).unwrap(); state.tttocea608.set_property("mode", mode).unwrap();
if mode.is_rollup() { if mode.is_rollup() {
state state
.textwrap .textwrap
.set_property("accumulate-time", &0u64) .set_property("accumulate-time", 0u64)
.unwrap(); .unwrap();
} else { } else {
let accumulate_time = self.settings.lock().unwrap().accumulate_time; let accumulate_time = self.settings.lock().unwrap().accumulate_time;
state state
.textwrap .textwrap
.set_property("accumulate-time", &accumulate_time) .set_property("accumulate-time", accumulate_time)
.unwrap(); .unwrap();
} }
} }
@ -776,7 +776,7 @@ impl ElementImpl for TranscriberBin {
fn pad_templates() -> &'static [gst::PadTemplate] { fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| { static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
let caps = gst::Caps::new_simple("video/x-raw", &[]); let caps = gst::Caps::builder("video/x-raw").build();
let video_src_pad_template = gst::PadTemplate::new( let video_src_pad_template = gst::PadTemplate::new(
"src_video", "src_video",
gst::PadDirection::Src, gst::PadDirection::Src,
@ -792,7 +792,7 @@ impl ElementImpl for TranscriberBin {
) )
.unwrap(); .unwrap();
let caps = gst::Caps::new_simple("audio/x-raw", &[]); let caps = gst::Caps::builder("audio/x-raw").build();
let audio_src_pad_template = gst::PadTemplate::new( let audio_src_pad_template = gst::PadTemplate::new(
"src_audio", "src_audio",
gst::PadDirection::Src, gst::PadDirection::Src,

View file

@ -213,10 +213,7 @@ impl State {
) { ) {
self.check_erase_display(element, bufferlist); self.check_erase_display(element, bufferlist);
let (fps_n, fps_d) = ( let (fps_n, fps_d) = (self.framerate.numer() as u64, self.framerate.denom() as u64);
*self.framerate.numer() as u64,
*self.framerate.denom() as u64,
);
let pts = (self.last_frame_no * gst::ClockTime::SECOND) let pts = (self.last_frame_no * gst::ClockTime::SECOND)
.mul_div_round(fps_d, fps_n) .mul_div_round(fps_d, fps_n)
@ -566,8 +563,8 @@ impl TtToCea608 {
}; };
let (fps_n, fps_d) = ( let (fps_n, fps_d) = (
*state.framerate.numer() as u64, state.framerate.numer() as u64,
*state.framerate.denom() as u64, state.framerate.denom() as u64,
); );
let frame_no = pts.mul_div_round(fps_n, fps_d).unwrap().seconds(); let frame_no = pts.mul_div_round(fps_n, fps_d).unwrap().seconds();
@ -949,8 +946,8 @@ impl TtToCea608 {
let mut state = self.state.lock().unwrap(); let mut state = self.state.lock().unwrap();
let (fps_n, fps_d) = ( let (fps_n, fps_d) = (
*state.framerate.numer() as u64, state.framerate.numer() as u64,
*state.framerate.denom() as u64, state.framerate.denom() as u64,
); );
let (timestamp, duration) = e.get(); let (timestamp, duration) = e.get();
@ -1178,11 +1175,11 @@ impl ElementImpl for TtToCea608 {
{ {
let caps = caps.get_mut().unwrap(); let caps = caps.get_mut().unwrap();
let s = gst::Structure::new_empty("text/x-raw"); let s = gst::Structure::builder("text/x-raw").build();
caps.append_structure(s); caps.append_structure(s);
let s = gst::Structure::builder("application/x-json") let s = gst::Structure::builder("application/x-json")
.field("format", &"cea608") .field("format", "cea608")
.build(); .build();
caps.append_structure(s); caps.append_structure(s);
} }
@ -1201,8 +1198,8 @@ impl ElementImpl for TtToCea608 {
); );
let caps = gst::Caps::builder("closedcaption/x-cea-608") let caps = gst::Caps::builder("closedcaption/x-cea-608")
.field("format", &"raw") .field("format", "raw")
.field("framerate", &framerate) .field("framerate", framerate)
.build(); .build();
let src_pad_template = gst::PadTemplate::new( let src_pad_template = gst::PadTemplate::new(

View file

@ -134,7 +134,7 @@ impl TtToJson {
EventView::Caps(_) => { EventView::Caps(_) => {
// We send our own caps downstream // We send our own caps downstream
let caps = gst::Caps::builder("application/x-json") let caps = gst::Caps::builder("application/x-json")
.field("format", &"cea608") .field("format", "cea608")
.build(); .build();
self.srcpad.push_event(gst::event::Caps::new(&caps)) self.srcpad.push_event(gst::event::Caps::new(&caps))
} }
@ -163,7 +163,7 @@ impl ElementImpl for TtToJson {
fn pad_templates() -> &'static [gst::PadTemplate] { fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| { static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
let caps = gst::Caps::builder("text/x-raw") let caps = gst::Caps::builder("text/x-raw")
.field("format", &"utf8") .field("format", "utf8")
.build(); .build();
let sink_pad_template = gst::PadTemplate::new( let sink_pad_template = gst::PadTemplate::new(
"sink", "sink",

View file

@ -73,7 +73,7 @@ fn test_have_cc_data_notify() {
h.set_sink_caps_str("closedcaption/x-cea-708,format=cc_data"); h.set_sink_caps_str("closedcaption/x-cea-708,format=cc_data");
h.element() h.element()
.unwrap() .unwrap()
.set_property("window", &(500_000_000u64)) .set_property("window", 500_000_000u64)
.unwrap(); .unwrap();
let state = Arc::new(Mutex::new(NotifyState::default())); let state = Arc::new(Mutex::new(NotifyState::default()));
@ -139,7 +139,7 @@ fn test_cc_data_window() {
h.set_sink_caps_str("closedcaption/x-cea-708,format=cc_data"); h.set_sink_caps_str("closedcaption/x-cea-708,format=cc_data");
h.element() h.element()
.unwrap() .unwrap()
.set_property("window", &500_000_000u64) .set_property("window", 500_000_000u64)
.unwrap(); .unwrap();
let state = Arc::new(Mutex::new(NotifyState::default())); let state = Arc::new(Mutex::new(NotifyState::default()));
@ -238,7 +238,7 @@ fn test_have_cdp_notify() {
h.set_sink_caps_str("closedcaption/x-cea-708,format=cdp"); h.set_sink_caps_str("closedcaption/x-cea-708,format=cdp");
h.element() h.element()
.unwrap() .unwrap()
.set_property("window", &500_000_000u64) .set_property("window", 500_000_000u64)
.unwrap(); .unwrap();
let state = Arc::new(Mutex::new(NotifyState::default())); let state = Arc::new(Mutex::new(NotifyState::default()));
@ -307,7 +307,7 @@ fn test_malformed_cdp_notify() {
let mut h = gst_check::Harness::new("ccdetect"); let mut h = gst_check::Harness::new("ccdetect");
h.set_src_caps_str("closedcaption/x-cea-708,format=cdp"); h.set_src_caps_str("closedcaption/x-cea-708,format=cdp");
h.set_sink_caps_str("closedcaption/x-cea-708,format=cdp"); h.set_sink_caps_str("closedcaption/x-cea-708,format=cdp");
h.element().unwrap().set_property("window", &0u64).unwrap(); h.element().unwrap().set_property("window", 0u64).unwrap();
let state = Arc::new(Mutex::new(NotifyState::default())); let state = Arc::new(Mutex::new(NotifyState::default()));
let state_c = state.clone(); let state_c = state.clone();
@ -388,7 +388,7 @@ fn test_gap_events() {
h.set_sink_caps_str("closedcaption/x-cea-708,format=cc_data"); h.set_sink_caps_str("closedcaption/x-cea-708,format=cc_data");
h.element() h.element()
.unwrap() .unwrap()
.set_property("window", &500_000_000u64) .set_property("window", 500_000_000u64)
.unwrap(); .unwrap();
let state = Arc::new(Mutex::new(NotifyState::default())); let state = Arc::new(Mutex::new(NotifyState::default()));

View file

@ -96,7 +96,7 @@ fn test_parse() {
assert_eq!( assert_eq!(
caps, caps,
gst::Caps::builder("text/x-raw") gst::Caps::builder("text/x-raw")
.field("format", &"utf8") .field("format", "utf8")
.build() .build()
); );
} }

View file

@ -93,11 +93,11 @@ Time Code Rate=30DF\r\n\
let mut h = gst_check::Harness::new("mccenc"); let mut h = gst_check::Harness::new("mccenc");
{ {
let enc = h.element().expect("could not create encoder"); let enc = h.element().expect("could not create encoder");
enc.set_property("uuid", &"14720C04-857D-40E2-86FC-F080DE44CE74") enc.set_property("uuid", "14720C04-857D-40E2-86FC-F080DE44CE74")
.unwrap(); .unwrap();
enc.set_property( enc.set_property(
"creation-date", "creation-date",
&glib::DateTime::new_utc(2018, 12, 27, 17, 34, 47.0).unwrap(), glib::DateTime::new_utc(2018, 12, 27, 17, 34, 47.0).unwrap(),
) )
.unwrap(); .unwrap();
} }

View file

@ -128,8 +128,8 @@ fn test_parse() {
assert_eq!( assert_eq!(
caps, caps,
gst::Caps::builder("closedcaption/x-cea-708") gst::Caps::builder("closedcaption/x-cea-708")
.field("format", &"cdp") .field("format", "cdp")
.field("framerate", &gst::Fraction::new(30000, 1001)) .field("framerate", gst::Fraction::new(30000, 1001))
.build() .build()
); );
} }

View file

@ -104,8 +104,8 @@ fn test_parse() {
assert_eq!( assert_eq!(
caps, caps,
gst::Caps::builder("closedcaption/x-cea-608") gst::Caps::builder("closedcaption/x-cea-608")
.field("format", &"raw") .field("format", "raw")
.field("framerate", &gst::Fraction::new(30000, 1001)) .field("framerate", gst::Fraction::new(30000, 1001))
.build() .build()
); );
} }
@ -195,8 +195,8 @@ fn test_timecodes() {
assert_eq!( assert_eq!(
caps, caps,
gst::Caps::builder("closedcaption/x-cea-608") gst::Caps::builder("closedcaption/x-cea-608")
.field("format", &"raw") .field("format", "raw")
.field("framerate", &gst::Fraction::new(30000, 1001)) .field("framerate", gst::Fraction::new(30000, 1001))
.build() .build()
); );
} }

View file

@ -365,7 +365,7 @@ impl ElementImpl for Dav1dDec {
fn pad_templates() -> &'static [gst::PadTemplate] { fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| { static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
let sink_caps = gst::Caps::new_simple("video/x-av1", &[]); let sink_caps = gst::Caps::builder("video/x-av1").build();
let sink_pad_template = gst::PadTemplate::new( let sink_pad_template = gst::PadTemplate::new(
"sink", "sink",
gst::PadDirection::Sink, gst::PadDirection::Sink,
@ -374,21 +374,18 @@ impl ElementImpl for Dav1dDec {
) )
.unwrap(); .unwrap();
let src_caps = gst::Caps::new_simple( let src_caps = gst::Caps::builder("video/x-raw")
"video/x-raw", .field("format", gst::List::from(video_output_formats()))
&[ .field("width", gst::IntRange::new(1, i32::MAX))
("format", &gst::List::from_owned(video_output_formats())), .field("height", gst::IntRange::new(1, i32::MAX))
("width", &gst::IntRange::<i32>::new(1, i32::MAX)), .field(
("height", &gst::IntRange::<i32>::new(1, i32::MAX)), "framerate",
( gst::FractionRange::new(
"framerate", gst::Fraction::new(0, 1),
&gst::FractionRange::new( gst::Fraction::new(i32::MAX, 1),
gst::Fraction::new(0, 1),
gst::Fraction::new(i32::MAX, 1),
),
), ),
], )
); .build();
let src_pad_template = gst::PadTemplate::new( let src_pad_template = gst::PadTemplate::new(
"src", "src",
gst::PadDirection::Src, gst::PadDirection::Src,

View file

@ -318,12 +318,12 @@ impl ElementImpl for Ffv1Dec {
fn pad_templates() -> &'static [gst::PadTemplate] { fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| { static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
let sink_caps = gst::Caps::builder("video/x-ffv") let sink_caps = gst::Caps::builder("video/x-ffv")
.field("ffvversion", &1) .field("ffvversion", 1)
.field("width", &gst::IntRange::<i32>::new(1, i32::MAX)) .field("width", gst::IntRange::new(1, i32::MAX))
.field("height", &gst::IntRange::<i32>::new(1, i32::MAX)) .field("height", gst::IntRange::new(1, i32::MAX))
.field( .field(
"framerate", "framerate",
&gst::FractionRange::new( gst::FractionRange::new(
gst::Fraction::new(0, 1), gst::Fraction::new(0, 1),
gst::Fraction::new(i32::MAX, 1), gst::Fraction::new(i32::MAX, 1),
), ),
@ -338,12 +338,12 @@ impl ElementImpl for Ffv1Dec {
.unwrap(); .unwrap();
let src_caps = gst::Caps::builder("video/x-raw") let src_caps = gst::Caps::builder("video/x-raw")
.field("format", &gst::List::from_owned(get_all_video_formats())) .field("format", gst::List::from(get_all_video_formats()))
.field("width", &gst::IntRange::<i32>::new(1, i32::MAX)) .field("width", gst::IntRange::new(1, i32::MAX))
.field("height", &gst::IntRange::<i32>::new(1, i32::MAX)) .field("height", gst::IntRange::new(1, i32::MAX))
.field( .field(
"framerate", "framerate",
&gst::FractionRange::new( gst::FractionRange::new(
gst::Fraction::new(0, 1), gst::Fraction::new(0, 1),
gst::Fraction::new(i32::MAX, 1), gst::Fraction::new(i32::MAX, 1),
), ),

View file

@ -210,18 +210,18 @@ impl ElementImpl for FlvDemux {
caps.append( caps.append(
gst::Caps::builder("audio/mpeg") gst::Caps::builder("audio/mpeg")
.field("mpegversion", &1i32) .field("mpegversion", 1i32)
.build(), .build(),
); );
caps.append( caps.append(
gst::Caps::builder("audio/x-raw") gst::Caps::builder("audio/x-raw")
.field("layout", &"interleaved") .field("layout", "interleaved")
.field("format", &gst::List::new(&[&"U8", &"S16LE"])) .field("format", gst::List::new(["U8", "S16LE"]))
.build(), .build(),
); );
caps.append( caps.append(
gst::Caps::builder("audio/x-adpcm") gst::Caps::builder("audio/x-adpcm")
.field("layout", &"swf") .field("layout", "swf")
.build(), .build(),
); );
caps.append(gst::Caps::builder("audio/x-nellymoser").build()); caps.append(gst::Caps::builder("audio/x-nellymoser").build());
@ -229,9 +229,9 @@ impl ElementImpl for FlvDemux {
caps.append(gst::Caps::builder("audio/x-mulaw").build()); caps.append(gst::Caps::builder("audio/x-mulaw").build());
caps.append( caps.append(
gst::Caps::builder("audio/mpeg") gst::Caps::builder("audio/mpeg")
.field("mpegversion", &4i32) .field("mpegversion", 4i32)
.field("framed", &true) .field("framed", true)
.field("stream-format", &"raw") .field("stream-format", "raw")
.build(), .build(),
); );
caps.append(gst::Caps::builder("audio/x-speex").build()); caps.append(gst::Caps::builder("audio/x-speex").build());
@ -250,7 +250,7 @@ impl ElementImpl for FlvDemux {
caps.append( caps.append(
gst::Caps::builder("video/x-flash-video") gst::Caps::builder("video/x-flash-video")
.field("flvversion", &1i32) .field("flvversion", 1i32)
.build(), .build(),
); );
caps.append(gst::Caps::builder("video/x-flash-screen").build()); caps.append(gst::Caps::builder("video/x-flash-screen").build());
@ -259,13 +259,13 @@ impl ElementImpl for FlvDemux {
caps.append(gst::Caps::builder("video/x-flash-screen2").build()); caps.append(gst::Caps::builder("video/x-flash-screen2").build());
caps.append( caps.append(
gst::Caps::builder("video/x-h264") gst::Caps::builder("video/x-h264")
.field("stream-format", &"avc") .field("stream-format", "avc")
.build(), .build(),
); );
caps.append(gst::Caps::builder("video/x-h263").build()); caps.append(gst::Caps::builder("video/x-h263").build());
caps.append( caps.append(
gst::Caps::builder("video/mpeg") gst::Caps::builder("video/mpeg")
.field("mpegversion", &4i32) .field("mpegversion", 4i32)
.build(), .build(),
); );
} }
@ -1269,44 +1269,44 @@ impl AudioFormat {
fn to_caps(&self) -> Option<gst::Caps> { fn to_caps(&self) -> Option<gst::Caps> {
let mut caps = match self.format { let mut caps = match self.format {
flavors::SoundFormat::MP3 | flavors::SoundFormat::MP3_8KHZ => Some( flavors::SoundFormat::MP3 | flavors::SoundFormat::MP3_8KHZ => Some(
gst::Caps::new_simple("audio/mpeg", &[("mpegversion", &1i32), ("layer", &3i32)]), gst::Caps::builder("audio/mpeg")
.field("mpegversion", 1i32)
.field("layer", 3i32)
.build(),
), ),
flavors::SoundFormat::PCM_NE | flavors::SoundFormat::PCM_LE => { flavors::SoundFormat::PCM_NE | flavors::SoundFormat::PCM_LE => {
if self.rate != 0 && self.channels != 0 { if self.rate != 0 && self.channels != 0 {
// Assume little-endian for "PCM_NE", it's probably more common and we have no // Assume little-endian for "PCM_NE", it's probably more common and we have no
// way to know what the endianness of the system creating the stream was // way to know what the endianness of the system creating the stream was
Some(gst::Caps::new_simple( Some(
"audio/x-raw", gst::Caps::builder("audio/x-raw")
&[ .field("layout", "interleaved")
("layout", &"interleaved"), .field("format", if self.width == 8 { "U8" } else { "S16LE" })
("format", &if self.width == 8 { "U8" } else { "S16LE" }), .build(),
], )
))
} else { } else {
None None
} }
} }
flavors::SoundFormat::ADPCM => Some(gst::Caps::new_simple( flavors::SoundFormat::ADPCM => Some(
"audio/x-adpcm", gst::Caps::builder("audio/x-adpcm")
&[("layout", &"swf")], .field("layout", "swf")
)), .build(),
),
flavors::SoundFormat::NELLYMOSER_16KHZ_MONO flavors::SoundFormat::NELLYMOSER_16KHZ_MONO
| flavors::SoundFormat::NELLYMOSER_8KHZ_MONO | flavors::SoundFormat::NELLYMOSER_8KHZ_MONO
| flavors::SoundFormat::NELLYMOSER => { | flavors::SoundFormat::NELLYMOSER => {
Some(gst::Caps::new_simple("audio/x-nellymoser", &[])) Some(gst::Caps::builder("audio/x-nellymoser").build())
} }
flavors::SoundFormat::PCM_ALAW => Some(gst::Caps::new_simple("audio/x-alaw", &[])), flavors::SoundFormat::PCM_ALAW => Some(gst::Caps::builder("audio/x-alaw").build()),
flavors::SoundFormat::PCM_ULAW => Some(gst::Caps::new_simple("audio/x-mulaw", &[])), flavors::SoundFormat::PCM_ULAW => Some(gst::Caps::builder("audio/x-mulaw").build()),
flavors::SoundFormat::AAC => self.aac_sequence_header.as_ref().map(|header| { flavors::SoundFormat::AAC => self.aac_sequence_header.as_ref().map(|header| {
gst::Caps::new_simple( gst::Caps::builder("audio/mpeg")
"audio/mpeg", .field("mpegversion", 4i32)
&[ .field("framed", true)
("mpegversion", &4i32), .field("stream-format", "raw")
("framed", &true), .field("codec_data", header)
("stream-format", &"raw"), .build()
("codec_data", &header),
],
)
}), }),
flavors::SoundFormat::SPEEX => { flavors::SoundFormat::SPEEX => {
use crate::bytes::*; use crate::bytes::*;
@ -1351,10 +1351,11 @@ impl AudioFormat {
}; };
let comment = gst::Buffer::from_mut_slice(comment); let comment = gst::Buffer::from_mut_slice(comment);
Some(gst::Caps::new_simple( Some(
"audio/x-speex", gst::Caps::builder("audio/x-speex")
&[("streamheader", &gst::Array::new(&[&header, &comment]))], .field("streamheader", gst::Array::new([header, comment]))
)) .build(),
)
} }
flavors::SoundFormat::DEVICE_SPECIFIC => { flavors::SoundFormat::DEVICE_SPECIFIC => {
// Nobody knows // Nobody knows
@ -1444,25 +1445,28 @@ impl VideoFormat {
fn to_caps(&self) -> Option<gst::Caps> { fn to_caps(&self) -> Option<gst::Caps> {
let mut caps = match self.format { let mut caps = match self.format {
flavors::CodecId::SORENSON_H263 => Some(gst::Caps::new_simple( flavors::CodecId::SORENSON_H263 => Some(
"video/x-flash-video", gst::Caps::builder("video/x-flash-video")
&[("flvversion", &1i32)], .field("flvversion", 1i32)
)), .build(),
flavors::CodecId::SCREEN => Some(gst::Caps::new_simple("video/x-flash-screen", &[])), ),
flavors::CodecId::VP6 => Some(gst::Caps::new_simple("video/x-vp6-flash", &[])), flavors::CodecId::SCREEN => Some(gst::Caps::builder("video/x-flash-screen").build()),
flavors::CodecId::VP6A => Some(gst::Caps::new_simple("video/x-vp6-flash-alpha", &[])), flavors::CodecId::VP6 => Some(gst::Caps::builder("video/x-vp6-flash").build()),
flavors::CodecId::SCREEN2 => Some(gst::Caps::new_simple("video/x-flash-screen2", &[])), flavors::CodecId::VP6A => Some(gst::Caps::builder("video/x-vp6-flash-alpha").build()),
flavors::CodecId::SCREEN2 => Some(gst::Caps::builder("video/x-flash-screen2").build()),
flavors::CodecId::H264 => self.avc_sequence_header.as_ref().map(|header| { flavors::CodecId::H264 => self.avc_sequence_header.as_ref().map(|header| {
gst::Caps::new_simple( gst::Caps::builder("video/x-h264")
"video/x-h264", .field("stream-format", "avc")
&[("stream-format", &"avc"), ("codec_data", &header)], .field("codec_data", &header)
) .build()
}), }),
flavors::CodecId::H263 => Some(gst::Caps::new_simple("video/x-h263", &[])), flavors::CodecId::H263 => Some(gst::Caps::builder("video/x-h263").build()),
flavors::CodecId::MPEG4Part2 => Some(gst::Caps::new_simple( flavors::CodecId::MPEG4Part2 => Some(
"video/mpeg", gst::Caps::builder("video/mpeg")
&[("mpegversion", &4i32), ("systemstream", &false)], .field("mpegversion", 4i32)
)), .field("systemstream", false)
.build(),
),
flavors::CodecId::JPEG => { flavors::CodecId::JPEG => {
// Unused according to spec // Unused according to spec
None None

View file

@ -221,31 +221,25 @@ impl ElementImpl for GifEnc {
fn pad_templates() -> &'static [gst::PadTemplate] { fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| { static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
let sink_caps = gst::Caps::new_simple( let sink_caps = gst::Caps::builder("video/x-raw")
"video/x-raw", .field(
&[ "format",
( gst::List::new([
"format", gst_video::VideoFormat::Rgb.to_str(),
&gst::List::new(&[ gst_video::VideoFormat::Rgba.to_str(),
&gst_video::VideoFormat::Rgb.to_str(), ]),
&gst_video::VideoFormat::Rgba.to_str(), )
]), .field("width", gst::IntRange::new(1, std::u16::MAX as i32))
.field("height", gst::IntRange::new(1, std::u16::MAX as i32))
.field(
"framerate",
gst::FractionRange::new(
gst::Fraction::new(1, 1),
// frame-delay timing in gif is a multiple of 10ms -> max 100fps
gst::Fraction::new(100, 1),
), ),
("width", &gst::IntRange::<i32>::new(1, std::u16::MAX as i32)), )
( .build();
"height",
&gst::IntRange::<i32>::new(1, std::u16::MAX as i32),
),
(
"framerate",
&gst::FractionRange::new(
gst::Fraction::new(1, 1),
// frame-delay timing in gif is a multiple of 10ms -> max 100fps
gst::Fraction::new(100, 1),
),
),
],
);
let sink_pad_template = gst::PadTemplate::new( let sink_pad_template = gst::PadTemplate::new(
"sink", "sink",
gst::PadDirection::Sink, gst::PadDirection::Sink,
@ -254,7 +248,7 @@ impl ElementImpl for GifEnc {
) )
.unwrap(); .unwrap();
let src_caps = gst::Caps::new_simple("image/gif", &[]); let src_caps = gst::Caps::builder("image/gif").build();
let src_pad_template = gst::PadTemplate::new( let src_pad_template = gst::PadTemplate::new(
"src", "src",
gst::PadDirection::Src, gst::PadDirection::Src,
@ -304,7 +298,7 @@ impl VideoEncoderImpl for GifEnc {
} }
let output_state = element let output_state = element
.set_output_state(gst::Caps::new_simple("image/gif", &[]), Some(state)) .set_output_state(gst::Caps::builder("image/gif").build(), Some(state))
.map_err(|_| gst::loggable_error!(CAT, "Failed to set output state"))?; .map_err(|_| gst::loggable_error!(CAT, "Failed to set output state"))?;
element element
.negotiate(output_state) .negotiate(output_state)

View file

@ -54,7 +54,7 @@ fn video_frame_to_memory_texture(
let texture_id = frame.plane_data(0).unwrap().as_ptr() as usize; let texture_id = frame.plane_data(0).unwrap().as_ptr() as usize;
let pixel_aspect_ratio = let pixel_aspect_ratio =
(*frame.info().par().numer() as f64) / (*frame.info().par().denom() as f64); (frame.info().par().numer() as f64) / (frame.info().par().denom() as f64);
if let Some(texture) = cached_textures.get(&texture_id) { if let Some(texture) = cached_textures.get(&texture_id) {
used_textures.insert(texture_id); used_textures.insert(texture_id);

View file

@ -360,21 +360,18 @@ impl ElementImpl for HsvDetector {
fn pad_templates() -> &'static [gst::PadTemplate] { fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| { static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
let caps = gst::Caps::new_simple( let caps = gst::Caps::builder("video/x-raw")
"video/x-raw", .field("format", gst::List::from(video_output_formats()))
&[ .field("width", gst::IntRange::new(0, i32::MAX))
("format", &gst::List::from_owned(video_output_formats())), .field("height", gst::IntRange::new(0, i32::MAX))
("width", &gst::IntRange::<i32>::new(0, i32::MAX)), .field(
("height", &gst::IntRange::<i32>::new(0, i32::MAX)), "framerate",
( gst::FractionRange::new(
"framerate", gst::Fraction::new(0, 1),
&gst::FractionRange::new( gst::Fraction::new(i32::MAX, 1),
gst::Fraction::new(0, 1),
gst::Fraction::new(i32::MAX, 1),
),
), ),
], )
); .build();
let src_pad_template = gst::PadTemplate::new( let src_pad_template = gst::PadTemplate::new(
"src", "src",
@ -385,21 +382,18 @@ impl ElementImpl for HsvDetector {
.unwrap(); .unwrap();
// sink pad capabilities // sink pad capabilities
let caps = gst::Caps::new_simple( let caps = gst::Caps::builder("video/x-raw")
"video/x-raw", .field("format", gst::List::from(video_input_formats()))
&[ .field("width", gst::IntRange::new(0, i32::MAX))
("format", &gst::List::from_owned(video_input_formats())), .field("height", gst::IntRange::new(0, i32::MAX))
("width", &gst::IntRange::<i32>::new(0, i32::MAX)), .field(
("height", &gst::IntRange::<i32>::new(0, i32::MAX)), "framerate",
( gst::FractionRange::new(
"framerate", gst::Fraction::new(0, 1),
&gst::FractionRange::new( gst::Fraction::new(i32::MAX, 1),
gst::Fraction::new(0, 1),
gst::Fraction::new(i32::MAX, 1),
),
), ),
], )
); .build();
let sink_pad_template = gst::PadTemplate::new( let sink_pad_template = gst::PadTemplate::new(
"sink", "sink",
@ -432,11 +426,11 @@ impl BaseTransformImpl for HsvDetector {
let mut other_caps = caps.clone(); let mut other_caps = caps.clone();
if direction == gst::PadDirection::Src { if direction == gst::PadDirection::Src {
for s in other_caps.make_mut().iter_mut() { for s in other_caps.make_mut().iter_mut() {
s.set("format", &gst::List::from_owned(video_input_formats())); s.set("format", gst::List::from(video_input_formats()));
} }
} else { } else {
for s in other_caps.make_mut().iter_mut() { for s in other_caps.make_mut().iter_mut() {
s.set("format", &gst::List::from_owned(video_output_formats())); s.set("format", gst::List::from(video_output_formats()));
} }
}; };

View file

@ -294,35 +294,32 @@ impl ElementImpl for HsvFilter {
fn pad_templates() -> &'static [gst::PadTemplate] { fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| { static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
// src pad capabilities // src pad capabilities
let caps = gst::Caps::new_simple( let caps = gst::Caps::builder("video/x-raw")
"video/x-raw", .field(
&[ "format",
( gst::List::new([
"format", gst_video::VideoFormat::Rgbx.to_str(),
&gst::List::new(&[ gst_video::VideoFormat::Xrgb.to_str(),
&gst_video::VideoFormat::Rgbx.to_str(), gst_video::VideoFormat::Bgrx.to_str(),
&gst_video::VideoFormat::Xrgb.to_str(), gst_video::VideoFormat::Xbgr.to_str(),
&gst_video::VideoFormat::Bgrx.to_str(), gst_video::VideoFormat::Rgba.to_str(),
&gst_video::VideoFormat::Xbgr.to_str(), gst_video::VideoFormat::Argb.to_str(),
&gst_video::VideoFormat::Rgba.to_str(), gst_video::VideoFormat::Bgra.to_str(),
&gst_video::VideoFormat::Argb.to_str(), gst_video::VideoFormat::Abgr.to_str(),
&gst_video::VideoFormat::Bgra.to_str(), gst_video::VideoFormat::Rgb.to_str(),
&gst_video::VideoFormat::Abgr.to_str(), gst_video::VideoFormat::Bgr.to_str(),
&gst_video::VideoFormat::Rgb.to_str(), ]),
&gst_video::VideoFormat::Bgr.to_str(), )
]), .field("width", gst::IntRange::new(0, i32::MAX))
.field("height", gst::IntRange::new(0, i32::MAX))
.field(
"framerate",
gst::FractionRange::new(
gst::Fraction::new(0, 1),
gst::Fraction::new(i32::MAX, 1),
), ),
("width", &gst::IntRange::<i32>::new(0, i32::MAX)), )
("height", &gst::IntRange::<i32>::new(0, i32::MAX)), .build();
(
"framerate",
&gst::FractionRange::new(
gst::Fraction::new(0, 1),
gst::Fraction::new(i32::MAX, 1),
),
),
],
);
let src_pad_template = gst::PadTemplate::new( let src_pad_template = gst::PadTemplate::new(
"src", "src",

View file

@ -426,35 +426,32 @@ impl ElementImpl for Rav1Enc {
fn pad_templates() -> &'static [gst::PadTemplate] { fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| { static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
let sink_caps = gst::Caps::new_simple( let sink_caps = gst::Caps::builder("video/x-raw")
"video/x-raw", .field(
&[ "format",
( gst::List::new([
"format", gst_video::VideoFormat::I420.to_str(),
&gst::List::new(&[ gst_video::VideoFormat::Y42b.to_str(),
&gst_video::VideoFormat::I420.to_str(), gst_video::VideoFormat::Y444.to_str(),
&gst_video::VideoFormat::Y42b.to_str(), gst_video::VideoFormat::I42010le.to_str(),
&gst_video::VideoFormat::Y444.to_str(), gst_video::VideoFormat::I42210le.to_str(),
&gst_video::VideoFormat::I42010le.to_str(), gst_video::VideoFormat::Y44410le.to_str(),
&gst_video::VideoFormat::I42210le.to_str(), gst_video::VideoFormat::I42012le.to_str(),
&gst_video::VideoFormat::Y44410le.to_str(), gst_video::VideoFormat::I42212le.to_str(),
&gst_video::VideoFormat::I42012le.to_str(), gst_video::VideoFormat::Y44412le.to_str(),
&gst_video::VideoFormat::I42212le.to_str(), // &gst_video::VideoFormat::Gray8.to_str(),
&gst_video::VideoFormat::Y44412le.to_str(), ]),
// &gst_video::VideoFormat::Gray8.to_str(), )
]), .field("width", gst::IntRange::new(1, std::i32::MAX))
.field("height", gst::IntRange::new(1, std::i32::MAX))
.field(
"framerate",
gst::FractionRange::new(
gst::Fraction::new(0, 1),
gst::Fraction::new(std::i32::MAX, 1),
), ),
("width", &gst::IntRange::<i32>::new(1, std::i32::MAX)), )
("height", &gst::IntRange::<i32>::new(1, std::i32::MAX)), .build();
(
"framerate",
&gst::FractionRange::new(
gst::Fraction::new(0, 1),
gst::Fraction::new(std::i32::MAX, 1),
),
),
],
);
let sink_pad_template = gst::PadTemplate::new( let sink_pad_template = gst::PadTemplate::new(
"sink", "sink",
gst::PadDirection::Sink, gst::PadDirection::Sink,
@ -463,7 +460,7 @@ impl ElementImpl for Rav1Enc {
) )
.unwrap(); .unwrap();
let src_caps = gst::Caps::new_simple("video/x-av1", &[]); let src_caps = gst::Caps::builder("video/x-av1").build();
let src_pad_template = gst::PadTemplate::new( let src_pad_template = gst::PadTemplate::new(
"src", "src",
gst::PadDirection::Src, gst::PadDirection::Src,
@ -603,8 +600,8 @@ impl VideoEncoderImpl for Rav1Enc {
speed_settings: config::SpeedSettings::from_preset(settings.speed_preset as usize), speed_settings: config::SpeedSettings::from_preset(settings.speed_preset as usize),
time_base: if video_info.fps() != gst::Fraction::new(0, 1) { time_base: if video_info.fps() != gst::Fraction::new(0, 1) {
data::Rational { data::Rational {
num: *video_info.fps().numer() as u64, num: video_info.fps().numer() as u64,
den: *video_info.fps().denom() as u64, den: video_info.fps().denom() as u64,
} }
} else { } else {
data::Rational { num: 30, den: 1 } data::Rational { num: 30, den: 1 }
@ -636,7 +633,7 @@ impl VideoEncoderImpl for Rav1Enc {
}); });
let output_state = element let output_state = element
.set_output_state(gst::Caps::new_simple("video/x-av1", &[]), Some(state)) .set_output_state(gst::Caps::builder("video/x-av1").build(), Some(state))
.map_err(|_| gst::loggable_error!(CAT, "Failed to set output state"))?; .map_err(|_| gst::loggable_error!(CAT, "Failed to set output state"))?;
element element
.negotiate(output_state) .negotiate(output_state)

View file

@ -121,7 +121,7 @@ fn test_encode(video_info: &gst_video::VideoInfo) {
let mut h = gst_check::Harness::new("rav1enc"); let mut h = gst_check::Harness::new("rav1enc");
{ {
let rav1enc = h.element().unwrap(); let rav1enc = h.element().unwrap();
rav1enc.set_property("speed-preset", &10u32).unwrap(); rav1enc.set_property("speed-preset", 10u32).unwrap();
} }
h.play(); h.play();
h.set_src_caps(video_info.to_caps().unwrap()); h.set_src_caps(video_info.to_caps().unwrap());

View file

@ -252,29 +252,26 @@ impl ElementImpl for PngEncoder {
fn pad_templates() -> &'static [gst::PadTemplate] { fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| { static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
let sink_caps = gst::Caps::new_simple( let sink_caps = gst::Caps::builder("video/x-raw")
"video/x-raw", .field(
&[ "format",
( gst::List::new([
"format", gst_video::VideoFormat::Gray8.to_str(),
&gst::List::new(&[ gst_video::VideoFormat::Gray16Be.to_str(),
&gst_video::VideoFormat::Gray8.to_str(), gst_video::VideoFormat::Rgb.to_str(),
&gst_video::VideoFormat::Gray16Be.to_str(), gst_video::VideoFormat::Rgba.to_str(),
&gst_video::VideoFormat::Rgb.to_str(), ]),
&gst_video::VideoFormat::Rgba.to_str(), )
]), .field("width", gst::IntRange::new(1, std::i32::MAX))
.field("height", gst::IntRange::new(1, std::i32::MAX))
.field(
"framerate",
gst::FractionRange::new(
gst::Fraction::new(1, 1),
gst::Fraction::new(std::i32::MAX, 1),
), ),
("width", &gst::IntRange::<i32>::new(1, std::i32::MAX)), )
("height", &gst::IntRange::<i32>::new(1, std::i32::MAX)), .build();
(
"framerate",
&gst::FractionRange::new(
gst::Fraction::new(1, 1),
gst::Fraction::new(std::i32::MAX, 1),
),
),
],
);
let sink_pad_template = gst::PadTemplate::new( let sink_pad_template = gst::PadTemplate::new(
"sink", "sink",
gst::PadDirection::Sink, gst::PadDirection::Sink,
@ -283,7 +280,7 @@ impl ElementImpl for PngEncoder {
) )
.unwrap(); .unwrap();
let src_caps = gst::Caps::new_simple("image/png", &[]); let src_caps = gst::Caps::builder("image/png").build();
let src_pad_template = gst::PadTemplate::new( let src_pad_template = gst::PadTemplate::new(
"src", "src",
gst::PadDirection::Src, gst::PadDirection::Src,
@ -320,7 +317,7 @@ impl VideoEncoderImpl for PngEncoder {
} }
let output_state = element let output_state = element
.set_output_state(gst::Caps::new_simple("image/png", &[]), Some(state)) .set_output_state(gst::Caps::builder("image/png").build(), Some(state))
.map_err(|_| gst::loggable_error!(CAT, "Failed to set output state"))?; .map_err(|_| gst::loggable_error!(CAT, "Failed to set output state"))?;
element element
.negotiate(output_state) .negotiate(output_state)

View file

@ -366,7 +366,7 @@ impl ElementImpl for WebPDec {
.unwrap(); .unwrap();
let caps = gst::Caps::builder("video/x-raw") let caps = gst::Caps::builder("video/x-raw")
.field("format", &"RGBA") .field("format", "RGBA")
.build(); .build();
let src_pad_template = gst::PadTemplate::new( let src_pad_template = gst::PadTemplate::new(