Fixed early audio with chan_lcr (Asterisk)
authorAndreas Eversberg <jolly@eversberg.eu>
Tue, 4 Dec 2012 14:41:23 +0000 (15:41 +0100)
committerAndreas Eversberg <jolly@eversberg.eu>
Sun, 16 Dec 2012 09:11:47 +0000 (10:11 +0100)
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
remote.cpp
remote.h

index 1695056..4ebaccf 100644 (file)
@@ -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));
index 4917f3b..f8c8621 100644 (file)
@@ -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(&param, 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])
index f7afa6a..5b4d284 100644 (file)
--- 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);