Fix various new clippy warnings

This commit is contained in:
Sebastian Dröge 2022-11-01 10:27:48 +02:00
parent 31d4ba2eae
commit a8250abbf1
44 changed files with 140 additions and 139 deletions

View file

@ -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));

View file

@ -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);

View file

@ -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)
}

View file

@ -80,7 +80,7 @@ fn create_pipeline() -> Result<gst::Pipeline, Box<dyn Error>> {
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();

View file

@ -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");

View file

@ -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();

View file

@ -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(".");

View file

@ -53,7 +53,7 @@ struct Keys {
impl Keys {
fn from_file(file: &Path) -> Result<Self, Box<dyn Error>> {
let f = File::open(&file)?;
let f = File::open(file)?;
serde_json::from_reader(f).map_err(From::from)
}
}

View file

@ -57,7 +57,7 @@ struct Keys {
impl Keys {
fn from_file(file: &Path) -> Result<Self, Box<dyn Error>> {
let f = File::open(&file)?;
let f = File::open(file)?;
serde_json::from_reader(f).map_err(From::from)
}
}

View file

@ -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();

View file

@ -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);

View file

@ -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()?;

View file

@ -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);

View file

@ -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();

View file

@ -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));
}

View file

@ -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()),

View file

@ -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<u8>, 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,

View file

@ -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::<i32>::new(1, u16::MAX as i32))
.field("height", gst::IntRange::<i32>::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::<i32>::new(1, u16::MAX as i32))
.field("height", gst::IntRange::<i32>::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::<i32>::new(1, u16::MAX as i32))
.field("height", gst::IntRange::<i32>::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::<i32>::new(1, u16::MAX as i32))
.field("height", gst::IntRange::<i32>::new(1, u16::MAX as i32))

View file

@ -102,7 +102,7 @@ pub fn parse_s3_url(url_str: &str) -> Result<GstS3Url, String> {
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());
}

View file

@ -215,16 +215,12 @@ impl GstObjectImpl for Device {}
impl DeviceImpl for Device {
fn create_element(&self, name: Option<&str>) -> Result<gst::Element, gst::LoggableError> {
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::<gst::Element>()
.unwrap();
let element = glib::Object::builder::<crate::ndisrc::NdiSrc>()
.property("name", name)
.property("ndi-name", source_info.ndi_name())
.property("url-address", source_info.url_address())
.build()
.upcast::<gst::Element>();
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::<super::Device>(&[
("caps", &caps),
("display-name", &display_name),
("device-class", &device_class),
("properties", &extra_properties),
]);
let device = glib::Object::builder::<super::Device>()
.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();

View file

@ -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::<i32>::new(1, std::i32::MAX))
.field("height", &gst::IntRange::<i32>::new(1, std::i32::MAX))
.field("width", gst::IntRange::<i32>::new(1, std::i32::MAX))
.field("height", gst::IntRange::<i32>::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::<i32>::new(1, i32::MAX))
.field("channels", &gst::IntRange::<i32>::new(1, i32::MAX))
.field("layout", &"interleaved")
.field("format", gst_audio::AUDIO_FORMAT_F32.to_str())
.field("rate", gst::IntRange::<i32>::new(1, i32::MAX))
.field("channels", gst::IntRange::<i32>::new(1, i32::MAX))
.field("layout", "interleaved")
.build(),
)
.build();

View file

@ -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,
);

View file

@ -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")

View file

@ -51,7 +51,7 @@ static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| {
});
static TEMPORAL_DELIMITER: Lazy<gst::Memory> =
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) {

View file

@ -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];

View file

@ -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<gst::StateChangeSuccess, gst::StateChangeError> {
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);
}
_ => (),
}

View file

@ -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());

View file

@ -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();

View file

@ -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| {

View file

@ -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!");

View file

@ -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();

View file

@ -27,7 +27,7 @@ fn create_pipeline(uris: Vec<String>, iterations: u32) -> anyhow::Result<gst::Pi
let pipeline = gst::Pipeline::default();
let playlist = gst::ElementFactory::make("uriplaylistbin")
.property("uris", &uris)
.property("iterations", &iterations)
.property("iterations", iterations)
.build()?;
pipeline.add(&playlist)?;

View file

@ -88,7 +88,7 @@ fn test(
let pipeline = gst::Pipeline::default();
let playlist = gst::ElementFactory::make("uriplaylistbin")
.property("uris", &uris)
.property("iterations", &iterations)
.property("iterations", iterations)
.build()
.unwrap();
let mq = gst::ElementFactory::make("multiqueue").build().unwrap();

View file

@ -12,7 +12,7 @@ pub fn repo_hash<P: AsRef<Path>>(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<P: AsRef<Path>>(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,

View file

@ -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);

View file

@ -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

View file

@ -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());

View file

@ -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);

View file

@ -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);
}

View file

@ -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] = [

View file

@ -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();
}

View file

@ -350,7 +350,7 @@ impl ElementImpl for Ffv1Dec {
vec![sink_pad_template, src_pad_template]
});
&*PAD_TEMPLATES
&PAD_TEMPLATES
}
}

View file

@ -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))

View file

@ -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();