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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 bool expect_cvo, | 229 bool expect_cvo, |
230 RtpHeaderExtensionMap* map, | 230 RtpHeaderExtensionMap* map, |
231 uint16_t seq_num, | 231 uint16_t seq_num, |
232 VideoRotation rotation) { | 232 VideoRotation rotation) { |
233 webrtc::RtpUtility::RtpHeaderParser rtp_parser(data, len); | 233 webrtc::RtpUtility::RtpHeaderParser rtp_parser(data, len); |
234 | 234 |
235 webrtc::RTPHeader rtp_header; | 235 webrtc::RTPHeader rtp_header; |
236 size_t length = static_cast<size_t>(rtp_sender_->BuildRTPheader( | 236 size_t length = static_cast<size_t>(rtp_sender_->BuildRTPheader( |
237 packet_, kPayload, expect_cvo /* marker_bit */, kTimestamp, 0)); | 237 packet_, kPayload, expect_cvo /* marker_bit */, kTimestamp, 0)); |
238 if (expect_cvo) { | 238 if (expect_cvo) { |
239 ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionTotalLength(), | 239 ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionLength(), |
240 length); | 240 length); |
241 } else { | 241 } else { |
242 ASSERT_EQ(kRtpHeaderSize, length); | 242 ASSERT_EQ(kRtpHeaderSize, length); |
243 } | 243 } |
244 ASSERT_TRUE(rtp_parser.Parse(&rtp_header, map)); | 244 ASSERT_TRUE(rtp_parser.Parse(&rtp_header, map)); |
245 ASSERT_FALSE(rtp_parser.RTCP()); | 245 ASSERT_FALSE(rtp_parser.RTCP()); |
246 EXPECT_EQ(payload_, rtp_header.payloadType); | 246 EXPECT_EQ(payload_, rtp_header.payloadType); |
247 EXPECT_EQ(seq_num, rtp_header.sequenceNumber); | 247 EXPECT_EQ(seq_num, rtp_header.sequenceNumber); |
248 EXPECT_EQ(kTimestamp, rtp_header.timestamp); | 248 EXPECT_EQ(kTimestamp, rtp_header.timestamp); |
249 EXPECT_EQ(rtp_sender_->SSRC(), rtp_header.ssrc); | 249 EXPECT_EQ(rtp_sender_->SSRC(), rtp_header.ssrc); |
250 EXPECT_EQ(0, rtp_header.numCSRCs); | 250 EXPECT_EQ(0, rtp_header.numCSRCs); |
251 EXPECT_EQ(0U, rtp_header.paddingLength); | 251 EXPECT_EQ(0U, rtp_header.paddingLength); |
252 EXPECT_EQ(ConvertVideoRotationToCVOByte(rotation), | 252 EXPECT_EQ(ConvertVideoRotationToCVOByte(rotation), |
253 rtp_header.extension.videoRotation); | 253 rtp_header.extension.videoRotation); |
254 } | 254 } |
255 }; | 255 }; |
256 | 256 |
257 TEST_F(RtpSenderTestWithoutPacer, | 257 TEST_F(RtpSenderTestWithoutPacer, |
258 RegisterRtpTransmissionTimeOffsetHeaderExtension) { | 258 RegisterRtpTransmissionTimeOffsetHeaderExtension) { |
259 EXPECT_EQ(0u, rtp_sender_->RtpHeaderExtensionTotalLength()); | 259 EXPECT_EQ(0u, rtp_sender_->RtpHeaderExtensionLength()); |
260 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( | 260 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( |
261 kRtpExtensionTransmissionTimeOffset, | 261 kRtpExtensionTransmissionTimeOffset, |
262 kTransmissionTimeOffsetExtensionId)); | 262 kTransmissionTimeOffsetExtensionId)); |
263 EXPECT_EQ(kRtpOneByteHeaderLength + kTransmissionTimeOffsetLength, | 263 EXPECT_EQ(kRtpOneByteHeaderLength + kTransmissionTimeOffsetLength, |
264 rtp_sender_->RtpHeaderExtensionTotalLength()); | 264 rtp_sender_->RtpHeaderExtensionLength()); |
265 EXPECT_EQ(0, rtp_sender_->DeregisterRtpHeaderExtension( | 265 EXPECT_EQ(0, rtp_sender_->DeregisterRtpHeaderExtension( |
266 kRtpExtensionTransmissionTimeOffset)); | 266 kRtpExtensionTransmissionTimeOffset)); |
267 EXPECT_EQ(0u, rtp_sender_->RtpHeaderExtensionTotalLength()); | 267 EXPECT_EQ(0u, rtp_sender_->RtpHeaderExtensionLength()); |
268 } | 268 } |
269 | 269 |
270 TEST_F(RtpSenderTestWithoutPacer, RegisterRtpAbsoluteSendTimeHeaderExtension) { | 270 TEST_F(RtpSenderTestWithoutPacer, RegisterRtpAbsoluteSendTimeHeaderExtension) { |
271 EXPECT_EQ(0u, rtp_sender_->RtpHeaderExtensionTotalLength()); | 271 EXPECT_EQ(0u, rtp_sender_->RtpHeaderExtensionLength()); |
272 EXPECT_EQ( | 272 EXPECT_EQ( |
273 0, rtp_sender_->RegisterRtpHeaderExtension(kRtpExtensionAbsoluteSendTime, | 273 0, rtp_sender_->RegisterRtpHeaderExtension(kRtpExtensionAbsoluteSendTime, |
274 kAbsoluteSendTimeExtensionId)); | 274 kAbsoluteSendTimeExtensionId)); |
275 EXPECT_EQ(RtpUtility::Word32Align(kRtpOneByteHeaderLength + | 275 EXPECT_EQ(RtpUtility::Word32Align(kRtpOneByteHeaderLength + |
276 kAbsoluteSendTimeLength), | 276 kAbsoluteSendTimeLength), |
277 rtp_sender_->RtpHeaderExtensionTotalLength()); | 277 rtp_sender_->RtpHeaderExtensionLength()); |
278 EXPECT_EQ(0, rtp_sender_->DeregisterRtpHeaderExtension( | 278 EXPECT_EQ(0, rtp_sender_->DeregisterRtpHeaderExtension( |
279 kRtpExtensionAbsoluteSendTime)); | 279 kRtpExtensionAbsoluteSendTime)); |
280 EXPECT_EQ(0u, rtp_sender_->RtpHeaderExtensionTotalLength()); | 280 EXPECT_EQ(0u, rtp_sender_->RtpHeaderExtensionLength()); |
281 } | 281 } |
282 | 282 |
283 TEST_F(RtpSenderTestWithoutPacer, RegisterRtpAudioLevelHeaderExtension) { | 283 TEST_F(RtpSenderTestWithoutPacer, RegisterRtpAudioLevelHeaderExtension) { |
284 EXPECT_EQ(0u, rtp_sender_->RtpHeaderExtensionTotalLength()); | 284 EXPECT_EQ(0u, rtp_sender_->RtpHeaderExtensionLength()); |
285 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension(kRtpExtensionAudioLevel, | 285 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension(kRtpExtensionAudioLevel, |
286 kAudioLevelExtensionId)); | 286 kAudioLevelExtensionId)); |
287 EXPECT_EQ( | 287 EXPECT_EQ( |
288 RtpUtility::Word32Align(kRtpOneByteHeaderLength + kAudioLevelLength), | 288 RtpUtility::Word32Align(kRtpOneByteHeaderLength + kAudioLevelLength), |
289 rtp_sender_->RtpHeaderExtensionTotalLength()); | 289 rtp_sender_->RtpHeaderExtensionLength()); |
290 EXPECT_EQ(0, | 290 EXPECT_EQ(0, |
291 rtp_sender_->DeregisterRtpHeaderExtension(kRtpExtensionAudioLevel)); | 291 rtp_sender_->DeregisterRtpHeaderExtension(kRtpExtensionAudioLevel)); |
292 EXPECT_EQ(0u, rtp_sender_->RtpHeaderExtensionTotalLength()); | 292 EXPECT_EQ(0u, rtp_sender_->RtpHeaderExtensionLength()); |
293 } | 293 } |
294 | 294 |
295 TEST_F(RtpSenderTestWithoutPacer, RegisterRtpHeaderExtensions) { | 295 TEST_F(RtpSenderTestWithoutPacer, RegisterRtpHeaderExtensions) { |
296 EXPECT_EQ(0u, rtp_sender_->RtpHeaderExtensionTotalLength()); | 296 EXPECT_EQ(0u, rtp_sender_->RtpHeaderExtensionLength()); |
297 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( | 297 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( |
298 kRtpExtensionTransmissionTimeOffset, | 298 kRtpExtensionTransmissionTimeOffset, |
299 kTransmissionTimeOffsetExtensionId)); | 299 kTransmissionTimeOffsetExtensionId)); |
300 EXPECT_EQ(RtpUtility::Word32Align(kRtpOneByteHeaderLength + | 300 EXPECT_EQ(RtpUtility::Word32Align(kRtpOneByteHeaderLength + |
301 kTransmissionTimeOffsetLength), | 301 kTransmissionTimeOffsetLength), |
302 rtp_sender_->RtpHeaderExtensionTotalLength()); | 302 rtp_sender_->RtpHeaderExtensionLength()); |
303 EXPECT_EQ( | 303 EXPECT_EQ( |
304 0, rtp_sender_->RegisterRtpHeaderExtension(kRtpExtensionAbsoluteSendTime, | 304 0, rtp_sender_->RegisterRtpHeaderExtension(kRtpExtensionAbsoluteSendTime, |
305 kAbsoluteSendTimeExtensionId)); | 305 kAbsoluteSendTimeExtensionId)); |
306 EXPECT_EQ(RtpUtility::Word32Align(kRtpOneByteHeaderLength + | 306 EXPECT_EQ(RtpUtility::Word32Align(kRtpOneByteHeaderLength + |
307 kTransmissionTimeOffsetLength + | 307 kTransmissionTimeOffsetLength + |
308 kAbsoluteSendTimeLength), | 308 kAbsoluteSendTimeLength), |
309 rtp_sender_->RtpHeaderExtensionTotalLength()); | 309 rtp_sender_->RtpHeaderExtensionLength()); |
310 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension(kRtpExtensionAudioLevel, | 310 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension(kRtpExtensionAudioLevel, |
311 kAudioLevelExtensionId)); | 311 kAudioLevelExtensionId)); |
312 EXPECT_EQ(RtpUtility::Word32Align( | 312 EXPECT_EQ(RtpUtility::Word32Align( |
313 kRtpOneByteHeaderLength + kTransmissionTimeOffsetLength + | 313 kRtpOneByteHeaderLength + kTransmissionTimeOffsetLength + |
314 kAbsoluteSendTimeLength + kAudioLevelLength), | 314 kAbsoluteSendTimeLength + kAudioLevelLength), |
315 rtp_sender_->RtpHeaderExtensionTotalLength()); | 315 rtp_sender_->RtpHeaderExtensionLength()); |
316 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( | 316 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( |
317 kRtpExtensionVideoRotation, kVideoRotationExtensionId)); | 317 kRtpExtensionVideoRotation, kVideoRotationExtensionId)); |
318 EXPECT_TRUE(rtp_sender_->ActivateCVORtpHeaderExtension()); | 318 EXPECT_TRUE(rtp_sender_->ActivateCVORtpHeaderExtension()); |
319 EXPECT_EQ(RtpUtility::Word32Align(kRtpOneByteHeaderLength + | 319 EXPECT_EQ(RtpUtility::Word32Align(kRtpOneByteHeaderLength + |
320 kTransmissionTimeOffsetLength + | 320 kTransmissionTimeOffsetLength + |
321 kAbsoluteSendTimeLength + | 321 kAbsoluteSendTimeLength + |
322 kAudioLevelLength + kVideoRotationLength), | 322 kAudioLevelLength + kVideoRotationLength), |
323 rtp_sender_->RtpHeaderExtensionTotalLength()); | 323 rtp_sender_->RtpHeaderExtensionLength()); |
324 | 324 |
325 // Deregister starts. | 325 // Deregister starts. |
326 EXPECT_EQ(0, rtp_sender_->DeregisterRtpHeaderExtension( | 326 EXPECT_EQ(0, rtp_sender_->DeregisterRtpHeaderExtension( |
327 kRtpExtensionTransmissionTimeOffset)); | 327 kRtpExtensionTransmissionTimeOffset)); |
328 EXPECT_EQ(RtpUtility::Word32Align(kRtpOneByteHeaderLength + | 328 EXPECT_EQ(RtpUtility::Word32Align(kRtpOneByteHeaderLength + |
329 kAbsoluteSendTimeLength + | 329 kAbsoluteSendTimeLength + |
330 kAudioLevelLength + kVideoRotationLength), | 330 kAudioLevelLength + kVideoRotationLength), |
331 rtp_sender_->RtpHeaderExtensionTotalLength()); | 331 rtp_sender_->RtpHeaderExtensionLength()); |
332 EXPECT_EQ(0, rtp_sender_->DeregisterRtpHeaderExtension( | 332 EXPECT_EQ(0, rtp_sender_->DeregisterRtpHeaderExtension( |
333 kRtpExtensionAbsoluteSendTime)); | 333 kRtpExtensionAbsoluteSendTime)); |
334 EXPECT_EQ(RtpUtility::Word32Align(kRtpOneByteHeaderLength + | 334 EXPECT_EQ(RtpUtility::Word32Align(kRtpOneByteHeaderLength + |
335 kAudioLevelLength + kVideoRotationLength), | 335 kAudioLevelLength + kVideoRotationLength), |
336 rtp_sender_->RtpHeaderExtensionTotalLength()); | 336 rtp_sender_->RtpHeaderExtensionLength()); |
337 EXPECT_EQ(0, | 337 EXPECT_EQ(0, |
338 rtp_sender_->DeregisterRtpHeaderExtension(kRtpExtensionAudioLevel)); | 338 rtp_sender_->DeregisterRtpHeaderExtension(kRtpExtensionAudioLevel)); |
339 EXPECT_EQ( | 339 EXPECT_EQ( |
340 RtpUtility::Word32Align(kRtpOneByteHeaderLength + kVideoRotationLength), | 340 RtpUtility::Word32Align(kRtpOneByteHeaderLength + kVideoRotationLength), |
341 rtp_sender_->RtpHeaderExtensionTotalLength()); | 341 rtp_sender_->RtpHeaderExtensionLength()); |
342 EXPECT_EQ( | 342 EXPECT_EQ( |
343 0, rtp_sender_->DeregisterRtpHeaderExtension(kRtpExtensionVideoRotation)); | 343 0, rtp_sender_->DeregisterRtpHeaderExtension(kRtpExtensionVideoRotation)); |
344 EXPECT_EQ(0u, rtp_sender_->RtpHeaderExtensionTotalLength()); | 344 EXPECT_EQ(0u, rtp_sender_->RtpHeaderExtensionLength()); |
345 } | 345 } |
346 | 346 |
347 TEST_F(RtpSenderTestWithoutPacer, RegisterRtpVideoRotationHeaderExtension) { | 347 TEST_F(RtpSenderTestWithoutPacer, RegisterRtpVideoRotationHeaderExtension) { |
348 EXPECT_EQ(0u, rtp_sender_->RtpHeaderExtensionTotalLength()); | 348 EXPECT_EQ(0u, rtp_sender_->RtpHeaderExtensionLength()); |
349 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( | 349 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( |
350 kRtpExtensionVideoRotation, kVideoRotationExtensionId)); | 350 kRtpExtensionVideoRotation, kVideoRotationExtensionId)); |
351 EXPECT_EQ(0u, rtp_sender_->RtpHeaderExtensionTotalLength()); | 351 EXPECT_EQ(0u, rtp_sender_->RtpHeaderExtensionLength()); |
352 | 352 |
353 EXPECT_TRUE(rtp_sender_->ActivateCVORtpHeaderExtension()); | 353 EXPECT_TRUE(rtp_sender_->ActivateCVORtpHeaderExtension()); |
354 EXPECT_EQ( | 354 EXPECT_EQ( |
355 RtpUtility::Word32Align(kRtpOneByteHeaderLength + kVideoRotationLength), | 355 RtpUtility::Word32Align(kRtpOneByteHeaderLength + kVideoRotationLength), |
356 rtp_sender_->RtpHeaderExtensionTotalLength()); | 356 rtp_sender_->RtpHeaderExtensionLength()); |
357 EXPECT_EQ( | 357 EXPECT_EQ( |
358 0, rtp_sender_->DeregisterRtpHeaderExtension(kRtpExtensionVideoRotation)); | 358 0, rtp_sender_->DeregisterRtpHeaderExtension(kRtpExtensionVideoRotation)); |
359 EXPECT_EQ(0u, rtp_sender_->RtpHeaderExtensionTotalLength()); | 359 EXPECT_EQ(0u, rtp_sender_->RtpHeaderExtensionLength()); |
360 } | 360 } |
361 | 361 |
362 TEST_F(RtpSenderTestWithoutPacer, BuildRTPPacket) { | 362 TEST_F(RtpSenderTestWithoutPacer, BuildRTPPacket) { |
363 size_t length = static_cast<size_t>(rtp_sender_->BuildRTPheader( | 363 size_t length = static_cast<size_t>(rtp_sender_->BuildRTPheader( |
364 packet_, kPayload, kMarkerBit, kTimestamp, 0)); | 364 packet_, kPayload, kMarkerBit, kTimestamp, 0)); |
365 ASSERT_EQ(kRtpHeaderSize, length); | 365 ASSERT_EQ(kRtpHeaderSize, length); |
366 | 366 |
367 // Verify | 367 // Verify |
368 webrtc::RtpUtility::RtpHeaderParser rtp_parser(packet_, length); | 368 webrtc::RtpUtility::RtpHeaderParser rtp_parser(packet_, length); |
369 webrtc::RTPHeader rtp_header; | 369 webrtc::RTPHeader rtp_header; |
(...skipping 16 matching lines...) Expand all Loading... |
386 | 386 |
387 TEST_F(RtpSenderTestWithoutPacer, | 387 TEST_F(RtpSenderTestWithoutPacer, |
388 BuildRTPPacketWithTransmissionOffsetExtension) { | 388 BuildRTPPacketWithTransmissionOffsetExtension) { |
389 EXPECT_EQ(0, rtp_sender_->SetTransmissionTimeOffset(kTimeOffset)); | 389 EXPECT_EQ(0, rtp_sender_->SetTransmissionTimeOffset(kTimeOffset)); |
390 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( | 390 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( |
391 kRtpExtensionTransmissionTimeOffset, | 391 kRtpExtensionTransmissionTimeOffset, |
392 kTransmissionTimeOffsetExtensionId)); | 392 kTransmissionTimeOffsetExtensionId)); |
393 | 393 |
394 size_t length = static_cast<size_t>(rtp_sender_->BuildRTPheader( | 394 size_t length = static_cast<size_t>(rtp_sender_->BuildRTPheader( |
395 packet_, kPayload, kMarkerBit, kTimestamp, 0)); | 395 packet_, kPayload, kMarkerBit, kTimestamp, 0)); |
396 ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionTotalLength(), | 396 ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionLength(), length); |
397 length); | |
398 | 397 |
399 // Verify | 398 // Verify |
400 webrtc::RtpUtility::RtpHeaderParser rtp_parser(packet_, length); | 399 webrtc::RtpUtility::RtpHeaderParser rtp_parser(packet_, length); |
401 webrtc::RTPHeader rtp_header; | 400 webrtc::RTPHeader rtp_header; |
402 | 401 |
403 RtpHeaderExtensionMap map; | 402 RtpHeaderExtensionMap map; |
404 map.Register(kRtpExtensionTransmissionTimeOffset, | 403 map.Register(kRtpExtensionTransmissionTimeOffset, |
405 kTransmissionTimeOffsetExtensionId); | 404 kTransmissionTimeOffsetExtensionId); |
406 const bool valid_rtp_header = rtp_parser.Parse(&rtp_header, &map); | 405 const bool valid_rtp_header = rtp_parser.Parse(&rtp_header, &map); |
407 | 406 |
(...skipping 18 matching lines...) Expand all Loading... |
426 TEST_F(RtpSenderTestWithoutPacer, | 425 TEST_F(RtpSenderTestWithoutPacer, |
427 BuildRTPPacketWithNegativeTransmissionOffsetExtension) { | 426 BuildRTPPacketWithNegativeTransmissionOffsetExtension) { |
428 const int kNegTimeOffset = -500; | 427 const int kNegTimeOffset = -500; |
429 EXPECT_EQ(0, rtp_sender_->SetTransmissionTimeOffset(kNegTimeOffset)); | 428 EXPECT_EQ(0, rtp_sender_->SetTransmissionTimeOffset(kNegTimeOffset)); |
430 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( | 429 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( |
431 kRtpExtensionTransmissionTimeOffset, | 430 kRtpExtensionTransmissionTimeOffset, |
432 kTransmissionTimeOffsetExtensionId)); | 431 kTransmissionTimeOffsetExtensionId)); |
433 | 432 |
434 size_t length = static_cast<size_t>(rtp_sender_->BuildRTPheader( | 433 size_t length = static_cast<size_t>(rtp_sender_->BuildRTPheader( |
435 packet_, kPayload, kMarkerBit, kTimestamp, 0)); | 434 packet_, kPayload, kMarkerBit, kTimestamp, 0)); |
436 ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionTotalLength(), | 435 ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionLength(), length); |
437 length); | |
438 | 436 |
439 // Verify | 437 // Verify |
440 webrtc::RtpUtility::RtpHeaderParser rtp_parser(packet_, length); | 438 webrtc::RtpUtility::RtpHeaderParser rtp_parser(packet_, length); |
441 webrtc::RTPHeader rtp_header; | 439 webrtc::RTPHeader rtp_header; |
442 | 440 |
443 RtpHeaderExtensionMap map; | 441 RtpHeaderExtensionMap map; |
444 map.Register(kRtpExtensionTransmissionTimeOffset, | 442 map.Register(kRtpExtensionTransmissionTimeOffset, |
445 kTransmissionTimeOffsetExtensionId); | 443 kTransmissionTimeOffsetExtensionId); |
446 const bool valid_rtp_header = rtp_parser.Parse(&rtp_header, &map); | 444 const bool valid_rtp_header = rtp_parser.Parse(&rtp_header, &map); |
447 | 445 |
448 ASSERT_TRUE(valid_rtp_header); | 446 ASSERT_TRUE(valid_rtp_header); |
449 ASSERT_FALSE(rtp_parser.RTCP()); | 447 ASSERT_FALSE(rtp_parser.RTCP()); |
450 VerifyRTPHeaderCommon(rtp_header); | 448 VerifyRTPHeaderCommon(rtp_header); |
451 EXPECT_EQ(length, rtp_header.headerLength); | 449 EXPECT_EQ(length, rtp_header.headerLength); |
452 EXPECT_TRUE(rtp_header.extension.hasTransmissionTimeOffset); | 450 EXPECT_TRUE(rtp_header.extension.hasTransmissionTimeOffset); |
453 EXPECT_EQ(kNegTimeOffset, rtp_header.extension.transmissionTimeOffset); | 451 EXPECT_EQ(kNegTimeOffset, rtp_header.extension.transmissionTimeOffset); |
454 } | 452 } |
455 | 453 |
456 TEST_F(RtpSenderTestWithoutPacer, BuildRTPPacketWithAbsoluteSendTimeExtension) { | 454 TEST_F(RtpSenderTestWithoutPacer, BuildRTPPacketWithAbsoluteSendTimeExtension) { |
457 EXPECT_EQ(0, rtp_sender_->SetAbsoluteSendTime(kAbsoluteSendTime)); | 455 EXPECT_EQ(0, rtp_sender_->SetAbsoluteSendTime(kAbsoluteSendTime)); |
458 EXPECT_EQ( | 456 EXPECT_EQ( |
459 0, rtp_sender_->RegisterRtpHeaderExtension(kRtpExtensionAbsoluteSendTime, | 457 0, rtp_sender_->RegisterRtpHeaderExtension(kRtpExtensionAbsoluteSendTime, |
460 kAbsoluteSendTimeExtensionId)); | 458 kAbsoluteSendTimeExtensionId)); |
461 | 459 |
462 size_t length = static_cast<size_t>(rtp_sender_->BuildRTPheader( | 460 size_t length = static_cast<size_t>(rtp_sender_->BuildRTPheader( |
463 packet_, kPayload, kMarkerBit, kTimestamp, 0)); | 461 packet_, kPayload, kMarkerBit, kTimestamp, 0)); |
464 ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionTotalLength(), | 462 ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionLength(), length); |
465 length); | |
466 | 463 |
467 // Verify | 464 // Verify |
468 webrtc::RtpUtility::RtpHeaderParser rtp_parser(packet_, length); | 465 webrtc::RtpUtility::RtpHeaderParser rtp_parser(packet_, length); |
469 webrtc::RTPHeader rtp_header; | 466 webrtc::RTPHeader rtp_header; |
470 | 467 |
471 RtpHeaderExtensionMap map; | 468 RtpHeaderExtensionMap map; |
472 map.Register(kRtpExtensionAbsoluteSendTime, kAbsoluteSendTimeExtensionId); | 469 map.Register(kRtpExtensionAbsoluteSendTime, kAbsoluteSendTimeExtensionId); |
473 const bool valid_rtp_header = rtp_parser.Parse(&rtp_header, &map); | 470 const bool valid_rtp_header = rtp_parser.Parse(&rtp_header, &map); |
474 | 471 |
475 ASSERT_TRUE(valid_rtp_header); | 472 ASSERT_TRUE(valid_rtp_header); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 rtp_sender_->SetVideoRotation(kRotation); | 536 rtp_sender_->SetVideoRotation(kRotation); |
540 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( | 537 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( |
541 kRtpExtensionVideoRotation, kVideoRotationExtensionId)); | 538 kRtpExtensionVideoRotation, kVideoRotationExtensionId)); |
542 EXPECT_TRUE(rtp_sender_->ActivateCVORtpHeaderExtension()); | 539 EXPECT_TRUE(rtp_sender_->ActivateCVORtpHeaderExtension()); |
543 | 540 |
544 RtpHeaderExtensionMap map; | 541 RtpHeaderExtensionMap map; |
545 map.Register(kRtpExtensionVideoRotation, kVideoRotationExtensionId); | 542 map.Register(kRtpExtensionVideoRotation, kVideoRotationExtensionId); |
546 | 543 |
547 size_t length = static_cast<size_t>( | 544 size_t length = static_cast<size_t>( |
548 rtp_sender_->BuildRTPheader(packet_, kPayload, true, kTimestamp, 0)); | 545 rtp_sender_->BuildRTPheader(packet_, kPayload, true, kTimestamp, 0)); |
549 ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionTotalLength(), | 546 ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionLength(), length); |
550 length); | |
551 | 547 |
552 // Verify | 548 // Verify |
553 webrtc::RtpUtility::RtpHeaderParser rtp_parser(packet_, length); | 549 webrtc::RtpUtility::RtpHeaderParser rtp_parser(packet_, length); |
554 webrtc::RTPHeader rtp_header; | 550 webrtc::RTPHeader rtp_header; |
555 | 551 |
556 ASSERT_TRUE(rtp_parser.Parse(&rtp_header, &map)); | 552 ASSERT_TRUE(rtp_parser.Parse(&rtp_header, &map)); |
557 ASSERT_FALSE(rtp_parser.RTCP()); | 553 ASSERT_FALSE(rtp_parser.RTCP()); |
558 VerifyRTPHeaderCommon(rtp_header); | 554 VerifyRTPHeaderCommon(rtp_header); |
559 EXPECT_EQ(length, rtp_header.headerLength); | 555 EXPECT_EQ(length, rtp_header.headerLength); |
560 EXPECT_TRUE(rtp_header.extension.hasVideoRotation); | 556 EXPECT_TRUE(rtp_header.extension.hasVideoRotation); |
(...skipping 26 matching lines...) Expand all Loading... |
587 EXPECT_EQ(length, rtp_header.headerLength); | 583 EXPECT_EQ(length, rtp_header.headerLength); |
588 EXPECT_FALSE(rtp_header.extension.hasVideoRotation); | 584 EXPECT_FALSE(rtp_header.extension.hasVideoRotation); |
589 } | 585 } |
590 | 586 |
591 TEST_F(RtpSenderTestWithoutPacer, BuildRTPPacketWithAudioLevelExtension) { | 587 TEST_F(RtpSenderTestWithoutPacer, BuildRTPPacketWithAudioLevelExtension) { |
592 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension(kRtpExtensionAudioLevel, | 588 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension(kRtpExtensionAudioLevel, |
593 kAudioLevelExtensionId)); | 589 kAudioLevelExtensionId)); |
594 | 590 |
595 size_t length = static_cast<size_t>(rtp_sender_->BuildRTPheader( | 591 size_t length = static_cast<size_t>(rtp_sender_->BuildRTPheader( |
596 packet_, kPayload, kMarkerBit, kTimestamp, 0)); | 592 packet_, kPayload, kMarkerBit, kTimestamp, 0)); |
597 ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionTotalLength(), | 593 ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionLength(), length); |
598 length); | |
599 | 594 |
600 // Verify | 595 // Verify |
601 webrtc::RtpUtility::RtpHeaderParser rtp_parser(packet_, length); | 596 webrtc::RtpUtility::RtpHeaderParser rtp_parser(packet_, length); |
602 webrtc::RTPHeader rtp_header; | 597 webrtc::RTPHeader rtp_header; |
603 | 598 |
604 // Updating audio level is done in RTPSenderAudio, so simulate it here. | 599 // Updating audio level is done in RTPSenderAudio, so simulate it here. |
605 rtp_parser.Parse(&rtp_header); | 600 rtp_parser.Parse(&rtp_header); |
606 rtp_sender_->UpdateAudioLevel(packet_, length, rtp_header, true, kAudioLevel); | 601 rtp_sender_->UpdateAudioLevel(packet_, length, rtp_header, true, kAudioLevel); |
607 | 602 |
608 RtpHeaderExtensionMap map; | 603 RtpHeaderExtensionMap map; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 0, rtp_sender_->RegisterRtpHeaderExtension(kRtpExtensionAbsoluteSendTime, | 670 0, rtp_sender_->RegisterRtpHeaderExtension(kRtpExtensionAbsoluteSendTime, |
676 kAbsoluteSendTimeExtensionId)); | 671 kAbsoluteSendTimeExtensionId)); |
677 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension(kRtpExtensionAudioLevel, | 672 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension(kRtpExtensionAudioLevel, |
678 kAudioLevelExtensionId)); | 673 kAudioLevelExtensionId)); |
679 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( | 674 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( |
680 kRtpExtensionTransportSequenceNumber, | 675 kRtpExtensionTransportSequenceNumber, |
681 kTransportSequenceNumberExtensionId)); | 676 kTransportSequenceNumberExtensionId)); |
682 | 677 |
683 size_t length = static_cast<size_t>(rtp_sender_->BuildRTPheader( | 678 size_t length = static_cast<size_t>(rtp_sender_->BuildRTPheader( |
684 packet_, kPayload, kMarkerBit, kTimestamp, 0)); | 679 packet_, kPayload, kMarkerBit, kTimestamp, 0)); |
685 ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionTotalLength(), | 680 ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionLength(), length); |
686 length); | |
687 | 681 |
688 // Verify | 682 // Verify |
689 webrtc::RtpUtility::RtpHeaderParser rtp_parser(packet_, length); | 683 webrtc::RtpUtility::RtpHeaderParser rtp_parser(packet_, length); |
690 webrtc::RTPHeader rtp_header; | 684 webrtc::RTPHeader rtp_header; |
691 | 685 |
692 // Updating audio level is done in RTPSenderAudio, so simulate it here. | 686 // Updating audio level is done in RTPSenderAudio, so simulate it here. |
693 rtp_parser.Parse(&rtp_header); | 687 rtp_parser.Parse(&rtp_header); |
694 rtp_sender_->UpdateAudioLevel(packet_, length, rtp_header, true, kAudioLevel); | 688 rtp_sender_->UpdateAudioLevel(packet_, length, rtp_header, true, kAudioLevel); |
695 | 689 |
696 RtpHeaderExtensionMap map; | 690 RtpHeaderExtensionMap map; |
(...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1588 TEST_F(RtpSenderVideoTest, SendVideoWithCVO) { | 1582 TEST_F(RtpSenderVideoTest, SendVideoWithCVO) { |
1589 RTPVideoHeader hdr = {0}; | 1583 RTPVideoHeader hdr = {0}; |
1590 hdr.rotation = kVideoRotation_90; | 1584 hdr.rotation = kVideoRotation_90; |
1591 | 1585 |
1592 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( | 1586 EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension( |
1593 kRtpExtensionVideoRotation, kVideoRotationExtensionId)); | 1587 kRtpExtensionVideoRotation, kVideoRotationExtensionId)); |
1594 EXPECT_TRUE(rtp_sender_->ActivateCVORtpHeaderExtension()); | 1588 EXPECT_TRUE(rtp_sender_->ActivateCVORtpHeaderExtension()); |
1595 | 1589 |
1596 EXPECT_EQ( | 1590 EXPECT_EQ( |
1597 RtpUtility::Word32Align(kRtpOneByteHeaderLength + kVideoRotationLength), | 1591 RtpUtility::Word32Align(kRtpOneByteHeaderLength + kVideoRotationLength), |
1598 rtp_sender_->RtpHeaderExtensionTotalLength()); | 1592 rtp_sender_->RtpHeaderExtensionLength()); |
1599 | 1593 |
1600 rtp_sender_video_->SendVideo(kRtpVideoGeneric, kVideoFrameKey, kPayload, | 1594 rtp_sender_video_->SendVideo(kRtpVideoGeneric, kVideoFrameKey, kPayload, |
1601 kTimestamp, 0, packet_, sizeof(packet_), nullptr, | 1595 kTimestamp, 0, packet_, sizeof(packet_), nullptr, |
1602 &hdr); | 1596 &hdr); |
1603 | 1597 |
1604 RtpHeaderExtensionMap map; | 1598 RtpHeaderExtensionMap map; |
1605 map.Register(kRtpExtensionVideoRotation, kVideoRotationExtensionId); | 1599 map.Register(kRtpExtensionVideoRotation, kVideoRotationExtensionId); |
1606 | 1600 |
1607 // Verify that this packet does have CVO byte. | 1601 // Verify that this packet does have CVO byte. |
1608 VerifyCVOPacket( | 1602 VerifyCVOPacket( |
1609 reinterpret_cast<uint8_t*>(transport_.sent_packets_[0]->data()), | 1603 reinterpret_cast<uint8_t*>(transport_.sent_packets_[0]->data()), |
1610 transport_.sent_packets_[0]->size(), true, &map, kSeqNum, hdr.rotation); | 1604 transport_.sent_packets_[0]->size(), true, &map, kSeqNum, hdr.rotation); |
1611 | 1605 |
1612 // Verify that this packet does have CVO byte. | 1606 // Verify that this packet does have CVO byte. |
1613 VerifyCVOPacket( | 1607 VerifyCVOPacket( |
1614 reinterpret_cast<uint8_t*>(transport_.sent_packets_[1]->data()), | 1608 reinterpret_cast<uint8_t*>(transport_.sent_packets_[1]->data()), |
1615 transport_.sent_packets_[1]->size(), true, &map, kSeqNum + 1, | 1609 transport_.sent_packets_[1]->size(), true, &map, kSeqNum + 1, |
1616 hdr.rotation); | 1610 hdr.rotation); |
1617 } | 1611 } |
1618 } // namespace webrtc | 1612 } // namespace webrtc |
OLD | NEW |