一般的HLS 码流没有ID3 tag,都是0x47 开头的标准TS流, Nuplayer 会检查标准TS流,如果不是TS 流,才会走到检查ID3 tag。
一般 TS码流的同步头有问题才会走到ID3 tag检查。
http live stream 协议中,定义了audio packet 必现带有ID3 tag,并且必现带有私有的“com.apple.streaming.transportStreamTimestamp”标识符,紧跟着 真正的时间戳。
Nuplayer 中的PlaylistFetcher 中实现这块代码, ffmpeg 中的hls.c 也实现了同样的代码。
协议定义:https://tools.ietf.org/html/draft-pantos-http-live-streaming-23
3.4. Packed Audio
A Packed Audio Segment contains encoded audio samples and ID3 tags that are simply packed together with minimal framing and no per- sample timestamps. Supported Packed Audio formats are AAC with ADTS framing [ISO_13818_7]; MP3 [ISO_13818_3]; AC-3 [AC_3]; and Enhanced AC-3 [AC_3]. A Packed Audio Segment has no Media Initialization Section. Each Packed Audio Segment MUST signal the timestamp of its first sample with an ID3 PRIV tag [ID3] at the beginning of the segment. The ID3 PRIV owner identifier MUST be "com.apple.streaming.transportStreamTimestamp". The ID3 payload MUST be a 33-bit MPEG-2 Program Elementary Stream timestamp expressed as a big-endian eight-octet number, with the upper 31 bits set to zero. Clients SHOULD NOT play Packed Audio Segments without this ID3 tag.