Skip to content
Snippets Groups Projects
Commit b492f77b authored by Yun Liu's avatar Yun Liu
Browse files

DTMF: sending INFO message continued.

parent d02dab61
No related branches found
No related tags found
No related merge requests found
...@@ -198,7 +198,8 @@ SIPVoIPLink::newOutgoingCall(const CallID& id, const std::string& toUrl) ...@@ -198,7 +198,8 @@ SIPVoIPLink::newOutgoingCall(const CallID& id, const std::string& toUrl)
{ {
SIPCall* call = new SIPCall(id, Call::Outgoing); SIPCall* call = new SIPCall(id, Call::Outgoing);
if (call) { if (call) {
call->setPeerNumber(toUrl); //call->setPeerNumber(toUrl);
call->setPeerNumber(getSipTo(toUrl));
_debug("Try to make a call to: %s with call ID: %s\n", toUrl.data(), id.data()); _debug("Try to make a call to: %s with call ID: %s\n", toUrl.data(), id.data());
// we have to add the codec before using it in SIPOutgoingInvite... // we have to add the codec before using it in SIPOutgoingInvite...
call->setCodecMap(Manager::instance().getCodecDescriptorMap()); call->setCodecMap(Manager::instance().getCodecDescriptorMap());
...@@ -360,6 +361,9 @@ SIPVoIPLink::refuse (const CallID& id) ...@@ -360,6 +361,9 @@ SIPVoIPLink::refuse (const CallID& id)
bool bool
SIPVoIPLink::carryingDTMFdigits(const CallID& id, char code UNUSED) SIPVoIPLink::carryingDTMFdigits(const CallID& id, char code UNUSED)
{ {
SIPCall* call = getSIPCall(id);
if (call==0) { _debug("Call doesn't exist\n"); return false; }
int duration = Manager::instance().getConfigInt(SIGNALISATION, PULSE_LENGTH); int duration = Manager::instance().getConfigInt(SIGNALISATION, PULSE_LENGTH);
const int body_len = 1000; const int body_len = 1000;
char *dtmf_body = new char[body_len]; char *dtmf_body = new char[body_len];
......
...@@ -1192,38 +1192,46 @@ bool UserAgent::refuse(SIPCall* call) ...@@ -1192,38 +1192,46 @@ bool UserAgent::refuse(SIPCall* call)
bool UserAgent::carryingDTMFdigits(SIPCall* call, char *msgBody) bool UserAgent::carryingDTMFdigits(SIPCall* call, char *msgBody)
{ {
pj_status_t status; pj_status_t status;
pjsip_method method;
pj_str_t methodName;
pjsip_tx_data *tdata; pjsip_tx_data *tdata;
pj_str_t from, to, contact, body; pj_str_t methodName, content;
pjsip_method method;
AccountID accId = Manager::instance().getAccountFromCall(call->getCallId()); pjsip_media_type ctype;
SIPAccount *account = dynamic_cast<SIPAccount *>(Manager::instance().getAccount(accId));
pj_strdup2(_pool, &methodName, "INFO"); pj_strdup2(_pool, &methodName, "INFO");
std::string fromStr = "sip:" + account->getUserName() + "@" + account->getServer();
pj_strdup2(_pool, &from, fromStr.data());
std::string toStr = "sip:" + call->getPeerNumber();
pj_strdup2(_pool, &to, toStr.data());
pj_strdup2(_pool, &contact, account->getContact().data());
pj_strdup2(_pool, &body, msgBody);
pjsip_method_init_np(&method, &methodName); pjsip_method_init_np(&method, &methodName);
status = pjsip_endpt_create_request(_endpt, &method, /* Create request message. */
&to, &from, &to, &contact, NULL, -1, &body, &tdata); status = pjsip_dlg_create_request( call->getInvSession()->dlg, &method,
if(status != PJ_SUCCESS) { -1, &tdata);
_debug("UserAgent: Can not create DTMF message!\n"); if (status != PJ_SUCCESS) {
_debug("UserAgent: Unable to create INFO request -- %d\n", status);
return false; return false;
}
/* Get MIME type */
pj_strdup2(_pool, &ctype.type, "application");
pj_strdup2(_pool, &ctype.subtype, "dtmf-relay");
/* Create "application/dtmf-relay" message body. */
pj_strdup2(_pool, &content, msgBody);
tdata->msg->body = pjsip_msg_body_create( tdata->pool, &ctype.type,
&ctype.subtype, &content);
if (tdata->msg->body == NULL) {
_debug("UserAgent: Unable to create msg body!\n");
pjsip_tx_data_dec_ref(tdata);
return false;
} }
status = pjsip_endpt_send_request(_endpt, tdata, -1, NULL, NULL); /* Send the request. */
if(status != PJ_SUCCESS) { status = pjsip_dlg_send_request( call->getInvSession()->dlg, tdata,
_debug("UserAgent: Can not send DTMF message!\n"); _mod.id, NULL);
if (status != PJ_SUCCESS) {
_debug("UserAgent: Unable to send MESSAGE request -- %d\n", status);
return false; return false;
} }
return true; return true;
} }
bool UserAgent::transfer(SIPCall *call, const std::string& to) bool UserAgent::transfer(SIPCall *call, const std::string& to)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment