Fix dtmfmode, dtmfcodec capability, Faststart for users and peers. Bug #4112

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5551 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Jeremy McNamara
2005-05-02 18:46:36 +00:00
parent 9a7b3b0347
commit 931e1debff
3 changed files with 68 additions and 27 deletions

View File

@@ -357,7 +357,8 @@ static struct oh323_user *build_user(char *name, struct ast_variable *v)
if (user) { if (user) {
memset(user, 0, sizeof(struct oh323_user)); memset(user, 0, sizeof(struct oh323_user));
strncpy(user->name, name, sizeof(user->name) - 1); strncpy(user->name, name, sizeof(user->name) - 1);
user->options.dtmfcodec = 101; memcpy(&user->options, &global_options, sizeof(user->options));
user->capability = capability;
/* set a native brigding default value */ /* set a native brigding default value */
user->bridge = bridging; user->bridge = bridging;
/* and default context */ /* and default context */
@@ -403,6 +404,29 @@ static struct oh323_user *build_user(char *name, struct ast_variable *v)
user->options.progress_audio = ast_true(v->value); user->options.progress_audio = ast_true(v->value);
} else if (!strcasecmp(v->name, "dtmfcodec")) { } else if (!strcasecmp(v->name, "dtmfcodec")) {
user->options.dtmfcodec = atoi(v->value); user->options.dtmfcodec = atoi(v->value);
} else if (!strcasecmp(v->name, "dtmfmode")) {
if (!strcasecmp(v->value, "inband")) {
user->dtmfmode = H323_DTMF_INBAND;
} else if (!strcasecmp(v->value, "rfc2833")) {
user->dtmfmode = H323_DTMF_RFC2833;
} else {
ast_log(LOG_WARNING, "Unknown DTMF Mode %s, using RFC2833\n", v->value);
user->dtmfmode = H323_DTMF_RFC2833;
}
} else if (!strcasecmp(v->name, "allow")) {
format = ast_getformatbyname(v->value);
if (format < 1) {
ast_log(LOG_WARNING, "Cannot allow unknown format '%s'\n", v->value);
} else {
user->capability |= format;
}
} else if (!strcasecmp(v->name, "disallow")) {
format = ast_getformatbyname(v->value);
if (format < 1) {
ast_log(LOG_WARNING, "Cannot disallow unknown format '%s'\n", v->value);
} else {
user->capability &= ~format;
}
} else if (!strcasecmp(v->name, "host")) { } else if (!strcasecmp(v->name, "host")) {
if (!strcasecmp(v->value, "dynamic")) { if (!strcasecmp(v->value, "dynamic")) {
ast_log(LOG_ERROR, "A dynamic host on a type=user does not make any sense\n"); ast_log(LOG_ERROR, "A dynamic host on a type=user does not make any sense\n");
@@ -473,8 +497,9 @@ static struct oh323_peer *build_peer(char *name, struct ast_variable *v)
peer->ha = NULL; peer->ha = NULL;
peer->addr.sin_family = AF_INET; peer->addr.sin_family = AF_INET;
peer->capability = capability; peer->capability = capability;
peer->options.dtmfcodec = 101; peer->dtmfmode = dtmfmode;
peer->dtmfmode = H323_DTMF_RFC2833; peer->bridge = bridging;
memcpy(&peer->options, &global_options, sizeof(peer->options));
while(v) { while(v) {
if (!strcasecmp(v->name, "bridge")) { if (!strcasecmp(v->name, "bridge")) {
@@ -530,7 +555,7 @@ static struct oh323_peer *build_peer(char *name, struct ast_variable *v)
if (format < 1) { if (format < 1) {
ast_log(LOG_WARNING, "Cannot disallow unknown format '%s'\n", v->value); ast_log(LOG_WARNING, "Cannot disallow unknown format '%s'\n", v->value);
} else { } else {
peer->capability |= ~format; peer->capability &= ~format;
} }
} else if (!strcasecmp(v->name, "host")) { } else if (!strcasecmp(v->name, "host")) {
if (!strcasecmp(v->value, "dynamic")) { if (!strcasecmp(v->value, "dynamic")) {
@@ -2061,7 +2086,7 @@ int reload_config(void)
if (strcasecmp(cat, "general")) { if (strcasecmp(cat, "general")) {
utype = ast_variable_retrieve(cfg, cat, "type"); utype = ast_variable_retrieve(cfg, cat, "type");
if (utype) { if (utype) {
if (!strcasecmp(utype, "user") || !strcasecmp(utype, "friend")) { if (!strcasecmp(utype, "user")) {
user = build_user(cat, ast_variable_browse(cfg, cat)); user = build_user(cat, ast_variable_browse(cfg, cat));
if (user) { if (user) {
ast_mutex_lock(&userl.lock); ast_mutex_lock(&userl.lock);
@@ -2069,7 +2094,7 @@ int reload_config(void)
userl.users = user; userl.users = user;
ast_mutex_unlock(&userl.lock); ast_mutex_unlock(&userl.lock);
} }
} else if (!strcasecmp(utype, "peer") || !strcasecmp(utype, "friend")) { } else if (!strcasecmp(utype, "peer")) {
peer = build_peer(cat, ast_variable_browse(cfg, cat)); peer = build_peer(cat, ast_variable_browse(cfg, cat));
if (peer) { if (peer) {
ast_mutex_lock(&peerl.lock); ast_mutex_lock(&peerl.lock);
@@ -2077,6 +2102,21 @@ int reload_config(void)
peerl.peers = peer; peerl.peers = peer;
ast_mutex_unlock(&peerl.lock); ast_mutex_unlock(&peerl.lock);
} }
} else if (!strcasecmp(utype, "friend")) {
user = build_user(cat, ast_variable_browse(cfg, cat));
peer = build_peer(cat, ast_variable_browse(cfg, cat));
if (user) {
ast_mutex_lock(&userl.lock);
user->next = userl.users;
userl.users = user;
ast_mutex_unlock(&userl.lock);
}
if (peer) {
ast_mutex_lock(&peerl.lock);
peer->next = peerl.peers;
peerl.peers = peer;
ast_mutex_unlock(&peerl.lock);
}
} else if (!strcasecmp(utype, "h323") || !strcasecmp(utype, "alias")) { } else if (!strcasecmp(utype, "h323") || !strcasecmp(utype, "alias")) {
alias = build_alias(cat, ast_variable_browse(cfg, cat)); alias = build_alias(cat, ast_variable_browse(cfg, cat));
if (alias) { if (alias) {

View File

@@ -298,7 +298,7 @@ int MyH323EndPoint::MakeCall(const PString & dest, PString & token, unsigned int
cout << " -- Making call to " << fullAddress << " without gatekeeper." << endl; cout << " -- Making call to " << fullAddress << " without gatekeeper." << endl;
} }
} }
if (!(connection = (MyH323Connection *)H323EndPoint::MakeCallLocked(fullAddress, token))) { if (!(connection = (MyH323Connection *)H323EndPoint::MakeCallLocked(fullAddress, token, opts))) {
if (h323debug) { if (h323debug) {
cout << "Error making call to \"" << fullAddress << '"' << endl; cout << "Error making call to \"" << fullAddress << '"' << endl;
} }

View File

@@ -51,6 +51,7 @@ struct oh323_user {
char callerid[80]; char callerid[80];
char accountcode[20]; char accountcode[20];
int amaflags; int amaflags;
int capability;
int bridge; int bridge;
int nat; int nat;
int dtmfmode; int dtmfmode;