QuteCom手记:Phapi/exosip事件②INVITE的响应

对于拨号INVITE的响应,常用有以下几种

1、OK(RINGING).

2、用户忙。

3、用户不存在。

 

exosip获取sip事件的函数:

qutecom-2-2-ad315899a4d2\wifo\eXosip\src\eXosip2.h

eXosip_event_t *eXosip_event_wait(int tv_s, int tv_ms);

 所有的事件都在这里接收。

 

phapi中调用eXosip_event_wait获取和处理sip事件:

qutecom-2-2-ad315899a4d2\wifo\phapi\phapi-old.c

  

static int ph_event_get(){
	
	//...
	
	for (;;) {  
		//在void *ph_api_thread(void *arg)线程中循环获取sip事件,并向上传递。
		  
  		je = eXosip_event_wait(0,phWaitTimeout);//获取事件,保存到je
  		
		if(je==NULL) {
			break;
		}
		
		counter++;

		if(phDebugLevel > 0) {
			ph_printf("\n<- %s (%i %i) [%i %s] %s requri=%s\n",
				evtnames[je->type], je->cid, je->did,
				je->status_code,
				je->reason_phrase,
				je->remote_uri,
				je->req_uri);
		}

		// get the plugin corresponding to that content-type
		
		if(isCallEvent(je)) {
			//SIP电话事件
			
			if((ca = ph_locate_call(je, je->type == EXOSIP_CALL_NEW ? 1 : 0)) == NULL) {
				return -1;
			}

			//...
			if(ca->owplPlugin == NULL) {
				ph_process_call_event_default(je);
				//向上传递sip事件
				
			} else {
				owplFireExosipCallEvent(je);
				//使用sip插件的情况。
				
			}

			ph_update_callstate_by_event(je);
            
            
		}else{
			switch(je->type){
				//SIP注册事件、消息事件、选项事件等除了电话事件的其他事件。
				
				case EXOSIP_REGISTRATION_SUCCESS:
					ph_reg_progress(je);
					break;
                                     //......

                                     //case .......

			         case EXOSIP_ENGINE_STOPPED:
					return -2;

				default:
					if(phDebugLevel > 0) {
						ph_printf("event(%i %i %i %i) text=%s\n", je->cid, je->sid, je->nid, je->did, je->textinfo);
					}
					break;
			}
		}

		eXosip_event_free(je);
	}

	ph_refresh_vlines();
	ph_scan_calls();

	if (counter>0) {
		return 0;
	}
	return -1;
}


 

 $1、完整流程以回复OK为例

ph_process_call_event_default( )//EXOSIP_CALL_RINGING

    ==>ph_call_ringing(je);

        ==>ph_call_retrieve_payloads   //启动本方的媒体流,仅回复OK时。

        ==>ph_call_media_start

              ==>ph_msession_start

                     ==>ph_msession_audio_start

        ==>owplFireCallEvent  (CALLSTATE_REMOTE_ALERTING,CALLSTATE_REMOTE_ALERTING_NORMAL,)  //以回复OK为例          

再透过SipCallbacks将事件传递给owphone模块.

    SipCallbacks::phoneCallStateChangedEventHandler

          ==>PhoneLine::setPhoneCallState

                ==>PhoneCall::setState

                       ==>CPhoneCall::stateChangedEventHandlerThreadSafe

                              ==>QtPhoneCall::stateChangedEvent

                                    ==>QtPhoneCall::updateStatusLabel//显示状态(正在拨号、用户找不到或者用户忙)



 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值