In the blog "Easyipcamera high-performance camera RTSP server Rtspserver solution" I introduced a live555 implementation of a set of rtspserver function components, when the developer after several months of debugging, has been the bottom of the performance debugging to a very good degree of the industry, the main optimization of several: send optimal scheduling optimization
Send optimization, the main is to adjust the buffer size of the live555 and the size of the data sent each time, as we all know, streaming media is sent to the various sizes of audio and video data, and these data large hundreds of K, small on a few bytes, if each of the scattered data to go over the send cycle, For live555 This single-threaded architecture, the performance is tight, so we made a few adjustments:
Increase Send packet size
MultiFramedRTPSink.cpp
47 lines:
setpacketsizes (1000, 8192);
RTPInterface.cpp
129 lines:
Increasesendbufferto (EnviR (), Fgs->socketnum (), 512*1024);
Data cumulative send, no longer send
//comment out 332 lines separately, modified to the following:
//if (!senddataovertcp (Socketnum, Framingheader, 4, False)) break;
if (!SENDDATAOVERTCP (socketnum, packet, PacketSize, True)) break;
struct Iovec iov[2];
Iov[0].iov_base = Framingheader;
Iov[0].iov_len = 4;
Iov[1].iov_base = packet;
Iov[1].iov_len = packetsize;
Writev (Socketnum, Iov, 2);
Optimization in the scheduling aspect
402 line//Current data buffer if not sent to complete, continue to send, no longer go through the live555 eventloop process, improve efficiency. #if 0//We have more frames left to send. Figure out as the next frame/is due to start playing, then make sure "we wait" long before//sending
The next packet.
struct Timeval timenow;
Gettimeofday (&timenow, NULL);
int secsdiff = fnextsendtime.tv_sec-timenow.tv_sec;
int64_t Usecondstogo = secsdiff*1000000 + (fnextsendtime.tv_usec-timenow.tv_usec); if (Usecondstogo < 0 | | Secsdiff < 0) {//Sanity check:make sure this time-to-delay is Non-negative:use
Condstogo = 0;
} if (Usecondstogo > 0) printf ("Usecondstogo:%d\n", Usecondstogo); Delay This amount of time:nexttask () = EnviR (). TaskScheduler (). Scheduledelayedtask (Usecondstogo, (taskfunc*) sendne
XT, this);
#else Sendnext (this); #endif
Such a few changes, greatly enhance the live555 in the network data delivery performance, so that in HiSilicon 3516A such a board, high-definition video can be upgraded to 4 4M high-definition video transmission, and very stable (of course, the network must ensure that most of the WiFi test will not be able to this effect). about Easyipcamera
Easyipcamera is a set of RTSP server components that are very stable, easy-to-use, and support multiple platforms (including Windows/linux 32&64,android,arm hisiv100/hisiv200/hisiv400 platforms). Applicable to Ipcamera, intranet RTSP service, such as small RTSP streaming media server, interface call is very simple and mature, do not need to pay attention to the rtspserver of client listening access, audio and video multiplexing, RTSP specific flow, RTP packaging and sending and other related issues, supporting a variety of audio and video formats , it is no longer necessary to deal with the complex process of the entire RTSP options/describe/setup/play/rtp/rtcp and worry about memory release, as you would call live555 Rtspserver. Get more information
Mail: support@easydarwin.org
WEB:www.EasyDarwin.org
Copyright©easydarwin.org 2012-2017