diff --git a/net/mpegtslive/src/mpegtslive/imp.rs b/net/mpegtslive/src/mpegtslive/imp.rs index b5824af61..95395ab34 100644 --- a/net/mpegtslive/src/mpegtslive/imp.rs +++ b/net/mpegtslive/src/mpegtslive/imp.rs @@ -524,21 +524,24 @@ impl State { let af = &af[..length]; reader.skip(8 * length as u32).context("af")?; - // Parse adaption field and update PCR if it's the PID of our selected program - if self.pmt.as_ref().map(|pmt| pmt.pcr_pid) == Some(header.pid) { - let mut af_reader = BitReader::endian(af, BigEndian); - let adaptation_field = af_reader.parse::().context("af")?; + // Zero-byte adaption field is valid and can be just skipped over. + if !af.is_empty() { + // Parse adaption field and update PCR if it's the PID of our selected program + if self.pmt.as_ref().map(|pmt| pmt.pcr_pid) == Some(header.pid) { + let mut af_reader = BitReader::endian(af, BigEndian); + let adaptation_field = af_reader.parse::().context("af")?; - // PCR present - if let Some(pcr) = adaptation_field.pcr { - if let Some(monotonic_time) = monotonic_time { - self.store_observation(imp, pcr, monotonic_time); - } else { - gst::warning!( - CAT, - imp = imp, - "Can't handle PCR without packet capture time" - ); + // PCR present + if let Some(pcr) = adaptation_field.pcr { + if let Some(monotonic_time) = monotonic_time { + self.store_observation(imp, pcr, monotonic_time); + } else { + gst::warning!( + CAT, + imp = imp, + "Can't handle PCR without packet capture time" + ); + } } } }