大家好,又见面了,我是你们的朋友全栈君。
oSIP的模块结构图如下(图2-1):
SIP parser |
URL parser |
SDP parser |
Finite State Machines |
Dialogue Facilities |
SDP negotiation Facilities |
Application |
状态机模块 |
解析器模块 |
工具模块(可选项) |
oSIP模块
|
图2-1 oSIP结构
|
ICT — Invite Client (outgoing) Transaction
NICT — Non-Invite Client (outgoing) Transaction
IST — Invite Server (incoming) Transaction
NIST — Non-Invite Server (incoming) Transaction
ICT_PRE_CALLING |
ICT_COMPLETED |
ICT_PROCEEDING |
ICT_TERMINATED |
Transaction initialization |
ICT_CALLING |
cb_ict_transport_error |
cb_ict_invite_sent |
cb_ict_invite_sent2 |
cb_ict_transport_error |
图 2-2: ICT State Machine |
cb_ict_kill_transaction |
cb_ict_transport_error |
cb_ict_1xx_received |
cb_ict_2xx_received |
cb_ict_transport_error |
cb_ict_1xx_received |
cb_ict_Nxx_received |
cb_ict_Nxx_received |
cb_ict_3456xx_received2 cb_ict_ack_sent2 |
cb_ict_xxx_xxxx |
表示从一种状态转换到另一种状态时将调用该回调函数 |
表示从一种状态转换到另一种状态时不调用任何回调函数 |
注:
NICT_PRE_TRYING |
NICT_COMPLETED |
NICT_PROCEEDING |
NICT_TERMINATED |
Transaction initialization |
NICT_TRYING |
cb_nict_transport_error |
cb_nict_XXX_sent |
cb_nict_request_sent2 |
cb_nict_1xx_received |
图2-3: NICT State Machine |
cb_nict_Nxx_received |
cb_nict_kill_transaction |
cb_nict_transport_error |
cb_nict_request_sent2 |
cb_nict_1xx_received |
cb_nict_Nxx_received |
cb_nict_transport_error |
cb_nict_xxx_xxxx |
表示从一种状态转换到另一种状态时将调用该回调函数 |
表示从一种状态转换到另一种状态时不调用任何回调函数 |
注:
IST_PRE_PROCEEDING |
IST_CONFIRMED |
IST_COMPLETED |
IST_TERMINATED |
Transaction initialization |
IST_PROCEEDING |
cb_ist_invite_received |
cb_ist_Nxx_sent |
图2-4: IST State Machine |
cb_ist_ack_received |
cb_ist_1xx_sent |
cb_ist_transport_error |
cb_ist_2xx_sent |
cb_ist_ack_received2 |
cb_ist_3456xx_sent2 |
cb_ist_invite_received2 |
cb_ist_kill_transaction |
cb_ist_transport_error |
cb_ist_xxx_xxxx |
表示从一种状态转换到另一种状态时将调用该回调函数 |
表示从一种状态转换到另一种状态时不调用任何回调函数 |
注:
NIST_PRE_TRYING |
NIST_COMPLETED |
NIST_PROCEEDING |
NIST_TERMINATED |
Transaction initialization |
NIST_TRYING |
cb_nist_XXX_ received |
cb_nist_1xx_sent |
图2-5: NIST State Machine |
cb_nist_Nxx_sent |
cb_nist_kill_transaction |
cb_nist_transport_error |
cb_nist_1xx_sent |
cb_nist_Nxx_sent |
cb_nist_transport_error |
cb_nist_request_received2 |
cb_nist_request_received2 |
cb_nist_xxx_xxxx |
表示从一种状态转换到另一种状态时将调用该回调函数 |
表示从一种状态转换到另一种状态时不调用任何回调函数 |
注:
SIP Header(头域) | Functions(函数名称—简写) | |
Accept | set(),get() | ☆ |
Accept-Encoding | set(),get(),init(),parse(),2char(),free(),clone() Getelement(),setelement() | ☆ |
Accept-Language | set(),get() | ☆ |
Alert-Info | set(),get() | ☆ |
Allow | set(),get() | ☆ |
Authentication-Info | ||
Authorization | Init(),set(),parse(),get(),getauth_type(),setauth_type(), Getusername(),setusername(),getrealm(),setrealm(), Getnonce(),setnonce(),geturi(),seturi(),getresponse(), Setresponse(),getdigest(),setdigest(),getalgorithm(), Setalgorithm(),getcnonce(),setcnonce(),getopaque(), Setopaque(),getmessage_qop(),setmessage_qop(), getnonce_count(),setnonce_count(),2char(),free(), clone() | ☆ |
Call-ID | set(),get(),parse(),2char(),free(),clone(),getnumber(), setnumber(),gethost(),sethost() | ☆ |
Call-Info | set(),get(),init(),parse(),2char(),free(),clone(), geturi(),seturi() | ☆ |
Contact | set(),get(),init(),parse(),2char(),free(),clone() | ☆ |
Content-Disposition | set(),get(),parse() | ☆ |
Content-Encoding | set(),get() | ☆ |
Content-Language | ||
Content-Length | set(),get(),init(),parse(),2char(),free(),clone() | ☆ |
Content-Type | set(),get(),init(),parse(),2char(),free(),clone() | ☆ |
CSeq | set(),get(),init(),parse(),2char(),free(),clone(), getnumber(),setnumber(),getmethod(),setmethod() | ☆ |
Date | ||
Error-Info | set(),get() | ☆ |
Expires | ||
From | set(),get(),init(),parse(),2char(),free(),clone(), getdisplayname(),setdisplayname(),geturl(),seturl(), param_get(),param_parseall(),param_setvalue(), param_getvalue(),param_getname(),param_setname(), compare() | ☆ |
In-Reply-To | ||
Max-Forwards | ||
Min-Expires | ||
MIME-Version | set(),get() | ☆ |
Organization | ||
Priority | ||
Proxy-Authenticate | set(),get() | ☆ |
Proxy-Authorization | set(),get() | ☆ |
Proxy-Require | ||
Record-Route | set(),get(),init(),parse(),2char(),free() | ☆ |
Reply-To | ||
Require | ||
Retry-After | ||
Route | set(),get(),init(),parse(),2char(),free() | ☆ |
Server | ||
Subject | ||
Supported | ||
Timestamp | ||
To | set(),get(),init(),parse(),2char(),free(),clone() | ☆ |
Unsupported | ||
User-Agent | ||
Via | set(),append(),get(),init(),free(),parse(),2char(), setversion(),getversion(),setprotocol(),getprotocol(), sethost(),gethost(),setport(),getport(),setcomment(), getcomment(),clone() | ☆ |
Warning | ||
WWW-Authenticate | Init(),set(),quoted_string_set(),token_set(),parse(), get(),getauth_type(),setauth_type(),getrealm(),setrealm(), getdomain(),setdomain(),getnonce(),setnonce(),getstale(), setstale(),getopaque(),setopaque(),getalgorithm(), setalgorithm(),getqop_options(),setqop_options(),2char(), free(),clone() | ☆ |
type(类型) | Functions(函数名称—简写) |
v | version_set(),version_get() |
o | origin_set(),username_get(),sess_id_get(), sess_version_get(),nettype_get(),addrtype_get(), addr_get() |
s | name_set(),name_get() |
i | info_set(),info_get() |
u | uri_set(),uri_get() |
e | email_add(),email_get() |
p | phone_add(),phone_get() |
c | connection_add(),connection_get(),nettype_get(), addrtype_get(),addr_get(),addr_multicast_ttl_get(), addr_multicast_int_get() |
b | bandwidth_add(),bwtype_get(),bandwidth_get() |
t | time_descr_add(),start_time_get(),stop_time_get() |
r | repeat_add(),repeat_get() |
z | adjustments_set(),adjustments_get() |
k | key_set(),keytype_get(),keydata_get() |
a | attribute_add(),att_field_get(),att_value_get() |
m | media_add(),media_get(),port_get(),number_of_port_get(), proto_get(),payload_add(),payload_get(), |
协商工具
(SDP negotiator)
帮助
end point提供协商codec等功能
Osip没有给开发者限定在特定的某个执行模式下,能够使开发者选定一个比较适合自己的模式。
Osip的各个模块是相对清晰、独立的,因而去掉某个模块时也比较容易。
Osip的解析器提供了较为完善的API,包含了消息的构造、修改和产生等。
oSIP目前版本源代码结构、定义比较混乱,并且缺乏文档,阅读比较困难;该问题将在oSIP2中得到改善。
oSIP不提供任何快速产生请求消息和响应消息的方法,所有请求消息和响应消息的形成必须调用一组sip message api来手动组装完成,关于这方面的缺陷,osip作者可能在以后会开发一个eXoSIP的API来完成。
由于oSIP结构简单,外围相关模块需要用户自己开发,如SIP消息的接收和发送,RTP/RTCP的语音数据的处理等。
Receive/Send SIP Messages |
SIP parser |
URL parser |
SDP parser |
Finite State Machines |
Dialogue Facilities |
SDP negotiation Facilities |
Main thread |
状态机模块 |
解析器模块 |
工具模块(可选项) |
oSIP模块
|
图4-1 oSIP应用
|
Receive/Send
RTP/RTCP
|
oSIP
Instance
|
Transaction
Context
|
①
|
②
|
③
|
⑥
|
④
|
⑤
|
⑦
|
B
|
A
|
Application
|
osip_global_init
()
和
osip_init()
,具体
操作代码如下:
osip_t *osip;
// initialise internal element first
if (0!=osip_global_init())
return -1;
// allocate a global osip element.
if (0!=osip_init(&osip))
return -1;
|
osip_setcb_send_message(osip, &application_cb_snd_message);
|
osip_setcb_ict_kill_transaction(osip,&application_cb_ict_kill_transaction);
osip_setcb_ist_kill_transaction(osip,&application_cb_ist_kill_transaction);
osip_setcb_nict_kill_transaction(osip,&application_cb_nict_kill_transaction);
osip_setcb_nist_kill_transaction(osip,&application_cb_nist_kill_transaction);
|
osip_setcb_ict_transport_error(osip,&application_cb_transport_error);
osip_setcb_ist_transport_error(osip,&application_cb_transport_error);
osip_setcb_nict_transport_error(osip,&application_cb_transport_error);
osip_setcb_nist_transport_error(osip,&application_cb_transport_error);
|
osip_setcb_ict_2xx_received2(osip,&application_cb_rcvresp_retransmission); osip_setcb_ict_3456xx_received2(osip,&application_cb_rcvresp_retransmission); osip_setcb_ict_invite_sent2(osip,&application_cb_sndreq_retransmission); osip_setcb_ist_2xx_sent2(osip,&application_cb_sndresp_retransmission); osip_setcb_ist_3456xx_sent2(osip,&application_cb_sndresp_retransmission); osip_setcb_ist_invite_received2(osip,&application_cb_rcvreq_retransmission); osip_setcb_nict_2xx_received2(osip,&application_cb_rcvresp_retransmission); osip_setcb_nict_3456xx_received2(osip,&application_cb_rcvresp_retransmission); osip_setcb_nict_request_sent2(osip,&application_cb_sndreq_retransmission); osip_setcb_nist_2xx_sent2(osip,&application_cb_sndresp_retransmission); osip_setcb_nist_3456xx_sent2(osip,&application_cb_sndresp_retransmission); osip_setcb_nist_request_received2(osip,&application_cb_rcvreq_retransmission); osip_setcb_ict_invite_sent (osip,&application_cb_sndinvite); osip_setcb_ict_ack_sent (osip,&application_cb_sndack); osip_setcb_nict_register_sent(osip,&application_cb_sndregister); osip_setcb_nict_bye_sent (osip,&application_cb_sndbye); osip_setcb_nict_cancel_sent (osip,&application_cb_sndcancel); osip_setcb_nict_info_sent (osip,&application_cb_sndinfo); osip_setcb_nict_options_sent (osip,&application_cb_sndoptions); osip_setcb_nict_subscribe_sent (osip,&application_cb_sndoptions); osip_setcb_nict_notify_sent (osip,&application_cb_sndoptions); osip_setcb_nict_unknown_sent(osip,&application_cb_sndunkrequest); osip_setcb_ict_1xx_received(osip,&application_cb_rcv1xx); osip_setcb_ict_2xx_received(osip,&application_cb_rcv2xx); osip_setcb_ict_3xx_received(osip,&application_cb_rcv3xx); osip_setcb_ict_4xx_received(osip,&application_cb_rcv4xx); osip_setcb_ict_5xx_received(osip,&application_cb_rcv5xx); osip_setcb_ict_6xx_received(osip,&application_cb_rcv6xx); osip_setcb_ist_1xx_sent(osip,&application_cb_snd1xx); osip_setcb_ist_2xx_sent(osip,&application_cb_snd2xx); osip_setcb_ist_3xx_sent(osip,&application_cb_snd3xx); osip_setcb_ist_4xx_sent(osip,&application_cb_snd4xx); osip_setcb_ist_5xx_sent(osip,&application_cb_snd5xx); |
osip_setcb_ist_6xx_sent(osip,&application_cb_snd6xx); osip_setcb_nict_1xx_received(osip,&application_cb_rcv1xx); osip_setcb_nict_2xx_received(osip,&application_cb_rcv2xx); osip_setcb_nict_3xx_received(osip,&application_cb_rcv3xx); osip_setcb_nict_4xx_received(osip,&application_cb_rcv4xx); osip_setcb_nict_5xx_received(osip,&application_cb_rcv5xx); osip_setcb_nict_6xx_received(osip,&application_cb_rcv6xx); osip_setcb_nist_1xx_sent(osip,&application_cb_snd1xx); osip_setcb_nist_2xx_sent(osip,&application_cb_snd2xx); osip_setcb_nist_3xx_sent(osip,&application_cb_snd3xx); osip_setcb_nist_4xx_sent(osip,&application_cb_snd4xx); osip_setcb_nist_5xx_sent(osip,&application_cb_snd5xx); osip_setcb_nist_6xx_sent(osip,&application_cb_snd6xx); osip_setcb_ist_invite_received (osip,&application_cb_rcvinvite); osip_setcb_ist_ack_received (osip,&application_cb_rcvack); osip_setcb_ist_ack_received2 (osip,&application_cb_rcvack2); osip_setcb_nist_register_received(osip,&application_cb_rcvregister); osip_setcb_nist_bye_received (osip,&application_cb_rcvbye); osip_setcb_nist_cancel_received (osip,&application_cb_rcvcancel); osip_setcb_nist_info_received (osip,&application_cb_rcvinfo); osip_setcb_nist_options_received (osip,&application_cb_rcvoptions); osip_setcb_nist_subscribe_received(osip,&application_cb_rcvoptions); osip_setcb_nist_notify_received (osip,&application_cb_rcvoptions); osip_setcb_nist_unknown_received (osip,&application_cb_rcvunkrequest); |
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/148657.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...