Hesong::Sipua::Account

class Account

SIP账户

构造

Account::Account(String* registerServer, String* project, String* userName, String* password, unsigned int regTimeout, unsigned int regRetry, unsigned int regFirstRetry, String* label)
参数:
  • registerServer – 注册服务器地址。地址格式为: host[:port] 。如果不提供端口,默认使用5060端口。
  • project – 项目名称
  • userName – 注册用户名
  • password – 注册密码
  • regTimeout – 注册超时值(秒)
  • regRetry – 注册重试时间(秒)
  • regFirstRetry – 首次注册重试时间(秒)
  • label – 账户标签
Account::Account(String* registerServer, String* project, String* userName, String* password, unsigned int regTimeout, unsigned int regRetry, unsigned int regFirstRetry)
Account::Account(String* registerServer, String* project, String* userName, unsigned int regTimeout, unsigned int retryInterval, unsigned int firstRetryInterval, String* label)
Account::Account(String* registerServer, String* project, String* userName, unsigned int regTimeout, unsigned int retryInterval, unsigned int firstRetryInterval)
Account::Account(String* registerServer, String* project, String* userName, String* password, String* label)
Account::Account(String* registerServer, String* project, String* userName, String* label)
Account::Account(String* registerServer, String* project, String* userName)

析构

~Account::Account()

方法

int Account::Add()

将账户数据添加到全局数据。如果不调用该方法,就无法针对账户实例做出任何呼叫、接听、注册操作。

调用该方法后,本类库会自动的向服务器注册该账户。

注解

一般来说,开发者不需要直接使用该方法,而是通过 Lib::AccountList::Add() 将账户对象加入到列表,此时,本方法会被自动调用。

void Account::Del()

将账户数据从全局数据中删除。一旦调用,此账户将从服务器注销,且该账户的当前通话会断开。

注解

开发者不应直接使用该方法。本类的析构函数会自动完成这一步骤。

void Account::AnswerCall()

接听当前来电

void Account::AnswerCall(CallInfo* callInfo)

接听来电

void Account::HangupCall()

挂断当前通话;拒接当前来电

void Account::HangupCall(CallInfo* callInfo)

挂断通话;拒接来电

void Account::MakeCall(String* callee)
参数 callee:被叫

发起呼叫

被叫号码直接指定号码/用户名即可, 不要 使用类似 sip:123@host 这样的格式。

void Account::SendDtmf(String* digits)
参数 digits:DTFM 码字符串

在当前通话中发送DTMF码

void Account::SendDtmf(CallInfo* callInfo, String* digits)
参数:
  • callInfo – 要发送DTMF码的通话
  • digits – DTFM 码字符串

发送DTMF码

void Account::Register()

注册

调用后,当前账户将相服务器进行注册。

注解

由于调用 Account::Add() 或者 Lib::AccountList::Add() 都会自动注册账户,所以开发者一般不需要使用该方法。

void Account::UnRegister()

反注册

调用后,本类库将向服务器发送该账户的反注册请求。

void Account::StartRereg()

该方法用于在注册请求返回 488 时,继续尝试注册。开发者请 不要调用

void Account::StopRereg()

该方法用于配合 Account::StartRereg() 使用。开发者请 不要调用

属性

RegInfo* Account::LastRegInfo

最近一次的注册结果信息

CallInfo* Account::CurrentCallInfo

当前正在进行的通话或者来电的信息

int Account::Id

账户ID

注意这个ID不是全局唯一的

String* Account::UserId

账户的用户ID字符串

格式是:

"project_name" <sip:user_name@server_address>
String* Account::RegUri

注册URI

格式是:

sip:host[:port]
String* Account::Realm

领域

String* Account::Project

项目名称

String* Account::UserName

注册用户名

String* Account::Password

注册密码

String* Account::Label

账户标签

Boolean* Account::ReRegOn488

是否在收到 status=488 的注册回复后,仍然尝试重注册。

默认值:false
Object* Account::tag

标签

事件

void Account::OnRegisterStateChanged(RegInfo* regInfo)
参数 regInfo:注册信息对象

账户的注册状态发生变化

void Account::OnIncomingCall(CallInfo* info)
参数 info:呼叫信息对象

收到来电

参数 info 是一个 CallInfo 对象。开发者可以在该事件的处理函数中:可以调用 CallInfo::Answer() 接听;可以调用 CallInfo::Hangup() 拒接。

开发者也可以直接调用 Account::AnswerCall()Account::HangupCall() 来进行接听与拒接。

void Account::OnCallStateChanged(CallInfo* regInfo)
参数 info:呼叫信息对象

呼叫状态发生变化