Hls protocol implementation

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.