webrtc: Fix clippy issues

This commit is contained in:
Thibault Saunier 2022-10-18 19:37:00 +02:00
parent 87fd49a9bf
commit b164daf510
5 changed files with 21 additions and 29 deletions

View file

@ -139,15 +139,7 @@ async fn run(args: Args) -> Result<(), Error> {
info!("Encoder: {}", encoder.factory().unwrap().name());
let configured = if let Some(factory) = encoder.factory() {
match factory.name().as_str() {
"does-not-exist" => {
// One could configure a hardware encoder to their liking here,
// and return true to make sure webrtcsink does not do any configuration
// of its own
true
}
_ => false,
}
matches!(factory.name().as_str(), "does-not-exist")
} else {
false
};

View file

@ -191,7 +191,7 @@ impl Default for PacketGroup {
}
fn pdur(d: &Duration) -> String {
let stdd = time::Duration::from_nanos(d.num_nanoseconds().unwrap().abs() as u64);
let stdd = time::Duration::from_nanos(d.num_nanoseconds().unwrap().unsigned_abs());
format!("{}{stdd:?}", if d.lt(&Duration::zero()) { "-" } else { "" })
}
@ -367,7 +367,7 @@ impl Detector {
.arrival;
while last_arrival - self.oldest_packet_in_window_ts() > *PACKETS_RECEIVED_WINDOW {
let oldest_seqnum = self.last_received_packets.iter().next().unwrap().0.clone();
let oldest_seqnum = *self.last_received_packets.iter().next().unwrap().0;
self.last_received_packets.remove(&oldest_seqnum);
}
}
@ -433,7 +433,7 @@ impl Detector {
for pkt in packets {
// We know feedbacks packets will arrive "soon" after the packets they are reported for or considered
// lost so we can make the assumption that
let mut seqnum = pkt.seqnum + (self.twcc_extended_seqnum & !(0xffff as u64));
let mut seqnum = pkt.seqnum + (self.twcc_extended_seqnum & !0xffff_u64);
if seqnum < self.twcc_extended_seqnum {
let diff = self.twcc_extended_seqnum.overflowing_sub(seqnum).0;
@ -1098,7 +1098,7 @@ impl BandwidthEstimator {
if !list.is_empty() {
if let Err(err) = bwe.imp().push_list(list) {
gst::error!(CAT, obj: &bwe, "pause task, reason: {err:?}");
return pause();
pause()
}
}
})?;

View file

@ -302,7 +302,7 @@ impl Default for State {
fn make_converter_for_video_caps(caps: &gst::Caps) -> Result<gst::Element, Error> {
assert!(caps.is_fixed());
let video_info = gst_video::VideoInfo::from_caps(&caps)?;
let video_info = gst_video::VideoInfo::from_caps(caps)?;
let ret = gst::Bin::new(None);
@ -468,7 +468,7 @@ fn setup_encoding(
.with_context(|| format!("Creating payloader {}", codec.payloader.name()))?;
let parse_filter = make_element("capsfilter", None)?;
pay.set_property("mtu", 1200 as u32);
pay.set_property("mtu", 1200_u32);
pay.set_property("pt", codec.payload as u32);
if let Some(ssrc) = ssrc {
@ -1004,7 +1004,7 @@ impl Session {
self.encoders.push(enc);
if let Some(ref rtpgccbwe) = self.rtpgccbwe.as_ref() {
if let Some(rtpgccbwe) = self.rtpgccbwe.as_ref() {
let max_bitrate = self.cc_info.max_bitrate * (self.encoders.len() as u32);
rtpgccbwe.set_property("max-bitrate", max_bitrate);
}
@ -1335,7 +1335,7 @@ impl WebRTCSink {
obj: element,
"consumer for session {} no longer exists (sessions: {:?}",
session_id,
state.sessions.keys().map(|id| id)
state.sessions.keys()
);
}
}
@ -1461,7 +1461,7 @@ impl WebRTCSink {
if e.factory().map_or(false, |f| f.name() == "rtprtxsend") {
if e.has_property("stuffing-kbps", Some(i32::static_type())) {
element.imp().set_rtptrxsend(&element, &session_id, e);
element.imp().set_rtptrxsend(element, &session_id, e);
} else {
gst::warning!(CAT, "rtprtxsend doesn't have a `stuffing-kbps` \
property, stuffing disabled");
@ -1785,7 +1785,7 @@ impl WebRTCSink {
let mut state = element.imp().state.lock().unwrap();
if let Some(mut session) = state.sessions.get_mut(session_id) {
if let Some(congestion_controller) = session.congestion_controller.as_mut() {
congestion_controller.loss_control(&element, stats, &mut session.encoders);
congestion_controller.loss_control(element, stats, &mut session.encoders);
}
session.stats = stats.to_owned();
}
@ -1843,7 +1843,7 @@ impl WebRTCSink {
/ (1. + (fec_percentage / 100.))
/ (session.encoders.len() as f64)) as i32;
if let Some(ref rtpxsend) = session.rtprtxsend.as_ref() {
if let Some(rtpxsend) = session.rtprtxsend.as_ref() {
rtpxsend.set_property("stuffing-kbps", (bitrate as f64 / 1000.) as i32);
}

View file

@ -1,7 +1,7 @@
/// The default protocol used by the signalling server
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, PartialEq)]
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct Peer {
pub id: String,
@ -9,7 +9,7 @@ pub struct Peer {
pub meta: Option<serde_json::Value>,
}
#[derive(Serialize, Deserialize, Debug, PartialEq)]
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq)]
#[serde(tag = "type")]
#[serde(rename_all = "camelCase")]
/// Messages sent from the server to peers
@ -75,7 +75,7 @@ pub struct StartSessionMessage {
pub peer_id: String,
}
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
#[serde(tag = "type")]
#[serde(rename_all = "camelCase")]
/// Conveys a SDP
@ -92,7 +92,7 @@ pub enum SdpMessage {
},
}
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
#[serde(rename_all = "camelCase")]
/// Contents of the peer message
pub enum PeerMessageInner {
@ -107,7 +107,7 @@ pub enum PeerMessageInner {
Sdp(SdpMessage),
}
#[derive(Serialize, Deserialize, Debug, PartialEq)]
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
/// Messages directly forwarded from one peer to another
pub struct PeerMessage {

View file

@ -291,11 +291,11 @@ impl Handler {
);
self.consumer_sessions
.entry(consumer_id.to_string())
.or_insert(HashSet::new())
.or_insert_with(HashSet::new)
.insert(session_id.clone());
self.producer_sessions
.entry(producer_id.to_string())
.or_insert(HashSet::new())
.or_insert_with(HashSet::new)
.insert(session_id.clone());
self.items.push_back((
consumer_id.to_string(),
@ -672,7 +672,7 @@ mod tests {
assert_eq!(
sent_message,
p::OutgoingMessage::EndSession(p::EndSessionMessage {
session_id: session_id
session_id
})
);
}
@ -723,7 +723,7 @@ mod tests {
assert_eq!(
sent_message,
p::OutgoingMessage::EndSession(p::EndSessionMessage {
session_id: session_id
session_id
})
);
}