mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-10-31 22:59:14 +00:00
Fix clippy warnings in the examples
This commit is contained in:
parent
d7baadee22
commit
b08a101cc6
4 changed files with 21 additions and 30 deletions
|
@ -3,9 +3,6 @@ use gst::*;
|
|||
extern crate gstreamer_app as gst_app;
|
||||
use gst_app::*;
|
||||
|
||||
extern crate glib;
|
||||
use glib::*;
|
||||
|
||||
use std::u64;
|
||||
use std::i16;
|
||||
use std::i32;
|
||||
|
@ -24,10 +21,10 @@ fn main() {
|
|||
appsink.set_caps(&Caps::new_simple(
|
||||
"audio/x-raw",
|
||||
&[
|
||||
(&"format", &"S16BE"),
|
||||
(&"layout", &"interleaved"),
|
||||
(&"channels", &(1i32)),
|
||||
(&"rate", &IntRange::<i32>::new(1, i32::MAX)),
|
||||
("format", &"S16BE"),
|
||||
("layout", &"interleaved"),
|
||||
("channels", &(1i32)),
|
||||
("rate", &IntRange::<i32>::new(1, i32::MAX)),
|
||||
],
|
||||
));
|
||||
|
||||
|
|
|
@ -3,9 +3,6 @@ use gst::*;
|
|||
extern crate gstreamer_app as gst_app;
|
||||
use gst_app::*;
|
||||
|
||||
extern crate glib;
|
||||
use glib::*;
|
||||
|
||||
use std::u64;
|
||||
use std::thread;
|
||||
|
||||
|
@ -27,10 +24,10 @@ fn main() {
|
|||
appsrc.set_caps(&Caps::new_simple(
|
||||
"video/x-raw",
|
||||
&[
|
||||
(&"format", &"BGRx"),
|
||||
(&"width", &(WIDTH as i32)),
|
||||
(&"height", &(HEIGHT as i32)),
|
||||
(&"framerate", &Fraction::new(2, 1)),
|
||||
("format", &"BGRx"),
|
||||
("width", &(WIDTH as i32)),
|
||||
("height", &(HEIGHT as i32)),
|
||||
("framerate", &Fraction::new(2, 1)),
|
||||
],
|
||||
));
|
||||
appsrc.set_property_format(Format::Time);
|
||||
|
|
|
@ -29,7 +29,7 @@ fn main() {
|
|||
// Need to move a new reference into the closure
|
||||
let pipeline_clone = pipeline.clone();
|
||||
decodebin.connect_pad_added(move |_, src_pad| {
|
||||
let ref pipeline = pipeline_clone;
|
||||
let pipeline = &pipeline_clone;
|
||||
|
||||
let (is_audio, is_video) = {
|
||||
let caps = src_pad.get_current_caps().unwrap();
|
||||
|
|
|
@ -20,21 +20,18 @@ fn main() {
|
|||
.unwrap();
|
||||
let src_pad = src.get_static_pad("src").unwrap();
|
||||
src_pad.add_probe(PAD_PROBE_TYPE_BUFFER, |_, probe_info| {
|
||||
match probe_info.data {
|
||||
Some(PadProbeData::Buffer(ref buffer)) => {
|
||||
let map = buffer.map_read().unwrap();
|
||||
let data = map.as_slice();
|
||||
let sum: f64 = data.chunks(2)
|
||||
.map(|sample| {
|
||||
let u: u16 = ((sample[0] as u16) << 8) | (sample[1] as u16);
|
||||
let f = (u as i16 as f64) / (i16::MAX as f64);
|
||||
f * f
|
||||
})
|
||||
.sum();
|
||||
let rms = (sum / ((data.len() / 2) as f64)).sqrt();
|
||||
println!("rms: {}", rms);
|
||||
}
|
||||
_ => (),
|
||||
if let Some(PadProbeData::Buffer(ref buffer)) = probe_info.data {
|
||||
let map = buffer.map_read().unwrap();
|
||||
let data = map.as_slice();
|
||||
let sum: f64 = data.chunks(2)
|
||||
.map(|sample| {
|
||||
let u: u16 = ((sample[0] as u16) << 8) | (sample[1] as u16);
|
||||
let f = (u as i16 as f64) / (i16::MAX as f64);
|
||||
f * f
|
||||
})
|
||||
.sum();
|
||||
let rms = (sum / ((data.len() / 2) as f64)).sqrt();
|
||||
println!("rms: {}", rms);
|
||||
}
|
||||
|
||||
PadProbeReturn::Ok
|
||||
|
|
Loading…
Reference in a new issue