修复判断是否为增强型rtmp协议相关bug

有符合整型右移7位可能为-1(而不是1)
这样将导致在处理增强型rtmp时,判断关键帧和配置帧失败
This commit is contained in:
xia-chu 2023-07-22 20:08:54 +08:00
parent 3e9a8b9d8b
commit b580d6c736

View File

@ -157,7 +157,7 @@ bool RtmpPacket::isVideoKeyFrame() const {
return false; return false;
} }
RtmpFrameType frame_type; RtmpFrameType frame_type;
if (buffer[0] >> 7 == 1) { if (buffer[0] >> 7) {
// IsExHeader == 1 // IsExHeader == 1
frame_type = (RtmpFrameType)((buffer[0] >> 4) & 0x07); frame_type = (RtmpFrameType)((buffer[0] >> 4) & 0x07);
} else { } else {
@ -176,7 +176,7 @@ bool RtmpPacket::isConfigFrame() const {
if (!isVideoKeyFrame()) { if (!isVideoKeyFrame()) {
return false; return false;
} }
if (buffer[0] >> 7 == 1) { if (buffer[0] >> 7) {
// IsExHeader == 1 // IsExHeader == 1
return (RtmpPacketType)(buffer[0] & 0x0f) == RtmpPacketType::PacketTypeSequenceStart; return (RtmpPacketType)(buffer[0] & 0x0f) == RtmpPacketType::PacketTypeSequenceStart;
} }
@ -263,7 +263,7 @@ CodecId parseVideoRtmpPacket(const uint8_t *data, size_t size, RtmpPacketInfo *i
info->codec = CodecInvalid; info->codec = CodecInvalid;
CHECK(size > 0); CHECK(size > 0);
if (data[0] >> 7 == 1) { if (data[0] >> 7) {
// IsExHeader == 1 // IsExHeader == 1
CHECK(size >= 5, "Invalid rtmp buffer size: ", size); CHECK(size >= 5, "Invalid rtmp buffer size: ", size);
info->is_enhanced = true; info->is_enhanced = true;