From 7d79e63a484c89b2329a51ca4c83a42ce2d8ff96 Mon Sep 17 00:00:00 2001 From: philipel Date: Tue, 23 May 2017 08:19:11 -0700 Subject: [PATCH] Cast sequence number in RtpFrameObject. BUG=webrtc:7700 Review-Url: https://codereview.webrtc.org/2902743002 Cr-Commit-Position: refs/heads/master@{#18237} --- webrtc/modules/video_coding/frame_object.cc | 9 +++++---- .../video_packet_buffer_unittest.cc | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/webrtc/modules/video_coding/frame_object.cc b/webrtc/modules/video_coding/frame_object.cc index bfe720fb5b..f2a5ab2719 100644 --- a/webrtc/modules/video_coding/frame_object.cc +++ b/webrtc/modules/video_coding/frame_object.cc @@ -35,7 +35,7 @@ RtpFrameObject::RtpFrameObject(PacketBuffer* packet_buffer, received_time_(received_time), times_nacked_(times_nacked) { VCMPacket* first_packet = packet_buffer_->GetPacket(first_seq_num); - RTC_DCHECK(first_packet); + RTC_CHECK(first_packet); // RtpFrameObject members frame_type_ = first_packet->frameType; @@ -74,10 +74,11 @@ RtpFrameObject::RtpFrameObject(PacketBuffer* packet_buffer, _frameType = kVideoFrameDelta; frame_type_ = kVideoFrameDelta; for (uint16_t seq_num = first_seq_num; - seq_num != last_seq_num + 1 && _frameType == kVideoFrameDelta; + seq_num != static_cast(last_seq_num + 1) && + _frameType == kVideoFrameDelta; ++seq_num) { VCMPacket* packet = packet_buffer_->GetPacket(seq_num); - RTC_DCHECK(packet); + RTC_CHECK(packet); const RTPVideoHeaderH264& header = packet->video_header.codecHeader.H264; for (size_t i = 0; i < header.nalus_length; ++i) { if (header.nalus[i].type == H264::NaluType::kIdr) { @@ -100,7 +101,7 @@ RtpFrameObject::RtpFrameObject(PacketBuffer* packet_buffer, timestamp = first_packet->timestamp; VCMPacket* last_packet = packet_buffer_->GetPacket(last_seq_num); - RTC_DCHECK(last_packet && last_packet->markerBit); + RTC_CHECK(last_packet && last_packet->markerBit); // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ // ts_126114v120700p.pdf Section 7.4.5. // The MTSI client shall add the payload bytes as defined in this clause diff --git a/webrtc/modules/video_coding/video_packet_buffer_unittest.cc b/webrtc/modules/video_coding/video_packet_buffer_unittest.cc index e418d12466..c5d1fce81d 100644 --- a/webrtc/modules/video_coding/video_packet_buffer_unittest.cc +++ b/webrtc/modules/video_coding/video_packet_buffer_unittest.cc @@ -502,6 +502,25 @@ TEST_F(TestPacketBuffer, OneH264FrameFillBuffer) { CheckFrame(0); } +TEST_F(TestPacketBuffer, OneH264FrameMaxSeqNum) { + VCMPacket packet; + packet.seqNum = 65534; + packet.codec = kVideoCodecH264; + packet.dataPtr = nullptr; + packet.sizeBytes = 0; + packet.is_first_packet_in_frame = true; + packet.markerBit = false; + packet_buffer_->InsertPacket(&packet); + + packet.is_first_packet_in_frame = false; + packet.seqNum = 65535; + packet.markerBit = true; + packet_buffer_->InsertPacket(&packet); + + EXPECT_EQ(1UL, frames_from_callback_.size()); + CheckFrame(65534); +} + TEST_F(TestPacketBuffer, PacketTimestamps) { rtc::Optional packet_ms; rtc::Optional packet_keyframe_ms;