]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
prevent writes if we dont have a remote addr
authorMathieu Rene <mrene@avgs.ca>
Thu, 26 Jul 2012 02:24:12 +0000 (22:24 -0400)
committerMathieu Rene <mrene@avgs.ca>
Thu, 26 Jul 2012 02:24:12 +0000 (22:24 -0400)
src/mod/endpoints/mod_sofia/rtp.c

index b24bb1653aa8d1914a52b7deefa837d26e8be87f..a12b3c6e558ed5af7e977dec4b4ad56f25370698 100644 (file)
@@ -188,11 +188,12 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
     tech_pvt->dtmf_type = DTMF_2833; /* XXX */
     
     if (zstr(local_addr) || local_port == 0) {
-        tech_pvt->mode = RTP_SENDONLY;
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "The local address and port must be set\n");
+        goto fail;
     } else if (zstr(remote_addr) || remote_port == 0) {
-        tech_pvt->mode = RTP_SENDRECV;
+        tech_pvt->mode = RTP_RECVONLY;
     } else {
-        
+        tech_pvt->mode = RTP_SENDRECV;
     }
     
     switch_core_session_set_private(*new_session, tech_pvt);
@@ -314,7 +315,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
        tech_pvt = switch_core_session_get_private(session);
        assert(tech_pvt != NULL);
     
-    if (!tech_pvt->rtp_session) {
+    if (!tech_pvt->rtp_session || tech_pvt->mode == RTP_RECVONLY) {
         goto cng;
     }
         
@@ -429,6 +430,7 @@ static switch_status_t channel_receive_event(switch_core_session_t *session, swi
                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error setting RTP remote address: %s\n", err);
             } else {
                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Set RTP remote: %s:%d\n", remote_addr, (int)remote_port);
+                tech_pvt->mode = RTP_SENDRECV;
             }
         }
         
@@ -439,6 +441,15 @@ static switch_status_t channel_receive_event(switch_core_session_t *session, swi
             /* Reset codec */
             switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Switching codec not yet implemented\n");
         }
+        
+        if (compare_var(event, channel, kRFC2833PT)) {
+            const char *szpt = switch_channel_get_variable(channel, kRFC2833PT);
+            int pt = !zstr(szpt) ? atoi(szpt) : 0;
+            
+            switch_channel_set_variable(channel, kRFC2833PT, szpt);
+            switch_rtp_set_telephony_event(tech_pvt->rtp_session, pt);
+        }
+    
     } else {
         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Received unknown command [%s] in event.\n", !command ? "null" : command);
     }