diff --git a/channels/chan_brcm.c b/channels/chan_brcm.c index aeee77a38dddf0a3e44e847e8650a3d7b967ac74..55e07a2b6b433fe55efb318ee71d2061495e0b0e 100644 --- a/channels/chan_brcm.c +++ b/channels/chan_brcm.c @@ -938,6 +938,22 @@ static int brcm_call(struct ast_channel *chan, const char *dest, int timeout) if(sub->channel_state == ALLOCATED) sub->channel_state = ONHOOK; brcm_send_ubus_event("USER_BUSY",p->line_id); + + struct brcm_pvt *tmp = p; + struct brcm_subchannel *s = NULL; + int con_id = -1; + + while(tmp) { + s = brcm_get_active_subchannel(tmp); + con_id = s->connection_id; + // for local call we need to find the other party and change its subchannel state to CALLENDED + // so the callStatus is properly set to Disconnected in brcm_answer() + if (con_id > 0 && (strncmp(tmp->callStatus, "Dialing", strlen(tmp->callStatus)) == 0)) { + s->channel_state = CALLENDED; + break; + } + tmp = brcm_get_next_pvt(tmp); + } } else { ast_debug(1, "Not call waiting\n"); @@ -1120,12 +1136,6 @@ static int brcm_answer(struct ast_channel *ast) ast_debug(1, "brcm_answer(%s)\n", ast_channel_name(ast)); pvt_lock(pvt, "TELCHAN answer"); - /*If the call is in RINGBACK state ,set status to connected */ - if(sub->channel_state == RINGBACK) - strncpy(pvt->callStatus, "Connected", CALL_STATUS_MAX_LEN); - else /*we arrive here in cases after hangup here ,so move to Disconnected state*/ - strncpy(pvt->callStatus, "Disconnected", CALL_STATUS_MAX_LEN); - /* For attended call transfer, if the transfer target has accepted the call initiated by * us as the tranferee, we can terminate the original call with the transferor */ if (sub->channel_state == TRANSFERING) { @@ -1158,6 +1168,11 @@ static int brcm_answer(struct ast_channel *ast) brcm_send_ubus_event("RINGING_OFF",pvt->line_id); endpt_signal(pvt->line_id, "ringback", "off", NULL); + if(sub->channel_state != CALLENDED) + strncpy(pvt->callStatus, "Connected", CALL_STATUS_MAX_LEN); + else + strncpy(pvt->callStatus, "Disconnected", CALL_STATUS_MAX_LEN); + pvt_unlock(pvt); return 0; @@ -1943,7 +1958,7 @@ static void handle_hookflash(struct brcm_subchannel *sub, struct brcm_subchannel struct ast_bridge_channel *bridge_channel; ast_log(LOG_NOTICE, "Hook Flash detected for phone line %d, p->dtmf_first = %d\r\n", sub->parent->line_id, p->dtmf_first); - + if (owner) { bridge = ast_channel_internal_bridge(owner); }