]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-7499: trying to fix rtp data len when rtp extension is used
authorSeven Du <dujinfang@gmail.com>
Tue, 10 Feb 2015 07:38:15 +0000 (15:38 +0800)
committerMichael Jerris <mike@jerris.com>
Thu, 28 May 2015 17:46:59 +0000 (12:46 -0500)
duplicated some code from 4943~4953, but that code has it's own problem, it forget to reset *bytes results to
larger frame->datalen could read beyond the buffer, and it also makes stats not accurate. But if we reset *bytes
at that place, then later the switch_vb_put_packet has problem because it depends that *bytes. this patch should
fix the datalen at least buf still leaves duplicated code and inaccurate stats.

src/switch_rtp.c

index b9db435eae7d05bd1c8808e1370bb322e74cc39d..2da7671b4a15db8a10e966983fcad1adbfa3e1a0 100644 (file)
@@ -5234,6 +5234,24 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t
                }
        }
 
+       /* recalculate body length in case rtp extension used */
+       if (!rtp_session->flags[SWITCH_RTP_FLAG_PROXY_MEDIA] && !rtp_session->flags[SWITCH_RTP_FLAG_UDPTL] &&
+               rtp_session->recv_msg.header.version == 2 && rtp_session->recv_msg.header.x) { /* header extensions */
+               uint16_t length;
+
+               rtp_session->recv_msg.ext = (switch_rtp_hdr_ext_t *) rtp_session->recv_msg.body;
+               length = ntohs((uint16_t)rtp_session->recv_msg.ext->length);
+
+               if (length < SWITCH_RTP_MAX_BUF_LEN_WORDS) {
+                       rtp_session->recv_msg.ebody = rtp_session->recv_msg.body + (length * 4) + 4;
+                       if (*bytes > (length * 4 + 4)) {
+                               *bytes -= (length * 4 + 4);
+                       } else {
+                               *bytes = 0;
+                       }
+               }
+       }
+
        return status;
 }