]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
update
authorAnthony Minessale <anthony.minessale@gmail.com>
Wed, 26 Nov 2008 15:22:26 +0000 (15:22 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Wed, 26 Nov 2008 15:22:26 +0000 (15:22 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10540 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_apr.h
src/switch_apr.c
src/switch_rtp.c

index 608b4762e2a9d0274a1d4c973fc3d4c6059c2723..94fb61d5f9e1f5be5a42c7b70312bf66c32c0eb8 100644 (file)
@@ -1123,6 +1123,7 @@ SWITCH_DECLARE(switch_status_t) switch_socket_sendto(switch_socket_t *sock, swit
  */
 SWITCH_DECLARE(switch_status_t) switch_socket_recvfrom(switch_sockaddr_t *from, switch_socket_t *sock, int32_t flags, char *buf, size_t *len);
 
+SWITCH_DECLARE(switch_status_t) switch_socket_atmark(switch_socket_t *sock, int *atmark);
 
 /**
  * Read data from a network.
index b21018cd2c08ee21e2705e8f3862bd53b88efaea..54eae09eca3e3b21feea7ba8624a42f26b9ba089 100644 (file)
@@ -754,6 +754,11 @@ SWITCH_DECLARE(int32_t) switch_sockaddr_get_family(switch_sockaddr_t *sa)
        return sa->family;
 }
 
+SWITCH_DECLARE(switch_status_t) switch_socket_atmark(switch_socket_t *sock, int *atmark)
+{
+       return apr_socket_atmark(sock, atmark);
+}
+
 SWITCH_DECLARE(switch_status_t) switch_socket_recvfrom(switch_sockaddr_t *from, switch_socket_t *sock, int32_t flags, char *buf, size_t *len)
 {
        apr_status_t r;
index fa386ea1b8c1111011a5d9aa9b4d3dd2b8b088f0..7738dfb2cdcc84dcec7b90ad82d598f688a1d2f9 100644 (file)
@@ -1269,32 +1269,35 @@ SWITCH_DECLARE(void) rtp_flush_read_buffer(switch_rtp_t *rtp_session)
        switch_size_t bytes;
        switch_status_t status;
 
-       if (!switch_rtp_ready(rtp_session)) {
+       if (!switch_rtp_ready(rtp_session) || switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA)) {
                return;
        }
-
+       
        READ_INC(rtp_session);
 
-       if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_NOBLOCK)) {
-               was_blocking = 1;
-               switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_NOBLOCK);           
-               switch_socket_opt_set(rtp_session->sock_input, SWITCH_SO_NONBLOCK, TRUE);
-       }
+       if (switch_rtp_ready(rtp_session)) {
+               if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_NOBLOCK)) {
+                       was_blocking = 1;
+                       switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_NOBLOCK);           
+                       switch_socket_opt_set(rtp_session->sock_input, SWITCH_SO_NONBLOCK, TRUE);
+               }
        
-       do {
-               bytes = sizeof(rtp_msg_t);
-               status = switch_socket_recvfrom(rtp_session->from_addr, rtp_session->sock_input, 0, (void *) &rtp_session->recv_msg, &bytes);
-       } while(bytes);
-
-       if (was_blocking) {
-               switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_NOBLOCK);
-        switch_socket_opt_set(rtp_session->sock_input, SWITCH_SO_NONBLOCK, FALSE);
+               do {
+                       if (switch_rtp_ready(rtp_session)) {
+                               bytes = sizeof(rtp_msg_t);
+                               status = switch_socket_recvfrom(rtp_session->from_addr, rtp_session->sock_input, 0, (void *) &rtp_session->recv_msg, &bytes);
+                       } else {
+                               break;
+                       }
+               } while(bytes > 0);
+               
+               if (was_blocking && switch_rtp_ready(rtp_session)) {
+                       switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_NOBLOCK);
+                       switch_socket_opt_set(rtp_session->sock_input, SWITCH_SO_NONBLOCK, FALSE);
+               }
        }
        
        READ_DEC(rtp_session);
-
-
-
 }
 
 #define return_cng_frame() do_cng = 1; goto timer_check