From db410f2f1946fa34327fa0ae2b9364a47717e9fc Mon Sep 17 00:00:00 2001 From: Matthew Jackson Date: Wed, 13 May 2026 20:30:01 -0700 Subject: [PATCH] mux: Rust 1.86 compat + fmt - m2ts_mux: replace u64::is_multiple_of (stable in 1.87+) with %. CI on the pinned 1.86 toolchain rejected the unstable feature use. - mux/{fmp4,hevc,m2ts_mux}: rustfmt drift cleanup (test-code wrapping). --- src/mux/fmp4/mod.rs | 3 ++- src/mux/hevc/mod.rs | 6 +++++- src/mux/m2ts_mux/mod.rs | 19 ++++++++++++++----- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/mux/fmp4/mod.rs b/src/mux/fmp4/mod.rs index a6f398a..4aac3fa 100644 --- a/src/mux/fmp4/mod.rs +++ b/src/mux/fmp4/mod.rs @@ -356,7 +356,8 @@ mod tests { let mut sink: Vec = Vec::new(); let mut mux = Fmp4Mux::new(&mut sink); // Trigger init emission via a single (stubbed) write. - mux.write_video(0, true, &[0x00, 0x00, 0x00, 0x01, 0x40]).unwrap(); + mux.write_video(0, true, &[0x00, 0x00, 0x00, 0x01, 0x40]) + .unwrap(); mux.finish().unwrap(); drop(mux); diff --git a/src/mux/hevc/mod.rs b/src/mux/hevc/mod.rs index 21e646c..41aba01 100644 --- a/src/mux/hevc/mod.rs +++ b/src/mux/hevc/mod.rs @@ -222,7 +222,11 @@ mod tests { // we can spot in the output. let mut hvcc = vec![0u8; 22]; hvcc.push(3); // numOfArrays - for (nal_type, payload) in [(32u8, [0x40, 0x01, 0x0C, 0x01]), (33, [0x42, 0x01, 0x01, 0x01]), (34, [0x44, 0x01, 0xC1, 0x72])] { + for (nal_type, payload) in [ + (32u8, [0x40, 0x01, 0x0C, 0x01]), + (33, [0x42, 0x01, 0x01, 0x01]), + (34, [0x44, 0x01, 0xC1, 0x72]), + ] { hvcc.push(nal_type & 0x3F); hvcc.extend_from_slice(&1u16.to_be_bytes()); // numNalus hvcc.extend_from_slice(&(payload.len() as u16).to_be_bytes()); diff --git a/src/mux/m2ts_mux/mod.rs b/src/mux/m2ts_mux/mod.rs index 8f96e82..2623bee 100644 --- a/src/mux/m2ts_mux/mod.rs +++ b/src/mux/m2ts_mux/mod.rs @@ -247,7 +247,8 @@ impl M2tsMux { let attach_pcr = first && (pid == PID_VIDEO) && (pcr.is_some()) - && (self.packets_written == 0 || self.video_packets_since_pcr >= PCR_INTERVAL_PACKETS); + && (self.packets_written == 0 + || self.video_packets_since_pcr >= PCR_INTERVAL_PACKETS); let af_body: Vec = if attach_pcr { build_pcr_adaptation(pcr.unwrap_or(0)) @@ -317,7 +318,7 @@ impl M2tsMux { } fn maybe_emit_psi(&mut self) -> io::Result<()> { - if self.packets_written == 0 || self.packets_written.is_multiple_of(PSI_INTERVAL_PACKETS) { + if self.packets_written == 0 || self.packets_written % PSI_INTERVAL_PACKETS == 0 { self.emit_pat()?; self.emit_pmt()?; } @@ -547,7 +548,12 @@ mod tests { /// All emitted bytes must align to 188-byte packet boundaries and /// every packet must start with `0x47`. fn assert_ts_well_formed(buf: &[u8]) { - assert_eq!(buf.len() % 188, 0, "stream not packet-aligned: {} bytes", buf.len()); + assert_eq!( + buf.len() % 188, + 0, + "stream not packet-aligned: {} bytes", + buf.len() + ); for (i, chunk) in buf.chunks(188).enumerate() { assert_eq!(chunk[0], 0x47, "packet {} missing sync byte", i); } @@ -567,7 +573,9 @@ mod tests { // than hardcoding sample bytes, verify the underlying algorithm // by checking that two distinct inputs produce distinct CRCs // and that the same input is deterministic. - let a = [0u8, 0xB0, 0x0D, 0x00, 0x01, 0xC1, 0x00, 0x00, 0x00, 0x01, 0xE1, 0x00]; + let a = [ + 0u8, 0xB0, 0x0D, 0x00, 0x01, 0xC1, 0x00, 0x00, 0x00, 0x01, 0xE1, 0x00, + ]; let mut b = a; b[5] ^= 0x01; // flip one bit let crc_a = mpegts_crc32(&a); @@ -612,7 +620,8 @@ mod tests { frame.extend_from_slice(&3u32.to_be_bytes()); frame.extend_from_slice(&[0x40, 0x01, 0x0C]); mux.write_video(0, &frame).unwrap(); - mux.write_audio(20_000_000, &[0x0B, 0x77, 0x12, 0x34]).unwrap(); + mux.write_audio(20_000_000, &[0x0B, 0x77, 0x12, 0x34]) + .unwrap(); mux.finish().unwrap(); drop(mux);