From: Super User Date: Thu, 24 Jul 2008 17:19:56 +0000 (+0200) Subject: fixed overlap dialing problem: X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=commitdiff_plain;h=3d7276bc7559bb15a6eb35dacdc2afb708ef047e fixed overlap dialing problem: -> YES, you may now overlap dial through asterisk fixed answering call when bridging, because asterisk will not call lcr_answer when bridging. modified: chan_lcr.c --- diff --git a/chan_lcr.c b/chan_lcr.c index 7eabe0e..5978865 100644 --- a/chan_lcr.c +++ b/chan_lcr.c @@ -690,7 +690,6 @@ static void lcr_start_pbx(struct chan_call *call, struct ast_channel *ast, int c /* change state */ call->state = CHAN_LCR_STATE_IN_PROCEEDING; - ast_setstate(ast, AST_STATE_OFFHOOK); goto start; } @@ -705,7 +704,6 @@ static void lcr_start_pbx(struct chan_call *call, struct ast_channel *ast, int c /* change state */ call->state = CHAN_LCR_STATE_IN_DIALING; - ast_setstate(ast, AST_STATE_OFFHOOK); /* if match, start pbx */ if (ast_exists_extension(ast, ast->context, ast->exten, 1, call->oad)) { @@ -742,6 +740,10 @@ static void lcr_start_pbx(struct chan_call *call, struct ast_channel *ast, int c goto release; } call->pbx_started = 1; +// if (call->state == CHAN_LCR_STATE_IN_DIALING) +// ast_setstate(ast, AST_STATE_DIALING); +// else +// ast_setstate(ast, AST_STATE_OFFHOOK); return; } @@ -996,6 +998,13 @@ static void lcr_in_information(struct chan_call *call, int message_type, union p return; } + /* change dailing state after setup */ + if (call->state == CHAN_LCR_STATE_IN_SETUP) { + CDEBUG(call, call->ast, "Changing from SETUP to DIALING state.\n"); + call->state = CHAN_LCR_STATE_IN_DIALING; +// ast_setstate(ast, AST_STATE_DIALING); + } + /* queue digits */ if (call->state == CHAN_LCR_STATE_IN_DIALING && param->information.id[0]) strncat(call->queue_string, param->information.id, sizeof(call->queue_string)-1); @@ -1520,10 +1529,11 @@ static int queue_send(void) CDEBUG(call, ast, "Sending queued digit '%c' to Asterisk.\n", *p); /* send digit to asterisk */ memset(&fr, 0, sizeof(fr)); - fr.frametype = AST_FRAME_DTMF; + fr.frametype = AST_FRAME_DTMF_BEGIN; fr.subclass = *p; fr.delivery = ast_tv(0, 0); - fr.len = 100; + ast_queue_frame(ast, &fr); + fr.frametype = AST_FRAME_DTMF_END; ast_queue_frame(ast, &fr); break; default: @@ -1823,17 +1833,19 @@ static int lcr_answer(struct ast_channel *ast) return -1; } - CDEBUG(call, ast, "Received answer from Asterisk.\n"); + CDEBUG(call, ast, "Received answer from Asterisk (maybe during lcr_bridge).\n"); /* copy connectinfo, if bridged */ if (call->bridge_call) memcpy(&call->connectinfo, &call->bridge_call->connectinfo, sizeof(struct connect_info)); /* send connect message to lcr */ - memset(&newparam, 0, sizeof(union parameter)); - memcpy(&newparam.connectinfo, &call->connectinfo, sizeof(struct connect_info)); - send_message(MESSAGE_CONNECT, call->ref, &newparam); + if (call->state != CHAN_LCR_STATE_CONNECT) { + memset(&newparam, 0, sizeof(union parameter)); + memcpy(&newparam.connectinfo, &call->connectinfo, sizeof(struct connect_info)); + send_message(MESSAGE_CONNECT, call->ref, &newparam); + call->state = CHAN_LCR_STATE_CONNECT; + } /* change state */ - call->state = CHAN_LCR_STATE_CONNECT; /* request bchannel */ if (!call->bchannel) { CDEBUG(call, ast, "Requesting B-channel.\n"); @@ -2143,7 +2155,7 @@ enum ast_bridge_result lcr_bridge(struct ast_channel *ast1, carr[0] = ast1; carr[1] = ast2; - + /* join via dsp (if the channels are currently open) */ ast_mutex_lock(&chan_lock); bridge_id = new_bridge_id(); @@ -2163,6 +2175,22 @@ enum ast_bridge_result lcr_bridge(struct ast_channel *ast1, bchannel_join(call2->bchannel, bridge_id); call2->bridge_call = call1; } + + if (call1->state == CHAN_LCR_STATE_IN_SETUP + || call1->state == CHAN_LCR_STATE_IN_DIALING + || call1->state == CHAN_LCR_STATE_IN_PROCEEDING + || call1->state == CHAN_LCR_STATE_IN_ALERTING) { + CDEBUG(call1, ast1, "Bridge established before lcr_answer, so we call it ourself: Calling lcr_answer...\n"); + lcr_answer(ast1); + } + if (call2->state == CHAN_LCR_STATE_IN_SETUP + || call2->state == CHAN_LCR_STATE_IN_DIALING + || call2->state == CHAN_LCR_STATE_IN_PROCEEDING + || call2->state == CHAN_LCR_STATE_IN_ALERTING) { + CDEBUG(call2, ast2, "Bridge established before lcr_answer, so we call it ourself: Calling lcr_answer...\n"); + lcr_answer(ast2); + } + ast_mutex_unlock(&chan_lock); while(1) {