Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(485)

Side by Side Diff: webrtc/modules/video_coding/video_coding_robustness_unittest.cc

Issue 1528503003: Lint enabled for webrtc/modules/video_coding folder. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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
(...skipping 29 matching lines...) Expand all
40 const size_t kMaxNackListSize = 250; 40 const size_t kMaxNackListSize = 250;
41 const int kMaxPacketAgeToNack = 450; 41 const int kMaxPacketAgeToNack = 450;
42 vcm_->SetNackSettings(kMaxNackListSize, kMaxPacketAgeToNack, 0); 42 vcm_->SetNackSettings(kMaxNackListSize, kMaxPacketAgeToNack, 0);
43 ASSERT_EQ(0, vcm_->RegisterFrameTypeCallback(&frame_type_callback_)); 43 ASSERT_EQ(0, vcm_->RegisterFrameTypeCallback(&frame_type_callback_));
44 ASSERT_EQ(0, vcm_->RegisterPacketRequestCallback(&request_callback_)); 44 ASSERT_EQ(0, vcm_->RegisterPacketRequestCallback(&request_callback_));
45 ASSERT_EQ(VCM_OK, vcm_->Codec(kVideoCodecVP8, &video_codec_)); 45 ASSERT_EQ(VCM_OK, vcm_->Codec(kVideoCodecVP8, &video_codec_));
46 ASSERT_EQ(VCM_OK, vcm_->RegisterReceiveCodec(&video_codec_, 1)); 46 ASSERT_EQ(VCM_OK, vcm_->RegisterReceiveCodec(&video_codec_, 1));
47 vcm_->RegisterExternalDecoder(&decoder_, video_codec_.plType); 47 vcm_->RegisterExternalDecoder(&decoder_, video_codec_.plType);
48 } 48 }
49 49
50 virtual void TearDown() { 50 virtual void TearDown() { VideoCodingModule::Destroy(vcm_); }
51 VideoCodingModule::Destroy(vcm_);
52 }
53 51
54 void InsertPacket(uint32_t timestamp, 52 void InsertPacket(uint32_t timestamp,
55 uint16_t seq_no, 53 uint16_t seq_no,
56 bool first, 54 bool first,
57 bool marker_bit, 55 bool marker_bit,
58 FrameType frame_type) { 56 FrameType frame_type) {
59 const uint8_t payload[kPayloadLen] = {0}; 57 const uint8_t payload[kPayloadLen] = {0};
60 WebRtcRTPHeader rtp_info; 58 WebRtcRTPHeader rtp_info;
61 memset(&rtp_info, 0, sizeof(rtp_info)); 59 memset(&rtp_info, 0, sizeof(rtp_info));
62 rtp_info.frameType = frame_type; 60 rtp_info.frameType = frame_type;
(...skipping 17 matching lines...) Expand all
80 rtc::scoped_ptr<SimulatedClock> clock_; 78 rtc::scoped_ptr<SimulatedClock> clock_;
81 NullEventFactory event_factory_; 79 NullEventFactory event_factory_;
82 }; 80 };
83 81
84 TEST_F(VCMRobustnessTest, TestHardNack) { 82 TEST_F(VCMRobustnessTest, TestHardNack) {
85 Sequence s; 83 Sequence s;
86 EXPECT_CALL(request_callback_, ResendPackets(_, 2)) 84 EXPECT_CALL(request_callback_, ResendPackets(_, 2))
87 .With(Args<0, 1>(ElementsAre(6, 7))) 85 .With(Args<0, 1>(ElementsAre(6, 7)))
88 .Times(1); 86 .Times(1);
89 for (int ts = 0; ts <= 6000; ts += 3000) { 87 for (int ts = 0; ts <= 6000; ts += 3000) {
90 EXPECT_CALL(decoder_, Decode(AllOf(Field(&EncodedImage::_timeStamp, ts), 88 EXPECT_CALL(decoder_,
91 Field(&EncodedImage::_length, 89 Decode(AllOf(Field(&EncodedImage::_timeStamp, ts),
92 kPayloadLen * 3), 90 Field(&EncodedImage::_length, kPayloadLen * 3),
93 Field(&EncodedImage::_completeFrame, 91 Field(&EncodedImage::_completeFrame, true)),
94 true)), 92 false, _, _, _))
95 false, _, _, _))
96 .Times(1) 93 .Times(1)
97 .InSequence(s); 94 .InSequence(s);
98 } 95 }
99 96
100 ASSERT_EQ(VCM_OK, vcm_->SetReceiverRobustnessMode( 97 ASSERT_EQ(VCM_OK, vcm_->SetReceiverRobustnessMode(
101 VideoCodingModule::kHardNack, 98 VideoCodingModule::kHardNack, kNoErrors));
102 kNoErrors));
103 99
104 InsertPacket(0, 0, true, false, kVideoFrameKey); 100 InsertPacket(0, 0, true, false, kVideoFrameKey);
105 InsertPacket(0, 1, false, false, kVideoFrameKey); 101 InsertPacket(0, 1, false, false, kVideoFrameKey);
106 InsertPacket(0, 2, false, true, kVideoFrameKey); 102 InsertPacket(0, 2, false, true, kVideoFrameKey);
107 clock_->AdvanceTimeMilliseconds(1000 / 30); 103 clock_->AdvanceTimeMilliseconds(1000 / 30);
108 104
109 InsertPacket(3000, 3, true, false, kVideoFrameDelta); 105 InsertPacket(3000, 3, true, false, kVideoFrameDelta);
110 InsertPacket(3000, 4, false, false, kVideoFrameDelta); 106 InsertPacket(3000, 4, false, false, kVideoFrameDelta);
111 InsertPacket(3000, 5, false, true, kVideoFrameDelta); 107 InsertPacket(3000, 5, false, true, kVideoFrameDelta);
112 clock_->AdvanceTimeMilliseconds(1000 / 30); 108 clock_->AdvanceTimeMilliseconds(1000 / 30);
(...skipping 16 matching lines...) Expand all
129 125
130 InsertPacket(6000, 6, true, false, kVideoFrameDelta); 126 InsertPacket(6000, 6, true, false, kVideoFrameDelta);
131 InsertPacket(6000, 7, false, false, kVideoFrameDelta); 127 InsertPacket(6000, 7, false, false, kVideoFrameDelta);
132 clock_->AdvanceTimeMilliseconds(10); 128 clock_->AdvanceTimeMilliseconds(10);
133 ASSERT_EQ(VCM_OK, vcm_->Process()); 129 ASSERT_EQ(VCM_OK, vcm_->Process());
134 130
135 ASSERT_EQ(VCM_OK, vcm_->Decode(0)); 131 ASSERT_EQ(VCM_OK, vcm_->Decode(0));
136 } 132 }
137 133
138 TEST_F(VCMRobustnessTest, TestHardNackNoneDecoded) { 134 TEST_F(VCMRobustnessTest, TestHardNackNoneDecoded) {
139 EXPECT_CALL(request_callback_, ResendPackets(_, _)) 135 EXPECT_CALL(request_callback_, ResendPackets(_, _)).Times(0);
140 .Times(0); 136 EXPECT_CALL(frame_type_callback_, RequestKeyFrame()).Times(1);
141 EXPECT_CALL(frame_type_callback_, RequestKeyFrame())
142 .Times(1);
143 137
144 ASSERT_EQ(VCM_OK, vcm_->SetReceiverRobustnessMode( 138 ASSERT_EQ(VCM_OK, vcm_->SetReceiverRobustnessMode(
145 VideoCodingModule::kHardNack, 139 VideoCodingModule::kHardNack, kNoErrors));
146 kNoErrors));
147 140
148 InsertPacket(3000, 3, true, false, kVideoFrameDelta); 141 InsertPacket(3000, 3, true, false, kVideoFrameDelta);
149 InsertPacket(3000, 4, false, false, kVideoFrameDelta); 142 InsertPacket(3000, 4, false, false, kVideoFrameDelta);
150 InsertPacket(3000, 5, false, true, kVideoFrameDelta); 143 InsertPacket(3000, 5, false, true, kVideoFrameDelta);
151 144
152 EXPECT_EQ(VCM_FRAME_NOT_READY, vcm_->Decode(0)); 145 EXPECT_EQ(VCM_FRAME_NOT_READY, vcm_->Decode(0));
153 ASSERT_EQ(VCM_OK, vcm_->Process()); 146 ASSERT_EQ(VCM_OK, vcm_->Process());
154 147
155 clock_->AdvanceTimeMilliseconds(10); 148 clock_->AdvanceTimeMilliseconds(10);
156 149
157 EXPECT_EQ(VCM_FRAME_NOT_READY, vcm_->Decode(0)); 150 EXPECT_EQ(VCM_FRAME_NOT_READY, vcm_->Decode(0));
158 ASSERT_EQ(VCM_OK, vcm_->Process()); 151 ASSERT_EQ(VCM_OK, vcm_->Process());
159 } 152 }
160 153
161 TEST_F(VCMRobustnessTest, TestModeNoneWithErrors) { 154 TEST_F(VCMRobustnessTest, TestModeNoneWithErrors) {
162 EXPECT_CALL(decoder_, InitDecode(_, _)).Times(1); 155 EXPECT_CALL(decoder_, InitDecode(_, _)).Times(1);
163 EXPECT_CALL(decoder_, Release()).Times(1); 156 EXPECT_CALL(decoder_, Release()).Times(1);
164 Sequence s1; 157 Sequence s1;
165 EXPECT_CALL(request_callback_, ResendPackets(_, 1)) 158 EXPECT_CALL(request_callback_, ResendPackets(_, 1))
166 .With(Args<0, 1>(ElementsAre(4))) 159 .With(Args<0, 1>(ElementsAre(4)))
167 .Times(0); 160 .Times(0);
168 161
169 EXPECT_CALL(decoder_, Copy()) 162 EXPECT_CALL(decoder_, Copy()).Times(0);
170 .Times(0); 163 EXPECT_CALL(decoderCopy_, Copy()).Times(0);
171 EXPECT_CALL(decoderCopy_, Copy())
172 .Times(0);
173 164
174 // Decode operations 165 // Decode operations
175 EXPECT_CALL(decoder_, Decode(AllOf(Field(&EncodedImage::_timeStamp, 0), 166 EXPECT_CALL(decoder_,
176 Field(&EncodedImage::_completeFrame, 167 Decode(AllOf(Field(&EncodedImage::_timeStamp, 0),
177 true)), 168 Field(&EncodedImage::_completeFrame, true)),
178 false, _, _, _)) 169 false, _, _, _))
179 .Times(1) 170 .Times(1)
180 .InSequence(s1); 171 .InSequence(s1);
181 EXPECT_CALL(decoder_, Decode(AllOf(Field(&EncodedImage::_timeStamp, 3000), 172 EXPECT_CALL(decoder_,
182 Field(&EncodedImage::_completeFrame, 173 Decode(AllOf(Field(&EncodedImage::_timeStamp, 3000),
183 false)), 174 Field(&EncodedImage::_completeFrame, false)),
184 false, _, _, _)) 175 false, _, _, _))
185 .Times(1) 176 .Times(1)
186 .InSequence(s1); 177 .InSequence(s1);
187 EXPECT_CALL(decoder_, Decode(AllOf(Field(&EncodedImage::_timeStamp, 6000), 178 EXPECT_CALL(decoder_,
188 Field(&EncodedImage::_completeFrame, 179 Decode(AllOf(Field(&EncodedImage::_timeStamp, 6000),
189 true)), 180 Field(&EncodedImage::_completeFrame, true)),
190 false, _, _, _)) 181 false, _, _, _))
191 .Times(1) 182 .Times(1)
192 .InSequence(s1); 183 .InSequence(s1);
193 EXPECT_CALL(decoder_, Decode(AllOf(Field(&EncodedImage::_timeStamp, 9000), 184 EXPECT_CALL(decoder_,
194 Field(&EncodedImage::_completeFrame, 185 Decode(AllOf(Field(&EncodedImage::_timeStamp, 9000),
195 true)), 186 Field(&EncodedImage::_completeFrame, true)),
196 false, _, _, _)) 187 false, _, _, _))
197 .Times(1) 188 .Times(1)
198 .InSequence(s1); 189 .InSequence(s1);
199 190
200 ASSERT_EQ(VCM_OK, vcm_->SetReceiverRobustnessMode( 191 ASSERT_EQ(VCM_OK, vcm_->SetReceiverRobustnessMode(VideoCodingModule::kNone,
201 VideoCodingModule::kNone, 192 kWithErrors));
202 kWithErrors));
203 193
204 InsertPacket(0, 0, true, false, kVideoFrameKey); 194 InsertPacket(0, 0, true, false, kVideoFrameKey);
205 InsertPacket(0, 1, false, false, kVideoFrameKey); 195 InsertPacket(0, 1, false, false, kVideoFrameKey);
206 InsertPacket(0, 2, false, true, kVideoFrameKey); 196 InsertPacket(0, 2, false, true, kVideoFrameKey);
207 EXPECT_EQ(VCM_OK, vcm_->Decode(33)); // Decode timestamp 0. 197 EXPECT_EQ(VCM_OK, vcm_->Decode(33)); // Decode timestamp 0.
208 EXPECT_EQ(VCM_OK, vcm_->Process()); // Expect no NACK list. 198 EXPECT_EQ(VCM_OK, vcm_->Process()); // Expect no NACK list.
209 199
210 clock_->AdvanceTimeMilliseconds(33); 200 clock_->AdvanceTimeMilliseconds(33);
211 InsertPacket(3000, 3, true, false, kVideoFrameDelta); 201 InsertPacket(3000, 3, true, false, kVideoFrameDelta);
212 // Packet 4 missing 202 // Packet 4 missing
213 InsertPacket(3000, 5, false, true, kVideoFrameDelta); 203 InsertPacket(3000, 5, false, true, kVideoFrameDelta);
214 EXPECT_EQ(VCM_FRAME_NOT_READY, vcm_->Decode(0)); 204 EXPECT_EQ(VCM_FRAME_NOT_READY, vcm_->Decode(0));
215 EXPECT_EQ(VCM_OK, vcm_->Process()); // Expect no NACK list. 205 EXPECT_EQ(VCM_OK, vcm_->Process()); // Expect no NACK list.
216 206
217 clock_->AdvanceTimeMilliseconds(33); 207 clock_->AdvanceTimeMilliseconds(33);
218 InsertPacket(6000, 6, true, false, kVideoFrameDelta); 208 InsertPacket(6000, 6, true, false, kVideoFrameDelta);
219 InsertPacket(6000, 7, false, false, kVideoFrameDelta); 209 InsertPacket(6000, 7, false, false, kVideoFrameDelta);
220 InsertPacket(6000, 8, false, true, kVideoFrameDelta); 210 InsertPacket(6000, 8, false, true, kVideoFrameDelta);
221 EXPECT_EQ(VCM_OK, vcm_->Decode(0)); // Decode timestamp 3000 incomplete. 211 EXPECT_EQ(VCM_OK, vcm_->Decode(0)); // Decode timestamp 3000 incomplete.
222 EXPECT_EQ(VCM_OK, vcm_->Process()); // Expect no NACK list. 212 EXPECT_EQ(VCM_OK, vcm_->Process()); // Expect no NACK list.
223 213
224 clock_->AdvanceTimeMilliseconds(10); 214 clock_->AdvanceTimeMilliseconds(10);
225 EXPECT_EQ(VCM_OK, vcm_->Decode(23)); // Decode timestamp 6000 complete. 215 EXPECT_EQ(VCM_OK, vcm_->Decode(23)); // Decode timestamp 6000 complete.
226 EXPECT_EQ(VCM_OK, vcm_->Process()); // Expect no NACK list. 216 EXPECT_EQ(VCM_OK, vcm_->Process()); // Expect no NACK list.
227 217
228 clock_->AdvanceTimeMilliseconds(23); 218 clock_->AdvanceTimeMilliseconds(23);
229 InsertPacket(3000, 4, false, false, kVideoFrameDelta); 219 InsertPacket(3000, 4, false, false, kVideoFrameDelta);
230 220
231 InsertPacket(9000, 9, true, false, kVideoFrameDelta); 221 InsertPacket(9000, 9, true, false, kVideoFrameDelta);
232 InsertPacket(9000, 10, false, false, kVideoFrameDelta); 222 InsertPacket(9000, 10, false, false, kVideoFrameDelta);
233 InsertPacket(9000, 11, false, true, kVideoFrameDelta); 223 InsertPacket(9000, 11, false, true, kVideoFrameDelta);
234 EXPECT_EQ(VCM_OK, vcm_->Decode(33)); // Decode timestamp 9000 complete. 224 EXPECT_EQ(VCM_OK, vcm_->Decode(33)); // Decode timestamp 9000 complete.
235 } 225 }
236 } // namespace webrtc 226 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698