TS: Increment PMT version when codecs change for strict demuxers. v8.0.30 - #4731
Merged
Conversation
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
force-pushed
the
fix/http-ts-pmt-version
branch
from
August 26, 2026 15:28
5c7b5ff to
ecc5d33
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix HTTP-TS playback with strict MPEG-TS demuxers, such as MobileVLCKit/libVLC on iOS, by incrementing the PMT
version_numberwhenever SRS refreshes the PMT after a codec-set change.Problem
For HTTP-TS, SRS may start with unknown audio/video codecs when
guess_has_avis 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 PID0x101.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 PID257 / 0x101was 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, whileSrsTsContext::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.