1. HLS Introduction
Hls, HTTP live streaming is a protocol defined by Apple for real-time stream transmission. HLS is implemented based on HTTP. The transmission content includes two parts: an m3u8 descriptive file, the second is ts media files.
1. m3u8 File
A media file is described in text and consists of a series of tags.
# Extm3u
# EXT-X-TARGETDURATION: 5
# Extinf: 5,
./0.ts
# Extinf: 5,
./1.ts
# Extm3u: the first line of each m3u8 file must be this tag.
# EXT-X-TARGETDURATION: specify the maximum length of media segments (seconds), # The length of time specified in extinf must be less than or equal to the maximum. This value can only appear once.
# Extinf: Describes the length of a single media file. Media files, such as./0.ts
2. Ts files
The file format defined by DVB is used for network transmission of audio and video. Audio and Video are intertwined by time stamp. The size of each data packet is 188 bytes.
Ii. Structure of the HLS implementation class
Chlsserver: Performs socket listening to manage clienthls requests.
Chlsclient: Implements HTTP Request Response and submits it to chlssource for Processing Based on the HLS content of the client request.
Chlssourcemanager: All HLS source managers. The HLS source can be local files or real-time data sources from networks or devices.
Chlssource: implements detailed HLS requests, including m3u8 file acquisition and TS fragment acquisition.
Iii. code snippets
------------------------------
QQ: 46687284. Welcome to exchange and cooperation.
Hls protocol implementation