当前位置:网站首页>A guide to P2P network penetration (stun) for metartc5.0 programming
A guide to P2P network penetration (stun) for metartc5.0 programming
2022-06-28 05:01:00 【metaRTC】
summary
In order to save server bandwidth during audio and video communication , The best communication efficiency is p2p, But in real application scenarios , Our clients are all inside the large LAN ,stun The protocol is to solve how to penetrate these LAN implementations p2p.
metaRTC5.0 Latest version support stun, send p2p Use network penetration technology to realize communication on the Internet .
Download the source code
https://github.com/metartc/metaRTC/releases/tag/5.0.022
https://github.com/metartc/metaRTC/releases/tag/5.0.022https://gitee.com/metartc/metaRTC/releases/5.0.022
https://gitee.com/metartc/metaRTC/releases/5.0.022

metaRTC5.0 Programming
metaRTC5.0 p2p stun There are two modes of programming :
- websockt+stun
- http+frpc(ngrok)+stun
Configuration parameters
Code configuration parameters
strcpy(m_context->avinfo.rtc.iceServerIP,"182.92.163.143"); //stun Server address
m_context->avinfo.rtc.iceStunPort=3478; //stun Server port
m_context->avinfo.rtc.hasIceServer=1; //1: Enable stun 0: close stunOr in the configuration file yang_config.ini Middle configuration
[rtc]
hasIceServer=1
usingDatachannel=1
iceStunPort=3478
iceServerIP=182.92.163.143
audioQueueCount=5
vidoeQueueCount=5Model a (websockt+stun)
Code in libmetartc5/src/yangp2p/YangP2pRtcIce.cpp in
// Initiate a connection to the opposite end
int32_t YangP2pRtcIce::connectPeer(int32_t nettype, string server,int32_t localPort,int32_t pport,string app,string stream) {
int32_t ret = 0;
YangPeerConnection* sh=(YangPeerConnection*)calloc(sizeof(YangPeerConnection),1);
.... Configuration parameters .....
// initialization YangPeerConnection
yang_create_peerConnection(sh);
sh->init(&sh->peer);
char* localSdp; // Local sdp
char* remoteSdp=(char*)calloc(12*1000,1); // Opposite end sdp
// towards stun Server send stun request Get the Internet address and port
if(m_context->avinfo.rtc.hasIceServer){
if(sh->requestStunServer(&sh->peer)!=Yang_Ok) yang_error("request stun server fail!");
}
// Get local end sdp
sh->createOffer(&sh->peer, &localSdp);
take sdp It is transmitted to the opposite end through signaling service
// Get the opposite end sdp after , start-up metartc
ret=sh->setRemoteDescription(&sh->peer,remoteSdp);
}// Get the opposite end sdp after , call sh->createAnswer(&sh->peer,answer);
// obtain answer after , It is transmitted to the opposite end through signaling service
int32_t YangP2pRtcIce::addPeer(char* remotesdp,char* answer,char* remoteIp,int32_t localPort,int* phasplay) {
Configuration parameters ...
// initialization YangPeerConnection
yang_create_peerConnection(sh);
sh->init(&sh->peer);
// towards stun Server send stun request Get the Internet address and port
if(m_context->avinfo.rtc.hasIceServer){
if(sh->requestStunServer(&sh->peer)!=Yang_Ok) yang_error("request stun server fail!");
}
// obtain answer Sdp
ret = sh->createAnswer(&sh->peer,answer);
.... obtain answer after , It is transmitted to the opposite end through signaling service
// Get the opposite end sdp after , start-up metartc
ret = sh->setRemoteDescription(&sh->peer,remotesdp);
.....
}Model 2 (http+frpc(ngrok)+stun)
In the original metap2p5 Of demo Modify... In code , Modify file libmetartc5/src/yangp2p/YangP2pRtc.cpp

adopt frpc(ngrok) Isomorphism http, Use the browser or client to directly access the Internet mapping address , The operating mode remains the same as the original mode .
边栏推荐
- openssl客户端编程:一个不起眼的函数导致的SSL会话失败问题
- 创新之源 理解通透 二
- JS 文本框失去焦点修改全半角文字和符号
- 使用class toplevel的messagebox时,窗口弹出问题。
- 开关电源电压型与电流型控制
- 氨基染料研究:Lumiprobe FAM 胺,6-异构体
- BioVendor sRAGE抗体解决方案
- [microservices openfeign] openfeign quick start service invocation based on feign
- Huawei's 9-year experience as a software testing director
- Distributed transaction - Final consistency scheme based on message compensation (local message table, message queue)
猜你喜欢

2022年最新辽宁建筑八大员(标准员)考试试题及答案

Light collector, Yunnan Baiyao!

2022高处安装、维护、拆除考试题及答案

交流电和直流电的区别是什么?

短视频本地生活版块成为热门,如何把握新的风口机遇?

Learning Tai Chi Maker - mqtt Chapter II (VI) mqtt wills

Severe tire damage: the first rock band in the world to broadcast live on the Internet

Operation of simulated examination platform of G3 boiler water treatment recurrent training question bank in 2022

Excel将一行的内容进行复制时,列与列之间是用制表符“\t”进行分隔的

Google Earth engine (GEE) - global flood database V1 (2000-2018)
随机推荐
2022西式面点师(高级)考试试题模拟考试平台操作
灵活的IP网络测试工具——— X-Launch
店铺进销存管理系统源码
2022年安全员-A证考试题库及模拟考试
Audio and video technology development weekly
C语言中函数是什么?编程中的函数与数学中的函数区别?理解编程语言中的函数
现代交换原理MOOC部分题目整理
整理网上蛋糕商城项目
Unity out ref params
分享一个因子挖掘的利器:遗传规划
Sword finger offer 53 - I. find the number I in the sorted array (improved bisection)
Differences between pragma and ifndef
Generate QR code in wechat applet
如何从零设计一款牛逼的高并发架构(建议收藏)
Operation of simulated examination platform of G3 boiler water treatment recurrent training question bank in 2022
Google Earth Engine(GEE)——全球洪水数据库 v1 (2000-2018年)
Cgo+gsoap+onvif learning summary: 8. Summary of arm platform cross compilation operation and common problems
The short video local life section has become popular. How to grasp the new opportunities?
Opencv实现颜色检测
Notepad++ -- column editing mode -- Usage / instance