OLD | NEW |
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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 void VerifyAll(int value) { | 107 void VerifyAll(int value) { |
108 for (int i = 0; i < seq_num_list_length_; ++i) | 108 for (int i = 0; i < seq_num_list_length_; ++i) |
109 EXPECT_EQ(seq_num_list_[i], value); | 109 EXPECT_EQ(seq_num_list_[i], value); |
110 } | 110 } |
111 | 111 |
112 int seq_num_list_[kMaxSeqNumListLength]; | 112 int seq_num_list_[kMaxSeqNumListLength]; |
113 int seq_num_list_length_; | 113 int seq_num_list_length_; |
114 }; | 114 }; |
115 | 115 |
116 TEST_F(TestSessionInfo, TestSimpleAPIs) { | 116 TEST_F(TestSessionInfo, TestSimpleAPIs) { |
117 packet_.is_first_packet_in_frame = true; | 117 packet_.isFirstPacket = true; |
118 packet_.seqNum = 0xFFFE; | 118 packet_.seqNum = 0xFFFE; |
119 packet_.sizeBytes = packet_buffer_size(); | 119 packet_.sizeBytes = packet_buffer_size(); |
120 packet_.frameType = kVideoFrameKey; | 120 packet_.frameType = kVideoFrameKey; |
121 FillPacket(0); | 121 FillPacket(0); |
122 EXPECT_EQ(packet_buffer_size(), | 122 EXPECT_EQ(packet_buffer_size(), |
123 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, | 123 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
124 kNoErrors, frame_data))); | 124 kNoErrors, frame_data))); |
125 EXPECT_FALSE(session_.HaveLastPacket()); | 125 EXPECT_FALSE(session_.HaveLastPacket()); |
126 EXPECT_EQ(kVideoFrameKey, session_.FrameType()); | 126 EXPECT_EQ(kVideoFrameKey, session_.FrameType()); |
127 | 127 |
128 packet_.is_first_packet_in_frame = false; | 128 packet_.isFirstPacket = false; |
129 packet_.markerBit = true; | 129 packet_.markerBit = true; |
130 packet_.seqNum += 1; | 130 packet_.seqNum += 1; |
131 EXPECT_EQ(packet_buffer_size(), | 131 EXPECT_EQ(packet_buffer_size(), |
132 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, | 132 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
133 kNoErrors, frame_data))); | 133 kNoErrors, frame_data))); |
134 EXPECT_TRUE(session_.HaveLastPacket()); | 134 EXPECT_TRUE(session_.HaveLastPacket()); |
135 EXPECT_EQ(packet_.seqNum, session_.HighSequenceNumber()); | 135 EXPECT_EQ(packet_.seqNum, session_.HighSequenceNumber()); |
136 EXPECT_EQ(0xFFFE, session_.LowSequenceNumber()); | 136 EXPECT_EQ(0xFFFE, session_.LowSequenceNumber()); |
137 | 137 |
138 // Insert empty packet which will be the new high sequence number. | 138 // Insert empty packet which will be the new high sequence number. |
139 // To make things more difficult we will make sure to have a wrap here. | 139 // To make things more difficult we will make sure to have a wrap here. |
140 packet_.is_first_packet_in_frame = false; | 140 packet_.isFirstPacket = false; |
141 packet_.markerBit = true; | 141 packet_.markerBit = true; |
142 packet_.seqNum = 2; | 142 packet_.seqNum = 2; |
143 packet_.sizeBytes = 0; | 143 packet_.sizeBytes = 0; |
144 packet_.frameType = kEmptyFrame; | 144 packet_.frameType = kEmptyFrame; |
145 EXPECT_EQ( | 145 EXPECT_EQ( |
146 0, session_.InsertPacket(packet_, frame_buffer_, kNoErrors, frame_data)); | 146 0, session_.InsertPacket(packet_, frame_buffer_, kNoErrors, frame_data)); |
147 EXPECT_EQ(packet_.seqNum, session_.HighSequenceNumber()); | 147 EXPECT_EQ(packet_.seqNum, session_.HighSequenceNumber()); |
148 } | 148 } |
149 | 149 |
150 TEST_F(TestSessionInfo, NormalOperation) { | 150 TEST_F(TestSessionInfo, NormalOperation) { |
151 packet_.seqNum = 0xFFFF; | 151 packet_.seqNum = 0xFFFF; |
152 packet_.is_first_packet_in_frame = true; | 152 packet_.isFirstPacket = true; |
153 packet_.markerBit = false; | 153 packet_.markerBit = false; |
154 FillPacket(0); | 154 FillPacket(0); |
155 EXPECT_EQ(packet_buffer_size(), | 155 EXPECT_EQ(packet_buffer_size(), |
156 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, | 156 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
157 kNoErrors, frame_data))); | 157 kNoErrors, frame_data))); |
158 | 158 |
159 packet_.is_first_packet_in_frame = false; | 159 packet_.isFirstPacket = false; |
160 for (int i = 1; i < 9; ++i) { | 160 for (int i = 1; i < 9; ++i) { |
161 packet_.seqNum += 1; | 161 packet_.seqNum += 1; |
162 FillPacket(i); | 162 FillPacket(i); |
163 ASSERT_EQ(packet_buffer_size(), | 163 ASSERT_EQ(packet_buffer_size(), |
164 static_cast<size_t>(session_.InsertPacket( | 164 static_cast<size_t>(session_.InsertPacket( |
165 packet_, frame_buffer_, kNoErrors, frame_data))); | 165 packet_, frame_buffer_, kNoErrors, frame_data))); |
166 } | 166 } |
167 | 167 |
168 packet_.seqNum += 1; | 168 packet_.seqNum += 1; |
169 packet_.markerBit = true; | 169 packet_.markerBit = true; |
170 FillPacket(9); | 170 FillPacket(9); |
171 EXPECT_EQ(packet_buffer_size(), | 171 EXPECT_EQ(packet_buffer_size(), |
172 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, | 172 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
173 kNoErrors, frame_data))); | 173 kNoErrors, frame_data))); |
174 | 174 |
175 EXPECT_EQ(10 * packet_buffer_size(), session_.SessionLength()); | 175 EXPECT_EQ(10 * packet_buffer_size(), session_.SessionLength()); |
176 for (int i = 0; i < 10; ++i) { | 176 for (int i = 0; i < 10; ++i) { |
177 SCOPED_TRACE("Calling VerifyPacket"); | 177 SCOPED_TRACE("Calling VerifyPacket"); |
178 VerifyPacket(frame_buffer_ + i * packet_buffer_size(), i); | 178 VerifyPacket(frame_buffer_ + i * packet_buffer_size(), i); |
179 } | 179 } |
180 } | 180 } |
181 | 181 |
182 TEST_F(TestSessionInfo, ErrorsEqualDecodableState) { | 182 TEST_F(TestSessionInfo, ErrorsEqualDecodableState) { |
183 packet_.seqNum = 0xFFFF; | 183 packet_.seqNum = 0xFFFF; |
184 packet_.is_first_packet_in_frame = false; | 184 packet_.isFirstPacket = false; |
185 packet_.markerBit = false; | 185 packet_.markerBit = false; |
186 FillPacket(3); | 186 FillPacket(3); |
187 EXPECT_EQ(packet_buffer_size(), | 187 EXPECT_EQ(packet_buffer_size(), |
188 static_cast<size_t>(session_.InsertPacket( | 188 static_cast<size_t>(session_.InsertPacket( |
189 packet_, frame_buffer_, kWithErrors, frame_data))); | 189 packet_, frame_buffer_, kWithErrors, frame_data))); |
190 EXPECT_TRUE(session_.decodable()); | 190 EXPECT_TRUE(session_.decodable()); |
191 } | 191 } |
192 | 192 |
193 TEST_F(TestSessionInfo, SelectiveDecodableState) { | 193 TEST_F(TestSessionInfo, SelectiveDecodableState) { |
194 packet_.seqNum = 0xFFFF; | 194 packet_.seqNum = 0xFFFF; |
195 packet_.is_first_packet_in_frame = false; | 195 packet_.isFirstPacket = false; |
196 packet_.markerBit = false; | 196 packet_.markerBit = false; |
197 FillPacket(1); | 197 FillPacket(1); |
198 frame_data.rolling_average_packets_per_frame = 11; | 198 frame_data.rolling_average_packets_per_frame = 11; |
199 frame_data.rtt_ms = 150; | 199 frame_data.rtt_ms = 150; |
200 EXPECT_EQ(packet_buffer_size(), | 200 EXPECT_EQ(packet_buffer_size(), |
201 static_cast<size_t>(session_.InsertPacket( | 201 static_cast<size_t>(session_.InsertPacket( |
202 packet_, frame_buffer_, kSelectiveErrors, frame_data))); | 202 packet_, frame_buffer_, kSelectiveErrors, frame_data))); |
203 EXPECT_FALSE(session_.decodable()); | 203 EXPECT_FALSE(session_.decodable()); |
204 | 204 |
205 packet_.seqNum -= 1; | 205 packet_.seqNum -= 1; |
206 FillPacket(0); | 206 FillPacket(0); |
207 packet_.is_first_packet_in_frame = true; | 207 packet_.isFirstPacket = true; |
208 EXPECT_EQ(packet_buffer_size(), | 208 EXPECT_EQ(packet_buffer_size(), |
209 static_cast<size_t>(session_.InsertPacket( | 209 static_cast<size_t>(session_.InsertPacket( |
210 packet_, frame_buffer_, kSelectiveErrors, frame_data))); | 210 packet_, frame_buffer_, kSelectiveErrors, frame_data))); |
211 EXPECT_TRUE(session_.decodable()); | 211 EXPECT_TRUE(session_.decodable()); |
212 | 212 |
213 packet_.is_first_packet_in_frame = false; | 213 packet_.isFirstPacket = false; |
214 packet_.seqNum += 1; | 214 packet_.seqNum += 1; |
215 for (int i = 2; i < 8; ++i) { | 215 for (int i = 2; i < 8; ++i) { |
216 packet_.seqNum += 1; | 216 packet_.seqNum += 1; |
217 FillPacket(i); | 217 FillPacket(i); |
218 EXPECT_EQ(packet_buffer_size(), | 218 EXPECT_EQ(packet_buffer_size(), |
219 static_cast<size_t>(session_.InsertPacket( | 219 static_cast<size_t>(session_.InsertPacket( |
220 packet_, frame_buffer_, kSelectiveErrors, frame_data))); | 220 packet_, frame_buffer_, kSelectiveErrors, frame_data))); |
221 EXPECT_TRUE(session_.decodable()); | 221 EXPECT_TRUE(session_.decodable()); |
222 } | 222 } |
223 | 223 |
224 packet_.seqNum += 1; | 224 packet_.seqNum += 1; |
225 FillPacket(8); | 225 FillPacket(8); |
226 EXPECT_EQ(packet_buffer_size(), | 226 EXPECT_EQ(packet_buffer_size(), |
227 static_cast<size_t>(session_.InsertPacket( | 227 static_cast<size_t>(session_.InsertPacket( |
228 packet_, frame_buffer_, kSelectiveErrors, frame_data))); | 228 packet_, frame_buffer_, kSelectiveErrors, frame_data))); |
229 EXPECT_TRUE(session_.decodable()); | 229 EXPECT_TRUE(session_.decodable()); |
230 } | 230 } |
231 | 231 |
232 TEST_F(TestSessionInfo, OutOfBoundsPackets1PacketFrame) { | 232 TEST_F(TestSessionInfo, OutOfBoundsPackets1PacketFrame) { |
233 packet_.seqNum = 0x0001; | 233 packet_.seqNum = 0x0001; |
234 packet_.is_first_packet_in_frame = true; | 234 packet_.isFirstPacket = true; |
235 packet_.markerBit = true; | 235 packet_.markerBit = true; |
236 FillPacket(1); | 236 FillPacket(1); |
237 EXPECT_EQ(packet_buffer_size(), | 237 EXPECT_EQ(packet_buffer_size(), |
238 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, | 238 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
239 kNoErrors, frame_data))); | 239 kNoErrors, frame_data))); |
240 | 240 |
241 packet_.seqNum = 0x0004; | 241 packet_.seqNum = 0x0004; |
242 packet_.is_first_packet_in_frame = true; | 242 packet_.isFirstPacket = true; |
243 packet_.markerBit = true; | 243 packet_.markerBit = true; |
244 FillPacket(1); | 244 FillPacket(1); |
245 EXPECT_EQ( | 245 EXPECT_EQ( |
246 -3, session_.InsertPacket(packet_, frame_buffer_, kNoErrors, frame_data)); | 246 -3, session_.InsertPacket(packet_, frame_buffer_, kNoErrors, frame_data)); |
247 packet_.seqNum = 0x0000; | 247 packet_.seqNum = 0x0000; |
248 packet_.is_first_packet_in_frame = false; | 248 packet_.isFirstPacket = false; |
249 packet_.markerBit = false; | 249 packet_.markerBit = false; |
250 FillPacket(1); | 250 FillPacket(1); |
251 EXPECT_EQ( | 251 EXPECT_EQ( |
252 -3, session_.InsertPacket(packet_, frame_buffer_, kNoErrors, frame_data)); | 252 -3, session_.InsertPacket(packet_, frame_buffer_, kNoErrors, frame_data)); |
253 } | 253 } |
254 | 254 |
255 TEST_F(TestSessionInfo, SetMarkerBitOnce) { | 255 TEST_F(TestSessionInfo, SetMarkerBitOnce) { |
256 packet_.seqNum = 0x0005; | 256 packet_.seqNum = 0x0005; |
257 packet_.is_first_packet_in_frame = false; | 257 packet_.isFirstPacket = false; |
258 packet_.markerBit = true; | 258 packet_.markerBit = true; |
259 FillPacket(1); | 259 FillPacket(1); |
260 EXPECT_EQ(packet_buffer_size(), | 260 EXPECT_EQ(packet_buffer_size(), |
261 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, | 261 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
262 kNoErrors, frame_data))); | 262 kNoErrors, frame_data))); |
263 ++packet_.seqNum; | 263 ++packet_.seqNum; |
264 packet_.is_first_packet_in_frame = true; | 264 packet_.isFirstPacket = true; |
265 packet_.markerBit = true; | 265 packet_.markerBit = true; |
266 FillPacket(1); | 266 FillPacket(1); |
267 EXPECT_EQ( | 267 EXPECT_EQ( |
268 -3, session_.InsertPacket(packet_, frame_buffer_, kNoErrors, frame_data)); | 268 -3, session_.InsertPacket(packet_, frame_buffer_, kNoErrors, frame_data)); |
269 } | 269 } |
270 | 270 |
271 TEST_F(TestSessionInfo, OutOfBoundsPacketsBase) { | 271 TEST_F(TestSessionInfo, OutOfBoundsPacketsBase) { |
272 // Allow packets in the range 5-6. | 272 // Allow packets in the range 5-6. |
273 packet_.seqNum = 0x0005; | 273 packet_.seqNum = 0x0005; |
274 packet_.is_first_packet_in_frame = true; | 274 packet_.isFirstPacket = true; |
275 packet_.markerBit = false; | 275 packet_.markerBit = false; |
276 FillPacket(1); | 276 FillPacket(1); |
277 EXPECT_EQ(packet_buffer_size(), | 277 EXPECT_EQ(packet_buffer_size(), |
278 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, | 278 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
279 kNoErrors, frame_data))); | 279 kNoErrors, frame_data))); |
280 // Insert an older packet with a first packet set. | 280 // Insert an older packet with a first packet set. |
281 packet_.seqNum = 0x0004; | 281 packet_.seqNum = 0x0004; |
282 packet_.is_first_packet_in_frame = true; | 282 packet_.isFirstPacket = true; |
283 packet_.markerBit = true; | 283 packet_.markerBit = true; |
284 FillPacket(1); | 284 FillPacket(1); |
285 EXPECT_EQ( | 285 EXPECT_EQ( |
286 -3, session_.InsertPacket(packet_, frame_buffer_, kNoErrors, frame_data)); | 286 -3, session_.InsertPacket(packet_, frame_buffer_, kNoErrors, frame_data)); |
287 packet_.seqNum = 0x0006; | 287 packet_.seqNum = 0x0006; |
288 packet_.is_first_packet_in_frame = true; | 288 packet_.isFirstPacket = true; |
289 packet_.markerBit = true; | 289 packet_.markerBit = true; |
290 FillPacket(1); | 290 FillPacket(1); |
291 EXPECT_EQ(packet_buffer_size(), | 291 EXPECT_EQ(packet_buffer_size(), |
292 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, | 292 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
293 kNoErrors, frame_data))); | 293 kNoErrors, frame_data))); |
294 packet_.seqNum = 0x0008; | 294 packet_.seqNum = 0x0008; |
295 packet_.is_first_packet_in_frame = false; | 295 packet_.isFirstPacket = false; |
296 packet_.markerBit = true; | 296 packet_.markerBit = true; |
297 FillPacket(1); | 297 FillPacket(1); |
298 EXPECT_EQ( | 298 EXPECT_EQ( |
299 -3, session_.InsertPacket(packet_, frame_buffer_, kNoErrors, frame_data)); | 299 -3, session_.InsertPacket(packet_, frame_buffer_, kNoErrors, frame_data)); |
300 } | 300 } |
301 | 301 |
302 TEST_F(TestSessionInfo, OutOfBoundsPacketsWrap) { | 302 TEST_F(TestSessionInfo, OutOfBoundsPacketsWrap) { |
303 packet_.seqNum = 0xFFFE; | 303 packet_.seqNum = 0xFFFE; |
304 packet_.is_first_packet_in_frame = true; | 304 packet_.isFirstPacket = true; |
305 packet_.markerBit = false; | 305 packet_.markerBit = false; |
306 FillPacket(1); | 306 FillPacket(1); |
307 EXPECT_EQ(packet_buffer_size(), | 307 EXPECT_EQ(packet_buffer_size(), |
308 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, | 308 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
309 kNoErrors, frame_data))); | 309 kNoErrors, frame_data))); |
310 | 310 |
311 packet_.seqNum = 0x0004; | 311 packet_.seqNum = 0x0004; |
312 packet_.is_first_packet_in_frame = false; | 312 packet_.isFirstPacket = false; |
313 packet_.markerBit = true; | 313 packet_.markerBit = true; |
314 FillPacket(1); | 314 FillPacket(1); |
315 EXPECT_EQ(packet_buffer_size(), | 315 EXPECT_EQ(packet_buffer_size(), |
316 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, | 316 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
317 kNoErrors, frame_data))); | 317 kNoErrors, frame_data))); |
318 packet_.seqNum = 0x0002; | 318 packet_.seqNum = 0x0002; |
319 packet_.is_first_packet_in_frame = false; | 319 packet_.isFirstPacket = false; |
320 packet_.markerBit = false; | 320 packet_.markerBit = false; |
321 FillPacket(1); | 321 FillPacket(1); |
322 ASSERT_EQ(packet_buffer_size(), | 322 ASSERT_EQ(packet_buffer_size(), |
323 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, | 323 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
324 kNoErrors, frame_data))); | 324 kNoErrors, frame_data))); |
325 packet_.seqNum = 0xFFF0; | 325 packet_.seqNum = 0xFFF0; |
326 packet_.is_first_packet_in_frame = false; | 326 packet_.isFirstPacket = false; |
327 packet_.markerBit = false; | 327 packet_.markerBit = false; |
328 FillPacket(1); | 328 FillPacket(1); |
329 EXPECT_EQ( | 329 EXPECT_EQ( |
330 -3, session_.InsertPacket(packet_, frame_buffer_, kNoErrors, frame_data)); | 330 -3, session_.InsertPacket(packet_, frame_buffer_, kNoErrors, frame_data)); |
331 packet_.seqNum = 0x0006; | 331 packet_.seqNum = 0x0006; |
332 packet_.is_first_packet_in_frame = false; | 332 packet_.isFirstPacket = false; |
333 packet_.markerBit = false; | 333 packet_.markerBit = false; |
334 FillPacket(1); | 334 FillPacket(1); |
335 EXPECT_EQ( | 335 EXPECT_EQ( |
336 -3, session_.InsertPacket(packet_, frame_buffer_, kNoErrors, frame_data)); | 336 -3, session_.InsertPacket(packet_, frame_buffer_, kNoErrors, frame_data)); |
337 } | 337 } |
338 | 338 |
339 TEST_F(TestSessionInfo, OutOfBoundsOutOfOrder) { | 339 TEST_F(TestSessionInfo, OutOfBoundsOutOfOrder) { |
340 // Insert out of bound regular packets, and then the first and last packet. | 340 // Insert out of bound regular packets, and then the first and last packet. |
341 // Verify that correct bounds are maintained. | 341 // Verify that correct bounds are maintained. |
342 packet_.seqNum = 0x0003; | 342 packet_.seqNum = 0x0003; |
343 packet_.is_first_packet_in_frame = false; | 343 packet_.isFirstPacket = false; |
344 packet_.markerBit = false; | 344 packet_.markerBit = false; |
345 FillPacket(1); | 345 FillPacket(1); |
346 EXPECT_EQ(packet_buffer_size(), | 346 EXPECT_EQ(packet_buffer_size(), |
347 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, | 347 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
348 kNoErrors, frame_data))); | 348 kNoErrors, frame_data))); |
349 // Insert an older packet with a first packet set. | 349 // Insert an older packet with a first packet set. |
350 packet_.seqNum = 0x0005; | 350 packet_.seqNum = 0x0005; |
351 packet_.is_first_packet_in_frame = true; | 351 packet_.isFirstPacket = true; |
352 packet_.markerBit = false; | 352 packet_.markerBit = false; |
353 FillPacket(1); | 353 FillPacket(1); |
354 EXPECT_EQ(packet_buffer_size(), | 354 EXPECT_EQ(packet_buffer_size(), |
355 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, | 355 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
356 kNoErrors, frame_data))); | 356 kNoErrors, frame_data))); |
357 packet_.seqNum = 0x0004; | 357 packet_.seqNum = 0x0004; |
358 packet_.is_first_packet_in_frame = false; | 358 packet_.isFirstPacket = false; |
359 packet_.markerBit = false; | 359 packet_.markerBit = false; |
360 FillPacket(1); | 360 FillPacket(1); |
361 EXPECT_EQ( | 361 EXPECT_EQ( |
362 -3, session_.InsertPacket(packet_, frame_buffer_, kNoErrors, frame_data)); | 362 -3, session_.InsertPacket(packet_, frame_buffer_, kNoErrors, frame_data)); |
363 packet_.seqNum = 0x0010; | 363 packet_.seqNum = 0x0010; |
364 packet_.is_first_packet_in_frame = false; | 364 packet_.isFirstPacket = false; |
365 packet_.markerBit = false; | 365 packet_.markerBit = false; |
366 FillPacket(1); | 366 FillPacket(1); |
367 EXPECT_EQ(packet_buffer_size(), | 367 EXPECT_EQ(packet_buffer_size(), |
368 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, | 368 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
369 kNoErrors, frame_data))); | 369 kNoErrors, frame_data))); |
370 packet_.seqNum = 0x0008; | 370 packet_.seqNum = 0x0008; |
371 packet_.is_first_packet_in_frame = false; | 371 packet_.isFirstPacket = false; |
372 packet_.markerBit = true; | 372 packet_.markerBit = true; |
373 FillPacket(1); | 373 FillPacket(1); |
374 EXPECT_EQ(packet_buffer_size(), | 374 EXPECT_EQ(packet_buffer_size(), |
375 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, | 375 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
376 kNoErrors, frame_data))); | 376 kNoErrors, frame_data))); |
377 | 377 |
378 packet_.seqNum = 0x0009; | 378 packet_.seqNum = 0x0009; |
379 packet_.is_first_packet_in_frame = false; | 379 packet_.isFirstPacket = false; |
380 packet_.markerBit = false; | 380 packet_.markerBit = false; |
381 FillPacket(1); | 381 FillPacket(1); |
382 EXPECT_EQ( | 382 EXPECT_EQ( |
383 -3, session_.InsertPacket(packet_, frame_buffer_, kNoErrors, frame_data)); | 383 -3, session_.InsertPacket(packet_, frame_buffer_, kNoErrors, frame_data)); |
384 } | 384 } |
385 | 385 |
386 TEST_F(TestNalUnits, OnlyReceivedEmptyPacket) { | 386 TEST_F(TestNalUnits, OnlyReceivedEmptyPacket) { |
387 packet_.is_first_packet_in_frame = false; | 387 packet_.isFirstPacket = false; |
388 packet_.completeNALU = kNaluComplete; | 388 packet_.completeNALU = kNaluComplete; |
389 packet_.frameType = kEmptyFrame; | 389 packet_.frameType = kEmptyFrame; |
390 packet_.sizeBytes = 0; | 390 packet_.sizeBytes = 0; |
391 packet_.seqNum = 0; | 391 packet_.seqNum = 0; |
392 packet_.markerBit = false; | 392 packet_.markerBit = false; |
393 EXPECT_EQ( | 393 EXPECT_EQ( |
394 0, session_.InsertPacket(packet_, frame_buffer_, kNoErrors, frame_data)); | 394 0, session_.InsertPacket(packet_, frame_buffer_, kNoErrors, frame_data)); |
395 | 395 |
396 EXPECT_EQ(0U, session_.MakeDecodable()); | 396 EXPECT_EQ(0U, session_.MakeDecodable()); |
397 EXPECT_EQ(0U, session_.SessionLength()); | 397 EXPECT_EQ(0U, session_.SessionLength()); |
398 } | 398 } |
399 | 399 |
400 TEST_F(TestNalUnits, OneIsolatedNaluLoss) { | 400 TEST_F(TestNalUnits, OneIsolatedNaluLoss) { |
401 packet_.is_first_packet_in_frame = true; | 401 packet_.isFirstPacket = true; |
402 packet_.completeNALU = kNaluComplete; | 402 packet_.completeNALU = kNaluComplete; |
403 packet_.seqNum = 0; | 403 packet_.seqNum = 0; |
404 packet_.markerBit = false; | 404 packet_.markerBit = false; |
405 FillPacket(0); | 405 FillPacket(0); |
406 EXPECT_EQ(packet_buffer_size(), | 406 EXPECT_EQ(packet_buffer_size(), |
407 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, | 407 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
408 kNoErrors, frame_data))); | 408 kNoErrors, frame_data))); |
409 | 409 |
410 packet_.is_first_packet_in_frame = false; | 410 packet_.isFirstPacket = false; |
411 packet_.completeNALU = kNaluComplete; | 411 packet_.completeNALU = kNaluComplete; |
412 packet_.seqNum += 2; | 412 packet_.seqNum += 2; |
413 packet_.markerBit = true; | 413 packet_.markerBit = true; |
414 FillPacket(2); | 414 FillPacket(2); |
415 EXPECT_EQ(packet_buffer_size(), | 415 EXPECT_EQ(packet_buffer_size(), |
416 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, | 416 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
417 kNoErrors, frame_data))); | 417 kNoErrors, frame_data))); |
418 | 418 |
419 EXPECT_EQ(0U, session_.MakeDecodable()); | 419 EXPECT_EQ(0U, session_.MakeDecodable()); |
420 EXPECT_EQ(2 * packet_buffer_size(), session_.SessionLength()); | 420 EXPECT_EQ(2 * packet_buffer_size(), session_.SessionLength()); |
421 SCOPED_TRACE("Calling VerifyNalu"); | 421 SCOPED_TRACE("Calling VerifyNalu"); |
422 EXPECT_TRUE(VerifyNalu(0, 1, 0)); | 422 EXPECT_TRUE(VerifyNalu(0, 1, 0)); |
423 SCOPED_TRACE("Calling VerifyNalu"); | 423 SCOPED_TRACE("Calling VerifyNalu"); |
424 EXPECT_TRUE(VerifyNalu(1, 1, 2)); | 424 EXPECT_TRUE(VerifyNalu(1, 1, 2)); |
425 } | 425 } |
426 | 426 |
427 TEST_F(TestNalUnits, LossInMiddleOfNalu) { | 427 TEST_F(TestNalUnits, LossInMiddleOfNalu) { |
428 packet_.is_first_packet_in_frame = true; | 428 packet_.isFirstPacket = true; |
429 packet_.completeNALU = kNaluComplete; | 429 packet_.completeNALU = kNaluComplete; |
430 packet_.seqNum = 0; | 430 packet_.seqNum = 0; |
431 packet_.markerBit = false; | 431 packet_.markerBit = false; |
432 FillPacket(0); | 432 FillPacket(0); |
433 EXPECT_EQ(packet_buffer_size(), | 433 EXPECT_EQ(packet_buffer_size(), |
434 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, | 434 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
435 kNoErrors, frame_data))); | 435 kNoErrors, frame_data))); |
436 | 436 |
437 packet_.is_first_packet_in_frame = false; | 437 packet_.isFirstPacket = false; |
438 packet_.completeNALU = kNaluEnd; | 438 packet_.completeNALU = kNaluEnd; |
439 packet_.seqNum += 2; | 439 packet_.seqNum += 2; |
440 packet_.markerBit = true; | 440 packet_.markerBit = true; |
441 FillPacket(2); | 441 FillPacket(2); |
442 EXPECT_EQ(packet_buffer_size(), | 442 EXPECT_EQ(packet_buffer_size(), |
443 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, | 443 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
444 kNoErrors, frame_data))); | 444 kNoErrors, frame_data))); |
445 | 445 |
446 EXPECT_EQ(packet_buffer_size(), session_.MakeDecodable()); | 446 EXPECT_EQ(packet_buffer_size(), session_.MakeDecodable()); |
447 EXPECT_EQ(packet_buffer_size(), session_.SessionLength()); | 447 EXPECT_EQ(packet_buffer_size(), session_.SessionLength()); |
448 SCOPED_TRACE("Calling VerifyNalu"); | 448 SCOPED_TRACE("Calling VerifyNalu"); |
449 EXPECT_TRUE(VerifyNalu(0, 1, 0)); | 449 EXPECT_TRUE(VerifyNalu(0, 1, 0)); |
450 } | 450 } |
451 | 451 |
452 TEST_F(TestNalUnits, StartAndEndOfLastNalUnitLost) { | 452 TEST_F(TestNalUnits, StartAndEndOfLastNalUnitLost) { |
453 packet_.is_first_packet_in_frame = true; | 453 packet_.isFirstPacket = true; |
454 packet_.completeNALU = kNaluComplete; | 454 packet_.completeNALU = kNaluComplete; |
455 packet_.seqNum = 0; | 455 packet_.seqNum = 0; |
456 packet_.markerBit = false; | 456 packet_.markerBit = false; |
457 FillPacket(0); | 457 FillPacket(0); |
458 EXPECT_EQ(packet_buffer_size(), | 458 EXPECT_EQ(packet_buffer_size(), |
459 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, | 459 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
460 kNoErrors, frame_data))); | 460 kNoErrors, frame_data))); |
461 | 461 |
462 packet_.is_first_packet_in_frame = false; | 462 packet_.isFirstPacket = false; |
463 packet_.completeNALU = kNaluIncomplete; | 463 packet_.completeNALU = kNaluIncomplete; |
464 packet_.seqNum += 2; | 464 packet_.seqNum += 2; |
465 packet_.markerBit = false; | 465 packet_.markerBit = false; |
466 FillPacket(1); | 466 FillPacket(1); |
467 EXPECT_EQ(packet_buffer_size(), | 467 EXPECT_EQ(packet_buffer_size(), |
468 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, | 468 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
469 kNoErrors, frame_data))); | 469 kNoErrors, frame_data))); |
470 | 470 |
471 EXPECT_EQ(packet_buffer_size(), session_.MakeDecodable()); | 471 EXPECT_EQ(packet_buffer_size(), session_.MakeDecodable()); |
472 EXPECT_EQ(packet_buffer_size(), session_.SessionLength()); | 472 EXPECT_EQ(packet_buffer_size(), session_.SessionLength()); |
473 SCOPED_TRACE("Calling VerifyNalu"); | 473 SCOPED_TRACE("Calling VerifyNalu"); |
474 EXPECT_TRUE(VerifyNalu(0, 1, 0)); | 474 EXPECT_TRUE(VerifyNalu(0, 1, 0)); |
475 } | 475 } |
476 | 476 |
477 TEST_F(TestNalUnits, ReorderWrapNoLoss) { | 477 TEST_F(TestNalUnits, ReorderWrapNoLoss) { |
478 packet_.seqNum = 0xFFFF; | 478 packet_.seqNum = 0xFFFF; |
479 packet_.is_first_packet_in_frame = false; | 479 packet_.isFirstPacket = false; |
480 packet_.completeNALU = kNaluIncomplete; | 480 packet_.completeNALU = kNaluIncomplete; |
481 packet_.seqNum += 1; | 481 packet_.seqNum += 1; |
482 packet_.markerBit = false; | 482 packet_.markerBit = false; |
483 FillPacket(1); | 483 FillPacket(1); |
484 EXPECT_EQ(packet_buffer_size(), | 484 EXPECT_EQ(packet_buffer_size(), |
485 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, | 485 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
486 kNoErrors, frame_data))); | 486 kNoErrors, frame_data))); |
487 | 487 |
488 packet_.is_first_packet_in_frame = true; | 488 packet_.isFirstPacket = true; |
489 packet_.completeNALU = kNaluComplete; | 489 packet_.completeNALU = kNaluComplete; |
490 packet_.seqNum -= 1; | 490 packet_.seqNum -= 1; |
491 packet_.markerBit = false; | 491 packet_.markerBit = false; |
492 FillPacket(0); | 492 FillPacket(0); |
493 EXPECT_EQ(packet_buffer_size(), | 493 EXPECT_EQ(packet_buffer_size(), |
494 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, | 494 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
495 kNoErrors, frame_data))); | 495 kNoErrors, frame_data))); |
496 | 496 |
497 packet_.is_first_packet_in_frame = false; | 497 packet_.isFirstPacket = false; |
498 packet_.completeNALU = kNaluEnd; | 498 packet_.completeNALU = kNaluEnd; |
499 packet_.seqNum += 2; | 499 packet_.seqNum += 2; |
500 packet_.markerBit = true; | 500 packet_.markerBit = true; |
501 FillPacket(2); | 501 FillPacket(2); |
502 EXPECT_EQ(packet_buffer_size(), | 502 EXPECT_EQ(packet_buffer_size(), |
503 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, | 503 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
504 kNoErrors, frame_data))); | 504 kNoErrors, frame_data))); |
505 | 505 |
506 EXPECT_EQ(0U, session_.MakeDecodable()); | 506 EXPECT_EQ(0U, session_.MakeDecodable()); |
507 EXPECT_EQ(3 * packet_buffer_size(), session_.SessionLength()); | 507 EXPECT_EQ(3 * packet_buffer_size(), session_.SessionLength()); |
508 SCOPED_TRACE("Calling VerifyNalu"); | 508 SCOPED_TRACE("Calling VerifyNalu"); |
509 EXPECT_TRUE(VerifyNalu(0, 1, 0)); | 509 EXPECT_TRUE(VerifyNalu(0, 1, 0)); |
510 } | 510 } |
511 | 511 |
512 TEST_F(TestNalUnits, WrapLosses) { | 512 TEST_F(TestNalUnits, WrapLosses) { |
513 packet_.seqNum = 0xFFFF; | 513 packet_.seqNum = 0xFFFF; |
514 packet_.is_first_packet_in_frame = false; | 514 packet_.isFirstPacket = false; |
515 packet_.completeNALU = kNaluIncomplete; | 515 packet_.completeNALU = kNaluIncomplete; |
516 packet_.markerBit = false; | 516 packet_.markerBit = false; |
517 FillPacket(1); | 517 FillPacket(1); |
518 EXPECT_EQ(packet_buffer_size(), | 518 EXPECT_EQ(packet_buffer_size(), |
519 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, | 519 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
520 kNoErrors, frame_data))); | 520 kNoErrors, frame_data))); |
521 | 521 |
522 packet_.is_first_packet_in_frame = false; | 522 packet_.isFirstPacket = false; |
523 packet_.completeNALU = kNaluEnd; | 523 packet_.completeNALU = kNaluEnd; |
524 packet_.seqNum += 2; | 524 packet_.seqNum += 2; |
525 packet_.markerBit = true; | 525 packet_.markerBit = true; |
526 FillPacket(2); | 526 FillPacket(2); |
527 EXPECT_EQ(packet_buffer_size(), | 527 EXPECT_EQ(packet_buffer_size(), |
528 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, | 528 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
529 kNoErrors, frame_data))); | 529 kNoErrors, frame_data))); |
530 | 530 |
531 EXPECT_EQ(2 * packet_buffer_size(), session_.MakeDecodable()); | 531 EXPECT_EQ(2 * packet_buffer_size(), session_.MakeDecodable()); |
532 EXPECT_EQ(0U, session_.SessionLength()); | 532 EXPECT_EQ(0U, session_.SessionLength()); |
533 } | 533 } |
534 | 534 |
535 TEST_F(TestNalUnits, ReorderWrapLosses) { | 535 TEST_F(TestNalUnits, ReorderWrapLosses) { |
536 packet_.seqNum = 0xFFFF; | 536 packet_.seqNum = 0xFFFF; |
537 | 537 |
538 packet_.is_first_packet_in_frame = false; | 538 packet_.isFirstPacket = false; |
539 packet_.completeNALU = kNaluEnd; | 539 packet_.completeNALU = kNaluEnd; |
540 packet_.seqNum += 2; | 540 packet_.seqNum += 2; |
541 packet_.markerBit = true; | 541 packet_.markerBit = true; |
542 FillPacket(2); | 542 FillPacket(2); |
543 EXPECT_EQ(packet_buffer_size(), | 543 EXPECT_EQ(packet_buffer_size(), |
544 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, | 544 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
545 kNoErrors, frame_data))); | 545 kNoErrors, frame_data))); |
546 | 546 |
547 packet_.seqNum -= 2; | 547 packet_.seqNum -= 2; |
548 packet_.is_first_packet_in_frame = false; | 548 packet_.isFirstPacket = false; |
549 packet_.completeNALU = kNaluIncomplete; | 549 packet_.completeNALU = kNaluIncomplete; |
550 packet_.markerBit = false; | 550 packet_.markerBit = false; |
551 FillPacket(1); | 551 FillPacket(1); |
552 EXPECT_EQ(packet_buffer_size(), | 552 EXPECT_EQ(packet_buffer_size(), |
553 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, | 553 static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_, |
554 kNoErrors, frame_data))); | 554 kNoErrors, frame_data))); |
555 | 555 |
556 EXPECT_EQ(2 * packet_buffer_size(), session_.MakeDecodable()); | 556 EXPECT_EQ(2 * packet_buffer_size(), session_.MakeDecodable()); |
557 EXPECT_EQ(0U, session_.SessionLength()); | 557 EXPECT_EQ(0U, session_.SessionLength()); |
558 } | 558 } |
559 | 559 |
560 } // namespace webrtc | 560 } // namespace webrtc |
OLD | NEW |