Fix codec negiocation on inbound calls. Bugs 3980, 4021, 4045
authorJeremy McNamara <jj@nufone.net>
Fri, 29 Apr 2005 04:22:47 +0000 (04:22 +0000)
committerJeremy McNamara <jj@nufone.net>
Fri, 29 Apr 2005 04:22:47 +0000 (04:22 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5526 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_h323.c
channels/h323/ast_h323.cpp

index 351237b..d27e816 100755 (executable)
@@ -559,6 +559,7 @@ static struct oh323_peer *build_peer(char *name, struct ast_variable *v)
 static int oh323_digit(struct ast_channel *c, char digit)
 {
        struct oh323_pvt *p = (struct oh323_pvt *) c->tech_pvt;
+       char *token;
        if (h323debug)
                ast_log(LOG_DEBUG, "Sending digit %c on %s\n", digit, c->name);
        if (!p)
@@ -569,10 +570,15 @@ static int oh323_digit(struct ast_channel *c, char digit)
        }
        /* If in-band DTMF is desired, send that */
        if ((p->dtmfmode & H323_DTMF_INBAND)) {
-               h323_send_tone(p->cd.call_token, digit);
+               token = p->cd.call_token ? strdup(p->cd.call_token) : NULL;
+               ast_mutex_unlock(&p->lock);
+               h323_send_tone(token, digit);
+               if (token)
+                       free(token);
+               oh323_update_info(c);
        }
-       ast_mutex_unlock(&p->lock);
-       oh323_update_info(c);
+       else
+               ast_mutex_unlock(&p->lock);
        return 0;
 }
 
@@ -1014,6 +1020,7 @@ static struct oh323_pvt *oh323_alloc(int callid)
        pvt->cd.call_reference = callid;
        pvt->bridge = bridging; 
        pvt->dtmfmode = dtmfmode;
+       pvt->capability = capability;
        if (pvt->dtmfmode & H323_DTMF_RFC2833) {
                pvt->nonCodecCapability |= AST_RTP_DTMF;
        }
@@ -1194,10 +1201,6 @@ static struct ast_channel *oh323_request(const char *type, int format, void *dat
                ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%d'\n", format);
                return NULL;
        }
-       /* Assign default capabilities */
-       pvt->capability = capability;
-       pvt->dtmfmode = H323_DTMF_RFC2833;
-
        strncpy(tmp, dest, sizeof(tmp) - 1);    
        host = strchr(tmp, '@');
        if (host) {
@@ -1222,6 +1225,8 @@ static struct ast_channel *oh323_request(const char *type, int format, void *dat
                        return NULL;
                }
        }
+       else
+               memcpy(&pvt->options, &global_options, sizeof(pvt->options));
 
        /* pass on our capabilites to the H.323 stack */
        ast_mutex_lock(&caplock);
@@ -1291,7 +1296,7 @@ struct rtp_info *external_rtp_create(unsigned call_reference, const char * token
        struct oh323_pvt *pvt;
        struct sockaddr_in us;
        struct rtp_info *info;
-               static char iabuf[INET_ADDRSTRLEN];
+       char iabuf[INET_ADDRSTRLEN];
 
        info = (struct rtp_info *)malloc(sizeof(struct rtp_info));
        if (!info) {
@@ -2405,6 +2410,12 @@ int unload_module()
        }
        h323_gk_urq();
        h323_end_process();
+       io_context_destroy(io);
+       sched_context_destroy(sched);
+       delete_users();
+       delete_aliases();
+       prune_peers();
+       ast_mutex_destroy(&aliasl.lock);
        ast_mutex_destroy(&userl.lock);
        ast_mutex_destroy(&peerl.lock);
        return 0; 
index cf1c33c..80cabd6 100755 (executable)
@@ -97,7 +97,7 @@ int PAsteriskLog::Buffer::overflow(int c)
 {
        if (pptr() >= epptr()) {
                int ppos = pptr() - pbase();
-               char *newptr = string.GetPointer(string.GetSize() + 10);
+               char *newptr = string.GetPointer(string.GetSize() + 2000);
                setp(newptr, newptr + string.GetSize() - 1);
                pbump(ppos);
        }
@@ -134,7 +134,7 @@ int PAsteriskLog::Buffer::sync()
        free(str);
 
        string = PString();
-       char *base = string.GetPointer(10);
+       char *base = string.GetPointer(2000);
        setp(base, base + string.GetSize() - 1);
        return 0;
 }
@@ -1092,6 +1092,7 @@ void h323_end_process(void)
        endPoint->ClearAllCalls();
        endPoint->RemoveListener(NULL);
        delete endPoint;
+       endPoint = NULL;
        PTrace::SetLevel(0);
        delete localProcess;
        delete logstream;