iOS开发之使用pjsip开发VoIP应用程序

转自:http://www.wuleilei.com/blog/327

最近项目中要用到VoIP,VoIP全称Voice over Internet Protocol,即网络电话,生活中经常用到,例如Skype。

能用到iPhone上面的VoIP库不多,最开始准备使用Lipphone,但其编译实在太慢,编译了N次也没有成功,最后放弃啦。后来尝试使用pjsip,居然成功了,简单的记录一下过程,其实是照着官网操作的:)

一、环境需求:

iPhone应用推荐使用SDK 4.x,当然3.x也支持;iPad应用只支持SDK 3.2以上。

二、编译之前的准备工作:

1、下载pjsip源代码

2、在目录/pjsip/pjlib/include/pj/中新建config_site.h,粘贴如下代码入内:

1
2
#define PJ_CONFIG_IPHONE 1
#<a href= "http://www.wuleilei.com/blog/327" > include </a> <pj/config_site_sample.h>

三、编译pjsip:

在终端中运行如下命令:

1
2
3
$ cd /path/to/your/pjsip/
$ ./configure-iphone
$ <a href= "http://www.wuleilei.com/blog/327" >make</a> dep && make clean && make

四、给模拟器编译pjsip库:

在终端中运行如下命令:

1
2
3
4
export DEVPATH=/Developer/Platforms/iPhoneSimulator.platform/Developer
export CC=/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc- 4.0
CFLAGS= "-O2 -m32 -miphoneos-version-min=4.0"  LDFLAGS= "-O2 -m32"  ./configure-iphone
make dep && make <a href= "http://www.wuleilei.com/blog/327" >clean</a> && make

五、编译sample:

编译目录pjproject/pjsip-apps/src/ipjsua中的项目,如果上面的步骤都成功了,这是你就可以看到app的主界面了。

六、测试通话:

1、搭建VoIP服务器:

网上有很多免费的SIP服务器,我使用的是MiniSipServer免费版,安装很简单,按界面提示一路下一步就OK了。安装完后别忘记了新建账户(这里以100和101为例)。

2、安装VoIP客户端:

这个也很多,我使用的是3CX Phone Client。登录账户100.

3、在iPhone的pjsip界面中登录账户101:

1
2
3
4
5
6
+a
Your SIP URL: (empty to cancel): sip: 101 @ 192.168 . 1.1
URL of the registrar: (empty to cancel): sip: 192.168 . 1.1
Auth Realm: (empty to cancel): *
<a href= "http://www.wuleilei.com/blog/327" >Auth</a> Username: (empty to cancel): 101
Auth Password: (empty to cancel): 123456

和100打电话:

1
2
3
4
+b
Enter buddy's URI: (empty to cancel): sip: 100 @ 192.168 . 1.1
m
Make call: 1

打电话操作还可以简化:

1
2
m
Make call: <a href= "http://www.wuleilei.com/blog/327" >sip</a>:sip: 100 @ 192.168 . 1.1

好了,完成了

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值