| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include <list> | 13 #include <list> |
| 14 #include <memory> | 14 #include <memory> |
| 15 #include <vector> |
| 15 | 16 |
| 16 #include "webrtc/test/gtest.h" | 17 #include "webrtc/common_video/h264/h264_common.h" |
| 17 #include "webrtc/test/gmock.h" | |
| 18 #include "webrtc/modules/video_coding/frame_buffer.h" | 18 #include "webrtc/modules/video_coding/frame_buffer.h" |
| 19 #include "webrtc/modules/video_coding/jitter_buffer.h" | 19 #include "webrtc/modules/video_coding/jitter_buffer.h" |
| 20 #include "webrtc/modules/video_coding/media_opt_util.h" | 20 #include "webrtc/modules/video_coding/media_opt_util.h" |
| 21 #include "webrtc/modules/video_coding/packet.h" | 21 #include "webrtc/modules/video_coding/packet.h" |
| 22 #include "webrtc/modules/video_coding/test/stream_generator.h" | 22 #include "webrtc/modules/video_coding/test/stream_generator.h" |
| 23 #include "webrtc/modules/video_coding/test/test_util.h" | 23 #include "webrtc/modules/video_coding/test/test_util.h" |
| 24 #include "webrtc/system_wrappers/include/clock.h" | 24 #include "webrtc/system_wrappers/include/clock.h" |
| 25 #include "webrtc/system_wrappers/include/field_trial.h" | 25 #include "webrtc/system_wrappers/include/field_trial.h" |
| 26 #include "webrtc/system_wrappers/include/metrics.h" | 26 #include "webrtc/system_wrappers/include/metrics.h" |
| 27 #include "webrtc/system_wrappers/include/metrics_default.h" | 27 #include "webrtc/system_wrappers/include/metrics_default.h" |
| 28 #include "webrtc/test/field_trial.h" | 28 #include "webrtc/test/field_trial.h" |
| 29 #include "webrtc/test/gmock.h" |
| 30 #include "webrtc/test/gtest.h" |
| 29 | 31 |
| 30 namespace webrtc { | 32 namespace webrtc { |
| 31 | 33 |
| 32 namespace { | 34 namespace { |
| 33 const uint32_t kProcessIntervalSec = 60; | 35 const uint32_t kProcessIntervalSec = 60; |
| 34 } // namespace | 36 } // namespace |
| 35 | 37 |
| 36 class Vp9SsMapTest : public ::testing::Test { | 38 class Vp9SsMapTest : public ::testing::Test { |
| 37 protected: | 39 protected: |
| 38 Vp9SsMapTest() : packet_() {} | 40 Vp9SsMapTest() : packet_() {} |
| (...skipping 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1153 | 1155 |
| 1154 EXPECT_EQ(kCompleteSession, | 1156 EXPECT_EQ(kCompleteSession, |
| 1155 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1157 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
| 1156 | 1158 |
| 1157 frame_out = DecodeCompleteFrame(); | 1159 frame_out = DecodeCompleteFrame(); |
| 1158 CheckOutFrame(frame_out, size_ * 2 + 4 * 2, true); | 1160 CheckOutFrame(frame_out, size_ * 2 + 4 * 2, true); |
| 1159 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); | 1161 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); |
| 1160 jitter_buffer_->ReleaseFrame(frame_out); | 1162 jitter_buffer_->ReleaseFrame(frame_out); |
| 1161 } | 1163 } |
| 1162 | 1164 |
| 1165 TEST_F(TestBasicJitterBuffer, SpsAndPpsHandling) { |
| 1166 jitter_buffer_->SetDecodeErrorMode(kNoErrors); |
| 1167 |
| 1168 packet_->timestamp = timestamp_; |
| 1169 packet_->frameType = kVideoFrameKey; |
| 1170 packet_->isFirstPacket = true; |
| 1171 packet_->markerBit = true; |
| 1172 packet_->codec = kVideoCodecH264; |
| 1173 packet_->video_header.codec = kRtpVideoH264; |
| 1174 packet_->video_header.codecHeader.H264.nalu_type = H264::NaluType::kIdr; |
| 1175 packet_->video_header.codecHeader.H264.nalus[0].type = H264::NaluType::kIdr; |
| 1176 packet_->video_header.codecHeader.H264.nalus[0].sps_id = -1; |
| 1177 packet_->video_header.codecHeader.H264.nalus[0].pps_id = 0; |
| 1178 packet_->video_header.codecHeader.H264.nalus_length = 1; |
| 1179 bool retransmitted = false; |
| 1180 EXPECT_EQ(kCompleteSession, |
| 1181 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
| 1182 // Not decodable since sps and pps are missing. |
| 1183 EXPECT_EQ(nullptr, DecodeCompleteFrame()); |
| 1184 |
| 1185 timestamp_ += 3000; |
| 1186 packet_->timestamp = timestamp_; |
| 1187 ++seq_num_; |
| 1188 packet_->seqNum = seq_num_; |
| 1189 packet_->frameType = kVideoFrameKey; |
| 1190 packet_->isFirstPacket = true; |
| 1191 packet_->markerBit = false; |
| 1192 packet_->codec = kVideoCodecH264; |
| 1193 packet_->video_header.codec = kRtpVideoH264; |
| 1194 packet_->video_header.codecHeader.H264.nalu_type = H264::NaluType::kStapA; |
| 1195 packet_->video_header.codecHeader.H264.nalus[0].type = H264::NaluType::kSps; |
| 1196 packet_->video_header.codecHeader.H264.nalus[0].sps_id = 0; |
| 1197 packet_->video_header.codecHeader.H264.nalus[0].pps_id = -1; |
| 1198 packet_->video_header.codecHeader.H264.nalus[1].type = H264::NaluType::kPps; |
| 1199 packet_->video_header.codecHeader.H264.nalus[1].sps_id = 0; |
| 1200 packet_->video_header.codecHeader.H264.nalus[1].pps_id = 0; |
| 1201 packet_->video_header.codecHeader.H264.nalus_length = 2; |
| 1202 // Not complete since the marker bit hasn't been received. |
| 1203 EXPECT_EQ(kIncomplete, |
| 1204 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
| 1205 |
| 1206 ++seq_num_; |
| 1207 packet_->seqNum = seq_num_; |
| 1208 packet_->frameType = kVideoFrameKey; |
| 1209 packet_->isFirstPacket = false; |
| 1210 packet_->markerBit = true; |
| 1211 packet_->codec = kVideoCodecH264; |
| 1212 packet_->video_header.codec = kRtpVideoH264; |
| 1213 packet_->video_header.codecHeader.H264.nalu_type = H264::NaluType::kIdr; |
| 1214 packet_->video_header.codecHeader.H264.nalus[0].type = H264::NaluType::kIdr; |
| 1215 packet_->video_header.codecHeader.H264.nalus[0].sps_id = -1; |
| 1216 packet_->video_header.codecHeader.H264.nalus[0].pps_id = 0; |
| 1217 packet_->video_header.codecHeader.H264.nalus_length = 1; |
| 1218 // Complete and decodable since the pps and sps are received in the first |
| 1219 // packet of this frame. |
| 1220 EXPECT_EQ(kCompleteSession, |
| 1221 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
| 1222 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); |
| 1223 ASSERT_NE(nullptr, frame_out); |
| 1224 jitter_buffer_->ReleaseFrame(frame_out); |
| 1225 |
| 1226 timestamp_ += 3000; |
| 1227 packet_->timestamp = timestamp_; |
| 1228 ++seq_num_; |
| 1229 packet_->seqNum = seq_num_; |
| 1230 packet_->frameType = kVideoFrameDelta; |
| 1231 packet_->isFirstPacket = true; |
| 1232 packet_->markerBit = true; |
| 1233 packet_->codec = kVideoCodecH264; |
| 1234 packet_->video_header.codec = kRtpVideoH264; |
| 1235 packet_->video_header.codecHeader.H264.nalu_type = H264::NaluType::kSlice; |
| 1236 packet_->video_header.codecHeader.H264.nalus[0].type = H264::NaluType::kSlice; |
| 1237 packet_->video_header.codecHeader.H264.nalus[0].sps_id = -1; |
| 1238 packet_->video_header.codecHeader.H264.nalus[0].pps_id = 0; |
| 1239 packet_->video_header.codecHeader.H264.nalus_length = 1; |
| 1240 // Complete and decodable since sps, pps and key frame has been received. |
| 1241 EXPECT_EQ(kCompleteSession, |
| 1242 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
| 1243 frame_out = DecodeCompleteFrame(); |
| 1244 ASSERT_NE(nullptr, frame_out); |
| 1245 jitter_buffer_->ReleaseFrame(frame_out); |
| 1246 } |
| 1247 |
| 1163 // Test threshold conditions of decodable state. | 1248 // Test threshold conditions of decodable state. |
| 1164 TEST_F(TestBasicJitterBuffer, PacketLossWithSelectiveErrorsThresholdCheck) { | 1249 TEST_F(TestBasicJitterBuffer, PacketLossWithSelectiveErrorsThresholdCheck) { |
| 1165 jitter_buffer_->SetDecodeErrorMode(kSelectiveErrors); | 1250 jitter_buffer_->SetDecodeErrorMode(kSelectiveErrors); |
| 1166 // Always start with a key frame. Use 10 packets to test Decodable State | 1251 // Always start with a key frame. Use 10 packets to test Decodable State |
| 1167 // boundaries. | 1252 // boundaries. |
| 1168 packet_->frameType = kVideoFrameKey; | 1253 packet_->frameType = kVideoFrameKey; |
| 1169 packet_->isFirstPacket = true; | 1254 packet_->isFirstPacket = true; |
| 1170 packet_->markerBit = false; | 1255 packet_->markerBit = false; |
| 1171 packet_->seqNum = seq_num_; | 1256 packet_->seqNum = seq_num_; |
| 1172 packet_->timestamp = timestamp_; | 1257 packet_->timestamp = timestamp_; |
| (...skipping 1453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2626 nack_list = jitter_buffer_->GetNackList(&extended); | 2711 nack_list = jitter_buffer_->GetNackList(&extended); |
| 2627 EXPECT_EQ(0u, nack_list.size()); | 2712 EXPECT_EQ(0u, nack_list.size()); |
| 2628 | 2713 |
| 2629 // Stream should be decodable from this point. | 2714 // Stream should be decodable from this point. |
| 2630 clock_->AdvanceTimeMilliseconds(kDefaultFramePeriodMs); | 2715 clock_->AdvanceTimeMilliseconds(kDefaultFramePeriodMs); |
| 2631 InsertFrame(kVideoFrameDelta); | 2716 InsertFrame(kVideoFrameDelta); |
| 2632 EXPECT_TRUE(DecodeCompleteFrame()); | 2717 EXPECT_TRUE(DecodeCompleteFrame()); |
| 2633 nack_list = jitter_buffer_->GetNackList(&extended); | 2718 nack_list = jitter_buffer_->GetNackList(&extended); |
| 2634 EXPECT_EQ(0u, nack_list.size()); | 2719 EXPECT_EQ(0u, nack_list.size()); |
| 2635 } | 2720 } |
| 2636 | |
| 2637 } // namespace webrtc | 2721 } // namespace webrtc |
| OLD | NEW |