Call Live555 receive RTSP live stream, convert to HTTP Live streaming (iOS live) protocol

Source: Internet
Author: User
Live555 receive RTSP live stream, convert HTTP Live streaming (iOS live) protocol

The RTSP protocol is also a widely used live/on-demand streaming protocol that previously implemented a program that received the RTSP protocol via live555 and then converted it to the HLS (Http live streaming) live protocol file. In order to receive the remote device or the server's multi-channel RTSP live data, real-time conversion to the HLS protocol file, to enable the iphone or ipad and other devices to watch the RTSP live source needs. Now share the idea of implementation as follows.

Essentials Analysis

First, the main purpose of the program is to extract the AAC encoded audio and the H . Encode video data from the multi-channel RTSP input source and generate Http Live streaming supports the mpeg-ts format fragment file and the corresponding m3u8 file. Therefore, the key points of this program are the following parts:

    1. Read the RTSP live stream
    2. analysis and processing of coded data for H. A and AAC
    3. Mpeg-ts Packaging and HLS segmentation generation Strategy
    4. m3u8 Index File

With the key points, you can analyze one item at a point.

Design Ideas

Based on the above analysis, the first choice is to read the RTSP broadcast protocol. We do not need to start from scratch, there are many on the network and RTSP related open source projects can use or learn from, I chose Live555.

LIVE555 is a cross-platform streaming media solution that primarily supports the RTSP protocol and seems to support SIP (this is also the focus of my immediate research, and will then write articles on SIP-related technology implementations). LIVE555 implements the entire structure of RTSP including the server-client, and is a well-known open source project. There are a lot of articles on the internet about Live555 learning and using, I don't specifically introduce.

The analysis and processing of the data of H. S and AAC, this is a difficult point for the people who have never done the related project development, it is mainly the understanding of related concepts. Fortunately I have been doing this piece, but also better to get.

3rd and 4th, you can refer to my previous article "Http Live streaming Live (iOS live) technical analysis and implementation" of the technical method to be implemented. Therefore, the main need to deal with is the acquisition of RTSP live stream data, as well as the processing of the data of H. S and AAC encoding.

So the general structure can be drawn as follows:

Logic and implementation1. Program Framework and Module description 2. Rtspcapture's interface

Rtspcapture is my program in the management of the RTSP live streaming data stream and analysis processing classes, interface is very important, basically this design can. (Of course, all the code will not be put up, interested can talk to me, here is only the key points.) )

The live555 variable that he uses, here ourrtspclient is actually the simple inheritance of rtspclient

3.RtspCapture calling live555 's main process

1. First, in the Rtspcapture constructor initialization

2. In the STARTRTSP function, create the rtspclient and send the "describe" command to begin acquiring the SDP. The callback function is continueafterdescribe. Create Mediasession here, then send the "Setup" command, and so on, which can be seen in the example of live555 and the instructions on the web.

3. Another key point is to invoke the LIVE555 environment event loop in its own thread loop, just like this

4. Analysis and processing of RTSP callback H264 data

Here is a demonstration of how to extract SPS and PPS information from the H264 data of RTSP callbacks. The parse function inside of the live555 is self-contained.

Program Effects

Program interface, very simple.

The configuration file is configured as follows:

Open RTSP Server, you can use VLC to stream files as RTSP server test

Show on iphone

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

haibindev.cnblogs.com, please contact QQ for cooperation. (reprint please indicate author and source ~)

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Call Live555 receive RTSP live stream, convert to HTTP Live streaming (iOS live) protocol

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.