exoSip+开发者手册.docx

上传人:b****5 文档编号:12028226 上传时间:2023-04-16 格式:DOCX 页数:37 大小:24.83KB
下载 相关 举报
exoSip+开发者手册.docx_第1页
第1页 / 共37页
exoSip+开发者手册.docx_第2页
第2页 / 共37页
exoSip+开发者手册.docx_第3页
第3页 / 共37页
exoSip+开发者手册.docx_第4页
第4页 / 共37页
exoSip+开发者手册.docx_第5页
第5页 / 共37页
点击查看更多>>
下载资源
资源描述

exoSip+开发者手册.docx

《exoSip+开发者手册.docx》由会员分享,可在线阅读,更多相关《exoSip+开发者手册.docx(37页珍藏版)》请在冰豆网上搜索。

exoSip+开发者手册.docx

exoSip+开发者手册

exoSip开发者手册

——本手册指导开发者利用exoSip栈开发用户代理

原文标题:

exoSIPUserManual

1TheeXtentedeXosipstack.............................................................................................................4

1.1How-ToinitializelibeXosip2........................................................................................4

1.2How-Toinitiate,modifyorterminatecalls...................................................................5

1.2.1Initiateacall......................................................................................................6

1.2.2Answeracall.....................................................................................................7

1.2.3Sendingotherrequest........................................................................................8

1.3How-Tosendorupdateregistrations............................................................................9

1.3.1Initiatearegistration.........................................................................................9

1.3.2Updatearegistration.........................................................................................9

1.3.3Closingtheregistration...................................................................................10

2GeneralpurposeAPI...............................................................................................................11

2.1eXosip2configurationAPI..........................................................................................11

2.1.1Functions.......................................................................................................................11

2.1.2FunctionDocumentation.................................................................................11

2.2eXosip2networkAPI..................................................................................................14

2.2.2Functions.........................................................................................................14

2.2.3FunctionDocumentation.................................................................................14

2.3eXosip2eventAPI............................................................................................................16

2.3.1DataStructures.......................................................................................................16

2.3.2Enumerations.........................................................................................................16

2.3.3Functions.......................................................................................................................17

2.3.4EnumerationTypeDocumentation.................................................................................17

2.3.5FunctionDocumentation................................................................................................19

3SIPmessagesandcallcontrolAPI..........................................................................................21

3.1eXosip2INVITEandCallManagement.....................................................................21

3.1.1Functions.........................................................................................................21

3.1.2FunctionDocumentation.................................................................................22

3.2eXosip2requestoutsideofdialog...............................................................................29

3.2.1Functions.........................................................................................................29

3.2.2FunctionDocumentation.................................................................................29

3.3eXosip2OPTIONSandUAcapabilitiesManagement...............................................31

3.3.1Functions.........................................................................................................31

3.3.2FunctionDocumentation.................................................................................31

3.4eXosip2PublicationManagement..............................................................................33

3.4.1Functions.........................................................................................................33

3.4.2FunctionDocumentation.................................................................................33

3.5eXosip2REFERandblindtranferManagementoutsideofcalls................................35

3.5.1Functions.........................................................................................................35

3.5.2FunctionDocumentation.................................................................................35

3.6eXosip2REGISTERandRegistrationManagement..................................................37

3.6.1Functions.........................................................................................................37

3.6.2FunctionDocumentation.................................................................................37

3.7eXosip2SUBSCRIBEandoutgoingsubscriptions.....................................................39

3.7.1Enumerations...................................................................................................39

3.7.2Functions.........................................................................................................39

3.7.3EnumerationTypeDocumentation..................................................................40

3.7.4FunctionDocumentation.................................................................................41

3.8eXosip2SUBSCRIBEandincomingsubscriptions....................................................43

3.8.1Functions.........................................................................................................43

3.8.2FunctionDocumentation.................................................................................43

3.9eXosip2authenticationAPI.........................................................................................46

3.9.1Functions.........................................................................................................46

3.9.2FunctionDocumentation.................................................................................46

3.10Xosip2SDPhelperAPI...............................................................................................48

3.10.1Functions.........................................................................................................48

3.10.2FunctionDocumentation.................................................................................48

1TheeXtentedeXosipstack

1.1How-ToinitializelibeXosip2.

WhenusingeXosip,yourfirsttaskistoinitializebotheXosipcontextandlibosip

library(parserandstatemachines).ThismustbedonepriortoanyuseoflibeXosip2.

include

inti;

TRACE_INITIALIZE(6,stdout);

i=eXosip_init();

if(i!

=0)

return-1;

i=eXosip_listen_addr(IPPROTO_UDP,NULL,port,AF_INET,0);

if(i!

=0)

{

eXosip_quit();

fprintf(stderr,"couldnotinitializetransportlayer\n");

return-1;

}

...thenyouhavetosendmessagesandwaitforeXosipevents...

Inthepreviouscode,you'velearnedhowto:

?

Initializetheosiptrace(compilethiscodewith-DENABLE_TRACE)

?

InitializeeXosip(andosip)stack

?

Openasocketforsignalling(onlyUDPwithinitialeXosip2version)

NowyouhavetohandleeXosipevents.HereissomecodetogeteXosip_eventfromtheeXosip2stack.

eXosip_event_t*je;

for(;;){

je=eXosip_event_wait(0,50);

eXosip_lock();

eXosip_automatic_action();

eXosip_unlock();

if(je==NULL)

break;

if(je->type==EXOSIP_CALL_NEW)

{

....

....

}

elseif(je->type==EXOSIP_CALL_ACK)

{

....

....

}

elseif(je->type==EXOSIP_CALL_ANSWERED)

{

....

....

}

else.....

....

....

eXosip_event_free(je);

}

YouwillreceiveoneeventforeachSIPmessagesent.Eacheventcontainsthe

originalrequestoftheaffectedtransactionandthelastresponsethattriggersthe

eventwhenavailable.

Youcanaccessallheadersfromthosemessagesandstoretheminyourowncontext

forotheractionsorgraphicdisplays.

Forexample,whenyoureceiveaREFERrequestforacalltransfer,you'lltypically

retreivethe"refer-To"header:

osip_header_t*referto_head=NULL;

i=osip_message_header_get_byname(evt->sip,"refer-to",0,

&referto_head);

if(referto_head==NULL||referto_head->hvalue==NULL)

TheeXosip_eventalsocontainsidentifiersforcalls,registrations,incoming

subscriptionsoroutgoingsubscriptionswhenapplicable.Thoseidentifiersareusedin

APItocontrolcalls,registrations,incomingoroutgoingsubscriptions.TheseAPIwill

builddefaultmessageswithusualSIPheaders(From,To,Call-ID,CSeq,Route,

Record-Route,Max-Forward...)andsendthosesmessagesforyou.

1.2How-Toinitiate,modifyorterminatecalls.

eXosip2offersaflexibleAPItohelpyoucontrolingcalls.

1.2.1Initiateacall

Tostartanoutgoingcall,youtypicallyneedafewheaderswhichwillbeusedby

eXosip2tobuildadefaultSIPINVITErequest.Thecodebelowisusedtostartacall:

osip_message_t*invite;

inti;

i=eXosip_call_build_initial_invite(&invite,

"

to@>",

"

from@>",

NULL,//optionnalrouteheader

"Thisisacallfora

conversation");

if(i!

=0)

{

return-1;

}

osip_message_set_supported(invite,"100rel");

{

chartmp[4096];

charlocalip[128];

eXosip_guess_localip(AF_INET,localip,128);

snprintf(tmp,4096,

"v=0\r\n"

"o=josua00INIP4%s\r\n"

"s=conversation\r\n"

"c=INIP4%s\r\n"

"t=00\r\n"

"m=audio%sRTP/AVP08101\r\n"

"a=rtpmap:

0PCMU/8000\r\n"

"a=rtpmap:

8PCMA/8000\r\n"

"a=rtpmap:

101telephone-event/800

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 农林牧渔 > 林学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1