diff --git a/src/egress/recorder.rs b/src/egress/recorder.rs index 2482e37..24c32df 100644 --- a/src/egress/recorder.rs +++ b/src/egress/recorder.rs @@ -42,7 +42,7 @@ impl RecorderEgress { m }; Ok(Self { - id: id.clone(), + id: *id, muxer, var_map, }) diff --git a/src/ingress/mod.rs b/src/ingress/mod.rs index 1fe2861..4e665f0 100644 --- a/src/ingress/mod.rs +++ b/src/ingress/mod.rs @@ -63,8 +63,7 @@ pub fn spawn_pipeline( }, Err(e) => { error!("Failed to create PipelineRunner: {}", e); - return; } - }; + } }); } diff --git a/src/ingress/rtmp.rs b/src/ingress/rtmp.rs index 8297a2c..5449639 100644 --- a/src/ingress/rtmp.rs +++ b/src/ingress/rtmp.rs @@ -98,7 +98,7 @@ impl RtmpClient { } let mx = self.session.handle_input(&self.reader_buf[..r])?; - if mx.len() > 0 { + if !mx.is_empty() { self.msg_queue.extend(mx); self.process_msg_queue()?; } @@ -187,7 +187,7 @@ impl RtmpClient { impl Read for RtmpClient { fn read(&mut self, buf: &mut [u8]) -> std::io::Result { // block this thread until something comes into [media_buf] - while self.media_buf.len() == 0 { + while self.media_buf.is_empty() { if let Err(e) = self.read_data() { error!("Error reading data: {}", e); return Ok(0); @@ -216,7 +216,6 @@ pub async fn listen(out_dir: String, addr: String, overseer: Arc) .spawn(move || { if let Err(e) = cc.read_until_publish_request(Duration::from_secs(10)) { error!("{}", e); - return; } else { let pr = cc.published_stream.as_ref().unwrap(); let info = ConnectionInfo { diff --git a/src/ingress/test.rs b/src/ingress/test.rs index 469071f..da52eef 100644 --- a/src/ingress/test.rs +++ b/src/ingress/test.rs @@ -179,7 +179,7 @@ impl Read for TestPatternSrc { fn read(&mut self, buf: &mut [u8]) -> std::io::Result { unsafe { while self.reader.occupied_len() < buf.len() { - self.next_pkt().map_err(|e| std::io::Error::other(e))?; + self.next_pkt().map_err(std::io::Error::other)?; } } self.reader.read(buf) diff --git a/src/mux/hls.rs b/src/mux/hls.rs index 361de79..c48433c 100644 --- a/src/mux/hls.rs +++ b/src/mux/hls.rs @@ -121,15 +121,12 @@ impl HlsVariant { std::fs::create_dir_all(PathBuf::from(&first_seg).parent().unwrap())?; let mut opts = HashMap::new(); - match segment_type { - SegmentType::FMP4 => { - opts.insert("fflags".to_string(), "-autobsf".to_string()); - opts.insert( - "movflags".to_string(), - "+frag_custom+dash+delay_moov".to_string(), - ); - } - _ => {} + if let SegmentType::FMP4 = segment_type { + opts.insert("fflags".to_string(), "-autobsf".to_string()); + opts.insert( + "movflags".to_string(), + "+frag_custom+dash+delay_moov".to_string(), + ); }; let mut mux = unsafe { Muxer::builder() @@ -242,7 +239,7 @@ impl HlsVariant { av_free((*ctx).url as *mut _); let next_seg_url = - Self::map_segment_path(&*self.out_dir, &self.name, self.idx, self.segment_type); + Self::map_segment_path(&self.out_dir, &self.name, self.idx, self.segment_type); (*ctx).url = cstr!(next_seg_url.as_str()); let ret = avio_open(&mut (*ctx).pb, (*ctx).url, AVIO_FLAG_WRITE); @@ -276,7 +273,7 @@ impl HlsVariant { idx: prev_seg, duration, path: PathBuf::from(Self::map_segment_path( - &*self.out_dir, + &self.out_dir, &self.name, prev_seg, self.segment_type, @@ -300,7 +297,7 @@ impl HlsVariant { if self.segments.len() > MAX_SEGMENTS { let n_drain = self.segments.len() - MAX_SEGMENTS; - let seg_dir = PathBuf::from(self.out_dir()); + let seg_dir = self.out_dir(); for seg in self.segments.drain(..n_drain) { // delete file let seg_path = seg_dir.join(seg.filename()); diff --git a/src/pipeline/runner.rs b/src/pipeline/runner.rs index b7c5801..42a6da2 100644 --- a/src/pipeline/runner.rs +++ b/src/pipeline/runner.rs @@ -109,7 +109,7 @@ impl PipelineRunner { for (var, enc) in &mut self.encoders { for mut pkt in enc.encode_frame(ptr::null_mut())? { for eg in self.egress.iter_mut() { - eg.process_pkt(pkt, &var)?; + eg.process_pkt(pkt, var)?; } av_packet_free(&mut pkt); }