目录
官方演示,太简单了,简单到看不懂:
https://www.pjsip.org/pjnath/docs/html/ice_demo_sample.htm
pisip提供了一个demo程序----icedemo
使用方法简单记录:
1.环境部署
在公网部署一个coturn服务器,记住它的ip和username、password
部署方法,参考上一篇文章的第五节
ubuntu20.04搭建janus服务器_zhuxian2009的博客-CSDN博客
2.下载pjsip源码
3.编译
按照README.txt的指示,很简单
$ ./configure
$ make dep && make clean && make
4.找到icedemo的位置
cd pjproject/pjsip-apps/bin/samples/x86_64-unknown-linux-gnu
5.执行icedemo,连接coturn服务器
此时需要coturn的信息了哈
./icedemo -s serverip -u abc -p 123456
10:29:16.386 os_core_unix.c !pjlib 2.12-dev for POSIX initialized
10:29:16.387 pjlib select() I/O Queue created (0x55bba0ad8828)
+----------------------------------------------------------------------+
| M E N U |
+---+------------------------------------------------------------------+
| c | create Create the instance |
| d | destroy Destroy the instance |
| i | init o|a Initialize ICE session as offerer or answerer |
| e | stop End/stop ICE session |
| s | show Display local ICE info |
| r | remote Input remote ICE info |
| b | start Begin ICE negotiation |
| x | send <compid> .. Send data to remote |
+---+------------------------------------------------------------------+
| h | help * Help! * |
| q | quit Quit |
+----------------------------------------------------------------------+
6.创建和配置
7.设置对端SDP
Local SDP (paste this to remote host):
--------------------------------------
v=0
o=- 3414953978 3414953978 IN IP4 localhost
s=ice
t=0 0
a=ice-ufrag:697045d7
a=ice-pwd:1e7b1c761c4e398f7def0983
m=audio 57855 RTP/AVP 0
c=IN IP4 113.89.216.208
a=candidate:Sc0a865af 1 UDP 1862270975 113.89.216.208 57855 typ srflx
a=candidate:Hc0a865af 1 UDP 1694498815 192.168.101.175 44495 typ host
![](https://img-blog.csdnimg.cn/69645eb2647a4974a25d91aa2bb172c6.png)
8.协商
9.相互发送数据