Realization of Rtspserver and high-Gao-qing bitrate video transmission optimization based on Live555

Source: Internet
Author: User
Realization of Rtspserver and high-Gao-qing bitrate video transmission optimization based on Live555

Recently, some of the RTSP server projects for PC and embedded platforms have been made, most of which are simple but fully functional and have a strong performance. After comprehensive consideration, the basic is on the basis of live555 based on the development, in the optimization of the Live555 itself and the program internal video data transmission optimization, not only to achieve the demand and performance exceeded expectations, to achieve the 8mbps~ 10Mbps High-Bitrate 1080p HD video for smooth streaming . Here are some optimization points to share:

Why based on Live555 development

In fact, I have developed a RTSP server program, and wrote an article about "a rtspserver design and implementation and RTSP2.0 Introduction", but the purpose of the development in addition to the implementation of RTSP broadcast, the main purpose is to simplify the code to facilitate customization, As a result, all the details of the interaction in the RTSP protocol are not fully implemented, and it is possible to delay the progress of the project on the basis of its overall expansion. Based on project considerations, we have chosen to develop the RTSP server program based on the Live555 of the RTSP Open source project, which is also considered to be relatively excellent.

LIVE555 is a cross-platform streaming media solution, in C + + for the development of language, the implementation of RTSP including the server-client's entire structure, and support H. S, h.265, MPEG, AAC and other video and audio coding, is a well-known open source project. As the RTSP Server, the source code only for the local file of the video source, but it is strong extensibility, can be provided by Live555 some base classes based on the development of the service program for their own project needs.

Core modules for Live555 architecture and RTSP data Flow Live555

The interactive process between RTSP server and client

Live555 Streaming Media module and service-side processing flow

LIVE555 's streaming module is basically divided into two parts: source and sink, and of course they have a common base class medium. For the server, source is the data source, sink is the data output, the video data is passed through MediaSource to Mediasink, and finally transmitted to the client through the Rtpinterface network. The modules and inheritance relationships used for the server:

As indicated, through the completion of their own servermediasubsession and mediasource to achieve the need for live broadcast of the H-coded data to live555, in order to achieve the RTSP live.

Optimization point of high bitrate video data transmission

For high-quality video footage, each frame of video data will be relatively large, this value will tend to exceed the live555 internal default memory processing size, because the optimization of live555, mainly focus on the expansion of memory buffer size, and avoid the memory data copy. The following are the effective optimization points that are summarized based on actual development and testing:

    1. The extended frame resolves the buffer size, which is bank_size, and the default value is 150k, which is set to 300k at least according to the H264 data frame size transferred. Otherwise out of size, may be discarded by Live555.
    2. Increase the size of the outpacketbuffer::maxsize, also to accommodate jumbo frame data, which may result in data loss.
    3. In Rtpinterface, increase the size of the socket send buffer, which is the parameter value of the Increasesendbufferto function
    4. For Multiframedrtpsink::sendpacketifnecessary, you can call Sendnext directly to try to build RTP packets to send packets, so the advantage of this modification is that the data that has been read is sent out as soon as possible, but it also takes up a bit of thread time.
    5. When an application passes data from its own thread to Live555, it should minimize the memory copy, preferably through a memory pool, to avoid copying memory blocking Live555 event loops

After the above modification, as well as the application internal code optimization, in the actual application, has realized the 8mbps~10mbps high bitrate 1080p HD video Smooth live broadcast.

Haibindev.cnblogs.com, please contact QQ for cooperation. (Please specify the author and source ~)

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.