QuteCom手记:exosip初始化和构建INVITE请求
来源:互联网 发布:daas 数据挖掘 编辑:程序博客网 时间:2024/06/06 18:39
@1、exosip初始化
qutecom/wifo/phapi/phapi.c
fun:owplInit()
Line:291
eXosip_set_user_agent(ua);设置SIP包头域User-Agent="qutecom/rev-335d495adbc1-trunk",即SIP客户端名称。
return_code = eXosip_init(0,0,udpPort,tcpPort,tlsPort); if (return_code != 0){ owplLogError("eXosip_init failed"); return OWPL_RESULT_FAILURE; } //... { const char * ua=QUTECOM_UA; eXosip_set_user_agent(ua); }
@2、创建一个INVITE请求包
拨出电话需要构建一个INVITE发给服务器,服务器转发给另一个UAC。
调用关系:
PhApiWrapper::makeCall()
==>owplCallConnect()
==>phLinePlaceCall_withCa()
==>eXosip_build_initial_invite()
函数声明:
qutecom/wifo/eXosip/include/eXosip/eXosip.h
/** * Build a default INVITE message for a new call. * * @param invite Pointer for the SIP element to hold. * @param to SIP url for callee. * @param from SIP url for caller. * @param route Route header for INVITE. (optionnal) * @param subject Subject for the call. */int eXosip_build_initial_invite(osip_message_t **invite, char *to, char *from, char *route, char *subject);
作用:
构建一个INVITE消息。
实现:
File: qutecom/wifo/eXosip/src/jrequest.c
/* this method can't be called unless the previous INVITE transaction is over. */int eXosip_build_initial_invite(osip_message_t **invite, char *to, char *from,char *route, char *subject){ int i; if (to!=NULL && *to=='/0') return -1; osip_clrspace(to);//清除空格 osip_clrspace(subject); osip_clrspace(from); osip_clrspace(route); if (route!=NULL && *route=='/0') route=NULL; if (subject!=NULL && *subject=='/0') subject=NULL;//构建INVITE包 i = generating_request_out_of_dialog(invite, "INVITE", to, from, route); if (i!=0) return -1;#if 0 if (subject==NULL) osip_message_set_subject(*invite, "New Call"); else osip_message_set_subject(*invite, subject);#else if (subject!=NULL) osip_message_set_subject(*invite, subject); //设置SIP头域的SUBJECT字段 //"Subject: Phone call"#endif /* after this delay, we should send a CANCEL *///设置超时 owsip_message_set_expires(*invite, "120"); /* osip_message_set_organization(*invite, "Jack's Org"); */ return 0;}
函数generating_request_out_of_dialog调用generating_request_out_of_dialog2
generating_request_out_of_dialog2在qutecom/wifo/eXosip/src/jrequest.c实现
部分代码
static intgenerating_request_out_of_dialog2(osip_message_t **dest, char *method_name, char *to, char *from, char *proxy, int seqnum){ //... i = osip_message_init(&request);//初始化 if (i!=0) return -1; /* prepare the request-line */ osip_message_set_method(request, osip_strdup(method_name)); osip_message_set_version(request, osip_strdup("SIP/2.0"));//"INVITE sip:to@192.168.105.14 SIP/2.0" osip_message_set_status_code(request, 0); osip_message_set_reason_phrase(request, NULL);// //... i = osip_message_set_to(request, to);//"To: <sip:to@192.168.105.14>" //... osip_message_set_from(request, from);// osip_from_set_tag(request->from, osip_from_tag_new_random());//"rom: <sip:from@192.168.105.5>;tag=29244" //... osip_call_id_set_number(callid, cidrand);//"Call-ID: 8103" //... osip_cseq_set_number(cseq, num); osip_cseq_set_method(cseq, osip_strdup(method_name)); request->cseq = cseq; //"CSeq: 20 INVITE" //... osip_message_set_max_forwards(request, "70"); /* a UA should start a request with 70 */ //Max-Forwards: 70 //... osip_message_set_via(request, tmp);//"Via: SIP/2.0/UDP 192.168.105.5:5060;rport;branch=z9hG4bK2195" //... osip_message_set_contact (request, contact) ;//"Contact: <sip:from@192.168.105.5:5060>" //... osip_message_set_user_agent(request, eXosip.user_agent);//"User-Agent: QuteCom2.2.1 (eXosip2/3.3.0)" //... //设定完头域后,INVITE消息应该长得像这样: //INVITE sip:to@192.168.105.14 SIP/2.0 //Via: SIP/2.0/UDP 192.168.105.5:5060;rport;branch=z9hG4bK2195 //From: <sip:from@192.168.105.5>;tag=29244 //To: <sip:to@192.168.105.14> //Call-ID: 8103 //CSeq: 20 INVITE //Contact: <sip:from@192.168.105.5:5060> //Max-Forwards: 70 //User-Agent: Linphone/3.2.1 (eXosip2/3.3.0) //Subject: Phone call //subject在eXosip_build_initial_invite中被设置。在本函数调用后随即调用}
这个函数调用了oSip2库的一系列xxsetxx函数设置INVITE包的各个头域。
头域的定义在《sip中文参考手册》P122 20 头域一节有完整说明
《sip中文参考手册》已经放在资源中。
- QuteCom手记:exosip初始化和构建INVITE请求
- QuteCom手记:Phapi/exosip事件①拨号INVITE
- QuteCom手记:Phapi/exosip事件②INVITE的响应
- QuteCom手记:sip简介&SIP:INVITE消息
- Qutecom手记:配置QuteCom开发环境
- QuteCom手记:phapi发送和接收音频数据的流程(ortp & portaudio)
- QuteCom手记:phapi的声音驱动
- QuteCom手记:使用Event类实现观察者模式
- ReSIProcate proxy 处理Invite请求处理流程
- exosip 和 pjsip 简介
- eXosip用户手册:1.1 如何初始化libeXosip2
- exosip
- Re-invite和Update的区别
- Re-invite和Update的区别
- sip register超时和invite超时
- SIP的REG,UNREG和INVITE
- oSIP和eXosip编译过程
- oSIP和eXosip编译过程
- 一个apache一个tomcat 配置N个网站
- pl/sql developer报错ORA-12170: TNS: 连接超时
- "Inferring Assertion for Complementary Synthesis" is accepted by ICCAD'11
- Android build system note
- 一个apache多个tomcat 配置N个网站
- QuteCom手记:exosip初始化和构建INVITE请求
- APACHE 2.2.4与TOMCAT6.0.14整合教程
- Hibernate面向JPA编程 映射元数据
- MTK 11A Gallery Widget
- fork系统调用
- sql 语句
- "Microsoft Office Access 不能在追加查询中追加所有记录。 Microsoft Office Access设置1字段为Null是因为类型转换失败,它未将0记录添加到表是因为键值冲突,没有添加0记录是因为锁定冲突,没有添加0记录是因为
- sql 数据库 sql 语句一些操作
- 委托的理解