As early as 2014 through the WebRTC realized the PC client real-time video voice, then the establishment of peer-to WEBRTC with the Libjingle library, using the Peerconnection API implementation. Later in the Remote Desktop, file transfer requires point-to-point connection, the Libjingle library for a period of time, found a few problems:
The 1.libjingle library is built using the XMPP protocol, but our clients do not support the XMPP protocol;
2.libjingle Library is huge, making rewriting difficult.
3. Stability issues.
Then, based on the UDT library to achieve a set of peer-to transfer library, use is also very convenient as long as the two sides agreed to the name of the simultaneous connection to the server can be a successful hole, and later use this library to replace the WEBRTC Libjingle library for transmission.
The implementation details are as follows:
Using WebRTC's voice_engine and video_engine to achieve video voice (because the Voice_engine and Video_engine APIs are simple and easy to maintain), the docking section is as follows:
1 classWebrtc_dllexport voenetwork2 {3 Public:4 //Factory for the voenetwork Sub-api. Increases an internal5 //Reference counter if successful. Returns NULL If the API is not6 //supported or if construction fails.7 Staticvoenetwork* GetInterface (voiceengine*voiceengine);8 9 //releases the Voenetwork Sub-api and decreases an internalTen //reference counter. Returns the new reference count. This value should One //Be zero for all sub-api:s before the Voiceengine object can be safely A //deleted. - Virtual intRelease () =0; - the //installs and enables a user-defined external transport protocol for a - //specified |channel|. - Virtual intRegisterexternaltransport ( - intChannel, transport& Transport) =0; + - //removes and disables a user-defined external transport protocol for a + //specified |channel|. A Virtual intDeregisterexternaltransport (intChannel) =0; at - //The packets received from the network should is passed to this - //function When external transport is enabled. Note that the data - //including the Rtp-header must also is given to the voiceengine. - Virtual intReceivedrtppacket ( - intChannelConst void* Data, unsignedintLength) =0; in - //The packets received from the network should is passed to this to //function When external transport is enabled. Note that the data + //including the Rtcp-header must also is given to the voiceengine. - Virtual intReceivedrtcppacket ( the intChannelConst void* Data, unsignedintLength) =0; * $ protected:Panax Notoginseng voenetwork () {} - Virtual~voenetwork () {} the};
Implement the interface of the transport class sendpacket,sendrtcppacket to send RTP and RTCP packets, call Voenetwork::registerexternaltransport () to register to Voice_ Engine, and then the received packets to voenetwork::receivedrtppacket and Voenetwork::receivedrtcppacket to deal with, the video is similar processing.
The road of WebRTC audio and video development