diff --git a/audio/audiofx/examples/hrtfrender.rs b/audio/audiofx/examples/hrtfrender.rs index 41ded273..61d70988 100644 --- a/audio/audiofx/examples/hrtfrender.rs +++ b/audio/audiofx/examples/hrtfrender.rs @@ -90,10 +90,10 @@ fn run() -> Result<(), Error> { let new_z = -x * f32::sin(ROTATION) + z * f32::cos(ROTATION); let objs = [gst::Structure::builder("application/spatial-object") - .field("x", &new_x) - .field("y", &y) - .field("z", &new_z) - .field("distance-gain", &gain) + .field("x", new_x) + .field("y", y) + .field("z", new_z) + .field("distance-gain", gain) .build()]; hrtf.set_property("spatial-objects", gst::Array::new(objs)); diff --git a/audio/audiofx/src/audioloudnorm/imp.rs b/audio/audiofx/src/audioloudnorm/imp.rs index 233982a2..915e5cb0 100644 --- a/audio/audiofx/src/audioloudnorm/imp.rs +++ b/audio/audiofx/src/audioloudnorm/imp.rs @@ -1560,7 +1560,7 @@ impl AudioLoudNorm { } // Need to reset the state now - *state = State::new(&*self.settings.lock().unwrap(), state.info.clone()); + *state = State::new(&self.settings.lock().unwrap(), state.info.clone()); } state.adapter.push(buffer); @@ -1602,7 +1602,7 @@ impl AudioLoudNorm { Err(_) => return false, }; } - *state = Some(State::new(&*self.settings.lock().unwrap(), info)); + *state = Some(State::new(&self.settings.lock().unwrap(), info)); drop(state); if let Some(outbuf) = outbuf { @@ -1623,7 +1623,7 @@ impl AudioLoudNorm { Err(gst::FlowError::Eos) => None, Err(_) => return false, }; - *state = State::new(&*self.settings.lock().unwrap(), state.info.clone()); + *state = State::new(&self.settings.lock().unwrap(), state.info.clone()); } drop(state); diff --git a/audio/audiofx/src/ebur128level/imp.rs b/audio/audiofx/src/ebur128level/imp.rs index 2d9a98e1..f4f102e2 100644 --- a/audio/audiofx/src/ebur128level/imp.rs +++ b/audio/audiofx/src/ebur128level/imp.rs @@ -138,7 +138,7 @@ impl ObjectImpl for EbuR128Level { .build()] }); - &*SIGNALS + &SIGNALS } fn properties() -> &'static [glib::ParamSpec] { @@ -482,7 +482,7 @@ impl BaseTransformImpl for EbuR128Level { if state.ebur128.mode().contains(ebur128::Mode::M) { match state.ebur128.loudness_momentary() { - Ok(loudness) => s.set("momentary-loudness", &loudness), + Ok(loudness) => s.set("momentary-loudness", loudness), Err(err) => gst::error!( CAT, imp: self, @@ -494,7 +494,7 @@ impl BaseTransformImpl for EbuR128Level { if state.ebur128.mode().contains(ebur128::Mode::S) { match state.ebur128.loudness_shortterm() { - Ok(loudness) => s.set("shortterm-loudness", &loudness), + Ok(loudness) => s.set("shortterm-loudness", loudness), Err(err) => gst::error!( CAT, imp: self, @@ -506,7 +506,7 @@ impl BaseTransformImpl for EbuR128Level { if state.ebur128.mode().contains(ebur128::Mode::I) { match state.ebur128.loudness_global() { - Ok(loudness) => s.set("global-loudness", &loudness), + Ok(loudness) => s.set("global-loudness", loudness), Err(err) => gst::error!( CAT, imp: self, @@ -516,7 +516,7 @@ impl BaseTransformImpl for EbuR128Level { } match state.ebur128.relative_threshold() { - Ok(threshold) => s.set("relative-threshold", &threshold), + Ok(threshold) => s.set("relative-threshold", threshold), Err(err) => gst::error!( CAT, imp: self, @@ -528,7 +528,7 @@ impl BaseTransformImpl for EbuR128Level { if state.ebur128.mode().contains(ebur128::Mode::LRA) { match state.ebur128.loudness_range() { - Ok(range) => s.set("loudness-range", &range), + Ok(range) => s.set("loudness-range", range), Err(err) => { gst::error!(CAT, imp: self, "Failed to get loudness range: {}", err) } diff --git a/audio/csound/examples/effect_example.rs b/audio/csound/examples/effect_example.rs index f1e8355f..98c7b63e 100644 --- a/audio/csound/examples/effect_example.rs +++ b/audio/csound/examples/effect_example.rs @@ -80,7 +80,7 @@ fn create_pipeline() -> Result> { let audio_sink = gst::parse_bin_from_description(AUDIO_SINK, true)?.upcast(); let csoundfilter = gst::ElementFactory::make("csoundfilter") - .property("csd-text", &CSD) + .property("csd-text", CSD) .build() .unwrap(); diff --git a/audio/csound/src/filter/imp.rs b/audio/csound/src/filter/imp.rs index 83c276be..ea0fa465 100644 --- a/audio/csound/src/filter/imp.rs +++ b/audio/csound/src/filter/imp.rs @@ -517,15 +517,15 @@ impl BaseTransformImpl for CsoundFilter { let ichannels = csound.input_channels() as i32; let ochannels = csound.output_channels() as i32; for s in new_caps.make_mut().iter_mut() { - s.set("format", &gst_audio::AUDIO_FORMAT_F64.to_str()); - s.set("rate", &sr); + s.set("format", gst_audio::AUDIO_FORMAT_F64.to_str()); + s.set("rate", sr); // replace the channel property with our values, // if they are not supported, the negotiation will fail. if direction == gst::PadDirection::Src { - s.set("channels", &ichannels); + s.set("channels", ichannels); } else { - s.set("channels", &ochannels); + s.set("channels", ochannels); } // Csound does not have a concept of channel-mask s.remove_field("channel-mask"); diff --git a/audio/csound/tests/csound_filter.rs b/audio/csound/tests/csound_filter.rs index a6564be2..275a90e3 100644 --- a/audio/csound/tests/csound_filter.rs +++ b/audio/csound/tests/csound_filter.rs @@ -57,7 +57,7 @@ fn init() { fn build_harness(src_caps: gst::Caps, sink_caps: gst::Caps, csd: &str) -> gst_check::Harness { let filter = gst::ElementFactory::make("csoundfilter") - .property("csd-text", &csd) + .property("csd-text", csd) .build() .unwrap(); diff --git a/generic/file/src/file_location.rs b/generic/file/src/file_location.rs index 83fa75d8..26684565 100644 --- a/generic/file/src/file_location.rs +++ b/generic/file/src/file_location.rs @@ -74,7 +74,7 @@ impl FileLocation { .parent() .expect("FileSink::set_location `location` with filename but without a parent") .to_owned(); - if parent_dir.is_relative() && parent_dir.components().next() == None { + if parent_dir.is_relative() && parent_dir.components().next().is_none() { // `location` only contains the filename // need to specify "." for `canonicalize` to resolve the actual path parent_dir = PathBuf::from("."); diff --git a/generic/sodium/examples/decrypt_example.rs b/generic/sodium/examples/decrypt_example.rs index 301c5443..f888c96e 100644 --- a/generic/sodium/examples/decrypt_example.rs +++ b/generic/sodium/examples/decrypt_example.rs @@ -53,7 +53,7 @@ struct Keys { impl Keys { fn from_file(file: &Path) -> Result> { - let f = File::open(&file)?; + let f = File::open(file)?; serde_json::from_reader(f).map_err(From::from) } } diff --git a/generic/sodium/examples/encrypt_example.rs b/generic/sodium/examples/encrypt_example.rs index 8a110a6d..b94fee5c 100644 --- a/generic/sodium/examples/encrypt_example.rs +++ b/generic/sodium/examples/encrypt_example.rs @@ -57,7 +57,7 @@ struct Keys { impl Keys { fn from_file(file: &Path) -> Result> { - let f = File::open(&file)?; + let f = File::open(file)?; serde_json::from_reader(f).map_err(From::from) } } diff --git a/generic/sodium/tests/decrypter.rs b/generic/sodium/tests/decrypter.rs index 2e779cda..43ba194f 100644 --- a/generic/sodium/tests/decrypter.rs +++ b/generic/sodium/tests/decrypter.rs @@ -75,7 +75,7 @@ fn test_pipeline() { }; let filesrc = gst::ElementFactory::make("filesrc") - .property("location", &input_path.to_str().unwrap()) + .property("location", input_path.to_str().unwrap()) .build() .unwrap(); diff --git a/generic/threadshare/examples/standalone/sink/imp.rs b/generic/threadshare/examples/standalone/sink/imp.rs index 97a7dae2..dae30931 100644 --- a/generic/threadshare/examples/standalone/sink/imp.rs +++ b/generic/threadshare/examples/standalone/sink/imp.rs @@ -610,7 +610,7 @@ impl TestSink { // Enable backpressure for items let (item_sender, item_receiver) = flume::bounded(0); - let task_impl = TestSinkTask::new(&*self.obj(), item_receiver); + let task_impl = TestSinkTask::new(&self.obj(), item_receiver); self.task.prepare(task_impl, context).block_on()?; *self.item_sender.lock().unwrap() = Some(item_sender); diff --git a/generic/threadshare/src/jitterbuffer/imp.rs b/generic/threadshare/src/jitterbuffer/imp.rs index 0b40eb02..7105720a 100644 --- a/generic/threadshare/src/jitterbuffer/imp.rs +++ b/generic/threadshare/src/jitterbuffer/imp.rs @@ -1259,7 +1259,7 @@ impl JitterBuffer { self.task .prepare( - JitterBufferTask::new(&*self.obj(), &self.src_pad_handler, &self.sink_pad_handler), + JitterBufferTask::new(&self.obj(), &self.src_pad_handler, &self.sink_pad_handler), context, ) .block_on()?; diff --git a/generic/threadshare/src/udpsink/imp.rs b/generic/threadshare/src/udpsink/imp.rs index f9186b33..cfb0763f 100644 --- a/generic/threadshare/src/udpsink/imp.rs +++ b/generic/threadshare/src/udpsink/imp.rs @@ -840,7 +840,7 @@ impl UdpSink { // Enable backpressure for items let (item_sender, item_receiver) = flume::bounded(0); let (cmd_sender, cmd_receiver) = flume::unbounded(); - let task_impl = UdpSinkTask::new(&*self.obj(), item_receiver, cmd_receiver); + let task_impl = UdpSinkTask::new(&self.obj(), item_receiver, cmd_receiver); self.task.prepare(task_impl, context).block_on()?; *self.item_sender.lock().unwrap() = Some(item_sender); diff --git a/generic/threadshare/tests/pipeline.rs b/generic/threadshare/tests/pipeline.rs index 3b8ea46d..caa66ac6 100644 --- a/generic/threadshare/tests/pipeline.rs +++ b/generic/threadshare/tests/pipeline.rs @@ -336,13 +336,13 @@ fn eos() { .name("src-eos") .property("caps", &caps) .property("do-timestamp", true) - .property("context", &CONTEXT) + .property("context", CONTEXT) .build() .unwrap(); let queue = gst::ElementFactory::make("ts-queue") .name("queue-eos") - .property("context", &CONTEXT) + .property("context", CONTEXT) .build() .unwrap(); @@ -636,7 +636,7 @@ fn socket_play_null_play() { let sink = gst::ElementFactory::make("ts-udpsink") .name(format!("sink-{}", TEST).as_str()) .property("socket", &socket) - .property("context", &TEST) + .property("context", TEST) .property("context-wait", 20u32) .build() .unwrap(); diff --git a/generic/threadshare/tests/udpsink.rs b/generic/threadshare/tests/udpsink.rs index 9245ce66..7bb80e01 100644 --- a/generic/threadshare/tests/udpsink.rs +++ b/generic/threadshare/tests/udpsink.rs @@ -100,6 +100,6 @@ fn test_chain() { assert!(buf == [42, 43, 44, 45, 0]); }); - let buf = gst::Buffer::from_slice(&[42, 43, 44, 45]); + let buf = gst::Buffer::from_slice([42, 43, 44, 45]); assert!(h.push(buf) == Ok(gst::FlowSuccess::Ok)); } diff --git a/mux/flavors/src/flvdemux/imp.rs b/mux/flavors/src/flvdemux/imp.rs index 909bd57c..dfcdb8d9 100644 --- a/mux/flavors/src/flvdemux/imp.rs +++ b/mux/flavors/src/flvdemux/imp.rs @@ -463,7 +463,7 @@ impl FlvDemux { match *state { State::Stopped => unreachable!(), State::NeedHeader => { - let header = match self.find_header(&mut *adapter) { + let header = match self.find_header(&mut adapter) { Ok(header) => header, Err(_) => { gst::trace!(CAT, imp: self, "Need more data"); @@ -503,7 +503,7 @@ impl FlvDemux { *skip_left -= skip as u32; } State::Streaming(ref mut sstate) => { - let res = sstate.handle_tag(self, &mut *adapter); + let res = sstate.handle_tag(self, &mut adapter); match res { Ok(None) => { @@ -533,7 +533,7 @@ impl FlvDemux { while adapter.available() >= 9 { let data = adapter.map(9).unwrap(); - if let Ok((_, header)) = flavors::header(&*data) { + if let Ok((_, header)) = flavors::header(&data) { gst::debug!(CAT, imp: self, "Found FLV header: {:?}", header); drop(data); adapter.flush(9); @@ -745,7 +745,7 @@ impl StreamingState { let data = adapter.map(tag_header.data_size as usize).unwrap(); - match flavors::script_data(&*data) { + match flavors::script_data(&data) { Ok((_, ref script_data)) if script_data.name == "onMetaData" => { gst::trace!(CAT, imp: imp, "Got script tag: {:?}", script_data); @@ -823,7 +823,9 @@ impl StreamingState { } } - if (!self.expect_video || self.video != None) && self.audio != None && !self.got_all_streams + if (!self.expect_video || self.video.is_some()) + && self.audio.is_some() + && !self.got_all_streams { gst::debug!(CAT, imp: imp, "Have all expected streams now"); self.got_all_streams = true; @@ -853,7 +855,7 @@ impl StreamingState { let data = adapter.map(1).unwrap(); - match flavors::aac_audio_packet_header(&*data) { + match flavors::aac_audio_packet_header(&data) { Err(nom::Err::Error(err)) | Err(nom::Err::Failure(err)) => { gst::error!(CAT, imp: imp, "Invalid AAC audio packet header: {:?}", err); drop(data); @@ -894,7 +896,7 @@ impl StreamingState { assert!(adapter.available() >= tag_header.data_size as usize); let data = adapter.map(1).unwrap(); - let data_header = match flavors::audio_data_header(&*data) { + let data_header = match flavors::audio_data_header(&data) { Err(nom::Err::Error(err)) | Err(nom::Err::Failure(err)) => { gst::error!(CAT, imp: imp, "Invalid audio data header: {:?}", err); drop(data); @@ -925,7 +927,7 @@ impl StreamingState { return Ok(events); } - if self.audio == None { + if self.audio.is_none() { adapter.flush((tag_header.data_size - offset) as usize); return Ok(events); } @@ -983,7 +985,9 @@ impl StreamingState { } } - if (!self.expect_audio || self.audio != None) && self.video != None && !self.got_all_streams + if (!self.expect_audio || self.audio.is_some()) + && self.video.is_some() + && !self.got_all_streams { gst::debug!(CAT, imp: imp, "Have all expected streams now"); self.got_all_streams = true; @@ -1012,7 +1016,7 @@ impl StreamingState { } let data = adapter.map(4).unwrap(); - match flavors::avc_video_packet_header(&*data) { + match flavors::avc_video_packet_header(&data) { Err(nom::Err::Error(err)) | Err(nom::Err::Failure(err)) => { gst::error!(CAT, imp: imp, "Invalid AVC video packet header: {:?}", err); drop(data); @@ -1065,7 +1069,7 @@ impl StreamingState { assert!(adapter.available() >= tag_header.data_size as usize); let data = adapter.map(1).unwrap(); - let data_header = match flavors::video_data_header(&*data) { + let data_header = match flavors::video_data_header(&data) { Err(nom::Err::Error(err)) | Err(nom::Err::Failure(err)) => { gst::error!(CAT, imp: imp, "Invalid video data header: {:?}", err); drop(data); @@ -1101,7 +1105,7 @@ impl StreamingState { return Ok(events); } - if self.video == None { + if self.video.is_none() { adapter.flush((tag_header.data_size - offset) as usize); return Ok(events); } @@ -1419,7 +1423,7 @@ impl VideoFormat { flavors::CodecId::H264 => self.avc_sequence_header.as_ref().map(|header| { gst::Caps::builder("video/x-h264") .field("stream-format", "avc") - .field("codec_data", &header) + .field("codec_data", header) .build() }), flavors::CodecId::H263 => Some(gst::Caps::builder("video/x-h263").build()), diff --git a/mux/fmp4/src/fmp4mux/boxes.rs b/mux/fmp4/src/fmp4mux/boxes.rs index 358a0d75..2a6cc9a1 100644 --- a/mux/fmp4/src/fmp4mux/boxes.rs +++ b/mux/fmp4/src/fmp4mux/boxes.rs @@ -673,7 +673,7 @@ fn write_tref( references: &[TrackReference], ) -> Result<(), Error> { for reference in references { - write_box(v, &reference.reference_type, |v| { + write_box(v, reference.reference_type, |v| { for track_id in &reference.track_ids { v.extend(track_id.to_be_bytes()); } @@ -1619,6 +1619,7 @@ fn write_mfhd(v: &mut Vec, cfg: &super::FragmentHeaderConfiguration) -> Resu } #[allow(clippy::identity_op)] +#[allow(clippy::bool_to_int_with_if)] fn sample_flags_from_buffer( timing_info: &super::FragmentTimingInfo, buffer: &gst::BufferRef, diff --git a/mux/fmp4/src/fmp4mux/imp.rs b/mux/fmp4/src/fmp4mux/imp.rs index 3a233ccf..788d4d5e 100644 --- a/mux/fmp4/src/fmp4mux/imp.rs +++ b/mux/fmp4/src/fmp4mux/imp.rs @@ -1620,7 +1620,7 @@ impl FMP4Mux { }; let caps = gst::Caps::builder("video/quicktime") .field("variant", variant) - .field("streamheader", gst::Array::new(&[&buffer])) + .field("streamheader", gst::Array::new([&buffer])) .build(); let mut list = gst::BufferList::new_sized(1); @@ -1684,7 +1684,7 @@ impl ObjectImpl for FMP4Mux { ] }); - &*PROPERTIES + &PROPERTIES } fn set_property(&self, _id: usize, value: &glib::Value, pspec: &glib::ParamSpec) { @@ -2517,13 +2517,13 @@ impl ElementImpl for DASHMP4Mux { gst::PadPresence::Always, &[ gst::Structure::builder("video/x-h264") - .field("stream-format", gst::List::new(&[&"avc", &"avc3"])) + .field("stream-format", gst::List::new(["avc", "avc3"])) .field("alignment", "au") .field("width", gst::IntRange::::new(1, u16::MAX as i32)) .field("height", gst::IntRange::::new(1, u16::MAX as i32)) .build(), gst::Structure::builder("video/x-h265") - .field("stream-format", gst::List::new(&[&"hvc1", &"hev1"])) + .field("stream-format", gst::List::new(["hvc1", "hev1"])) .field("alignment", "au") .field("width", gst::IntRange::::new(1, u16::MAX as i32)) .field("height", gst::IntRange::::new(1, u16::MAX as i32)) @@ -2607,13 +2607,13 @@ impl ElementImpl for ONVIFFMP4Mux { gst::PadPresence::Request, &[ gst::Structure::builder("video/x-h264") - .field("stream-format", gst::List::new(&[&"avc", &"avc3"])) + .field("stream-format", gst::List::new(["avc", "avc3"])) .field("alignment", "au") .field("width", gst::IntRange::::new(1, u16::MAX as i32)) .field("height", gst::IntRange::::new(1, u16::MAX as i32)) .build(), gst::Structure::builder("video/x-h265") - .field("stream-format", gst::List::new(&[&"hvc1", &"hev1"])) + .field("stream-format", gst::List::new(["hvc1", "hev1"])) .field("alignment", "au") .field("width", gst::IntRange::::new(1, u16::MAX as i32)) .field("height", gst::IntRange::::new(1, u16::MAX as i32)) diff --git a/net/aws/src/s3url.rs b/net/aws/src/s3url.rs index 1a331118..3d601aed 100644 --- a/net/aws/src/s3url.rs +++ b/net/aws/src/s3url.rs @@ -102,7 +102,7 @@ pub fn parse_s3_url(url_str: &str) -> Result { Some(_) => return Err("Bad query, only 'version' is supported".to_owned()), }; - if q.next() != None { + if q.next().is_some() { return Err("Extra query terms, only 'version' is supported".to_owned()); } diff --git a/net/ndi/src/device_provider/imp.rs b/net/ndi/src/device_provider/imp.rs index f67d1e55..94b975c5 100644 --- a/net/ndi/src/device_provider/imp.rs +++ b/net/ndi/src/device_provider/imp.rs @@ -215,16 +215,12 @@ impl GstObjectImpl for Device {} impl DeviceImpl for Device { fn create_element(&self, name: Option<&str>) -> Result { let source_info = self.source.get().unwrap(); - let element = glib::Object::with_type( - crate::ndisrc::NdiSrc::static_type(), - &[ - ("name", &name), - ("ndi-name", &source_info.ndi_name()), - ("url-address", &source_info.url_address()), - ], - ) - .dynamic_cast::() - .unwrap(); + let element = glib::Object::builder::() + .property("name", name) + .property("ndi-name", source_info.ndi_name()) + .property("url-address", source_info.url_address()) + .build() + .upcast::(); Ok(element) } @@ -242,16 +238,16 @@ impl super::Device { // Put the url-address into the extra properties let extra_properties = gst::Structure::builder("properties") - .field("ndi-name", &source.ndi_name()) - .field("url-address", &source.url_address()) + .field("ndi-name", source.ndi_name()) + .field("url-address", source.url_address()) .build(); - let device = glib::Object::new::(&[ - ("caps", &caps), - ("display-name", &display_name), - ("device-class", &device_class), - ("properties", &extra_properties), - ]); + let device = glib::Object::builder::() + .property("caps", caps) + .property("display-name", display_name) + .property("device-class", device_class) + .property("properties", extra_properties) + .build(); let imp = device.imp(); imp.source.set(source.to_owned()).unwrap(); diff --git a/net/ndi/src/ndisink/imp.rs b/net/ndi/src/ndisink/imp.rs index f2d185b8..585f09b3 100644 --- a/net/ndi/src/ndisink/imp.rs +++ b/net/ndi/src/ndisink/imp.rs @@ -121,23 +121,23 @@ impl ElementImpl for NdiSink { gst::Structure::builder("video/x-raw") .field( "format", - &gst::List::new(&[ - &gst_video::VideoFormat::Uyvy.to_str(), - &gst_video::VideoFormat::I420.to_str(), - &gst_video::VideoFormat::Nv12.to_str(), - &gst_video::VideoFormat::Nv21.to_str(), - &gst_video::VideoFormat::Yv12.to_str(), - &gst_video::VideoFormat::Bgra.to_str(), - &gst_video::VideoFormat::Bgrx.to_str(), - &gst_video::VideoFormat::Rgba.to_str(), - &gst_video::VideoFormat::Rgbx.to_str(), + gst::List::new([ + gst_video::VideoFormat::Uyvy.to_str(), + gst_video::VideoFormat::I420.to_str(), + gst_video::VideoFormat::Nv12.to_str(), + gst_video::VideoFormat::Nv21.to_str(), + gst_video::VideoFormat::Yv12.to_str(), + gst_video::VideoFormat::Bgra.to_str(), + gst_video::VideoFormat::Bgrx.to_str(), + gst_video::VideoFormat::Rgba.to_str(), + gst_video::VideoFormat::Rgbx.to_str(), ]), ) - .field("width", &gst::IntRange::::new(1, std::i32::MAX)) - .field("height", &gst::IntRange::::new(1, std::i32::MAX)) + .field("width", gst::IntRange::::new(1, std::i32::MAX)) + .field("height", gst::IntRange::::new(1, std::i32::MAX)) .field( "framerate", - &gst::FractionRange::new( + gst::FractionRange::new( gst::Fraction::new(0, 1), gst::Fraction::new(std::i32::MAX, 1), ), @@ -146,10 +146,10 @@ impl ElementImpl for NdiSink { ) .structure( gst::Structure::builder("audio/x-raw") - .field("format", &gst_audio::AUDIO_FORMAT_F32.to_str()) - .field("rate", &gst::IntRange::::new(1, i32::MAX)) - .field("channels", &gst::IntRange::::new(1, i32::MAX)) - .field("layout", &"interleaved") + .field("format", gst_audio::AUDIO_FORMAT_F32.to_str()) + .field("rate", gst::IntRange::::new(1, i32::MAX)) + .field("channels", gst::IntRange::::new(1, i32::MAX)) + .field("layout", "interleaved") .build(), ) .build(); diff --git a/net/ndi/src/ndisrc/receiver.rs b/net/ndi/src/ndisrc/receiver.rs index 97f05937..83d4634c 100644 --- a/net/ndi/src/ndisrc/receiver.rs +++ b/net/ndi/src/ndisrc/receiver.rs @@ -1299,14 +1299,14 @@ impl Receiver { gst::ReferenceTimestampMeta::add( buffer, - &*crate::TIMECODE_CAPS, + &crate::TIMECODE_CAPS, (video_frame.timecode() as u64 * 100).nseconds(), gst::ClockTime::NONE, ); if video_frame.timestamp() != ndisys::NDIlib_recv_timestamp_undefined { gst::ReferenceTimestampMeta::add( buffer, - &*crate::TIMESTAMP_CAPS, + &crate::TIMESTAMP_CAPS, (video_frame.timestamp() as u64 * 100).nseconds(), gst::ClockTime::NONE, ); @@ -1670,14 +1670,14 @@ impl Receiver { gst::ReferenceTimestampMeta::add( buffer, - &*crate::TIMECODE_CAPS, + &crate::TIMECODE_CAPS, (audio_frame.timecode() as u64 * 100).nseconds(), gst::ClockTime::NONE, ); if audio_frame.timestamp() != ndisys::NDIlib_recv_timestamp_undefined { gst::ReferenceTimestampMeta::add( buffer, - &*crate::TIMESTAMP_CAPS, + &crate::TIMESTAMP_CAPS, (audio_frame.timestamp() as u64 * 100).nseconds(), gst::ClockTime::NONE, ); diff --git a/net/reqwest/src/reqwesthttpsrc/imp.rs b/net/reqwest/src/reqwesthttpsrc/imp.rs index 697a6868..65eeb723 100644 --- a/net/reqwest/src/reqwesthttpsrc/imp.rs +++ b/net/reqwest/src/reqwesthttpsrc/imp.rs @@ -562,7 +562,7 @@ impl ReqwestHttpSrc { if let Some(ref mut caps) = caps { let caps = caps.get_mut().unwrap(); let s = caps.structure_mut(0).unwrap(); - s.set("content-type", &content_type.as_ref()); + s.set("content-type", content_type.as_ref()); } else if content_type.type_() == "audio" && content_type.subtype() == "L16" { let channels = content_type .get_param("channels") diff --git a/net/rtp/src/av1/depay/imp.rs b/net/rtp/src/av1/depay/imp.rs index c2a163a2..83e1a23e 100644 --- a/net/rtp/src/av1/depay/imp.rs +++ b/net/rtp/src/av1/depay/imp.rs @@ -51,7 +51,7 @@ static CAT: Lazy = Lazy::new(|| { }); static TEMPORAL_DELIMITER: Lazy = - Lazy::new(|| gst::Memory::from_slice(&[0b0001_0010, 0])); + Lazy::new(|| gst::Memory::from_slice([0b0001_0010, 0])); impl RTPAv1Depay { fn reset(&self, state: &mut State) { diff --git a/net/rtp/src/av1/pay/imp.rs b/net/rtp/src/av1/pay/imp.rs index 1591ad29..66e5a874 100644 --- a/net/rtp/src/av1/pay/imp.rs +++ b/net/rtp/src/av1/pay/imp.rs @@ -390,7 +390,7 @@ impl RTPAv1Pay { let aggr_header: [u8; 1] = [ (state.open_obu_fragment as u8) << 7 | // Z - ((packet.last_obu_fragment_size != None) as u8) << 6 | // Y + ((packet.last_obu_fragment_size.is_some()) as u8) << 6 | // Y (w as u8) << 4 | // W (state.first_packet_in_seq as u8) << 3 // N ; 1]; diff --git a/net/webrtc/src/webrtcsink/imp.rs b/net/webrtc/src/webrtcsink/imp.rs index 9b663365..9127d613 100644 --- a/net/webrtc/src/webrtcsink/imp.rs +++ b/net/webrtc/src/webrtcsink/imp.rs @@ -519,7 +519,7 @@ fn setup_encoding( // Firefox). In any case, restrict to exclude RGB formats altogether, // and let videoconvert do the conversion properly if needed. structure_builder = - structure_builder.field("format", &gst::List::new(&[&"NV12", &"YV12", &"I420"])); + structure_builder.field("format", gst::List::new(["NV12", "YV12", "I420"])); } gst::Caps::builder_full_with_any_features() @@ -2751,7 +2751,7 @@ impl ElementImpl for WebRTCSink { WebRTCSink::catch_panic_pad_function( parent, || false, - |this| this.sink_event(pad.upcast_ref(), &*this.obj(), event), + |this| this.sink_event(pad.upcast_ref(), &this.obj(), event), ) }) .build(); @@ -2780,7 +2780,7 @@ impl ElementImpl for WebRTCSink { ) -> Result { let element = self.obj(); if let gst::StateChange::ReadyToPaused = transition { - if let Err(err) = self.prepare(&*element) { + if let Err(err) = self.prepare(&element) { gst::element_error!( element, gst::StreamError::Failed, @@ -2794,7 +2794,7 @@ impl ElementImpl for WebRTCSink { match transition { gst::StateChange::PausedToReady => { - if let Err(err) = self.unprepare(&*element) { + if let Err(err) = self.unprepare(&element) { gst::element_error!( element, gst::StreamError::Failed, @@ -2808,7 +2808,7 @@ impl ElementImpl for WebRTCSink { } gst::StateChange::PausedToPlaying => { let mut state = self.state.lock().unwrap(); - state.maybe_start_signaller(&*element); + state.maybe_start_signaller(&element); } _ => (), } diff --git a/tutorial/src/rgb2gray/imp.rs b/tutorial/src/rgb2gray/imp.rs index 37e2ad5f..5ba14554 100644 --- a/tutorial/src/rgb2gray/imp.rs +++ b/tutorial/src/rgb2gray/imp.rs @@ -261,7 +261,7 @@ impl BaseTransformImpl for Rgb2Gray { let mut caps = caps.clone(); for s in caps.make_mut().iter_mut() { - s.set("format", &gst_video::VideoFormat::Bgrx.to_str()); + s.set("format", gst_video::VideoFormat::Bgrx.to_str()); } caps @@ -277,7 +277,7 @@ impl BaseTransformImpl for Rgb2Gray { for s in caps.iter() { let mut s_gray = s.to_owned(); - s_gray.set("format", &gst_video::VideoFormat::Gray8.to_str()); + s_gray.set("format", gst_video::VideoFormat::Gray8.to_str()); gray_caps.append_structure(s_gray); } gray_caps.append(caps.clone()); diff --git a/tutorial/src/sinesrc/imp.rs b/tutorial/src/sinesrc/imp.rs index 42be86d2..24364680 100644 --- a/tutorial/src/sinesrc/imp.rs +++ b/tutorial/src/sinesrc/imp.rs @@ -404,7 +404,7 @@ impl BaseSrcImpl for SineSrc { gst::debug!(CAT, imp: self, "Configuring for caps {}", caps); self.obj() - .set_blocksize(info.bpf() * (*self.settings.lock().unwrap()).samples_per_buffer); + .set_blocksize(info.bpf() * (self.settings.lock().unwrap()).samples_per_buffer); let settings = *self.settings.lock().unwrap(); let mut state = self.state.lock().unwrap(); diff --git a/utils/fallbackswitch/src/fallbacksrc/imp.rs b/utils/fallbackswitch/src/fallbacksrc/imp.rs index 7c011273..1f9a0161 100644 --- a/utils/fallbackswitch/src/fallbacksrc/imp.rs +++ b/utils/fallbackswitch/src/fallbacksrc/imp.rs @@ -54,7 +54,7 @@ impl Stats { fn to_structure(&self) -> gst::Structure { gst::Structure::builder("application/x-fallbacksrc-stats") .field("num-retry", self.num_retry) - .field("num-fallback-retry", &self.num_fallback_retry) + .field("num-fallback-retry", self.num_fallback_retry) .field("last-retry-reason", self.last_retry_reason) .field( "last-fallback-retry-reason", @@ -1893,7 +1893,7 @@ impl FallbackSrc { // Link the new source pad in let switch_pad = switch.request_pad_simple("sink_%u").unwrap(); - switch_pad.set_property("priority", if fallback_source { 1u32 } else { 0u32 }); + switch_pad.set_property("priority", u32::from(fallback_source)); ghostpad.link(&switch_pad).unwrap(); pad.add_probe(gst::PadProbeType::EVENT_DOWNSTREAM, move |pad, info| { diff --git a/utils/togglerecord/src/togglerecord/imp.rs b/utils/togglerecord/src/togglerecord/imp.rs index b15cd569..55052134 100644 --- a/utils/togglerecord/src/togglerecord/imp.rs +++ b/utils/togglerecord/src/togglerecord/imp.rs @@ -744,7 +744,7 @@ impl ToggleRecord { // FIXME it would help a lot if we could expect current_running_time // and possibly current_running_time_end at some point. - if data.can_clip(&*state) + if data.can_clip(&state) && current_running_time.map_or(false, |cur_rt| cur_rt < last_recording_start) && current_running_time_end .map_or(false, |cur_rt_end| cur_rt_end > last_recording_start) @@ -778,7 +778,7 @@ impl ToggleRecord { gst::log!(CAT, obj: pad, "Clipping to segment {:?}", segment); - if let Some(data) = data.clip(&*state, &segment) { + if let Some(data) = data.clip(&state, &segment) { return Ok(HandleResult::Pass(data)); } else { gst::warning!(CAT, obj: pad, "Complete buffer clipped!"); @@ -799,7 +799,7 @@ impl ToggleRecord { last_recording_start, ); return Ok(HandleResult::Drop); - } else if data.can_clip(&*state) + } else if data.can_clip(&state) && current_running_time .opt_lt(rec_state.last_recording_stop) .unwrap_or(false) @@ -836,7 +836,7 @@ impl ToggleRecord { gst::log!(CAT, obj: pad, "Clipping to segment {:?}", segment,); - if let Some(data) = data.clip(&*state, &segment) { + if let Some(data) = data.clip(&state, &segment) { return Ok(HandleResult::Pass(data)); } else { gst::warning!(CAT, obj: pad, "Complete buffer clipped!"); @@ -935,7 +935,7 @@ impl ToggleRecord { last_recording_stop, ); Ok(HandleResult::Pass(data)) - } else if data.can_clip(&*state) + } else if data.can_clip(&state) && current_running_time < last_recording_stop && current_running_time_end .map_or(false, |cur_rt_end| cur_rt_end > last_recording_stop) @@ -960,7 +960,7 @@ impl ToggleRecord { gst::log!(CAT, obj: pad, "Clipping to segment {:?}", segment,); - if let Some(data) = data.clip(&*state, &segment) { + if let Some(data) = data.clip(&state, &segment) { Ok(HandleResult::Pass(data)) } else { gst::warning!(CAT, obj: pad, "Complete buffer clipped!"); @@ -1016,7 +1016,7 @@ impl ToggleRecord { last_recording_start, ); Ok(HandleResult::Pass(data)) - } else if data.can_clip(&*state) + } else if data.can_clip(&state) && current_running_time < last_recording_start && current_running_time_end .map_or(false, |cur_rt_end| cur_rt_end > last_recording_start) @@ -1041,7 +1041,7 @@ impl ToggleRecord { gst::log!(CAT, obj: pad, "Clipping to segment {:?}", segment); - if let Some(data) = data.clip(&*state, &segment) { + if let Some(data) = data.clip(&state, &segment) { Ok(HandleResult::Pass(data)) } else { gst::warning!(CAT, obj: pad, "Complete buffer clipped!"); diff --git a/utils/tracers/src/pipeline_snapshot/imp.rs b/utils/tracers/src/pipeline_snapshot/imp.rs index f3f537ae..7c041f04 100644 --- a/utils/tracers/src/pipeline_snapshot/imp.rs +++ b/utils/tracers/src/pipeline_snapshot/imp.rs @@ -182,7 +182,7 @@ impl PipelineSnapshot { use signal_hook::consts::signal::*; use signal_hook::iterator::Signals; - let mut signals = Signals::new(&[SIGUSR1])?; + let mut signals = Signals::new([SIGUSR1])?; let signal_handle = signals.handle(); let tracer_weak = self.obj().downgrade(); diff --git a/utils/uriplaylistbin/examples/playlist.rs b/utils/uriplaylistbin/examples/playlist.rs index 0f3bdfe2..804fdc73 100644 --- a/utils/uriplaylistbin/examples/playlist.rs +++ b/utils/uriplaylistbin/examples/playlist.rs @@ -27,7 +27,7 @@ fn create_pipeline(uris: Vec, iterations: u32) -> anyhow::Result>(path: P) -> Option<(String, String)> { Some(path) => vec!["-C", path], None => vec![], }; - args.extend(&["log", "-1", "--format=%h_%cd", "--date=short"]); + args.extend(["log", "-1", "--format=%h_%cd", "--date=short"]); let output = Command::new("git").args(&args).output().ok()?; if !output.status.success() { return None; @@ -38,7 +38,7 @@ fn dirty>(path: P) -> bool { Some(path) => vec!["-C", path], None => vec![], }; - args.extend(&["ls-files", "-m"]); + args.extend(["ls-files", "-m"]); match Command::new("git").args(&args).output() { Ok(modified_files) => !modified_files.stdout.is_empty(), Err(_) => false, diff --git a/video/closedcaption/src/caption_frame.rs b/video/closedcaption/src/caption_frame.rs index dda738cc..ef2f3d07 100644 --- a/video/closedcaption/src/caption_frame.rs +++ b/video/closedcaption/src/caption_frame.rs @@ -55,7 +55,7 @@ impl CaptionFrame { let len = ffi::caption_frame_to_text( &self.0 as *const _ as *mut _, data.as_ptr() as *mut _, - if full { 1 } else { 0 }, + i32::from(full), ); data.set_len(len as usize); diff --git a/video/closedcaption/src/mcc_enc/imp.rs b/video/closedcaption/src/mcc_enc/imp.rs index 3febb2a7..e4fbdfd8 100644 --- a/video/closedcaption/src/mcc_enc/imp.rs +++ b/video/closedcaption/src/mcc_enc/imp.rs @@ -297,7 +297,7 @@ impl MccEnc { }; let checksum = map.iter().fold(0u8, |sum, b| sum.wrapping_add(*b)); - Self::encode_payload(outbuf, &*map); + Self::encode_payload(outbuf, &map); if checksum == 0 { outbuf.push(b'Z'); @@ -322,10 +322,10 @@ impl MccEnc { let mut outbuf = Vec::new(); if state.need_headers { state.need_headers = false; - self.generate_headers(&*state, &mut outbuf)?; + self.generate_headers(&state, &mut outbuf)?; } - self.generate_caption(&*state, &buffer, &mut outbuf)?; + self.generate_caption(&state, &buffer, &mut outbuf)?; let mut buf = gst::Buffer::from_mut_slice(outbuf); buffer diff --git a/video/closedcaption/src/scc_enc/imp.rs b/video/closedcaption/src/scc_enc/imp.rs index 23fcbbf6..58c2b497 100644 --- a/video/closedcaption/src/scc_enc/imp.rs +++ b/video/closedcaption/src/scc_enc/imp.rs @@ -203,7 +203,7 @@ impl State { outbuf.push(b' '); } - Self::encode_payload(&mut outbuf, &*map); + Self::encode_payload(&mut outbuf, &map); } outbuf.extend_from_slice(b"\r\n\r\n".as_ref()); diff --git a/video/closedcaption/src/transcriberbin/imp.rs b/video/closedcaption/src/transcriberbin/imp.rs index ab2514c9..33679bed 100644 --- a/video/closedcaption/src/transcriberbin/imp.rs +++ b/video/closedcaption/src/transcriberbin/imp.rs @@ -245,13 +245,13 @@ impl TranscriberBin { let cc_caps_mut = cc_caps.make_mut(); let s = cc_caps_mut.structure_mut(0).unwrap(); - s.set("framerate", &state.framerate.unwrap()); + s.set("framerate", state.framerate.unwrap()); state.cccapsfilter.set_property("caps", &cc_caps); let max_size_time = settings.latency + settings.accumulate_time; - for queue in &[&state.audio_queue_passthrough, &state.video_queue] { + for queue in [&state.audio_queue_passthrough, &state.video_queue] { queue.set_property("max-size-bytes", 0u32); queue.set_property("max-size-buffers", 0u32); queue.set_property("max-size-time", max_size_time); diff --git a/video/closedcaption/tests/cea608tott.rs b/video/closedcaption/tests/cea608tott.rs index 01db571d..9a04d499 100644 --- a/video/closedcaption/tests/cea608tott.rs +++ b/video/closedcaption/tests/cea608tott.rs @@ -74,7 +74,7 @@ fn test_parse() { ); let data = buf.map_readable().unwrap(); - let s = std::str::from_utf8(&*data) + let s = std::str::from_utf8(&data) .unwrap_or_else(|_| panic!("Non-UTF8 data for {}th buffer", i + 1)); assert_eq!(e.2, s, "Unexpected data for {}th buffer", i + 1); } diff --git a/video/closedcaption/tests/tttocea608.rs b/video/closedcaption/tests/tttocea608.rs index 89ccff61..a97e04c9 100644 --- a/video/closedcaption/tests/tttocea608.rs +++ b/video/closedcaption/tests/tttocea608.rs @@ -39,7 +39,7 @@ fn test_non_timed_buffer() { let mut h = gst_check::Harness::new_parse("tttocea608 mode=pop-on"); h.set_src_caps_str("text/x-raw"); - let inbuf = gst::Buffer::from_slice(&"Hello"); + let inbuf = gst::Buffer::from_slice("Hello"); assert_eq!(h.push(inbuf), Err(gst::FlowError::Error)); } @@ -56,7 +56,7 @@ fn test_one_timed_buffer_and_eos() { let _event = h.pull_event().unwrap(); } - let inbuf = new_timed_buffer(&"Hello", ClockTime::SECOND, ClockTime::SECOND); + let inbuf = new_timed_buffer("Hello", ClockTime::SECOND, ClockTime::SECOND); assert_eq!(h.push(inbuf), Ok(gst::FlowSuccess::Ok)); @@ -155,10 +155,10 @@ fn test_erase_display_memory_non_spliced() { let _event = h.pull_event().unwrap(); } - let inbuf = new_timed_buffer(&"Hello", 1_000_000_000.nseconds(), ClockTime::SECOND); + let inbuf = new_timed_buffer("Hello", 1_000_000_000.nseconds(), ClockTime::SECOND); assert_eq!(h.push(inbuf), Ok(gst::FlowSuccess::Ok)); - let inbuf = new_timed_buffer(&"World", 3_000_000_000.nseconds(), ClockTime::SECOND); + let inbuf = new_timed_buffer("World", 3_000_000_000.nseconds(), ClockTime::SECOND); assert_eq!(h.push(inbuf), Ok(gst::FlowSuccess::Ok)); let mut erase_display_buffers = 0; @@ -197,11 +197,11 @@ fn test_erase_display_memory_spliced() { let _event = h.pull_event().unwrap(); } - let inbuf = new_timed_buffer(&"Hello", 1_000_000_000.nseconds(), ClockTime::SECOND); + let inbuf = new_timed_buffer("Hello", 1_000_000_000.nseconds(), ClockTime::SECOND); assert_eq!(h.push(inbuf), Ok(gst::FlowSuccess::Ok)); let inbuf = new_timed_buffer( - &"World, Lorem Ipsum", + "World, Lorem Ipsum", 2_000_000_000.nseconds(), ClockTime::SECOND, ); @@ -243,10 +243,10 @@ fn test_output_gaps() { let _event = h.pull_event().unwrap(); } - let inbuf = new_timed_buffer(&"Hello", 1_000_000_000.nseconds(), ClockTime::SECOND); + let inbuf = new_timed_buffer("Hello", 1_000_000_000.nseconds(), ClockTime::SECOND); assert_eq!(h.push(inbuf), Ok(gst::FlowSuccess::Ok)); - let inbuf = new_timed_buffer(&"World", 3_000_000_000.nseconds(), ClockTime::SECOND); + let inbuf = new_timed_buffer("World", 3_000_000_000.nseconds(), ClockTime::SECOND); assert_eq!(h.push(inbuf), Ok(gst::FlowSuccess::Ok)); h.push_event(gst::event::Eos::new()); @@ -317,10 +317,10 @@ fn test_one_timed_buffer_and_eos_roll_up2() { let _event = h.pull_event().unwrap(); } - let inbuf = new_timed_buffer(&"Hello", ClockTime::SECOND, ClockTime::SECOND); + let inbuf = new_timed_buffer("Hello", ClockTime::SECOND, ClockTime::SECOND); assert_eq!(h.push(inbuf), Ok(gst::FlowSuccess::Ok)); - let inbuf = new_timed_buffer(&"World", 2.seconds(), 1.nseconds()); + let inbuf = new_timed_buffer("World", 2.seconds(), 1.nseconds()); assert_eq!(h.push(inbuf), Ok(gst::FlowSuccess::Ok)); let expected: [(ClockTime, ClockTime, [u8; 2usize]); 5] = [ @@ -433,7 +433,7 @@ fn test_word_wrap_roll_up() { let _event = h.pull_event().unwrap(); } - let inbuf = new_timed_buffer(&"Hello World", ClockTime::SECOND, ClockTime::SECOND); + let inbuf = new_timed_buffer("Hello World", ClockTime::SECOND, ClockTime::SECOND); assert_eq!(h.push(inbuf), Ok(gst::FlowSuccess::Ok)); let expected: [(ClockTime, ClockTime, [u8; 2usize]); 11] = [ diff --git a/video/dav1d/src/dav1ddec/imp.rs b/video/dav1d/src/dav1ddec/imp.rs index d89bb7be..89f50ef7 100644 --- a/video/dav1d/src/dav1ddec/imp.rs +++ b/video/dav1d/src/dav1ddec/imp.rs @@ -669,7 +669,7 @@ impl VideoDecoderImpl for Dav1dDec { is_live = latency_query.result().0; } - max_frame_delay = if is_live { 1 } else { 0 }; + max_frame_delay = u32::from(is_live); } else { max_frame_delay = settings.max_frame_delay.try_into().unwrap(); } diff --git a/video/ffv1/src/ffv1dec/imp.rs b/video/ffv1/src/ffv1dec/imp.rs index 14b7ef4f..6eece27c 100644 --- a/video/ffv1/src/ffv1dec/imp.rs +++ b/video/ffv1/src/ffv1dec/imp.rs @@ -350,7 +350,7 @@ impl ElementImpl for Ffv1Dec { vec![sink_pad_template, src_pad_template] }); - &*PAD_TEMPLATES + &PAD_TEMPLATES } } diff --git a/video/gtk4/src/sink/paintable/imp.rs b/video/gtk4/src/sink/paintable/imp.rs index e4ed42b2..43f6bb61 100644 --- a/video/gtk4/src/sink/paintable/imp.rs +++ b/video/gtk4/src/sink/paintable/imp.rs @@ -139,7 +139,7 @@ impl SinkPaintable { if let Some(frame) = frame { gst::trace!(CAT, imp: self, "Received new frame"); - let new_paintables = frame.into_textures(&mut *self.cached_textures.borrow_mut()); + let new_paintables = frame.into_textures(&mut self.cached_textures.borrow_mut()); let new_size = new_paintables .first() .map(|p| (f32::round(p.width) as u32, f32::round(p.height) as u32)) diff --git a/video/videofx/tests/colordetect.rs b/video/videofx/tests/colordetect.rs index caab5a0f..9b7b527c 100644 --- a/video/videofx/tests/colordetect.rs +++ b/video/videofx/tests/colordetect.rs @@ -25,7 +25,7 @@ fn test_red_color() { let src = gst::ElementFactory::make("videotestsrc") .property_from_str("pattern", "red") - .property("num-buffers", &2i32) + .property("num-buffers", 2i32) .build() .unwrap();