Skip to content
Snippets Groups Projects
Commit d845a8cc authored by Alexandre Savard's avatar Alexandre Savard
Browse files

[#5211] Use individual memory pool for dtmfs

parent aa41a3be
No related branches found
No related tags found
No related merge requests found
......@@ -1432,16 +1432,24 @@ SIPVoIPLink::dtmfSipInfo (SIPCall *call, char code)
pj_str_t methodName, content;
pjsip_method method;
pjsip_media_type ctype;
pj_pool_t *tmp_pool;
_debug ("UserAgent: Send DTMF %c", code);
// Create a temporary memory pool
tmp_pool = pj_pool_create (&_cp->factory, "tmpdtmf10", 1000, 1000, NULL);
if (tmp_pool == NULL) {
_debug ("UserAgent: Could not initialize memory pool while sending DTMF");
return false;
}
duration = Manager::instance().voipPreferences.getPulseLength();
dtmf_body = new char[body_len];
snprintf (dtmf_body, body_len - 1, "Signal=%c\r\nDuration=%d\r\n", code, duration);
pj_strdup2 (_pool, &methodName, "INFO");
pj_strdup2 (tmp_pool, &methodName, "INFO");
pjsip_method_init_np (&method, &methodName);
/* Create request message. */
......@@ -1453,12 +1461,12 @@ SIPVoIPLink::dtmfSipInfo (SIPCall *call, char code)
}
/* Get MIME type */
pj_strdup2 (_pool, &ctype.type, "application");
pj_strdup2 (tmp_pool, &ctype.type, "application");
pj_strdup2 (_pool, &ctype.subtype, "dtmf-relay");
pj_strdup2 (tmp_pool, &ctype.subtype, "dtmf-relay");
/* Create "application/dtmf-relay" message body. */
pj_strdup2 (_pool, &content, dtmf_body);
pj_strdup2 (tmp_pool, &content, dtmf_body);
tdata->msg->body = pjsip_msg_body_create (tdata->pool, &ctype.type, &ctype.subtype, &content);
......@@ -1476,6 +1484,8 @@ SIPVoIPLink::dtmfSipInfo (SIPCall *call, char code)
return false;
}
pj_pool_release(tmp_pool);
return true;
}
......@@ -2446,15 +2456,11 @@ int SIPVoIPLink::createUdpTransport (AccountID id)
return !PJ_SUCCESS;
}
//strcpy (tmpIP, listeningAddress.data());
/* Init published name */
pj_bzero (&a_name, sizeof (pjsip_host_port));
pj_cstr (&a_name.host, listeningAddress.c_str());
a_name.port = listeningPort;
//pj_strdup2 (_pool, &a_name.host, tmpIP);
//a_name.port = (pj_uint16_t) listeningPort;
status = pjsip_udp_transport_start (_endpt, &bound_addr, &a_name, 1, &transport);
// Print info from transport manager associated to endpoint
......@@ -2462,20 +2468,14 @@ int SIPVoIPLink::createUdpTransport (AccountID id)
pjsip_tpmgr_dump_transports (tpmgr);
if (status != PJ_SUCCESS) {
_debug ("UserAgent: (%d) Unable to start UDP transport on %s:%d", status, listeningAddress.data(), listeningPort);
return status;
} else {
_debug ("UserAgent: UDP transport initialized successfully on %s:%d", listeningAddress.c_str (), listeningPort);
if (account == NULL) {
_debug ("UserAgent: Use transport as local UDP server");
_localUDPTransport = transport;
} else {
_debug ("UserAgent: bind transport to account %s", account->getAccountID().c_str());
account->setAccountTransport (transport);
}
......@@ -2490,8 +2490,6 @@ std::string SIPVoIPLink::findLocalAddressFromUri (const std::string& uri, pjsip_
pjsip_transport_type_e transportType;
pjsip_tpselector *tp_sel;
_debug ("SIP: Find local address from URI");
// Find the transport that must be used with the given uri
pj_str_t tmp;
pj_strdup2_with_null (_pool, &tmp, uri.c_str());
......@@ -2572,6 +2570,8 @@ std::string SIPVoIPLink::findLocalAddressFromUri (const std::string& uri, pjsip_
_debug ("SIP: Local address discovered from attached transport: %s", localaddr.c_str());
// pj_pool_release(tmp_pool);
return localaddr;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment