From 705f2dac84720c9c3d24d5c26f23733773077536 Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Tue, 4 Dec 2012 15:41:23 +0100 Subject: [PATCH] Fixed early audio with chan_lcr (Asterisk) If progress message is received, go into proceeding state. Send audio, if proceeding/alerting state, so RTP stream is sent in both directions. This is essential when using NAT. --- chan_lcr.c | 9 +++++++++ remote.cpp | 12 +++++++++--- remote.h | 1 + 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/chan_lcr.c b/chan_lcr.c index 1695056..4ebaccf 100644 --- a/chan_lcr.c +++ b/chan_lcr.c @@ -3012,6 +3012,15 @@ static int lcr_indicate(struct ast_channel *ast, int cond, const void *data, siz break; case AST_CONTROL_PROGRESS: CDEBUG(call, ast, "Received indicate AST_CONTROL_PROGRESS from Asterisk.\n"); + if (call->state == CHAN_LCR_STATE_IN_SETUP + || call->state == CHAN_LCR_STATE_IN_DIALING) { + CDEBUG(call, ast, "Changing to proceeding state, because no more dialing possible.\n"); + /* send message to lcr */ + memset(&newparam, 0, sizeof(union parameter)); + send_message(MESSAGE_PROCEEDING, call->ref, &newparam); + /* change state */ + call->state = CHAN_LCR_STATE_IN_PROCEEDING; + } /* request bchannel */ CDEBUG(call, ast, "Requesting audio path.\n"); memset(&newparam, 0, sizeof(union parameter)); diff --git a/remote.cpp b/remote.cpp index 4917f3b..f8c8621 100644 --- a/remote.cpp +++ b/remote.cpp @@ -24,6 +24,7 @@ Premote::Premote(int type, char *portname, struct port_settings *settings, struc p_r_ref = new_remote++; SCPY(p_r_remote_app, interface->remote_app); p_r_tones = (interface->is_tones == IS_YES); + p_r_earlyb = (interface->is_earlyb == IS_YES); /* send new ref to remote socket */ memset(¶m, 0, sizeof(union parameter)); @@ -233,9 +234,14 @@ int Premote::bridge_rx(unsigned char *data, int len) union parameter newparam; int l; - /* don't send tones, if not enabled or not connected */ - if (!p_r_tones - && p_state != PORT_STATE_CONNECT) + /* send tones, if connected, or if early audio is enabled in proceeding/alerting state */ + if (p_state != PORT_STATE_CONNECT + && !(p_r_earlyb + && (p_state == PORT_STATE_OUT_PROCEEDING + || p_state == PORT_STATE_OUT_ALERTING)) + && !(p_r_tones + && (p_state == PORT_STATE_IN_PROCEEDING + || p_state == PORT_STATE_IN_ALERTING))) return 0; if (p_tone_name[0]) diff --git a/remote.h b/remote.h index f7afa6a..5b4d284 100644 --- a/remote.h +++ b/remote.h @@ -11,6 +11,7 @@ class Premote : public Port int p_r_remote_id; /* remote instance (socket) */ char p_r_remote_app[32]; int p_r_tones; + int p_r_earlyb; int message_epoint(unsigned int epoint_id, int message_id, union parameter *param); void message_remote(int message_type, union parameter *param); -- 2.13.6