mpegtslivesrc: Handle zero-byte adaption fields

Simply skip over them instead of handling them as parse error.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/2048>
This commit is contained in:
Sebastian Dröge 2025-01-21 14:22:47 +02:00 committed by Backport Bot
parent 0b0c1cbf50
commit b70ad7895f

View file

@ -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::<AdaptionField>().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::<AdaptionField>().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"
);
}
}
}
}