mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-26 12:37:09 +08:00
修复rtp存在ext时无法解析的bug:#585
This commit is contained in:
parent
43164d3670
commit
dc3701e6cc
@ -101,16 +101,18 @@ bool RtpReceiver::handleOneRtp(int track_index, TrackType type, int samplerate,
|
|||||||
//ssrc匹配正确,不匹配计数清零
|
//ssrc匹配正确,不匹配计数清零
|
||||||
_ssrc_err_count[track_index] = 0;
|
_ssrc_err_count[track_index] = 0;
|
||||||
|
|
||||||
//获取rtp中媒体数据偏移量
|
//rtp 12个固定字节头
|
||||||
rtp.offset = 12 + 4;
|
rtp.offset = 12;
|
||||||
|
//rtp有csrc
|
||||||
rtp.offset += 4 * csrc;
|
rtp.offset += 4 * csrc;
|
||||||
if (ext && rtp_raw_len >= rtp.offset) {
|
if (ext) {
|
||||||
/* calculate the header extension length (stored as number of 32-bit words) */
|
//rtp有ext
|
||||||
ext = (AV_RB16(rtp_raw_ptr + rtp.offset - 2) + 1) << 2;
|
uint16_t reserved = AV_RB16(rtp_raw_ptr + rtp.offset);
|
||||||
rtp.offset += ext;
|
uint16_t extlen = AV_RB16(rtp_raw_ptr + rtp.offset + 2) << 2;
|
||||||
|
rtp.offset += extlen + 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rtp_raw_len + 4 <= rtp.offset) {
|
if (rtp_raw_len <= rtp.offset) {
|
||||||
WarnL << "无有效负载的rtp包:" << rtp_raw_len << " <= " << (int) rtp.offset;
|
WarnL << "无有效负载的rtp包:" << rtp_raw_len << " <= " << (int) rtp.offset;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -128,9 +130,10 @@ bool RtpReceiver::handleOneRtp(int track_index, TrackType type, int samplerate,
|
|||||||
payload_ptr[1] = rtp.interleaved;
|
payload_ptr[1] = rtp.interleaved;
|
||||||
payload_ptr[2] = rtp_raw_len >> 8;
|
payload_ptr[2] = rtp_raw_len >> 8;
|
||||||
payload_ptr[3] = (rtp_raw_len & 0x00FF);
|
payload_ptr[3] = (rtp_raw_len & 0x00FF);
|
||||||
|
//添加rtp over tcp前4个字节的偏移量
|
||||||
|
rtp.offset += 4;
|
||||||
//拷贝rtp负载
|
//拷贝rtp负载
|
||||||
memcpy(payload_ptr + 4, rtp_raw_ptr, rtp_raw_len);
|
memcpy(payload_ptr + 4, rtp_raw_ptr, rtp_raw_len);
|
||||||
|
|
||||||
//排序rtp
|
//排序rtp
|
||||||
auto seq = rtp_ptr->sequence;
|
auto seq = rtp_ptr->sequence;
|
||||||
_rtp_sortor[track_index].sortPacket(seq, std::move(rtp_ptr));
|
_rtp_sortor[track_index].sortPacket(seq, std::move(rtp_ptr));
|
||||||
|
Loading…
Reference in New Issue
Block a user