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

View file

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

View file

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

View file

@ -75,7 +75,7 @@ fn run_test(
.downcast::<gst_app::AppSink>()
.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)
.build()
.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 _relative_threshold = s.get::<f64>("relative-threshold").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()[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()[0].type_(), glib::Type::F64);
}

View file

@ -64,7 +64,9 @@ impl ElementImpl for ClaxonDec {
fn pad_templates() -> &'static [gst::PadTemplate] {
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(
"sink",
gst::PadDirection::Sink,
@ -73,23 +75,20 @@ impl ElementImpl for ClaxonDec {
)
.unwrap();
let src_caps = gst::Caps::new_simple(
"audio/x-raw",
&[
(
"format",
&gst::List::new(&[
&gst_audio::AudioFormat::S8.to_str(),
&gst_audio::AUDIO_FORMAT_S16.to_str(),
&gst_audio::AUDIO_FORMAT_S2432.to_str(),
&gst_audio::AUDIO_FORMAT_S32.to_str(),
]),
),
("rate", &gst::IntRange::<i32>::new(1, 655_350)),
("channels", &gst::IntRange::<i32>::new(1, 8)),
("layout", &"interleaved"),
],
);
let src_caps = gst::Caps::builder("audio/x-raw")
.field(
"format",
gst::List::new([
gst_audio::AudioFormat::S8.to_str(),
gst_audio::AUDIO_FORMAT_S16.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))
.field("layout", "interleaved")
.build();
let src_pad_template = gst::PadTemplate::new(
"src",
gst::PadDirection::Src,
@ -124,7 +123,7 @@ impl AudioDecoderImpl for ClaxonDec {
let mut audio_info: Option<gst_audio::AudioInfo> = None;
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();
if streamheaders.len() < 2 {

View file

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

View file

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

View file

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

View file

@ -71,7 +71,7 @@ impl ElementImpl for LewtonDec {
fn pad_templates() -> &'static [gst::PadTemplate] {
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(
"sink",
gst::PadDirection::Sink,
@ -80,15 +80,12 @@ impl ElementImpl for LewtonDec {
)
.unwrap();
let src_caps = gst::Caps::new_simple(
"audio/x-raw",
&[
("format", &gst_audio::AUDIO_FORMAT_F32.to_str()),
("rate", &gst::IntRange::<i32>::new(1, std::i32::MAX)),
("channels", &gst::IntRange::<i32>::new(1, 255)),
("layout", &"interleaved"),
],
);
let src_caps = gst::Caps::builder("audio/x-raw")
.field("format", gst_audio::AUDIO_FORMAT_F32.to_str())
.field("rate", gst::IntRange::new(1, std::i32::MAX))
.field("channels", gst::IntRange::new(1i32, 255))
.field("layout", "interleaved")
.build();
let src_pad_template = gst::PadTemplate::new(
"src",
gst::PadDirection::Src,
@ -139,7 +136,7 @@ impl AudioDecoderImpl for LewtonDec {
let mut state = state_guard.as_mut().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();
if streamheaders.len() < 3 {
gst_debug!(

View file

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

View file

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

View file

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

View file

@ -42,13 +42,13 @@ fn typefind_register(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
"sodium_encrypted_typefind",
gst::Rank::None,
None,
Some(&Caps::new_simple("application/x-sodium-encrypted", &[])),
Some(&Caps::builder("application/x-sodium-encrypted").build()),
|typefind| {
if let Some(data) = typefind.peek(0, TYPEFIND_HEADER_SIZE as u32) {
if data == TYPEFIND_HEADER {
typefind.suggest(
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();
filesrc
.set_property("location", &input_path.to_str().unwrap())
.set_property("location", input_path.to_str().unwrap())
.expect("failed to set property");
let dec = gst::ElementFactory::make("sodiumdecrypter", None).unwrap();

View file

@ -78,7 +78,7 @@ fn encrypt_file() {
.expect("failed to set property");
enc.set_property("receiver-key", &*RECEIVER_PUBLIC)
.expect("failed to set property");
enc.set_property("block-size", &1024u32)
enc.set_property("block-size", 1024u32)
.expect("failed to set property");
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 {
let sink =
gst::ElementFactory::make("fakesink", Some(format!("sink-{}", i).as_str())).unwrap();
sink.set_property("sync", &false).unwrap();
sink.set_property("async", &false).unwrap();
sink.set_property("sync", false).unwrap();
sink.set_property("async", false).unwrap();
let counter_clone = Arc::clone(&counter);
sink.static_pad("sink").unwrap().add_probe(
@ -83,11 +83,9 @@ fn main() {
let source =
gst::ElementFactory::make("udpsrc", Some(format!("source-{}", i).as_str()))
.unwrap();
source.set_property("port", 40000i32 + i as i32).unwrap();
source
.set_property("port", &(40000i32 + (i as i32)))
.unwrap();
source
.set_property("retrieve-sender-address", &false)
.set_property("retrieve-sender-address", false)
.unwrap();
source
@ -96,13 +94,11 @@ fn main() {
let source =
gst::ElementFactory::make("ts-udpsrc", Some(format!("source-{}", i).as_str()))
.unwrap();
source.set_property("port", 40000i32 + i as i32).unwrap();
source
.set_property("port", &(40000i32 + (i as i32)))
.set_property("context", format!("context-{}", (i as u32) % n_groups))
.unwrap();
source
.set_property("context", &format!("context-{}", (i as u32) % n_groups))
.unwrap();
source.set_property("context-wait", &wait).unwrap();
source.set_property("context-wait", wait).unwrap();
source
}
@ -112,8 +108,8 @@ fn main() {
Some(format!("source-{}", i).as_str()),
)
.unwrap();
source.set_property("host", &"127.0.0.1").unwrap();
source.set_property("port", &40000i32).unwrap();
source.set_property("host", "127.0.0.1").unwrap();
source.set_property("port", 40000i32).unwrap();
source
}
@ -123,12 +119,12 @@ fn main() {
Some(format!("source-{}", i).as_str()),
)
.unwrap();
source.set_property("host", &"127.0.0.1").unwrap();
source.set_property("port", &40000i32).unwrap();
source.set_property("host", "127.0.0.1").unwrap();
source.set_property("port", 40000i32).unwrap();
source
.set_property("context", &format!("context-{}", (i as u32) % n_groups))
.set_property("context", format!("context-{}", (i as u32) % n_groups))
.unwrap();
source.set_property("context-wait", &wait).unwrap();
source.set_property("context-wait", wait).unwrap();
source
}
@ -139,10 +135,10 @@ fn main() {
)
.unwrap();
source
.set_property("samplesperbuffer", &((wait as i32) * 8000 / 1000))
.set_property("samplesperbuffer", (wait as i32) * 8000 / 1000)
.unwrap();
sink.set_property("sync", &true).unwrap();
sink.set_property("sync", true).unwrap();
source
}
@ -151,12 +147,12 @@ fn main() {
gst::ElementFactory::make("ts-tonesrc", Some(format!("source-{}", i).as_str()))
.unwrap();
source
.set_property("samples-per-buffer", &((wait as u32) * 8000 / 1000))
.set_property("samples-per-buffer", (wait as u32) * 8000 / 1000)
.unwrap();
source
.set_property("context", &format!("context-{}", (i as u32) % n_groups))
.set_property("context", format!("context-{}", (i as u32) % n_groups))
.unwrap();
source.set_property("context-wait", &wait).unwrap();
source.set_property("context-wait", wait).unwrap();
source
}

View file

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

View file

@ -33,12 +33,12 @@ fn push() {
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();
appsrc.set_property("caps", &caps).unwrap();
appsrc.set_property("do-timestamp", &true).unwrap();
appsrc.set_property("context", &"appsrc-push").unwrap();
appsrc.set_property("do-timestamp", true).unwrap();
appsrc.set_property("context", "appsrc-push").unwrap();
}
h.play();
@ -99,12 +99,12 @@ fn pause_regular() {
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();
appsrc.set_property("caps", &caps).unwrap();
appsrc.set_property("do-timestamp", &true).unwrap();
appsrc.set_property("context", &"appsrc-pause").unwrap();
appsrc.set_property("do-timestamp", true).unwrap();
appsrc.set_property("context", "appsrc-pause").unwrap();
}
h.play();
@ -169,12 +169,12 @@ fn flush_regular() {
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();
appsrc.set_property("caps", &caps).unwrap();
appsrc.set_property("do-timestamp", &true).unwrap();
appsrc.set_property("context", &"appsrc-flush").unwrap();
appsrc.set_property("do-timestamp", true).unwrap();
appsrc.set_property("context", "appsrc-flush").unwrap();
}
h.play();
@ -228,13 +228,13 @@ fn pause_flush() {
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();
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_flush")
.set_property("context", "appsrc-pause_flush")
.unwrap();
}

View file

@ -51,24 +51,24 @@ fn jb_pipeline() {
let pipeline = gst::Pipeline::new(None);
let src = gst::ElementFactory::make("audiotestsrc", Some("audiotestsrc")).unwrap();
src.set_property("is-live", &true).unwrap();
src.set_property("num-buffers", &BUFFER_NB).unwrap();
src.set_property("is-live", true).unwrap();
src.set_property("num-buffers", BUFFER_NB).unwrap();
let enc = gst::ElementFactory::make("alawenc", Some("alawenc")).unwrap();
let pay = gst::ElementFactory::make("rtppcmapay", Some("rtppcmapay")).unwrap();
let jb = gst::ElementFactory::make("ts-jitterbuffer", Some("ts-jitterbuffer")).unwrap();
jb.set_property("context", &"jb_pipeline").unwrap();
jb.set_property("context-wait", &CONTEXT_WAIT).unwrap();
jb.set_property("latency", &LATENCY).unwrap();
jb.set_property("context", "jb_pipeline").unwrap();
jb.set_property("context-wait", CONTEXT_WAIT).unwrap();
jb.set_property("latency", LATENCY).unwrap();
let depay = gst::ElementFactory::make("rtppcmadepay", Some("rtppcmadepay")).unwrap();
let dec = gst::ElementFactory::make("alawdec", Some("alawdec")).unwrap();
let sink = gst::ElementFactory::make("appsink", Some("appsink")).unwrap();
sink.set_property("sync", &false).unwrap();
sink.set_property("async", &false).unwrap();
sink.set_property("emit-signals", &true).unwrap();
sink.set_property("sync", false).unwrap();
sink.set_property("async", false).unwrap();
sink.set_property("emit-signals", true).unwrap();
pipeline
.add_many(&[&src, &enc, &pay, &jb, &depay, &dec, &sink])
@ -115,30 +115,30 @@ fn jb_ts_pipeline() {
let pipeline = gst::Pipeline::new(None);
let src = gst::ElementFactory::make("audiotestsrc", Some("audiotestsrc")).unwrap();
src.set_property("is-live", &true).unwrap();
src.set_property("num-buffers", &BUFFER_NB).unwrap();
src.set_property("is-live", true).unwrap();
src.set_property("num-buffers", BUFFER_NB).unwrap();
let queue = gst::ElementFactory::make("ts-queue", Some("ts-queue")).unwrap();
queue
.set_property("context", &"jb_ts_pipeline_queue")
.set_property("context", "jb_ts_pipeline_queue")
.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 pay = gst::ElementFactory::make("rtppcmapay", Some("rtppcmapay")).unwrap();
let jb = gst::ElementFactory::make("ts-jitterbuffer", Some("ts-jitterbuffer")).unwrap();
jb.set_property("context", &"jb_ts_pipeline").unwrap();
jb.set_property("context-wait", &CONTEXT_WAIT).unwrap();
jb.set_property("latency", &LATENCY).unwrap();
jb.set_property("context", "jb_ts_pipeline").unwrap();
jb.set_property("context-wait", CONTEXT_WAIT).unwrap();
jb.set_property("latency", LATENCY).unwrap();
let depay = gst::ElementFactory::make("rtppcmadepay", Some("rtppcmadepay")).unwrap();
let dec = gst::ElementFactory::make("alawdec", Some("alawdec")).unwrap();
let sink = gst::ElementFactory::make("appsink", Some("appsink")).unwrap();
sink.set_property("sync", &false).unwrap();
sink.set_property("async", &false).unwrap();
sink.set_property("emit-signals", &true).unwrap();
sink.set_property("sync", false).unwrap();
sink.set_property("async", false).unwrap();
sink.set_property("emit-signals", true).unwrap();
pipeline
.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();
ts_queue
.set_property("context", &format!("{}_queue", name))
.set_property("context", format!("{}_queue", name))
.unwrap();
ts_queue
.set_property("context-wait", &(THROTTLING_DURATION.as_millis() as u32))
.set_property("context-wait", THROTTLING_DURATION.as_millis() as u32)
.unwrap();
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();
ts_proxy_sink
.set_property("proxy-context", &format!("{}_proxy_context", name))
.set_property("proxy-context", format!("{}_proxy_context", name))
.unwrap();
let ts_proxy_src = gst::ElementFactory::make("ts-proxysrc", Some("ts-proxysrc")).unwrap();
ts_proxy_src
.set_property("proxy-context", &format!("{}_proxy_context", name))
.set_property("proxy-context", format!("{}_proxy_context", name))
.unwrap();
ts_proxy_src
.set_property("context", &format!("{}_context", name))
.set_property("context", format!("{}_context", name))
.unwrap();
ts_proxy_src
.set_property("context-wait", &(THROTTLING_DURATION.as_millis() as u32))
.set_property("context-wait", THROTTLING_DURATION.as_millis() as u32)
.unwrap();
let (pipeline, src_element, _sink_element, receiver) =

View file

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

View file

@ -45,11 +45,11 @@ fn test_push() {
fakesrc.link(&proxysink).unwrap();
proxysrc.link(&appsink).unwrap();
fakesrc.set_property("num-buffers", &3i32).unwrap();
proxysink.set_property("proxy-context", &"test1").unwrap();
proxysrc.set_property("proxy-context", &"test1").unwrap();
fakesrc.set_property("num-buffers", 3i32).unwrap();
proxysink.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()));
@ -117,8 +117,8 @@ fn test_from_pipeline_to_pipeline() {
pipe_2.add_many(&[&pxsrc, &fakesink]).unwrap();
pxsrc.link(&fakesink).unwrap();
pxsink.set_property("proxy-context", &"test2").unwrap();
pxsrc.set_property("proxy-context", &"test2").unwrap();
pxsink.set_property("proxy-context", "test2").unwrap();
pxsrc.set_property("proxy-context", "test2").unwrap();
pipe_1.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();
pxsrc_2.link(&pxsink_2).unwrap();
pxsrc_1.set_property("proxy-context", &"test3").unwrap();
pxsink_2.set_property("proxy-context", &"test3").unwrap();
pxsrc_1.set_property("proxy-context", "test3").unwrap();
pxsink_2.set_property("proxy-context", "test3").unwrap();
pxsrc_2.set_property("proxy-context", &"test4").unwrap();
pxsink_1.set_property("proxy-context", &"test4").unwrap();
pxsrc_2.set_property("proxy-context", "test4").unwrap();
pxsink_1.set_property("proxy-context", "test4").unwrap();
pipe_1.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();
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()));

View file

@ -56,17 +56,17 @@ fn test_push() {
let tcpclientsrc = gst::ElementFactory::make("ts-tcpclientsrc", None).unwrap();
let appsink = gst::ElementFactory::make("appsink", None).unwrap();
appsink.set_property("sync", &false).unwrap();
appsink.set_property("async", &false).unwrap();
appsink.set_property("sync", false).unwrap();
appsink.set_property("async", false).unwrap();
pipeline.add_many(&[&tcpclientsrc, &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("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()));

View file

@ -99,7 +99,7 @@ fn test_client_management() {
/* The client properties is writable too */
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();
let clients = udpsink
.property("clients")
@ -125,7 +125,7 @@ fn test_chain() {
h.set_src_caps_str("foo/bar");
{
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 || {

View file

@ -35,12 +35,12 @@ fn test_push() {
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();
udpsrc.set_property("caps", &caps).unwrap();
udpsrc.set_property("port", &5000i32).unwrap();
udpsrc.set_property("context", &"test-push").unwrap();
udpsrc.set_property("port", 5000i32).unwrap();
udpsrc.set_property("context", "test-push").unwrap();
}
h.play();
@ -105,10 +105,8 @@ fn test_socket_reuse() {
{
let udpsrc = ts_src_h.element().unwrap();
udpsrc.set_property("port", &6000i32).unwrap();
udpsrc
.set_property("context", &"test-socket-reuse")
.unwrap();
udpsrc.set_property("port", 6000i32).unwrap();
udpsrc.set_property("context", "test-socket-reuse").unwrap();
}
ts_src_h.play();
@ -122,18 +120,16 @@ fn test_socket_reuse() {
let udpsink = sink_h.element().unwrap();
udpsink.set_property("socket", &socket).unwrap();
udpsink.set_property("host", &"127.0.0.1").unwrap();
udpsink.set_property("port", &6001i32).unwrap();
udpsink.set_property("host", "127.0.0.1").unwrap();
udpsink.set_property("port", 6001i32).unwrap();
}
sink_h.play();
sink_h.set_src_caps_str("application/test");
{
let udpsrc = ts_src_h2.element().unwrap();
udpsrc.set_property("port", &6001i32).unwrap();
udpsrc
.set_property("context", &"test-socket-reuse")
.unwrap();
udpsrc.set_property("port", 6001i32).unwrap();
udpsrc.set_property("context", "test-socket-reuse").unwrap();
}
ts_src_h2.play();

View file

@ -429,11 +429,11 @@ impl ReqwestHttpSrc {
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() {
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() {
append_header(&field, value);
}
@ -552,7 +552,7 @@ impl ReqwestHttpSrc {
.and_then(|s| s.parse::<i32>().ok())
.map(|icy_metaint| {
gst::Caps::builder("application/x-icy")
.field("metadata-interval", &icy_metaint)
.field("metadata-interval", icy_metaint)
.build()
});
@ -578,10 +578,10 @@ impl ReqwestHttpSrc {
caps = Some(
gst::Caps::builder("audio/x-unaligned-raw")
.field("format", &"S16BE")
.field("layout", &"interleaved")
.field("channels", &channels)
.field("rate", &rate)
.field("format", "S16BE")
.field("layout", "interleaved")
.field("channels", channels)
.field("rate", rate)
.build(),
);
}

View file

@ -142,7 +142,7 @@ impl Harness {
});
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();
// 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"))
},
|src| {
src.set_property("keep-alive", &false).unwrap();
src.set_property("compress", &true).unwrap();
src.set_property("iradio-mode", &false).unwrap();
src.set_property("user-agent", &"test user-agent").unwrap();
src.set_property("keep-alive", false).unwrap();
src.set_property("compress", true).unwrap();
src.set_property("iradio-mode", false).unwrap();
src.set_property("user-agent", "test user-agent").unwrap();
},
);
@ -485,10 +485,10 @@ fn test_extra_headers() {
src.set_property(
"extra-headers",
&gst::Structure::builder("headers")
.field("foo", &"bar")
.field("baz", &1i32)
.field("list", &gst::List::new(&[&1i32, &2i32]))
.field("array", &gst::Array::new(&[&1i32, &2i32]))
.field("foo", "bar")
.field("baz", 1i32)
.field("list", gst::List::new([1i32, 2i32]))
.field("array", gst::Array::new([1i32, 2i32]))
.build(),
)
.unwrap();
@ -650,8 +650,8 @@ fn test_iradio_mode() {
assert_eq!(
caps,
gst::Caps::builder("application/x-icy")
.field("metadata-interval", &8192i32)
.field("content-type", &"audio/mpeg; rate=44100")
.field("metadata-interval", 8192i32)
.field("content-type", "audio/mpeg; rate=44100")
.build()
);
@ -726,10 +726,10 @@ fn test_audio_l16() {
assert_eq!(
caps,
gst::Caps::builder("audio/x-unaligned-raw")
.field("format", &"S16BE")
.field("layout", &"interleaved")
.field("channels", &2i32)
.field("rate", &48_000i32)
.field("format", "S16BE")
.field("layout", "interleaved")
.field("channels", 2i32)
.field("rate", 48_000i32)
.build()
);
}
@ -760,8 +760,8 @@ fn test_authorization() {
}
},
|src| {
src.set_property("user-id", &"user").unwrap();
src.set_property("user-pw", &"password").unwrap();
src.set_property("user-id", "user").unwrap();
src.set_property("user-pw", "password").unwrap();
},
);
@ -860,7 +860,7 @@ fn test_network_error() {
let mut h = Harness::new(
|_req| unreachable!(),
|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")
.field("format", &"utf8")
.field("format", "utf8")
.build();
events.push(
gst::event::Caps::builder(&caps)
@ -1275,7 +1275,7 @@ impl ElementImpl for Transcriber {
fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
let src_caps = gst::Caps::builder("text/x-raw")
.field("format", &"utf8")
.field("format", "utf8")
.build();
let src_pad_template = gst::PadTemplate::new(
"src",
@ -1286,9 +1286,9 @@ impl ElementImpl for Transcriber {
.unwrap();
let sink_caps = gst::Caps::builder("audio/x-raw")
.field("format", &"S16LE")
.field("rate", &gst::IntRange::<i32>::new(8000, 48000))
.field("channels", &1)
.field("format", "S16LE")
.field("rate", gst::IntRange::new(8000i32, 48000))
.field("channels", 1)
.build();
let sink_pad_template = gst::PadTemplate::new(
"sink",

View file

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

View file

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

View file

@ -40,12 +40,12 @@ fn test_replace_all() {
{
let regex = h.element().expect("Could not create regex");
let command = gst::Structure::new(
"replace-all",
&[("pattern", &"crap"), ("replacement", &"trap")],
);
let command = gst::Structure::builder("replace-all")
.field("pattern", "crap")
.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();
}

View file

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

View file

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

View file

@ -64,7 +64,7 @@ impl ObjectSubclass for ProgressBin {
// Create the progressreport element.
let progress = gst::ElementFactory::make("progressreport", Some("progress")).unwrap();
// 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
Self {

View file

@ -205,27 +205,24 @@ impl ElementImpl for Rgb2Gray {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
// On the src pad, we can produce BGRx and GRAY8 of any
// width/height and with any framerate
let caps = gst::Caps::new_simple(
"video/x-raw",
&[
(
"format",
&gst::List::new(&[
&gst_video::VideoFormat::Bgrx.to_str(),
&gst_video::VideoFormat::Gray8.to_str(),
]),
let caps = gst::Caps::builder("video/x-raw")
.field(
"format",
gst::List::new([
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)),
(
"framerate",
&gst::FractionRange::new(
gst::Fraction::new(0, 1),
gst::Fraction::new(i32::MAX, 1),
),
),
],
);
)
.build();
// The src pad template must be named "src" for basetransform
// and specific a pad that is always there
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
// width/height and with any framerate
let caps = gst::Caps::new_simple(
"video/x-raw",
&[
("format", &gst_video::VideoFormat::Bgrx.to_str()),
("width", &gst::IntRange::<i32>::new(0, i32::MAX)),
("height", &gst::IntRange::<i32>::new(0, i32::MAX)),
(
"framerate",
&gst::FractionRange::new(
gst::Fraction::new(0, 1),
gst::Fraction::new(i32::MAX, 1),
),
let caps = gst::Caps::builder("video/x-raw")
.field("format", gst_video::VideoFormat::Bgrx.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),
),
],
);
)
.build();
// The sink pad template must be named "sink" for basetransform
// and specific a pad that is always there
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(|| {
// On the src pad, we can produce F32/F64 with any sample rate
// and any number of channels
let caps = gst::Caps::new_simple(
"audio/x-raw",
&[
(
"format",
&gst::List::new(&[
&gst_audio::AUDIO_FORMAT_F32.to_str(),
&gst_audio::AUDIO_FORMAT_F64.to_str(),
]),
),
("layout", &"interleaved"),
("rate", &gst::IntRange::<i32>::new(1, i32::MAX)),
("channels", &gst::IntRange::<i32>::new(1, i32::MAX)),
],
);
let caps = gst::Caps::builder("audio/x-raw")
.field(
"format",
gst::List::new([
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))
.field("channels", gst::IntRange::new(1, i32::MAX))
.build();
// The src pad template must be named "src" for basesrc
// and specific a pad that is always there
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.
```rust
let caps = gst::Caps::new_simple(
"video/x-raw",
&[
(
"format",
&gst::List::new(&[
&gst_video::VideoFormat::Bgrx.to_str(),
&gst_video::VideoFormat::Gray8.to_str(),
]),
let caps = gst::Caps::builder("video/x-raw")
.field(
"format",
gst::List::new([
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)),
(
"framerate",
&gst::FractionRange::new(
gst::Fraction::new(0, 1),
gst::Fraction::new(i32::MAX, 1),
),
),
],
);
)
.build();
let src_pad_template = gst::PadTemplate::new(
"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);
let caps = gst::Caps::new_simple(
"video/x-raw",
&[
("format", &gst_video::VideoFormat::Bgrx.to_str()),
("width", &gst::IntRange::<i32>::new(0, i32::MAX)),
("height", &gst::IntRange::<i32>::new(0, i32::MAX)),
(
"framerate",
&gst::FractionRange::new(
gst::Fraction::new(0, 1),
gst::Fraction::new(i32::MAX, 1),
),
let caps = gst::Caps::builder("video/x-raw")
.field("format", gst_video::VideoFormat::Bgrx.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),
),
],
);
)
.build();
let sink_pad_template = gst::PadTemplate::new(
"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
// and any number of channels
let caps = gst::Caps::new_simple(
"audio/x-raw",
&[
(
"format",
&gst::List::new(&[
&gst_audio::AUDIO_FORMAT_F32.to_str(),
&gst_audio::AUDIO_FORMAT_F64.to_str(),
]),
),
("layout", &"interleaved"),
("rate", &gst::IntRange::<i32>::new(1, i32::MAX)),
("channels", &gst::IntRange::<i32>::new(1, i32::MAX)),
],
);
let caps = gst::Caps::builder("audio/x-raw")
.field(
"format",
gst::List::new([
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))
.field("channels", gst::IntRange::new(1, i32::MAX))
.build();
// The src pad template must be named "src" for basesrc
// and specific a pad that is always there
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();
fallbackswitch
.set_property("timeout", &gst::ClockTime::SECOND)
.set_property("timeout", gst::ClockTime::SECOND)
.unwrap();
let decodebin = gst::ElementFactory::make("decodebin", None).unwrap();

View file

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

View file

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

View file

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

View file

@ -33,12 +33,12 @@ fn create_pipeline() -> (
let pipeline = gst::Pipeline::new(None);
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();
let timeoverlay = gst::ElementFactory::make("timeoverlay", None).unwrap();
timeoverlay
.set_property("font-desc", &"Monospace 20")
.set_property("font-desc", "Monospace 20")
.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();
video_enc.set_property("rc-lookahead", &10i32).unwrap();
video_enc.set_property("key-int-max", &30u32).unwrap();
video_enc.set_property("rc-lookahead", 10i32).unwrap();
video_enc.set_property("key-int-max", 30u32).unwrap();
let video_parse = gst::ElementFactory::make("h264parse", 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();
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 file_sink = gst::ElementFactory::make("filesink", None).unwrap();
file_sink
.set_property("location", &"recording.mp4")
.unwrap();
file_sink.set_property("async", &false).unwrap();
file_sink.set_property("sync", &false).unwrap();
file_sink.set_property("location", "recording.mp4").unwrap();
file_sink.set_property("async", false).unwrap();
file_sink.set_property("sync", false).unwrap();
pipeline
.add_many(&[
@ -262,7 +260,7 @@ fn create_ui(app: &gtk::Application) {
.unwrap()
.get::<bool>()
.unwrap();
togglerecord.set_property("record", &recording).unwrap();
togglerecord.set_property("record", recording).unwrap();
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 {
if video_info.fps() != 0.into() {
gst::ClockTime::SECOND.mul_div_floor(
*video_info.fps().denom() as u64,
*video_info.fps().numer() as u64,
video_info.fps().denom() as u64,
video_info.fps().numer() as u64,
)
} else {
gst::ClockTime::NONE

View file

@ -53,7 +53,7 @@ fn setup_sender_receiver(
thread::JoinHandle<()>,
) {
let fakesink = gst::ElementFactory::make("fakesink", None).unwrap();
fakesink.set_property("async", &false).unwrap();
fakesink.set_property("async", false).unwrap();
pipeline.add(&fakesink).unwrap();
let main_stream = pad == "src";
@ -111,17 +111,17 @@ fn setup_sender_receiver(
assert!(sinkpad.send_event(gst::event::StreamStart::new("test")));
let caps = if main_stream {
gst::Caps::builder("video/x-raw")
.field("format", &"ARGB")
.field("width", &320i32)
.field("height", &240i32)
.field("framerate", &gst::Fraction::new(50, 1))
.field("format", "ARGB")
.field("width", 320i32)
.field("height", 240i32)
.field("framerate", gst::Fraction::new(50, 1))
.build()
} else {
gst::Caps::builder("audio/x-raw")
.field("format", &"U8")
.field("layout", &"interleaved")
.field("rate", &8000i32)
.field("channels", &1i32)
.field("format", "U8")
.field("layout", "interleaved")
.field("rate", 8000i32)
.field("channels", 1i32)
.build()
};
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();
togglerecord.set_property("record", &true).unwrap();
togglerecord.set_property("record", true).unwrap();
sender_input.send(SendData::Buffers(10)).unwrap();
drop(sender_input);
@ -330,7 +330,7 @@ fn test_one_stream_gaps_open() {
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::Gaps(5)).unwrap();
drop(sender_input);
@ -365,7 +365,7 @@ fn test_one_stream_close_open() {
sender_input.send(SendData::Buffers(10)).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();
drop(sender_input);
@ -397,10 +397,10 @@ fn test_one_stream_open_close() {
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();
receiver_input_done.recv().unwrap();
togglerecord.set_property("record", &false).unwrap();
togglerecord.set_property("record", false).unwrap();
sender_input.send(SendData::Buffers(10)).unwrap();
drop(sender_input);
@ -432,13 +432,13 @@ fn test_one_stream_open_close_open() {
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();
receiver_input_done.recv().unwrap();
togglerecord.set_property("record", &false).unwrap();
togglerecord.set_property("record", false).unwrap();
sender_input.send(SendData::Buffers(10)).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();
drop(sender_input);
@ -478,7 +478,7 @@ fn test_two_stream_open() {
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_2.send(SendData::Buffers(11)).unwrap();
@ -536,7 +536,7 @@ fn test_two_stream_open_shift() {
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_2.send(SendData::Buffers(11)).unwrap();
@ -599,7 +599,7 @@ fn test_two_stream_open_shift_main() {
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_2.send(SendData::Buffers(12)).unwrap();
@ -676,7 +676,7 @@ fn test_two_stream_open_close() {
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_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
// 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();
receiver_input_done_2.recv().unwrap();
@ -745,7 +745,7 @@ fn test_two_stream_close_open() {
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_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
// 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();
receiver_input_done_2.recv().unwrap();
@ -814,7 +814,7 @@ fn test_two_stream_open_close_open() {
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_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
// 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();
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();
// 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_2.send(SendData::Buffers(10)).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();
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::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
// 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();
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();
// 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_2.send(SendData::Buffers(10)).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();
togglerecord.set_property("record", &false).unwrap();
togglerecord.set_property("record", false).unwrap();
sender_input_1.send(SendData::Buffers(10)).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,
// so will be dropped, and as such the next frame of sender 2 will also be dropped
// 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::Buffers(9)).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
// The first one is a delta frame, so we only actually stop recording
// 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::Buffers(9)).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();
togglerecord.set_property("record", &true).unwrap();
togglerecord.set_property("record", true).unwrap();
sender_input_1.send(SendData::Buffers(10)).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
// 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();
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();
// 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_2.send(SendData::Buffers(10)).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();
togglerecord.set_property("record", &true).unwrap();
togglerecord.set_property("record", true).unwrap();
// Send 10 buffers to main stream first
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();
togglerecord.set_property("record", &true).unwrap();
togglerecord.set_property("record", true).unwrap();
// Send 10 buffers to main stream first
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();
togglerecord.set_property("record", &true).unwrap();
togglerecord.set_property("record", true).unwrap();
sender_input_1.send(SendData::Buffers(10)).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();
togglerecord.set_property("record", &true).unwrap();
togglerecord.set_property("record", true).unwrap();
sender_input_1.send(SendData::Buffers(10)).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();
togglerecord.set_property("record", &true).unwrap();
togglerecord.set_property("record", true).unwrap();
sender_input_1.send(SendData::Buffers(10)).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] {
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(
"sink",
gst::PadDirection::Sink,
@ -63,15 +65,12 @@ impl ElementImpl for CdgDec {
)
.unwrap();
let src_caps = gst::Caps::new_simple(
"video/x-raw",
&[
("format", &gst_video::VideoFormat::Rgba.to_str()),
("width", &(CDG_WIDTH as i32)),
("height", &(CDG_HEIGHT as i32)),
("framerate", &gst::Fraction::new(0, 1)),
],
);
let src_caps = gst::Caps::builder("video/x-raw")
.field("format", gst_video::VideoFormat::Rgba.to_str())
.field("width", CDG_WIDTH as i32)
.field("height", CDG_HEIGHT as i32)
.field("framerate", gst::Fraction::new(0, 1))
.build();
let src_pad_template = gst::PadTemplate::new(
"src",
gst::PadDirection::Src,

View file

@ -60,7 +60,7 @@ impl ElementImpl for CdgParse {
fn pad_templates() -> &'static [gst::PadTemplate] {
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(
"sink",
gst::PadDirection::Sink,
@ -69,15 +69,12 @@ impl ElementImpl for CdgParse {
)
.unwrap();
let src_caps = gst::Caps::new_simple(
"video/x-cdg",
&[
("width", &(CDG_WIDTH as i32)),
("height", &(CDG_HEIGHT as i32)),
("framerate", &gst::Fraction::new(0, 1)),
("parsed", &true),
],
);
let src_caps = gst::Caps::builder("video/x-cdg")
.field("width", CDG_WIDTH as i32)
.field("height", CDG_HEIGHT as i32)
.field("framerate", gst::Fraction::new(0, 1))
.field("parsed", true)
.build();
let src_pad_template = gst::PadTemplate::new(
"src",
gst::PadDirection::Src,
@ -136,15 +133,12 @@ impl BaseParseImpl for CdgParse {
let pad = element.src_pad();
if pad.current_caps().is_none() {
// Set src pad caps
let src_caps = gst::Caps::new_simple(
"video/x-cdg",
&[
("width", &(CDG_WIDTH as i32)),
("height", &(CDG_HEIGHT as i32)),
("framerate", &gst::Fraction::new(0, 1)),
("parsed", &true),
],
);
let src_caps = gst::Caps::builder("video/x-cdg")
.field("width", CDG_WIDTH as i32)
.field("height", CDG_HEIGHT as i32)
.field("framerate", gst::Fraction::new(0, 1))
.field("parsed", true)
.build();
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",
gst::Rank::None,
Some("cdg"),
Some(&Caps::new_simple("video/x-cdg", &[])),
Some(&Caps::builder("video/x-cdg").build()),
|mut typefind| {
let proba = compute_probability(&mut typefind);
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
let filesrc = gst::ElementFactory::make("pushfilesrc", None).unwrap();
filesrc
.set_property("location", &input_path.to_str().unwrap())
.set_property("location", input_path.to_str().unwrap())
.expect("failed to set 'location' property");
{
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 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();
caps.append_structure(s);
}

View file

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

View file

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

View file

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

View file

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

View file

@ -195,8 +195,8 @@ impl State {
let framerate = self.framerate.unwrap();
let dur = gst::ClockTime::SECOND.mul_div_floor(
self.internal_buffer.len() as u64 * *framerate.denom() as u64,
*framerate.numer() as u64,
self.internal_buffer.len() as u64 * framerate.denom() as u64,
framerate.numer() as u64,
);
buf_mut.set_duration(dur);
@ -409,10 +409,10 @@ impl ElementImpl for SccEnc {
fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
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")
.field("format", &"raw")
.field("framerate", &framerates)
.field("format", "raw")
.field("framerate", framerates)
.build();
let sink_pad_template = gst::PadTemplate::new(
"sink",

View file

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

View file

@ -67,7 +67,7 @@ impl Default for Settings {
fn default() -> Self {
Self {
cc_caps: gst::Caps::builder("closedcaption/x-cea-608")
.field("format", &"raw")
.field("format", "raw")
.build(),
passthrough: DEFAULT_PASSTHROUGH,
latency: DEFAULT_LATENCY,
@ -139,16 +139,16 @@ impl TranscriberBin {
state
.transcriber_queue
.set_property("max-size-buffers", &0u32)
.set_property("max-size-buffers", 0u32)
.unwrap();
state
.transcriber_queue
.set_property("max-size-time", &0u64)
.set_property("max-size-time", 0u64)
.unwrap();
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);
@ -208,7 +208,7 @@ impl TranscriberBin {
state
.cccombiner
.set_property("latency", &(100 * gst::ClockTime::MSECOND))
.set_property("latency", 100 * gst::ClockTime::MSECOND)
.unwrap();
self.audio_sinkpad
@ -239,15 +239,15 @@ impl TranscriberBin {
let max_size_time = settings.latency + settings.accumulate_time;
for queue in &[&state.audio_queue_passthrough, &state.video_queue] {
queue.set_property("max-size-bytes", &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-bytes", 0u32).unwrap();
queue.set_property("max-size-buffers", 0u32).unwrap();
queue.set_property("max-size-time", max_size_time).unwrap();
}
let latency_ms = settings.latency.mseconds() as u32;
state
.transcriber
.set_property("latency", &latency_ms)
.set_property("latency", latency_ms)
.unwrap();
if !settings.passthrough {
@ -349,19 +349,19 @@ impl TranscriberBin {
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() {
state
.textwrap
.set_property("accumulate-time", &0u64)
.set_property("accumulate-time", 0u64)
.unwrap();
} else {
let accumulate_time = self.settings.lock().unwrap().accumulate_time;
state
.textwrap
.set_property("accumulate-time", &accumulate_time)
.set_property("accumulate-time", accumulate_time)
.unwrap();
}
}
@ -776,7 +776,7 @@ impl ElementImpl for TranscriberBin {
fn pad_templates() -> &'static [gst::PadTemplate] {
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(
"src_video",
gst::PadDirection::Src,
@ -792,7 +792,7 @@ impl ElementImpl for TranscriberBin {
)
.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(
"src_audio",
gst::PadDirection::Src,

View file

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

View file

@ -134,7 +134,7 @@ impl TtToJson {
EventView::Caps(_) => {
// We send our own caps downstream
let caps = gst::Caps::builder("application/x-json")
.field("format", &"cea608")
.field("format", "cea608")
.build();
self.srcpad.push_event(gst::event::Caps::new(&caps))
}
@ -163,7 +163,7 @@ impl ElementImpl for TtToJson {
fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
let caps = gst::Caps::builder("text/x-raw")
.field("format", &"utf8")
.field("format", "utf8")
.build();
let sink_pad_template = gst::PadTemplate::new(
"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.element()
.unwrap()
.set_property("window", &(500_000_000u64))
.set_property("window", 500_000_000u64)
.unwrap();
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.element()
.unwrap()
.set_property("window", &500_000_000u64)
.set_property("window", 500_000_000u64)
.unwrap();
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.element()
.unwrap()
.set_property("window", &500_000_000u64)
.set_property("window", 500_000_000u64)
.unwrap();
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");
h.set_src_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_c = state.clone();
@ -388,7 +388,7 @@ fn test_gap_events() {
h.set_sink_caps_str("closedcaption/x-cea-708,format=cc_data");
h.element()
.unwrap()
.set_property("window", &500_000_000u64)
.set_property("window", 500_000_000u64)
.unwrap();
let state = Arc::new(Mutex::new(NotifyState::default()));

View file

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

View file

@ -93,11 +93,11 @@ Time Code Rate=30DF\r\n\
let mut h = gst_check::Harness::new("mccenc");
{
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();
enc.set_property(
"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();
}

View file

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

View file

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

View file

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

View file

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

View file

@ -210,18 +210,18 @@ impl ElementImpl for FlvDemux {
caps.append(
gst::Caps::builder("audio/mpeg")
.field("mpegversion", &1i32)
.field("mpegversion", 1i32)
.build(),
);
caps.append(
gst::Caps::builder("audio/x-raw")
.field("layout", &"interleaved")
.field("format", &gst::List::new(&[&"U8", &"S16LE"]))
.field("layout", "interleaved")
.field("format", gst::List::new(["U8", "S16LE"]))
.build(),
);
caps.append(
gst::Caps::builder("audio/x-adpcm")
.field("layout", &"swf")
.field("layout", "swf")
.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/mpeg")
.field("mpegversion", &4i32)
.field("framed", &true)
.field("stream-format", &"raw")
.field("mpegversion", 4i32)
.field("framed", true)
.field("stream-format", "raw")
.build(),
);
caps.append(gst::Caps::builder("audio/x-speex").build());
@ -250,7 +250,7 @@ impl ElementImpl for FlvDemux {
caps.append(
gst::Caps::builder("video/x-flash-video")
.field("flvversion", &1i32)
.field("flvversion", 1i32)
.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-h264")
.field("stream-format", &"avc")
.field("stream-format", "avc")
.build(),
);
caps.append(gst::Caps::builder("video/x-h263").build());
caps.append(
gst::Caps::builder("video/mpeg")
.field("mpegversion", &4i32)
.field("mpegversion", 4i32)
.build(),
);
}
@ -1269,44 +1269,44 @@ impl AudioFormat {
fn to_caps(&self) -> Option<gst::Caps> {
let mut caps = match self.format {
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 => {
if self.rate != 0 && self.channels != 0 {
// 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
Some(gst::Caps::new_simple(
"audio/x-raw",
&[
("layout", &"interleaved"),
("format", &if self.width == 8 { "U8" } else { "S16LE" }),
],
))
Some(
gst::Caps::builder("audio/x-raw")
.field("layout", "interleaved")
.field("format", if self.width == 8 { "U8" } else { "S16LE" })
.build(),
)
} else {
None
}
}
flavors::SoundFormat::ADPCM => Some(gst::Caps::new_simple(
"audio/x-adpcm",
&[("layout", &"swf")],
)),
flavors::SoundFormat::ADPCM => Some(
gst::Caps::builder("audio/x-adpcm")
.field("layout", "swf")
.build(),
),
flavors::SoundFormat::NELLYMOSER_16KHZ_MONO
| flavors::SoundFormat::NELLYMOSER_8KHZ_MONO
| 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_ULAW => Some(gst::Caps::new_simple("audio/x-mulaw", &[])),
flavors::SoundFormat::PCM_ALAW => Some(gst::Caps::builder("audio/x-alaw").build()),
flavors::SoundFormat::PCM_ULAW => Some(gst::Caps::builder("audio/x-mulaw").build()),
flavors::SoundFormat::AAC => self.aac_sequence_header.as_ref().map(|header| {
gst::Caps::new_simple(
"audio/mpeg",
&[
("mpegversion", &4i32),
("framed", &true),
("stream-format", &"raw"),
("codec_data", &header),
],
)
gst::Caps::builder("audio/mpeg")
.field("mpegversion", 4i32)
.field("framed", true)
.field("stream-format", "raw")
.field("codec_data", header)
.build()
}),
flavors::SoundFormat::SPEEX => {
use crate::bytes::*;
@ -1351,10 +1351,11 @@ impl AudioFormat {
};
let comment = gst::Buffer::from_mut_slice(comment);
Some(gst::Caps::new_simple(
"audio/x-speex",
&[("streamheader", &gst::Array::new(&[&header, &comment]))],
))
Some(
gst::Caps::builder("audio/x-speex")
.field("streamheader", gst::Array::new([header, comment]))
.build(),
)
}
flavors::SoundFormat::DEVICE_SPECIFIC => {
// Nobody knows
@ -1444,25 +1445,28 @@ impl VideoFormat {
fn to_caps(&self) -> Option<gst::Caps> {
let mut caps = match self.format {
flavors::CodecId::SORENSON_H263 => Some(gst::Caps::new_simple(
"video/x-flash-video",
&[("flvversion", &1i32)],
)),
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::VP6A => Some(gst::Caps::new_simple("video/x-vp6-flash-alpha", &[])),
flavors::CodecId::SCREEN2 => Some(gst::Caps::new_simple("video/x-flash-screen2", &[])),
flavors::CodecId::SORENSON_H263 => Some(
gst::Caps::builder("video/x-flash-video")
.field("flvversion", 1i32)
.build(),
),
flavors::CodecId::SCREEN => Some(gst::Caps::builder("video/x-flash-screen").build()),
flavors::CodecId::VP6 => Some(gst::Caps::builder("video/x-vp6-flash").build()),
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| {
gst::Caps::new_simple(
"video/x-h264",
&[("stream-format", &"avc"), ("codec_data", &header)],
)
gst::Caps::builder("video/x-h264")
.field("stream-format", "avc")
.field("codec_data", &header)
.build()
}),
flavors::CodecId::H263 => Some(gst::Caps::new_simple("video/x-h263", &[])),
flavors::CodecId::MPEG4Part2 => Some(gst::Caps::new_simple(
"video/mpeg",
&[("mpegversion", &4i32), ("systemstream", &false)],
)),
flavors::CodecId::H263 => Some(gst::Caps::builder("video/x-h263").build()),
flavors::CodecId::MPEG4Part2 => Some(
gst::Caps::builder("video/mpeg")
.field("mpegversion", 4i32)
.field("systemstream", false)
.build(),
),
flavors::CodecId::JPEG => {
// Unused according to spec
None

View file

@ -221,31 +221,25 @@ impl ElementImpl for GifEnc {
fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
let sink_caps = gst::Caps::new_simple(
"video/x-raw",
&[
(
"format",
&gst::List::new(&[
&gst_video::VideoFormat::Rgb.to_str(),
&gst_video::VideoFormat::Rgba.to_str(),
]),
let sink_caps = gst::Caps::builder("video/x-raw")
.field(
"format",
gst::List::new([
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)),
(
"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),
),
),
],
);
)
.build();
let sink_pad_template = gst::PadTemplate::new(
"sink",
gst::PadDirection::Sink,
@ -254,7 +248,7 @@ impl ElementImpl for GifEnc {
)
.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(
"src",
gst::PadDirection::Src,
@ -304,7 +298,7 @@ impl VideoEncoderImpl for GifEnc {
}
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"))?;
element
.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 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) {
used_textures.insert(texture_id);

View file

@ -360,21 +360,18 @@ impl ElementImpl for HsvDetector {
fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
let caps = gst::Caps::new_simple(
"video/x-raw",
&[
("format", &gst::List::from_owned(video_output_formats())),
("width", &gst::IntRange::<i32>::new(0, i32::MAX)),
("height", &gst::IntRange::<i32>::new(0, i32::MAX)),
(
"framerate",
&gst::FractionRange::new(
gst::Fraction::new(0, 1),
gst::Fraction::new(i32::MAX, 1),
),
let caps = gst::Caps::builder("video/x-raw")
.field("format", gst::List::from(video_output_formats()))
.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),
),
],
);
)
.build();
let src_pad_template = gst::PadTemplate::new(
"src",
@ -385,21 +382,18 @@ impl ElementImpl for HsvDetector {
.unwrap();
// sink pad capabilities
let caps = gst::Caps::new_simple(
"video/x-raw",
&[
("format", &gst::List::from_owned(video_input_formats())),
("width", &gst::IntRange::<i32>::new(0, i32::MAX)),
("height", &gst::IntRange::<i32>::new(0, i32::MAX)),
(
"framerate",
&gst::FractionRange::new(
gst::Fraction::new(0, 1),
gst::Fraction::new(i32::MAX, 1),
),
let caps = gst::Caps::builder("video/x-raw")
.field("format", gst::List::from(video_input_formats()))
.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),
),
],
);
)
.build();
let sink_pad_template = gst::PadTemplate::new(
"sink",
@ -432,11 +426,11 @@ impl BaseTransformImpl for HsvDetector {
let mut other_caps = caps.clone();
if direction == gst::PadDirection::Src {
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 {
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] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
// src pad capabilities
let caps = gst::Caps::new_simple(
"video/x-raw",
&[
(
"format",
&gst::List::new(&[
&gst_video::VideoFormat::Rgbx.to_str(),
&gst_video::VideoFormat::Xrgb.to_str(),
&gst_video::VideoFormat::Bgrx.to_str(),
&gst_video::VideoFormat::Xbgr.to_str(),
&gst_video::VideoFormat::Rgba.to_str(),
&gst_video::VideoFormat::Argb.to_str(),
&gst_video::VideoFormat::Bgra.to_str(),
&gst_video::VideoFormat::Abgr.to_str(),
&gst_video::VideoFormat::Rgb.to_str(),
&gst_video::VideoFormat::Bgr.to_str(),
]),
let caps = gst::Caps::builder("video/x-raw")
.field(
"format",
gst::List::new([
gst_video::VideoFormat::Rgbx.to_str(),
gst_video::VideoFormat::Xrgb.to_str(),
gst_video::VideoFormat::Bgrx.to_str(),
gst_video::VideoFormat::Xbgr.to_str(),
gst_video::VideoFormat::Rgba.to_str(),
gst_video::VideoFormat::Argb.to_str(),
gst_video::VideoFormat::Bgra.to_str(),
gst_video::VideoFormat::Abgr.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)),
(
"framerate",
&gst::FractionRange::new(
gst::Fraction::new(0, 1),
gst::Fraction::new(i32::MAX, 1),
),
),
],
);
)
.build();
let src_pad_template = gst::PadTemplate::new(
"src",

View file

@ -426,35 +426,32 @@ impl ElementImpl for Rav1Enc {
fn pad_templates() -> &'static [gst::PadTemplate] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
let sink_caps = gst::Caps::new_simple(
"video/x-raw",
&[
(
"format",
&gst::List::new(&[
&gst_video::VideoFormat::I420.to_str(),
&gst_video::VideoFormat::Y42b.to_str(),
&gst_video::VideoFormat::Y444.to_str(),
&gst_video::VideoFormat::I42010le.to_str(),
&gst_video::VideoFormat::I42210le.to_str(),
&gst_video::VideoFormat::Y44410le.to_str(),
&gst_video::VideoFormat::I42012le.to_str(),
&gst_video::VideoFormat::I42212le.to_str(),
&gst_video::VideoFormat::Y44412le.to_str(),
// &gst_video::VideoFormat::Gray8.to_str(),
]),
let sink_caps = gst::Caps::builder("video/x-raw")
.field(
"format",
gst::List::new([
gst_video::VideoFormat::I420.to_str(),
gst_video::VideoFormat::Y42b.to_str(),
gst_video::VideoFormat::Y444.to_str(),
gst_video::VideoFormat::I42010le.to_str(),
gst_video::VideoFormat::I42210le.to_str(),
gst_video::VideoFormat::Y44410le.to_str(),
gst_video::VideoFormat::I42012le.to_str(),
gst_video::VideoFormat::I42212le.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)),
(
"framerate",
&gst::FractionRange::new(
gst::Fraction::new(0, 1),
gst::Fraction::new(std::i32::MAX, 1),
),
),
],
);
)
.build();
let sink_pad_template = gst::PadTemplate::new(
"sink",
gst::PadDirection::Sink,
@ -463,7 +460,7 @@ impl ElementImpl for Rav1Enc {
)
.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(
"src",
gst::PadDirection::Src,
@ -603,8 +600,8 @@ impl VideoEncoderImpl for Rav1Enc {
speed_settings: config::SpeedSettings::from_preset(settings.speed_preset as usize),
time_base: if video_info.fps() != gst::Fraction::new(0, 1) {
data::Rational {
num: *video_info.fps().numer() as u64,
den: *video_info.fps().denom() as u64,
num: video_info.fps().numer() as u64,
den: video_info.fps().denom() as u64,
}
} else {
data::Rational { num: 30, den: 1 }
@ -636,7 +633,7 @@ impl VideoEncoderImpl for Rav1Enc {
});
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"))?;
element
.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 rav1enc = h.element().unwrap();
rav1enc.set_property("speed-preset", &10u32).unwrap();
rav1enc.set_property("speed-preset", 10u32).unwrap();
}
h.play();
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] {
static PAD_TEMPLATES: Lazy<Vec<gst::PadTemplate>> = Lazy::new(|| {
let sink_caps = gst::Caps::new_simple(
"video/x-raw",
&[
(
"format",
&gst::List::new(&[
&gst_video::VideoFormat::Gray8.to_str(),
&gst_video::VideoFormat::Gray16Be.to_str(),
&gst_video::VideoFormat::Rgb.to_str(),
&gst_video::VideoFormat::Rgba.to_str(),
]),
let sink_caps = gst::Caps::builder("video/x-raw")
.field(
"format",
gst::List::new([
gst_video::VideoFormat::Gray8.to_str(),
gst_video::VideoFormat::Gray16Be.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)),
(
"framerate",
&gst::FractionRange::new(
gst::Fraction::new(1, 1),
gst::Fraction::new(std::i32::MAX, 1),
),
),
],
);
)
.build();
let sink_pad_template = gst::PadTemplate::new(
"sink",
gst::PadDirection::Sink,
@ -283,7 +280,7 @@ impl ElementImpl for PngEncoder {
)
.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(
"src",
gst::PadDirection::Src,
@ -320,7 +317,7 @@ impl VideoEncoderImpl for PngEncoder {
}
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"))?;
element
.negotiate(output_state)

View file

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