iOS Linphone集成总结

在前期导入SDK包和相关静态库的添加,以及报错问题可以参考 江湖哥的博客http://blog.csdn.net/frf881128/article/details/50234479 写得很给力啊,还有以下这位的文章http://julang200.com/ios/2015/02/05/linphone-iphone代码解读.html
本文主要简述一下流程
1.初始化 􏰬􏰭􏰮startLibLinphone*
(1)模块初始化,包含􏰲􏰳mediastreamer2、ilbc、silk、amr、x264、h264、bcg729 <pre>ms_init();
libmsilbc_init();
libmssilk_init();
libmsamr_init();
libmsx264_init();
libmsopenh264_init();
libmsbcg729_init(); </pre> *
(2)创建􏰴􏰵linphone core(createLinphoneCore)
<pre> theLinphoneCore =linphone_core_new_with_config (&linphonec_vtable ,configDb ,self /* user_data /);</pre> linphonec_vtable􏰅􏰶􏰇􏰷􏰸􏰹􏰺(􏰻LinphoneManager.m) <pre> staticLinphoneCoreVTable linphonec_vtable = {
.show =NULL,
.call_state_changed =(LinphoneCoreCallStateChangedCb)linphone_iphone_call_state,
.registration_state_changed = linphone_iphone_registration_state,
.notify_presence_received=NULL,
.new_subscription_requested = NULL,
.auth_info_requested = NULL,
.display_status = linphone_iphone_display_status,
.display_message=linphone_iphone_log,
.display_warning=linphone_iphone_log,
.display_url=NULL,
.text_received=NULL,
.message_received=linphone_iphone_message_received,
.dtmf_received=NULL,
.transfer_state_changed=linphone_iphone_transfer_state_changed,
.is_composing_received = linphone_iphone_is_composing_received,
.configuring_status= linphone_iphone_configuring_status_changed,
.global_state_changed =linphone_iphone_global_state_changed }; </pre> LinphoneCoreVTable􏰲􏰳包含: global_state_changed 全局状态改变回调;
􏰼􏰽􏰾􏰿􏱀􏱁􏰷􏰸 registration_state_changed注册状态回调; 􏱂􏱃􏰾􏰿􏱀􏱁􏰷􏰸
call_state_changed 呼叫状态回调 􏱄􏱅􏰾􏰿􏱀􏱁􏰷􏰸 * ...(􏱆􏰻详见linphonecore.h)
(3)初始化􏰬􏰭􏰮audio session<pre> AVAudioSession *audioSession = [AVAudioSession sharedInstance];
BOOL bAudioInputAvailable= audioSession.inputAvailable ;
[audioSession setActive:NO error: &err ];
</pre>
2.注册
(1)􏰯linphone_auth_info_new 生成人证信息
(2)􏰯linphone_core_clear_all_auth_info 􏱪􏱫􏰶􏰇􏱦􏱧􏱨􏱩清空所有认证信息
(3)􏰯linphone_core_add_auth_info􏱬􏱭􏱦􏱧􏱨􏱩 添加认证信息
3.配置项
<pre>linphone_core_set_sip_transports 设置􏲉􏲊􏲋􏲌􏰇􏱘sip传输协议有TCP、UDP、TLS
linphone_address_set_username 􏱘􏱔􏱳􏲍􏲎 设置用户名
linphone_address_set_domain 􏱘􏱔􏲏􏲎设置域名
linphone_auth_info_new 􏰴􏰵􏱦􏱧􏱨􏱩创建认证信息
􏲏􏲎linphone_core_add_auth_info 􏱬􏱭􏱦􏱧􏱨􏱩添加认证信息
linphone_core_enable_payload_type 音视频开关配置 􏲑􏲒􏲓􏲔􏲕􏱰􏱔 </pre>

4.来电通知
􏰡􏰇􏰎􏲖􏰃当有来电时,会触发call_state_changed􏲘􏱤􏱁􏰮发生变化(linphonec_vtable),􏰯于是会回调􏱹􏰓􏱑􏰸􏱳􏰷􏰸linphone_iphone_call_state
<pre> static void linphone_iphone_call_state(LinphoneCorelc, LinphoneCall call, LinphoneCallState state,const char* message)
{
[(LinphoneManager*)linphone_core_get_user_data(lc) onCall:call StateChanged: statewithMessage: message];
} </pre>呼叫状态如下 􏱄􏱅􏰾􏰿􏲙􏲇􏱍:
<pre>
typedef enum_LinphoneCallState{
LinphoneCallIdle = 0, //􏰬􏰭􏰮􏰾􏰿初始化状态
LinphoneCallIncomingReceived =1, //􏰎􏲖 来电
LinphoneCallOutgoingInit = 2, //􏲔􏰭􏱄􏱉开始呼出
LinphoneCallOutgoingProgress = 3, //􏲚􏰆􏲛􏲜􏱄􏱉正在处理呼出
LinphoneCallOutgoingRinging = 4, //呼出正在响铃
􏱄􏱉􏲚􏰆􏲝LinphoneCallOutgoingEarlyMedia = 5, LinphoneCallConnected = 6, //接通
􏰹􏱼LinphoneCallStreamsRunning = 7, //􏲞􏲟􏲠􏱼􏲡􏰝􏰵􏱥􏲢 媒体流通道构建成功
LinphoneCallPausing = 8,LinphoneCallPaused = 9, LinphoneCallResuming = 10, LinphoneCallRefered = 11,//􏰇􏱝􏰎􏲖有新来电,转出当前会话
LinphoneCallError = 12, LinphoneCallEnd = 13, //结束
􏰜􏲥LinphoneCallPausedByRemote = 14, //􏲦􏲧􏰜􏲥远程结束
LinphoneCallUpdatedByRemote = 15, //􏱰􏱔􏲨􏱝配置更新
LinphoneCallIncomingEarlyMedia = 16, LinphoneCallUpdating =17, LinphoneCallReleased = 18
} LinphoneCallState; </pre>

后续继续更新

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容