Only receive RTP audio data, if connected to remote.
[lcr.git] / sip.cpp
diff --git a/sip.cpp b/sip.cpp
index 4d5be39..ee455a8 100644 (file)
--- a/sip.cpp
+++ b/sip.cpp
@@ -62,6 +62,8 @@ Psip::Psip(int type, char *portname, struct port_settings *settings, struct inte
        p_s_rtp_tx_action = 0;
 
        PDEBUG(DEBUG_SIP, "Created new Psip(%s).\n", portname);
+       if (!p_s_sip_inst)
+               FATAL("No SIP instance for interface\n");
 }
 
 
@@ -256,6 +258,11 @@ we only support alaw and ulaw!
        n = payload_len;
        from = payload;
        to = payload;
+       if (psip->p_echotest) {
+               /* echo rtp data we just received */
+               psip->rtp_send_frame(from, n, (options.law=='a')?PAYLOAD_TYPE_ALAW:PAYLOAD_TYPE_ULAW);
+               return 0;
+       }
        while(n--)
                *to++ = flip[*from++];
        psip->bridge_tx(payload, payload_len);
@@ -278,7 +285,8 @@ static int rtp_sock_callback(struct lcr_fd *fd, unsigned int what, void *instanc
 //                     psip->rtp_shutdown();
                        return len;
                }
-               rc = rtp_decode(psip, buffer, len);
+               if (psip->p_s_rtp_is_connected)
+                       rc = rtp_decode(psip, buffer, len);
        }
 
        return rc;