Jrtplib + P2P experiment results

Source: Internet
Author: User

I have already written P2P video transmission, but all of them are handwritten.CodeIn some cases, the Code is not standardized. I heard that jrtplib is well written, and I have analyzed it clearly some time ago. I will take it for testing today.

Jrtplib3.7.1 has two main tasks:

First, the data to be sent and received must be split and reorganized. I began to collect two-way linked lists. Later I found that the processing was not good enough and the memory was always wrong (I haven't studied the data structure for a long time ). Later, the allocation buffer was used directly. When sending data, the offset was indicated. the received data was directly filled with offset, which was very simple. Of course, check whether there are repeated data during receiving. The Code has time to be sorted and uploaded.

The second is to inherit the rtpsession and write a response class, which is received and sent here.

Then, write a dialog boxProgramUse DirectShow to call the camera, capture data in samplegrabber mode, and press libavcodec to 264. Use directsound to collect sound and use speex to compress the data. First in the Intranet test, two PCs (or virtual machines), directly to the other side of the IP address and port pronunciation video, after receiving decoding, the effect is very good.

So far, jprtlib has performed very well, and the code quality is also very good.

However, there is a problem in the next step. I use jrtplib to write the server to help the two sides make holes. The strange thing is that the client and server only send a few command words, and both sides are quite slow in response. I looked at the jrtplib code and modified the buffer that the socket received and sent. The time is limited. It is estimated that the efficiency is affected by the coordination between RTP and RTCP.

To sum up, it is ideal to use jrtplib to transmit audio and video media data. However, if you use it for server processing commands, the efficiency is definitely not good (of course, modifying its source code can also solve the problem ).

There are also workarounds: you can write a simple and reliable UDP dedicated for command communication, use it to get the IP address and port of the other party, and then send it to jrtplib, then jrtplib can send data to this IP port.

However, it is better to refer to the jrtplib source code to encapsulate a better UDP transmission library.

Transmission of audio and video, because of the large amount of data, basically no re-transmission is required, as long as the packet loss control and synchronization are done, so jrtplib is not required.

The main problem with jrtplib is restructuring.

ReorganizationAlgorithmIt is attached with the test code, but it is also stable.

 

More TechnologiesArticleSee Shi Changquan's personal website: http://www.joyvc.cn

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.