Skip to content

TS: Increment PMT version when codecs change for strict demuxers. v8.0.30 - #4731

Merged
winlinvip merged 3 commits into
ossrs:developfrom
suzp1984:fix/http-ts-pmt-version
Aug 26, 2026
Merged

TS: Increment PMT version when codecs change for strict demuxers. v8.0.30#4731
winlinvip merged 3 commits into
ossrs:developfrom
suzp1984:fix/http-ts-pmt-version

Conversation

@suzp1984

@suzp1984 suzp1984 commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Fix HTTP-TS playback with strict MPEG-TS demuxers, such as MobileVLCKit/libVLC on iOS, by incrementing the PMT version_number whenever SRS refreshes the PMT after a codec-set change.

Problem

For HTTP-TS, SRS may start with unknown audio/video codecs when guess_has_av is enabled. If the first media packet is video, SRS emits an initial PMT that describes only the video PID. When AAC audio is discovered later, SRS emits another PMT that adds the AAC PID 0x101.

Before this fix, every PMT used version_number = 0. Strict demuxers can treat a same-version PMT as unchanged, ignore the refreshed PMT, and then drop AAC packets because PID 257 / 0x101 was never registered. The visible symptom is video playback without audio for HTTP-TS on iOS libVLC.

Root cause

SrsTsPacket::create_pmt() hardcoded the PMT version to zero, while SrsTsContext::encode() already refreshes PAT/PMT when the codec set changes. The PMT content changes, but the PMT version does not, so strict receivers may reject the update.

The PMT was always written with version_number=0. On HTTP-TS, when AAC
audio appears after the initial video-only PMT, strict demuxers such as
libVLC ignored the re-announced PMT (same version) and reported "Audio
packets for PID 257 arrive but have no PMT entry", dropping the audio.

Bump the PMT version_number modulo 32 each time encode_pat_pmt() is
invoked due to a codec change, as required by ISO/IEC 13818-1 2.6.4. The
PAT is left unchanged because its program-to-PMT-PID mapping never
changes, and the version resets to 0 on SrsTsContext::reset() so each
HLS segment starts fresh.

Add KernelTSTest.PmtVersionIncrementsOnCodecChange which drives the
real HTTP-TS codec-discovery ordering and asserts the on-wire PMT
versions are [0, 1], and [0] after reset.

Co-Authored-By: Claude <noreply@anthropic.com>
Update SRS 8.0 revision to v8.0.29 in both C++ and Go version files, and add the changelog entry for PR ossrs#4731.

---------

Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
@winlinvip winlinvip changed the title TS: Increment PMT version when codecs change for strict demuxers. TS: Increment PMT version when codecs change for strict demuxers. v8.0.29 Aug 26, 2026
@winlinvip winlinvip changed the title TS: Increment PMT version when codecs change for strict demuxers. v8.0.29 TS: Increment PMT version when codecs change for strict demuxers. v8.0.30 Aug 26, 2026
@winlinvip
winlinvip force-pushed the fix/http-ts-pmt-version branch from 5c7b5ff to ecc5d33 Compare August 26, 2026 15:28
@winlinvip
winlinvip merged commit b0d775a into ossrs:develop Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants