zoukankan      html  css  js  c++  java
  • 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

    这时,听到电话响声的你是不是感到很兴奋呢!

  • 相关阅读:
    文件操作相关utils
    读取excel工具utils
    下载EXCEL文件Utils
    日期操作utils
    常用的utils
    坐标系转换Utils
    C# vs2019 CS0006 编译器错误CS1704
    C# 控制台形式 owin 添加WebApi 和Swagger
    Windows 下 Redis服务自动停止 处理
    Dotfuscator 混淆C# .Net代码 netcore
  • 原文地址:https://www.cnblogs.com/Rmeo/p/4157145.html
Copyright © 2011-2022 走看看