OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 log_dumper->LogVideoReceiveStreamConfig(receiver_config); | 299 log_dumper->LogVideoReceiveStreamConfig(receiver_config); |
300 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); | 300 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
301 log_dumper->LogVideoSendStreamConfig(sender_config); | 301 log_dumper->LogVideoSendStreamConfig(sender_config); |
302 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); | 302 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
303 size_t rtcp_index = 1; | 303 size_t rtcp_index = 1; |
304 size_t playout_index = 1; | 304 size_t playout_index = 1; |
305 size_t bwe_loss_index = 1; | 305 size_t bwe_loss_index = 1; |
306 for (size_t i = 1; i <= rtp_count; i++) { | 306 for (size_t i = 1; i <= rtp_count; i++) { |
307 log_dumper->LogRtpHeader( | 307 log_dumper->LogRtpHeader( |
308 (i % 2 == 0) ? kIncomingPacket : kOutgoingPacket, | 308 (i % 2 == 0) ? kIncomingPacket : kOutgoingPacket, |
309 (i % 3 == 0) ? MediaType::AUDIO : MediaType::VIDEO, | |
310 rtp_packets[i - 1].data(), rtp_packets[i - 1].size()); | 309 rtp_packets[i - 1].data(), rtp_packets[i - 1].size()); |
311 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); | 310 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
312 if (i * rtcp_count >= rtcp_index * rtp_count) { | 311 if (i * rtcp_count >= rtcp_index * rtp_count) { |
313 log_dumper->LogRtcpPacket( | 312 log_dumper->LogRtcpPacket( |
314 (rtcp_index % 2 == 0) ? kIncomingPacket : kOutgoingPacket, | 313 (rtcp_index % 2 == 0) ? kIncomingPacket : kOutgoingPacket, |
315 rtcp_index % 3 == 0 ? MediaType::AUDIO : MediaType::VIDEO, | |
316 rtcp_packets[rtcp_index - 1].data(), | 314 rtcp_packets[rtcp_index - 1].data(), |
317 rtcp_packets[rtcp_index - 1].size()); | 315 rtcp_packets[rtcp_index - 1].size()); |
318 rtcp_index++; | 316 rtcp_index++; |
319 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); | 317 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
320 } | 318 } |
321 if (i * playout_count >= playout_index * rtp_count) { | 319 if (i * playout_count >= playout_index * rtp_count) { |
322 log_dumper->LogAudioPlayout(playout_ssrcs[playout_index - 1]); | 320 log_dumper->LogAudioPlayout(playout_ssrcs[playout_index - 1]); |
323 playout_index++; | 321 playout_index++; |
324 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); | 322 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
325 } | 323 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 RtcEventLogTestHelper::VerifyVideoSendStreamConfig(parsed_log, 2, | 359 RtcEventLogTestHelper::VerifyVideoSendStreamConfig(parsed_log, 2, |
362 sender_config); | 360 sender_config); |
363 size_t event_index = config_count + 1; | 361 size_t event_index = config_count + 1; |
364 size_t rtcp_index = 1; | 362 size_t rtcp_index = 1; |
365 size_t playout_index = 1; | 363 size_t playout_index = 1; |
366 size_t bwe_loss_index = 1; | 364 size_t bwe_loss_index = 1; |
367 for (size_t i = 1; i <= rtp_count; i++) { | 365 for (size_t i = 1; i <= rtp_count; i++) { |
368 RtcEventLogTestHelper::VerifyRtpEvent( | 366 RtcEventLogTestHelper::VerifyRtpEvent( |
369 parsed_log, event_index, | 367 parsed_log, event_index, |
370 (i % 2 == 0) ? kIncomingPacket : kOutgoingPacket, | 368 (i % 2 == 0) ? kIncomingPacket : kOutgoingPacket, |
371 (i % 3 == 0) ? MediaType::AUDIO : MediaType::VIDEO, | |
372 rtp_packets[i - 1].data(), rtp_packets[i - 1].headers_size(), | 369 rtp_packets[i - 1].data(), rtp_packets[i - 1].headers_size(), |
373 rtp_packets[i - 1].size()); | 370 rtp_packets[i - 1].size()); |
374 event_index++; | 371 event_index++; |
375 if (i * rtcp_count >= rtcp_index * rtp_count) { | 372 if (i * rtcp_count >= rtcp_index * rtp_count) { |
376 RtcEventLogTestHelper::VerifyRtcpEvent( | 373 RtcEventLogTestHelper::VerifyRtcpEvent( |
377 parsed_log, event_index, | 374 parsed_log, event_index, |
378 rtcp_index % 2 == 0 ? kIncomingPacket : kOutgoingPacket, | 375 rtcp_index % 2 == 0 ? kIncomingPacket : kOutgoingPacket, |
379 rtcp_index % 3 == 0 ? MediaType::AUDIO : MediaType::VIDEO, | |
380 rtcp_packets[rtcp_index - 1].data(), | 376 rtcp_packets[rtcp_index - 1].data(), |
381 rtcp_packets[rtcp_index - 1].size()); | 377 rtcp_packets[rtcp_index - 1].size()); |
382 event_index++; | 378 event_index++; |
383 rtcp_index++; | 379 rtcp_index++; |
384 } | 380 } |
385 if (i * playout_count >= playout_index * rtp_count) { | 381 if (i * playout_count >= playout_index * rtp_count) { |
386 RtcEventLogTestHelper::VerifyPlayoutEvent( | 382 RtcEventLogTestHelper::VerifyPlayoutEvent( |
387 parsed_log, event_index, playout_ssrcs[playout_index - 1]); | 383 parsed_log, event_index, playout_ssrcs[playout_index - 1]); |
388 event_index++; | 384 event_index++; |
389 playout_index++; | 385 playout_index++; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 // filename. | 443 // filename. |
448 auto test_info = ::testing::UnitTest::GetInstance()->current_test_info(); | 444 auto test_info = ::testing::UnitTest::GetInstance()->current_test_info(); |
449 const std::string temp_filename = | 445 const std::string temp_filename = |
450 test::OutputPath() + test_info->test_case_name() + test_info->name(); | 446 test::OutputPath() + test_info->test_case_name() + test_info->name(); |
451 | 447 |
452 // Add RTP, start logging, add RTCP and then stop logging | 448 // Add RTP, start logging, add RTCP and then stop logging |
453 rtc::ScopedFakeClock fake_clock; | 449 rtc::ScopedFakeClock fake_clock; |
454 fake_clock.SetTimeMicros(prng.Rand<uint32_t>()); | 450 fake_clock.SetTimeMicros(prng.Rand<uint32_t>()); |
455 std::unique_ptr<RtcEventLog> log_dumper(RtcEventLog::Create()); | 451 std::unique_ptr<RtcEventLog> log_dumper(RtcEventLog::Create()); |
456 | 452 |
457 log_dumper->LogRtpHeader(kIncomingPacket, MediaType::VIDEO, rtp_packet.data(), | 453 log_dumper->LogRtpHeader(kIncomingPacket, rtp_packet.data(), |
458 rtp_packet.size()); | 454 rtp_packet.size()); |
459 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); | 455 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
460 | 456 |
461 log_dumper->StartLogging(temp_filename, 10000000); | 457 log_dumper->StartLogging(temp_filename, 10000000); |
462 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); | 458 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
463 | 459 |
464 log_dumper->LogRtcpPacket(kOutgoingPacket, MediaType::VIDEO, | 460 log_dumper->LogRtcpPacket(kOutgoingPacket, rtcp_packet.data(), |
465 rtcp_packet.data(), rtcp_packet.size()); | 461 rtcp_packet.size()); |
466 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); | 462 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
467 | 463 |
468 log_dumper->StopLogging(); | 464 log_dumper->StopLogging(); |
469 | 465 |
470 // Read the generated file from disk. | 466 // Read the generated file from disk. |
471 ParsedRtcEventLog parsed_log; | 467 ParsedRtcEventLog parsed_log; |
472 ASSERT_TRUE(parsed_log.ParseFile(temp_filename)); | 468 ASSERT_TRUE(parsed_log.ParseFile(temp_filename)); |
473 | 469 |
474 // Verify that what we read back from the event log is the same as | 470 // Verify that what we read back from the event log is the same as |
475 // what we wrote down. | 471 // what we wrote down. |
476 EXPECT_EQ(4u, parsed_log.GetNumberOfEvents()); | 472 EXPECT_EQ(4u, parsed_log.GetNumberOfEvents()); |
477 | 473 |
478 RtcEventLogTestHelper::VerifyLogStartEvent(parsed_log, 0); | 474 RtcEventLogTestHelper::VerifyLogStartEvent(parsed_log, 0); |
479 | 475 |
480 RtcEventLogTestHelper::VerifyRtpEvent( | 476 RtcEventLogTestHelper::VerifyRtpEvent( |
481 parsed_log, 1, kIncomingPacket, MediaType::VIDEO, rtp_packet.data(), | 477 parsed_log, 1, kIncomingPacket, rtp_packet.data(), |
482 rtp_packet.headers_size(), rtp_packet.size()); | 478 rtp_packet.headers_size(), rtp_packet.size()); |
483 | 479 |
484 RtcEventLogTestHelper::VerifyRtcpEvent(parsed_log, 2, kOutgoingPacket, | 480 RtcEventLogTestHelper::VerifyRtcpEvent( |
485 MediaType::VIDEO, rtcp_packet.data(), | 481 parsed_log, 2, kOutgoingPacket, rtcp_packet.data(), rtcp_packet.size()); |
486 rtcp_packet.size()); | |
487 | 482 |
488 RtcEventLogTestHelper::VerifyLogEndEvent(parsed_log, 3); | 483 RtcEventLogTestHelper::VerifyLogEndEvent(parsed_log, 3); |
489 | 484 |
490 // Clean up temporary file - can be pretty slow. | 485 // Clean up temporary file - can be pretty slow. |
491 remove(temp_filename.c_str()); | 486 remove(temp_filename.c_str()); |
492 } | 487 } |
493 | 488 |
494 TEST(RtcEventLogTest, LogLossBasedBweUpdateAndReadBack) { | 489 TEST(RtcEventLogTest, LogLossBasedBweUpdateAndReadBack) { |
495 Random prng(1234); | 490 Random prng(1234); |
496 | 491 |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 VideoSendConfigReadWriteTest test; | 867 VideoSendConfigReadWriteTest test; |
873 test.DoTest(); | 868 test.DoTest(); |
874 } | 869 } |
875 | 870 |
876 TEST(RtcEventLogTest, LogAudioNetworkAdaptation) { | 871 TEST(RtcEventLogTest, LogAudioNetworkAdaptation) { |
877 AudioNetworkAdaptationReadWriteTest test; | 872 AudioNetworkAdaptationReadWriteTest test; |
878 test.DoTest(); | 873 test.DoTest(); |
879 } | 874 } |
880 | 875 |
881 } // namespace webrtc | 876 } // namespace webrtc |
OLD | NEW |