From 289e4f695ad05ce641fb3668b9f9ed8dff301979 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sat, 24 Oct 2020 23:32:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=A1=E9=AA=8Crtp=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E5=90=88=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Rtsp/RtpReceiver.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Rtsp/RtpReceiver.cpp b/src/Rtsp/RtpReceiver.cpp index 1509f1e0..3ae03e01 100644 --- a/src/Rtsp/RtpReceiver.cpp +++ b/src/Rtsp/RtpReceiver.cpp @@ -36,7 +36,11 @@ bool RtpReceiver::handleOneRtp(int track_index, TrackType type, int samplerate, return false; } + uint32_t version = rtp_raw_ptr[0] >> 6; uint8_t padding = 0; + uint8_t ext = rtp_raw_ptr[0] & 0x10; + uint8_t csrc = rtp_raw_ptr[0] & 0x0f; + if (rtp_raw_ptr[0] & 0x20) { //获取padding大小 padding = rtp_raw_ptr[rtp_raw_len - 1]; @@ -46,6 +50,10 @@ bool RtpReceiver::handleOneRtp(int track_index, TrackType type, int samplerate, rtp_raw_len -= padding; } + if (version != 2) { + throw std::invalid_argument("非法的rtp,version != 2"); + } + auto rtp_ptr = _rtp_pool.obtain(); auto &rtp = *rtp_ptr; @@ -95,8 +103,6 @@ bool RtpReceiver::handleOneRtp(int track_index, TrackType type, int samplerate, //获取rtp中媒体数据偏移量 rtp.offset = 12 + 4; - int csrc = rtp_raw_ptr[0] & 0x0f; - int ext = rtp_raw_ptr[0] & 0x10; rtp.offset += 4 * csrc; if (ext && rtp_raw_len >= rtp.offset) { /* calculate the header extension length (stored as number of 32-bit words) */