Remove various unnecessary & from property/structure field related code

This commit is contained in:
Sebastian Dröge 2021-10-24 19:11:30 +03:00
parent b4a3738b82
commit 92f9f3be39
30 changed files with 100 additions and 100 deletions

View file

@ -60,7 +60,7 @@ fn create_pipeline() -> Result<gst::Pipeline, Error> {
&gst::Caps::builder("audio/x-raw")
.field("format", gst_audio::AUDIO_FORMAT_S16.to_str())
.field("layout", "interleaved")
.field("channels", (1i32))
.field("channels", 1i32)
.field("rate", gst::IntRange::<i32>::new(1, i32::MAX))
.build(),
));

View file

@ -81,7 +81,7 @@ fn example_main() -> Result<(), Error> {
gst::ElementFactory::make("decodebin", None).map_err(|_| MissingElement("decodebin"))?;
// Tell the filesrc what file to load
src.set_property("location", &uri)?;
src.set_property("location", uri)?;
pipeline.add_many(&[&src, &decodebin])?;
gst::Element::link_many(&[&src, &decodebin])?;

View file

@ -104,9 +104,9 @@ fn example_main() -> Result<(), Error> {
let sink =
gst::ElementFactory::make("filesink", None).map_err(|_| MissingElement("filesink"))?;
src.set_property("uri", &uri)
src.set_property("uri", uri)
.expect("setting URI Property failed");
sink.set_property("location", &output_file)
sink.set_property("location", output_file)
.expect("setting location property failed");
// Configure the encodebin.

View file

@ -81,9 +81,9 @@ fn create_pipeline() -> Result<gst::Pipeline, Error> {
// with images of the size 800x800, and framerate of 15 fps, since my laptop struggles
// rendering it at the default 30 fps
let caps = gst::Caps::builder("video/x-raw")
.field("width", &800i32)
.field("height", &800i32)
.field("framerate", &gst::Fraction::new(15, 1))
.field("width", 800i32)
.field("height", 800i32)
.field("framerate", gst::Fraction::new(15, 1))
.build();
capsfilter.set_property("caps", &caps).unwrap();

View file

@ -80,8 +80,8 @@ fn create_pipeline() -> Result<gst::Pipeline, Error> {
// Plug in a capsfilter element that will force the videotestsrc and the cairooverlay to work
// with images of the size 800x800.
let caps = gst::Caps::builder("video/x-raw")
.field("width", &800i32)
.field("height", &800i32)
.field("width", 800i32)
.field("height", 800i32)
.build();
capsfilter.set_property("caps", &caps).unwrap();

View file

@ -29,7 +29,7 @@ fn example_main() {
// Create a new playbin element, and tell it what uri to play back.
let playbin = gst::ElementFactory::make("playbin", None).unwrap();
playbin.set_property("uri", &uri).unwrap();
playbin.set_property("uri", uri).unwrap();
// For flags handling
// With flags, one can configure playbin's behavior such as whether it

View file

@ -92,7 +92,7 @@ fn make_fec_decoder(rtpbin: &gst::Element, sess_id: u32) -> Result<gst::Element,
.unwrap();
fecdec.set_property("storage", &internal_storage)?;
fecdec.set_property("pt", &100u32)?;
fecdec.set_property("pt", 100u32)?;
Ok(fecdec)
}
@ -134,7 +134,7 @@ fn example_main() -> Result<(), Error> {
pipeline.add_many(&[&enc, &mux, &sink])?;
gst::Element::link_many(&[&filter, &enc, &mux, &sink])?;
sink.set_property("location", &"out.mkv")?;
sink.set_property("location", "out.mkv")?;
enc.set_property_from_str("tune", "zerolatency")?;
eprintln!("Recording to out.mkv");
}
@ -147,7 +147,7 @@ fn example_main() -> Result<(), Error> {
let storage = values[1]
.get::<gst::Element>()
.expect("rtpbin \"new-storage\" signal values[1]");
storage.set_property("size-time", &250_000_000u64).unwrap();
storage.set_property("size-time", 250_000_000u64).unwrap();
None
})?;
@ -232,10 +232,10 @@ fn example_main() -> Result<(), Error> {
.field("height", 1080i32)
.build();
src.set_property("address", &"127.0.0.1")?;
src.set_property("address", "127.0.0.1")?;
src.set_property("caps", &rtp_caps)?;
netsim.set_property("drop-probability", &drop_probability)?;
rtpbin.set_property("do-lost", &true)?;
netsim.set_property("drop-probability", drop_probability)?;
rtpbin.set_property("do-lost", true)?;
filter.set_property("caps", &video_caps)?;
let bus = pipeline

View file

@ -72,9 +72,9 @@ fn connect_decodebin_pad(src_pad: &gst::Pad, sink: &gst::Element) -> Result<(),
fn make_fec_encoder(fec_percentage: u32) -> Result<gst::Element, Error> {
let fecenc = make_element("rtpulpfecenc", None)?;
fecenc.set_property("pt", &100u32)?;
fecenc.set_property("multipacket", &true)?;
fecenc.set_property("percentage", &fec_percentage)?;
fecenc.set_property("pt", 100u32)?;
fecenc.set_property("multipacket", true)?;
fecenc.set_property("percentage", fec_percentage)?;
Ok(fecenc)
}
@ -152,16 +152,16 @@ fn example_main() -> Result<(), Error> {
let video_caps = gst::Caps::builder("video/x-raw").build();
src.set_property_from_str("pattern", "ball")?;
sink.set_property("host", &"127.0.0.1")?;
sink.set_property("sync", &true)?;
enc.set_property("keyframe-max-dist", &30i32)?;
enc.set_property("threads", &12i32)?;
enc.set_property("cpu-used", &(-16i32))?;
enc.set_property("deadline", &1i64)?;
sink.set_property("host", "127.0.0.1")?;
sink.set_property("sync", true)?;
enc.set_property("keyframe-max-dist", 30i32)?;
enc.set_property("threads", 12i32)?;
enc.set_property("cpu-used", -16i32)?;
enc.set_property("deadline", 1i64)?;
enc.set_property_from_str("error-resilient", "default")?;
src.set_property("expose-all-streams", &false)?;
src.set_property("caps", &video_caps)?;
src.set_property("uri", &uri)?;
src.set_property("expose-all-streams", false)?;
src.set_property("caps", video_caps)?;
src.set_property("uri", uri)?;
let bus = pipeline
.bus()

View file

@ -130,10 +130,10 @@ mod media_factory {
let pay = gst::ElementFactory::make("rtpvp8pay", Some("pay0")).unwrap();
// Configure the videotestsrc live
src.set_property("is-live", &true).unwrap();
src.set_property("is-live", true).unwrap();
// Produce encoded data as fast as possible
enc.set_property("deadline", &1i64).unwrap();
enc.set_property("deadline", 1i64).unwrap();
bin.add_many(&[&src, &enc, &pay]).unwrap();
gst::Element::link_many(&[&src, &enc, &pay]).unwrap();

View file

@ -47,14 +47,14 @@ fn create_pipeline(uri: String, out_path: std::path::PathBuf) -> Result<gst::Pip
.expect("Sink element is expected to be an appsink!");
// Don't synchronize on the clock, we only want a snapshot asap.
appsink.set_property("sync", &false).unwrap();
appsink.set_property("sync", false).unwrap();
// Tell the appsink what format we want.
// This can be set after linking the two objects, because format negotiation between
// both elements will happen during pre-rolling of the pipeline.
appsink.set_caps(Some(
&gst::Caps::builder("video/x-raw")
.field("format", &gst_video::VideoFormat::Rgba.to_str())
.field("format", gst_video::VideoFormat::Rgba.to_str())
.build(),
));

View file

@ -31,7 +31,7 @@ fn example_main() {
let src = gst::ElementFactory::make("filesrc", None).unwrap();
let decodebin = gst::ElementFactory::make("decodebin", None).unwrap();
src.set_property("location", &uri).unwrap();
src.set_property("location", uri).unwrap();
pipeline.add_many(&[&src, &decodebin]).unwrap();
gst::Element::link_many(&[&src, &decodebin]).unwrap();

View file

@ -68,17 +68,17 @@ fn example_main() -> Result<(), Error> {
let sink =
gst::ElementFactory::make("filesink", None).map_err(|_| MissingElement("filesink"))?;
sink.set_property("location", &output_file)
sink.set_property("location", output_file)
.expect("setting location property failed");
// Increase the queue capacity to 100MB to avoid a stalling pipeline
queue
.set_property("max-size-buffers", &0u32)
.set_property("max-size-buffers", 0u32)
.expect("changing capacity of multiqueue failed");
queue
.set_property("max-size-time", &0u64)
.set_property("max-size-time", 0u64)
.expect("changing capacity of multiqueue failed");
queue
.set_property("max-size-bytes", &(1024u32 * 1024 * 100))
.set_property("max-size-bytes", 1024u32 * 1024 * 100)
.expect("changing capacity of multiqueue failed");
pipeline

View file

@ -24,10 +24,10 @@ fn example_main() {
/* Completely contrived example that takes the 4:3 input video, cuts out a 5:4 frame
* and then adds pillarbox borders to place it in a 16:9 target area */
/* The output will be the full frame: */
sinkpad.set_property("xpos", &0i32).unwrap();
sinkpad.set_property("ypos", &0i32).unwrap();
sinkpad.set_property("width", &1280i32).unwrap();
sinkpad.set_property("height", &720i32).unwrap();
sinkpad.set_property("xpos", 0i32).unwrap();
sinkpad.set_property("ypos", 0i32).unwrap();
sinkpad.set_property("width", 1280i32).unwrap();
sinkpad.set_property("height", 720i32).unwrap();
let mut converter_config = gst_video::VideoConverterConfig::new();
/* Crop the input frame to 5:4: */

View file

@ -543,14 +543,14 @@ impl App {
.dynamic_cast::<gst_app::AppSink>()
.expect("Sink element is expected to be an appsink!");
appsink.set_property("enable-last-sample", &false)?;
appsink.set_property("emit-signals", &false)?;
appsink.set_property("max-buffers", &1u32)?;
appsink.set_property("enable-last-sample", false)?;
appsink.set_property("emit-signals", false)?;
appsink.set_property("max-buffers", 1u32)?;
let caps = gst::Caps::builder("video/x-raw")
.features(&[&gst_gl::CAPS_FEATURE_MEMORY_GL_MEMORY])
.field("format", &gst_video::VideoFormat::Rgba.to_str())
.field("texture-target", &"2D")
.field("format", gst_video::VideoFormat::Rgba.to_str())
.field("texture-target", "2D")
.build();
appsink.set_caps(Some(&caps));

View file

@ -1035,7 +1035,7 @@ mod tests {
let videotestsrc = gst::ElementFactory::make("videotestsrc", None).unwrap();
let appsink = gst::ElementFactory::make("appsink", None).unwrap();
videotestsrc.set_property("num-buffers", &5).unwrap();
videotestsrc.set_property("num-buffers", 5).unwrap();
let pipeline = gst::Pipeline::new(None);
pipeline.add(&videotestsrc).unwrap();

View file

@ -454,7 +454,7 @@ mod tests {
let appsrc = gst::ElementFactory::make("appsrc", None).unwrap();
let fakesink = gst::ElementFactory::make("fakesink", None).unwrap();
fakesink.set_property("signal-handoffs", &true).unwrap();
fakesink.set_property("signal-handoffs", true).unwrap();
let pipeline = gst::Pipeline::new(None);
pipeline.add(&appsrc).unwrap();

View file

@ -61,13 +61,13 @@ pub fn audio_make_raw_caps(
.collect();
let builder = gst::caps::Caps::builder("audio/x-raw")
.field("format", &gst::List::from_owned(formats))
.field("rate", &gst::IntRange::<i32>::new(1, i32::MAX))
.field("channels", &gst::IntRange::<i32>::new(1, i32::MAX));
.field("format", gst::List::from_owned(formats))
.field("rate", gst::IntRange::<i32>::new(1, i32::MAX))
.field("channels", gst::IntRange::<i32>::new(1, i32::MAX));
match layout {
crate::AudioLayout::Interleaved => builder.field("layout", &"interleaved"),
crate::AudioLayout::NonInterleaved => builder.field("layout", &"non-interleaved"),
crate::AudioLayout::Interleaved => builder.field("layout", "interleaved"),
crate::AudioLayout::NonInterleaved => builder.field("layout", "non-interleaved"),
crate::AudioLayout::__Unknown(_) => builder,
}
}
@ -112,8 +112,8 @@ mod tests {
&[crate::AudioFormat::S16be, crate::AudioFormat::S16le],
crate::AudioLayout::NonInterleaved,
)
.field("rate", &16000)
.field("channels", &2)
.field("rate", 16000)
.field("channels", 2)
.build();
assert_eq!(
caps.to_string(),

View file

@ -205,12 +205,12 @@ pub fn video_make_raw_caps(
.collect();
gst::caps::Caps::builder("video/x-raw")
.field("format", &gst::List::from_owned(formats))
.field("width", &gst::IntRange::<i32>::new(1, i32::MAX))
.field("height", &gst::IntRange::<i32>::new(1, i32::MAX))
.field("format", gst::List::from_owned(formats))
.field("width", gst::IntRange::<i32>::new(1, i32::MAX))
.field("height", gst::IntRange::<i32>::new(1, i32::MAX))
.field(
"framerate",
&gst::FractionRange::new(gst::Fraction::new(0, 1), gst::Fraction::new(i32::MAX, 1)),
gst::FractionRange::new(gst::Fraction::new(0, 1), gst::Fraction::new(i32::MAX, 1)),
)
}
@ -302,9 +302,9 @@ mod tests {
}
let caps = video_make_raw_caps(&[crate::VideoFormat::Nv12, crate::VideoFormat::Nv16])
.field("width", &800)
.field("height", &600)
.field("framerate", &gst::Fraction::new(30, 1))
.field("width", 800)
.field("height", 600)
.field("framerate", gst::Fraction::new(30, 1))
.build();
assert_eq!(caps.to_string(), "video/x-raw, format=(string){ NV12, NV16 }, width=(int)800, height=(int)600, framerate=(fraction)30/1");
}

View file

@ -885,13 +885,13 @@ mod tests {
);
let caps = Caps::builder("foo/bar")
.field("int", &12)
.field("int", 12)
.any_features()
.build();
assert_eq!(caps.to_string(), "foo/bar(ANY), int=(int)12");
let caps = Caps::builder("foo/bar")
.field("int", &12)
.field("int", 12)
.features(&["foo:bla", "foo:baz"])
.build();
assert_eq!(caps.to_string(), "foo/bar(foo:bla, foo:baz), int=(int)12");
@ -918,7 +918,7 @@ mod tests {
let caps = Caps::builder_full()
.structure(
Structure::builder("audio/x-raw")
.field("format", &"S16LE")
.field("format", "S16LE")
.build(),
)
.structure(Structure::builder("video/x-raw").build())

View file

@ -145,7 +145,7 @@ mod tests {
*notify_clone.lock().unwrap() = Some((id.clone(), prop.name()));
});
identity.set_property("silent", &false).unwrap();
identity.set_property("silent", false).unwrap();
assert_eq!(
*notify.lock().unwrap(),
Some((identity.upcast::<crate::Object>(), "silent"))

View file

@ -254,7 +254,7 @@ mod tests {
crate::init().unwrap();
let info = Structure::builder("sample.info")
.field("f3", &123i32)
.field("f3", 123i32)
.build();
let sample = Sample::builder().info(info).build();

View file

@ -103,8 +103,8 @@ mod tests {
}
let caps = Caps::builder("sample/caps")
.field("int", &12)
.field("bool", &true)
.field("int", 12)
.field("bool", true)
.build();
let mut segment = Segment::new();
@ -121,7 +121,7 @@ mod tests {
segment.set_duration(GenericFormattedValue::from(ClockTime::NONE));
let info = Structure::builder("sample.info")
.field("f3", &123i32)
.field("f3", 123i32)
.build();
Sample::builder()
@ -333,8 +333,8 @@ mod tests {
}
let caps = Caps::builder("sample/caps")
.field("int", &12)
.field("bool", &true)
.field("int", 12)
.field("bool", true)
.build();
let mut segment = Segment::new();
@ -351,7 +351,7 @@ mod tests {
segment.set_duration(GenericFormattedValue::from(ClockTime::NONE));
let info = Structure::builder("sample.info")
.field("f3", &123i32)
.field("f3", 123i32)
.build();
Sample::builder()

View file

@ -900,9 +900,9 @@ mod tests {
let mut s = Structure::new_empty("test");
assert_eq!(s.name(), "test");
s.set("f1", &"abc");
s.set("f1", "abc");
s.set("f2", &String::from("bcd"));
s.set("f3", &123i32);
s.set("f3", 123i32);
assert_eq!(s.get::<&str>("f1"), Ok("abc"));
assert_eq!(s.get::<Option<&str>>("f2"), Ok(Some("bcd")));
@ -952,9 +952,9 @@ mod tests {
crate::init().unwrap();
let s = Structure::builder("test")
.field("f1", &"abc")
.field("f1", "abc")
.field("f2", &String::from("bcd"))
.field("f3", &123i32)
.field("f3", 123i32)
.build();
assert_eq!(s.name(), "test");
@ -993,9 +993,9 @@ mod tests {
crate::init().unwrap();
let s = Structure::builder("test")
.field("f1", &"abc")
.field("f1", "abc")
.field("f2", &String::from("bcd"))
.field("f3", &123i32)
.field("f3", 123i32)
.build();
let s2 = Structure::from_iter(

View file

@ -176,16 +176,16 @@ mod tests {
crate::init().unwrap();
let s = Structure::builder("test")
.field("f1", &"abc")
.field("f1", "abc")
.field("f2", &String::from("bcd"))
.field("f3", &123i32)
.field("fraction", &Fraction::new(1, 2))
.field("date", &Date::new_dmy(19, DateMonth::August, 2019).unwrap())
.field("f3", 123i32)
.field("fraction", Fraction::new(1, 2))
.field("date", Date::new_dmy(19, DateMonth::August, 2019).unwrap())
.field(
"date_time",
&DateTime::new(2f32, 2019, 8, 19, 13, 34, 42f64).unwrap(),
DateTime::new(2f32, 2019, 8, 19, 13, 34, 42f64).unwrap(),
)
.field("array", &Array::new(&[&1, &2]))
.field("array", Array::new(&[&1, &2]))
.build();
let pretty_config = ron::ser::PrettyConfig::new().new_line("".to_string());
@ -252,16 +252,16 @@ mod tests {
crate::init().unwrap();
let s = Structure::builder("test")
.field("f1", &"abc")
.field("f2", &"bcd".to_owned())
.field("f3", &123i32)
.field("fraction", &Fraction::new(1, 2))
.field("date", &Date::new_dmy(19, DateMonth::August, 2019).unwrap())
.field("f1", "abc")
.field("f2", "bcd".to_owned())
.field("f3", 123i32)
.field("fraction", Fraction::new(1, 2))
.field("date", Date::new_dmy(19, DateMonth::August, 2019).unwrap())
.field(
"date_time",
&DateTime::new(2f32, 2019, 8, 19, 13, 34, 42f64).unwrap(),
DateTime::new(2f32, 2019, 8, 19, 13, 34, 42f64).unwrap(),
)
.field("array", &Array::new(&[&1, &2]))
.field("array", Array::new(&[&1, &2]))
.build();
let s_ser = ron::ser::to_string(&s).unwrap();
let s_de: Structure = ron::de::from_str(s_ser.as_str()).unwrap();

View file

@ -806,7 +806,7 @@ mod tests {
let src = ElementFactory::make("fakesrc", None).unwrap();
let sink = ElementFactory::make("fakesink", None).unwrap();
src.set_property("num-buffers", &100i32).unwrap();
src.set_property("num-buffers", 100i32).unwrap();
pipeline
.add_many(&[&src, element.upcast_ref(), &sink])

View file

@ -31,7 +31,7 @@ fn tutorial_main() {
let uri =
"https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm";
source
.set_property("uri", &uri)
.set_property("uri", uri)
.expect("Can't set uri property on uridecodebin");
// Connect the pad-added signal

View file

@ -32,7 +32,7 @@ fn tutorial_main() {
let uri =
"https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm";
playbin
.set_property("uri", &uri)
.set_property("uri", uri)
.expect("Can't set uri property on playbin");
// Start playing

View file

@ -302,7 +302,7 @@ mod tutorial5 {
let uri = "https://www.freedesktop.org/software/gstreamer-sdk/\
data/media/sintel_trailer-480p.webm";
let playbin = gst::ElementFactory::make("playbin", None).unwrap();
playbin.set_property("uri", &uri).unwrap();
playbin.set_property("uri", uri).unwrap();
playbin
.connect("video-tags-changed", false, |args| {

View file

@ -24,7 +24,7 @@ fn tutorial_main() {
let pipeline = gst::Pipeline::new(Some("test-pipeline"));
audio_source.set_property("freq", &215.0).unwrap();
audio_source.set_property("freq", 215.0).unwrap();
visual.set_property_from_str("shader", "none").unwrap();
visual.set_property_from_str("style", "lines").unwrap();

View file

@ -20,7 +20,7 @@ fn tutorial_main() -> Result<(), Error> {
let uri =
"https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm";
let pipeline = gst::ElementFactory::make("playbin", None)?;
pipeline.set_property("uri", &uri).unwrap();
pipeline.set_property("uri", uri).unwrap();
// Set the download flag
let flags = pipeline.property("flags")?;
@ -34,7 +34,7 @@ fn tutorial_main() -> Result<(), Error> {
pipeline.set_property_from_value("flags", &flags).unwrap();
// Uncomment this line to limit the amount of downloaded data.
// pipeline.set_property("ring-buffer-max-size", &4_000_000u64)?;
// pipeline.set_property("ring-buffer-max-size", 4_000_000u64)?;
// Start playing
let mut is_live = false;
@ -110,7 +110,7 @@ fn tutorial_main() -> Result<(), Error> {
.unwrap()
);
// Uncomment this line to keep the temporary file after the program exists.
// download_buffer.set_property("temp-remove", &false).ok();
// download_buffer.set_property("temp-remove", false).ok();
None
})?;