Override channel dtmf methods in chan.dtmf only if explicitly requested.

git-svn-id: http://yate.null.ro/svn/yate/trunk@5276 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
marian 2012-09-19 14:11:11 +00:00
parent 1204460b32
commit 08654d5b53
4 changed files with 65 additions and 14 deletions

View File

@ -42,7 +42,10 @@
; This parameter can be overridden from routing by 'odtmfmethods' for outgoing call leg
; and 'idtmfmethods' for incoming call leg
; Also, this parameter can be overridden in chan.dtmf messages by a 'methods' parameter
; NOTE: When overridden from chan.dtmf an empty or invalid 'methods' parameter will be ignored
; NOTE:
; When overridden from chan.dtmf an empty or invalid 'methods' parameter will be ignored
; Methods indicated in chan.dtmf message will be intersected with channel capabilities
; unless an explicit boolean true 'methods_override' parameter is present
; This parameter is applied on reload for new calls only
;dtmfmethods=rfc2833,h323,inband

View File

@ -123,7 +123,10 @@
; This parameter can be overridden from routing by 'odtmfmethods' for outgoing call leg
; and 'idtmfmethods' for incoming call leg
; Also, this parameter can be overridden in chan.dtmf messages by a 'methods' parameter
; NOTE: When overridden from chan.dtmf an empty or invalid 'methods' parameter will be ignored
; NOTE:
; When overridden from chan.dtmf an empty or invalid 'methods' parameter will be ignored
; Methods indicated in chan.dtmf message will be intersected with channel capabilities
; unless an explicit boolean true 'methods_override' parameter is present
; This parameter is applied on reload for new calls only
;dtmfmethods=rfc2833,info,inband

View File

@ -289,7 +289,10 @@ public:
// Replace all methods from comma separated list
// If no method is set use other or setDefEmpty (reset to default)
// Return false if methods contain unknown methods
bool set(const String& methods, const DtmfMethods* other, bool setDefEmpty = true);
bool set(const String& methods, const DtmfMethods* other, bool setDefEmpty = true,
bool intersectOther = false);
// Intersect with other methods
void intersect(const DtmfMethods& other);
// Retrieve a method from deperecated parameters
// Reset the method if the parameter is false
// Display a message anyway if warn is not false
@ -299,6 +302,7 @@ public:
void reset(int method);
// Build a string list from methods
void buildMethods(String& buf, const char* sep = ",");
bool hasMethod(int method) const;
inline void printMethods(DebugEnabler* enabler, int level, const String& str) {
String tmp;
buildMethods(tmp);
@ -768,7 +772,8 @@ const TokenDict DtmfMethods::s_methodName[] = {
// Replace all methods from comma separated list
// If no method is set use other or setDefEmpty (reset to default)
bool DtmfMethods::set(const String& methods, const DtmfMethods* other, bool setDefEmpty)
bool DtmfMethods::set(const String& methods, const DtmfMethods* other, bool setDefEmpty,
bool intersectOther)
{
set();
bool found = false;
@ -787,14 +792,26 @@ bool DtmfMethods::set(const String& methods, const DtmfMethods* other, bool setD
}
TelEngine::destruct(m);
if (!found) {
if (other)
if (other) {
*this = *other;
intersectOther = false;
}
else if (setDefEmpty)
setDefault();
}
if (intersectOther && other)
intersect(*other);
return ok;
}
// Intersect with other methods
void DtmfMethods::intersect(const DtmfMethods& other)
{
for (int i = 0; i < MethodCount; i++)
if (m_methods[i] != MethodCount && !other.hasMethod(m_methods[i]))
m_methods[i] = MethodCount;
}
// Retrieve a method from deperecated parameters
// Reset the method if the parameter is false
// Display a message anyway if warn is not false
@ -830,6 +847,14 @@ void DtmfMethods::buildMethods(String& buf, const char* sep)
buf.append(lookup(m_methods[i],s_methodName),sep);
}
bool DtmfMethods::hasMethod(int method) const
{
for (int i = 0; i < MethodCount; i++)
if (m_methods[i] == method)
return true;
return false;
}
// Get a number of thread idle intervals from a time period
static inline unsigned int threadIdleIntervals(u_int64_t periodUs)
@ -3025,8 +3050,10 @@ bool YateH323Chan::msgTone(Message& msg, const char* tone)
return false;
DtmfMethods methods = m_dtmfMethods;
const String* param = msg.getParam(YSTRING("methods"));
if (param)
methods.set(*param,&m_dtmfMethods);
if (param) {
bool intersect = !msg.getBoolValue(YSTRING("methods_override"));
methods.set(*param,&m_dtmfMethods,true,intersect);
}
bool retVal = false;
bool ok = false;
for (int i = 0; !ok && i < DtmfMethods::MethodCount; i++) {

View File

@ -165,7 +165,10 @@ public:
// Replace all methods from comma separated list
// If no method is set use other or setDefEmpty (reset to default)
// Return false if methods contain unknown methods
bool set(const String& methods, const DtmfMethods* other, bool setDefEmpty = true);
bool set(const String& methods, const DtmfMethods* other, bool setDefEmpty = true,
bool intersectOther = false);
// Intersect with other methods
void intersect(const DtmfMethods& other);
// Retrieve a method from deperecated parameters
// Reset the method if the parameter is false
// Display a message anyway if warn is not false
@ -175,7 +178,7 @@ public:
void reset(int method);
// Build a string list from methods
void buildMethods(String& buf, const char* sep = ",");
bool hasMethod(int method);
bool hasMethod(int method) const;
inline void printMethods(DebugEnabler* enabler, int level, const String& str) {
String tmp;
buildMethods(tmp);
@ -1850,7 +1853,8 @@ static void setAuthError(SIPTransaction* trans, const NamedList& params,
// Replace all methods from comma separated list
// If no method is set use other or setDefEmpty (reset to default)
bool DtmfMethods::set(const String& methods, const DtmfMethods* other, bool setDefEmpty)
bool DtmfMethods::set(const String& methods, const DtmfMethods* other, bool setDefEmpty,
bool intersectOther)
{
set();
bool found = false;
@ -1869,14 +1873,26 @@ bool DtmfMethods::set(const String& methods, const DtmfMethods* other, bool setD
}
TelEngine::destruct(m);
if (!found) {
if (other)
if (other) {
*this = *other;
intersectOther = false;
}
else if (setDefEmpty)
setDefault();
}
if (intersectOther && other)
intersect(*other);
return ok;
}
// Intersect with other methods
void DtmfMethods::intersect(const DtmfMethods& other)
{
for (int i = 0; i < MethodCount; i++)
if (m_methods[i] != MethodCount && !other.hasMethod(m_methods[i]))
m_methods[i] = MethodCount;
}
// Retrieve a method from deperecated parameters
// Reset the method if the parameter is false
// Display a message anyway if warn is not false
@ -1912,7 +1928,7 @@ void DtmfMethods::buildMethods(String& buf, const char* sep)
buf.append(lookup(m_methods[i],s_methodName),sep);
}
bool DtmfMethods::hasMethod(int method)
bool DtmfMethods::hasMethod(int method) const
{
for (int i = 0; i < MethodCount; i++)
if (m_methods[i] == method)
@ -6554,8 +6570,10 @@ bool YateSIPConnection::msgTone(Message& msg, const char* tone)
return true;
DtmfMethods methods = m_dtmfMethods;
const String* param = msg.getParam(YSTRING("methods"));
if (param)
methods.set(*param,&m_dtmfMethods);
if (param) {
bool intersect = !msg.getBoolValue(YSTRING("methods_override"));
methods.set(*param,&m_dtmfMethods,true,intersect);
}
else {
const String* method = msg.getParam(YSTRING("method"));
if (method) {