--- ../../asterisk-addons-1.6.1.0/channels/chan_ooh323.c 2009-06-17 22:11:14.000000000 +0400 +++ channels/chan_ooh323.c 2009-06-23 02:57:44.000000000 +0400 @@ -206,6 +206,7 @@ int onAlerting(ooCallData *call); int onProgress(ooCallData *call); int onNewCallCreated(ooCallData *call); +int onOutgoingCall(ooCallData *call); int onCallEstablished(ooCallData *call); int onCallCleared(ooCallData *call); @@ -261,7 +262,7 @@ static struct ast_channel *ooh323_new(struct ooh323_pvt *i, int state, - const char *host) + const char *host, int capability) { struct ast_channel *ch = NULL; int fmt; @@ -271,10 +272,12 @@ /* Don't hold a h323 pvt lock while we allocate a channel */ ast_mutex_unlock(&i->lock); - ch = ast_channel_alloc(1, state, i->callerid_num, i->callerid_name, i->accountcode, i->exten, i->context, i->amaflags, "OOH323/%s-%ld", host, callnumber); - ast_mutex_lock(&ooh323c_cn_lock); - callnumber++; - ast_mutex_unlock(&ooh323c_cn_lock); + ch = ast_channel_alloc(1, state, i->callerid_num, i->callerid_name, + i->accountcode, i->exten, i->context, i->amaflags, + "OOH323/%s-%ld", host, callnumber); + ast_mutex_lock(&ooh323c_cn_lock); + callnumber++; + ast_mutex_unlock(&ooh323c_cn_lock); ast_mutex_lock(&i->lock); @@ -282,10 +285,8 @@ ast_channel_lock(ch); ch->tech = &ooh323_tech; - /* ch->nativeformats = i->capability; */ - ch->nativeformats = 0; - - /* fmt = ast_best_codec(ch->nativeformats); */ + fmt = (capability) ? capability : i->capability; + ch->nativeformats = AST_FORMAT_SLINEAR; ch->fds[0] = ast_rtp_fd(i->rtp); ch->fds[1] = ast_rtcp_fd(i->rtp); @@ -296,10 +297,8 @@ ch->adsicpe = AST_ADSI_UNAVAILABLE; ch->writeformat = 0; ch->rawwriteformat = 0; - /* ch->rawwriteformat = fmt; */ ch->readformat = 0; ch->rawreadformat = 0; - /* ch->rawreadformat = fmt; */ ch->tech_pvt = i; i->owner = ch; @@ -321,18 +320,7 @@ ch->priority = 1; - /* Leak! it's done by ast_channel_alloc */ - /* if (i->callerid_name) - { - ch->cid.cid_name = strdup(i->callerid_name); - } - if (i->callerid_num) { - - ch->cid.cid_num = strdup(i->callerid_num); - } */ - - if(!ast_test_flag(i, H323_OUTGOING)) - { + if(!ast_test_flag(i, H323_OUTGOING)) { if (!ast_strlen_zero(i->caller_h323id)) { pbx_builtin_setvar_helper(ch, "_CALLER_H323ID", i->caller_h323id); @@ -365,8 +353,6 @@ ast_hangup(ch); ch = NULL; } - /* ast_set_flag(i, H323_NEEDSTART); - restart_monitor(); */ } } else ast_log(LOG_WARNING, "Unable to allocate channel structure\n"); @@ -489,7 +475,7 @@ ast_set_flag(p, H323_OUTGOING); - ast_copy_string(tmp, data, sizeof(tmp)); + ast_copy_string(tmp, data, sizeof(tmp)); dest = strchr(tmp, '/'); @@ -531,11 +517,11 @@ if (ext) ast_copy_string(p->exten, ext, sizeof(p->exten)); - if (peer->capability & format) { + /* if (peer->capability & format) { p->capability = peer->capability & format; - } else { + } else { */ p->capability = peer->capability; - } + /* } */ memcpy(&p->prefs, &peer->prefs, sizeof(struct ast_codec_pref)); p->dtmfmode = peer->dtmfmode; ast_copy_string(p->accountcode, peer->accountcode, sizeof(p->accountcode)); @@ -557,7 +543,7 @@ } - chan = ooh323_new(p, AST_STATE_DOWN, p->username); + chan = ooh323_new(p, AST_STATE_DOWN, p->username, format); ast_mutex_unlock(&p->lock); @@ -796,12 +782,13 @@ } if (ast->cid.cid_name) { - if(p->callerid_name) free(p->callerid_name); - p->callerid_name = strdup(ast->cid.cid_name); + if(p->callerid_name) free(p->callerid_name); + p->callerid_name = strdup(ast->cid.cid_name); } else{ ast->cid.cid_name = strdup(gCallerID); - if(p->callerid_name) free(p->callerid_name); + if(p->callerid_name) + free(p->callerid_name); p->callerid_name = strdup(ast->cid.cid_name); } @@ -814,7 +801,8 @@ if ((val = pbx_builtin_getvar_helper(ast, "CALLER_H323DIALEDDIGITS"))) { ast_copy_string(p->caller_dialedDigits, val, sizeof(p->caller_dialedDigits)); - if(!p->callerid_num) p->callerid_num = strdup(val); + if(!p->callerid_num) + p->callerid_num = strdup(val); } if ((val = pbx_builtin_getvar_helper(ast, "CALLER_H323EMAIL"))) { @@ -852,7 +840,7 @@ ast_mutex_unlock(&p->lock); if (res != OO_OK) { ast_log(LOG_ERROR, "Failed to make call\n"); - return -1; /* ToDO: cleanup */ + return -1; /* ToDO: cleanup */ } if (gH323Debug) ast_verbose("+++ ooh323_call\n"); @@ -1170,9 +1158,9 @@ if (p->owner->writeformat == 0) p->owner->writeformat = fmt; ast_set_write_format(p->owner, p->owner->writeformat); - /* if (p->owner->readformat == 0) + if (p->owner->readformat == 0) p->owner->readformat = fmt; - ast_set_read_format(p->owner, p->owner->readformat); */ + ast_set_read_format(p->owner, p->owner->readformat); ast_channel_unlock(p->owner); } else ast_log(LOG_ERROR, "No owner found\n"); @@ -1450,15 +1438,16 @@ /* if no extension found, set to default 's' */ if (ast_strlen_zero(p->exten)) { - p->exten[0]='s'; - p->exten[1]='\0'; + p->exten[0]='s'; + p->exten[1]='\0'; } - if (!p->callerid_name) { + /* May there isn't needed to setup ip as name */ + /* if (!p->callerid_name) { p->callerid_name = strdup(call->remoteIP); } - if (p->callerid_name) { + if (p->callerid_name) { */ user = find_user(p->callerid_name, call->remoteIP); if(user && (user->incominglimit == 0 || user->inUse < user->incominglimit)) { ast_mutex_lock(&user->lock); @@ -1491,15 +1480,14 @@ ast_set_flag(p, H323_NEEDDESTROY); return -1; } - } } - +/* } */ ooh323c_set_capability_for_call(call, &p->prefs, p->capability, p->dtmfmode); configure_local_rtp(p, call); /* Incoming call */ - c = ooh323_new(p, AST_STATE_RING, p->username); + c = ooh323_new(p, AST_STATE_RING, p->username, p->capability); if(!c) { ast_mutex_unlock(&p->lock); ast_log(LOG_ERROR, "Could not create ast_channel\n"); @@ -1516,6 +1504,68 @@ +int onOutgoingCall(ooCallData *call) +{ + struct ooh323_pvt *p = NULL; + int i = 0; + + if (gH323Debug) + ast_verbose("--- onOutgoingCall %lx: %s\n", call, call->callToken); + + if (strcmp(call->callType, "outgoing")) { + p = find_call(call); + if (!p) { + ast_log(LOG_ERROR, "Failed to find a matching call.\n"); + return -1; + } + ast_mutex_lock(&p->lock); + + if (p->callerid_name) { + ooCallSetCallerId(call, p->callerid_name); + } + if (p->callerid_num) { + i = 0; + while (*(p->callerid_num + i) != '\0') { + if(!isdigit(*(p->callerid_num+i))) { break; } + i++; + } + if(*(p->callerid_num+i) == '\0') + ooCallSetCallingPartyNumber(call, p->callerid_num); + else { + if(!p->callerid_name) + ooCallSetCallerId(call, p->callerid_num); + } + } + + if (!ast_strlen_zero(p->caller_h323id)) + ooCallAddAliasH323ID(call, p->caller_h323id); + + if (!ast_strlen_zero(p->caller_dialedDigits)) { + if (gH323Debug) { + ast_verbose("Setting dialed digits %s\n", p->caller_dialedDigits); + } + ooCallAddAliasDialedDigits(call, p->caller_dialedDigits); + } else if (p->callerid_num) { + if (ooIsDailedDigit(p->callerid_num)) { + if (gH323Debug) { + ast_verbose("setting callid number %s\n", p->callerid_num); + } + ooCallAddAliasDialedDigits(call, p->callerid_num); + } else if (ast_strlen_zero(p->caller_h323id)) { + ooCallAddAliasH323ID(call, p->callerid_num); + } + } + + + ast_mutex_unlock(&p->lock); + } + + if (gH323Debug) + ast_verbose("+++ onOutgoingCall %s\n", call->callToken); + return OO_OK; +} + + int onNewCallCreated(ooCallData *call) { struct ooh323_pvt *p = NULL; @@ -1545,12 +1595,12 @@ if (p->callerid_num) { i = 0; while (*(p->callerid_num + i) != '\0') { - if(!isdigit(*(p->callerid_num+i))) { break; } - i++; + if(!isdigit(*(p->callerid_num+i))) { break; } + i++; } if(*(p->callerid_num+i) == '\0') ooCallSetCallingPartyNumber(call, p->callerid_num); - else{ + else { if(!p->callerid_name) ooCallSetCallerId(call, p->callerid_num); } @@ -2664,7 +2714,7 @@ .onAlerting = onAlerting, .onProgress = onProgress, .onIncomingCall = NULL, - .onOutgoingCall = NULL, + .onOutgoingCall = onOutgoingCall, .onCallEstablished = onCallEstablished, .onCallCleared = onCallCleared, .openLogicalChannels = NULL, @@ -3465,8 +3515,8 @@ ast_set_read_format(p->owner, p->owner->readformat); ast_set_write_format(p->owner, p->owner->writeformat); } - if (!p->owner->readformat) - p->owner->readformat = p->owner->nativeformats; + /* if (!p->owner->readformat) + p->owner->readformat = p->owner->nativeformats; */ if ((p->dtmfmode & H323_DTMF_INBAND) && p->vad) { f = ast_dsp_process(p->owner, p->vad, f); --- ../../asterisk-addons-1.6.1.0/channels/ooh323c/src/oochannels.c 2009-06-02 05:29:32.000000000 +0400 +++ channels/ooh323c/src/oochannels.c 2009-06-20 19:46:54.000000000 +0400 @@ -1562,8 +1562,8 @@ return OO_FAILED; } - if(gH323ep.h323Callbacks.onOutgoingCall) - gH323ep.h323Callbacks.onOutgoingCall(call); + /* if(gH323ep.h323Callbacks.onOutgoingCall) + gH323ep.h323Callbacks.onOutgoingCall(call); */ break; case OOCallProceeding: OOTRACEINFO3("Sent Message - CallProceeding (%s, %s)\n", call->callType, --- ../../asterisk-addons-1.6.1.0/channels/ooh323c/src/ooq931.c 2009-06-23 03:00:18.000000000 +0400 +++ channels/ooh323c/src/ooq931.c 2009-06-23 01:52:38.000000000 +0400 @@ -1672,6 +1672,8 @@ /* Get cause value and h225 reason code corresponding to OOCallClearReason*/ ooQ931GetCauseAndReasonCodeFromCallClearReason(call->callEndReason, &cause, &h225ReasonCode); + if (call->q931cause == 0) + call->q931cause = cause; /* Set Cause IE */ ooQ931SetCauseIE(pctxt, q931msg, call->q931cause, 0, 0); @@ -2132,6 +2134,11 @@ } return OO_FAILED; } + + if(gH323ep.h323Callbacks.onOutgoingCall) { + /* Outgoing call callback function */ + gH323ep.h323Callbacks.onOutgoingCall(call); + } ret = ooH323MakeCall_helper(call); }