SIP address parser API SIP地址解析器API
自定义
typedef enum _LinphoneTransportType LinphoneTransportType
typedef struct SalAddress LinphoneAddress
枚举类型
enum _LinphoneTransportType{
LinphoneTransportUdp,
LinphoneTransportTcp,
LinphoneTransportTls,
LinphoneTransportDtls
}
函数类型
详细描述
这个api用于操作SIP地址(‘from'或者‘to’)
自定义文档
typedef struct SalAddress LinphoneAddress
代表一个SIP地址
LinphoneAddress是一个不透明的对象,用来表示一个SIP地址,即SIP的‘from’和‘to'消息头的内容.一个SIP地址由显示名字,用户名,域名,端口,和不同的uri头(如tags)组成.它类似‘Alice<sip:alice@example.net>’.LinphoneAddress有提取和操作地址的所有部分.当地址部分为空时(例如username为空).访问器方法饭NULL.
typedef enum _LinphoneTransportType LinphoneTransportType
传输类型
枚举类型文档
enum _LinphoneTransportType
枚举 描述传输类型
函数文档
char* linphone_address_as_string(const LinphoneAddress* u)
返回地址的字符串形式.返回的char*必须有应用程序释放.用ms_free().
char* linphone_address_as_string_uri_only(const LinphoneAddress* u)
只返回SIP URI的字符串,显示名字被移除.返回的char*必须由应用程序释放.用ms_free().
void linphone_address_clean(LinphoneAddress* uri)
移除地址的 tags和uri头以便可以显示给用户
LinphoneAddress* linphone_address_clone(const LinphoneAddress* addr)
克隆一个LinphoneAddress对象
void linphone_address_destroy(LinphoneAddress* u)
销毁一个LinphoneAddress对象(实际上是调用了linphone_address_unref())
已弃用:
用linphone_address_unref()代替
bool_t linphone_address_equal(const LinphoneAddress* a1, const LinphoneAddress* a2)
比较两个LinphoneAddress考虑tags和headers在内
参数
[in] a1 LinphoneAddress对象
[in] a2 LinphoneAddress对象
返回
如果两个LinphoneAddress对象相等返回TRUE.
另参见
linphone_address_weak_equal()
const char* linphone_address_get_dispkay_name(const LinphoneAddress* u)
返回显示名字
const char* linphone_address_get_domain(const LinphoneAddress* u)
返回域名
const char* linphone_address_get_method_param(const LinphoneAddress* addr)
获取方法参数的值
const char* linphone_address_get_password(const LinphoneAddress* addr)
获取地址编码的密码.它同于基本身份验证(不推荐)
参数
addr LinphoneAddress对象
返回
如果有返回密码,否则返回NULL
int linphone_address_get_port(const LinphoneAddress* u)
获取端口.如果没有就返回0
const char* linphone_address_get_scheme(const LinphoneAddress* u)
返回地址方案,通常为“sip”
bool_t linphone_address_get_secure(const LinphoneAddress* uri)
如果地址指向一个安全的选址(sips)返回true.
LinphoneTransportType linphone_address_get_transport(const LinphoneAddress* uri)
获取传输类型
const char* linphone_address_get_username(const LinphoneAddress* u)
返回username
bool_t linphone_address_is_secure(const LinphoneAddress* uri)
已弃用:
用linphone_address_get_secure()代替
bool_t linphone_address_is_sip(const LinphoneAddress* uri)
如果地址是一个可路由的sip地址返回true.
LinphoneAddress* linphone_address_new(const char* addr)
通过解析用户提供的地址来构造一个LinphoneAddress对象,该地址以字符串表示.
LinphoneAddress* linphone_address_ref(LinphoneAddress* addr)
增加LinphoneAddress对象的引用计数
int linphone_address_set_display_name(LinphoneAddress* u, const char* display_name)
设置显示名字
int linphone_address_set_domain(LinphoneAddress* uri, const char* host)
设置域名
void linphone_address_set_header(LinphoneAddress* addr, const char* header_name, const char* header_value)
设置一个header到地址.header用“?”与地址隔离,例如<sip:test#linphone.org?SomeHeader=SomeValue>.
参数
addr LinphoneAddress对象
header_name 头的名字
header_value 头的值
void linphone_address_set_method_param(LinphoneAddress* addr, const char* method)
设置方法参数的值
void linphone_address_set_password(LinphoneAddress* addr, const char* passwd)
设置地址编码的密码.它用于基本身份验证(不推荐)
参数
addr LinphoneAddress对象
passwd 设置的密码
int linphone_address_set_port(LinphoneAddress* uri, int port)
设置端口
void linphone_address_set_secure(LinphoneAddress* addr, bool_t enabled)
使地址指向一个安全的地址(sips方案)
参数
[in] addr LinphoneAddress对象
[in] enabled 如果请求的地址是安全的返回TRUE
int linphone_address_set_transport(LinphoneAddress* uri, LinphoneTransportType tp)
设置用户名
void linphone_address_unref(LinphoneAddress* addr)
减少LinphoneAddress对象的引用计数.当降到0时,释放对象内存
bool_t linphone_address_weak_equal(const LinphoneAddress* a1, const LinphoneAddress* a2)
比较两个LinphoneAddress忽略tags和headers,基本上只是域名、用户名和端口
参数
[in] a1 LinphoneAddress对象
[in] a2 LinphoneAddress对象
返回
如果LinphoneAddress对象相等返回TRUE
参见
linphone_address_equal()
LinphoneAddress* linphone_core_create_address(LinphoneCore* lc, const char* address)
创建一个LinphoneAddress对象,通过解析用户提供的地址字符串
参数
[in] lc LinphoneCore对象
[in] address 地址字符串
返回
新建的LinphoneAddress对象