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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 GenerateRtpPacket(&extensions, csrcs_count, packet_size, &prng)); | 276 GenerateRtpPacket(&extensions, csrcs_count, packet_size, &prng)); |
277 } | 277 } |
278 // Create rtcp_count RTCP packets containing random data. | 278 // Create rtcp_count RTCP packets containing random data. |
279 for (size_t i = 0; i < rtcp_count; i++) { | 279 for (size_t i = 0; i < rtcp_count; i++) { |
280 rtcp_packets.push_back(GenerateRtcpPacket(&prng)); | 280 rtcp_packets.push_back(GenerateRtcpPacket(&prng)); |
281 } | 281 } |
282 // Create playout_count random SSRCs to use when logging AudioPlayout events. | 282 // Create playout_count random SSRCs to use when logging AudioPlayout events. |
283 for (size_t i = 0; i < playout_count; i++) { | 283 for (size_t i = 0; i < playout_count; i++) { |
284 playout_ssrcs.push_back(prng.Rand<uint32_t>()); | 284 playout_ssrcs.push_back(prng.Rand<uint32_t>()); |
285 } | 285 } |
286 // Create bwe_loss_count random bitrate updates for BwePacketLoss. | 286 // Create bwe_loss_count random bitrate updates for LossBasedBwe. |
287 for (size_t i = 0; i < bwe_loss_count; i++) { | 287 for (size_t i = 0; i < bwe_loss_count; i++) { |
288 bwe_loss_updates.push_back( | 288 bwe_loss_updates.push_back( |
289 std::make_pair(prng.Rand<int32_t>(), prng.Rand<uint8_t>())); | 289 std::make_pair(prng.Rand<int32_t>(), prng.Rand<uint8_t>())); |
290 } | 290 } |
291 // Create configurations for the video streams. | 291 // Create configurations for the video streams. |
292 GenerateVideoReceiveConfig(extensions_bitvector, &receiver_config, &prng); | 292 GenerateVideoReceiveConfig(extensions_bitvector, &receiver_config, &prng); |
293 GenerateVideoSendConfig(extensions_bitvector, &sender_config, &prng); | 293 GenerateVideoSendConfig(extensions_bitvector, &sender_config, &prng); |
294 const int config_count = 2; | 294 const int config_count = 2; |
295 | 295 |
296 // Find the name of the current test, in order to use it as a temporary | 296 // Find the name of the current test, in order to use it as a temporary |
(...skipping 29 matching lines...) Expand all Loading... |
326 rtcp_packets[rtcp_index - 1].size()); | 326 rtcp_packets[rtcp_index - 1].size()); |
327 rtcp_index++; | 327 rtcp_index++; |
328 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); | 328 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
329 } | 329 } |
330 if (i * playout_count >= playout_index * rtp_count) { | 330 if (i * playout_count >= playout_index * rtp_count) { |
331 log_dumper->LogAudioPlayout(playout_ssrcs[playout_index - 1]); | 331 log_dumper->LogAudioPlayout(playout_ssrcs[playout_index - 1]); |
332 playout_index++; | 332 playout_index++; |
333 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); | 333 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
334 } | 334 } |
335 if (i * bwe_loss_count >= bwe_loss_index * rtp_count) { | 335 if (i * bwe_loss_count >= bwe_loss_index * rtp_count) { |
336 log_dumper->LogBwePacketLossEvent( | 336 log_dumper->LogLossBasedBweUpdate( |
337 bwe_loss_updates[bwe_loss_index - 1].first, | 337 bwe_loss_updates[bwe_loss_index - 1].first, |
338 bwe_loss_updates[bwe_loss_index - 1].second, i); | 338 bwe_loss_updates[bwe_loss_index - 1].second, i); |
339 bwe_loss_index++; | 339 bwe_loss_index++; |
340 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); | 340 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
341 } | 341 } |
342 if (i == rtp_count / 2) { | 342 if (i == rtp_count / 2) { |
343 log_dumper->StartLogging(temp_filename, 10000000); | 343 log_dumper->StartLogging(temp_filename, 10000000); |
344 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); | 344 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
345 } | 345 } |
346 } | 346 } |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 RtcEventLogTestHelper::VerifyRtcpEvent(parsed_log, 2, kOutgoingPacket, | 493 RtcEventLogTestHelper::VerifyRtcpEvent(parsed_log, 2, kOutgoingPacket, |
494 MediaType::VIDEO, rtcp_packet.data(), | 494 MediaType::VIDEO, rtcp_packet.data(), |
495 rtcp_packet.size()); | 495 rtcp_packet.size()); |
496 | 496 |
497 RtcEventLogTestHelper::VerifyLogEndEvent(parsed_log, 3); | 497 RtcEventLogTestHelper::VerifyLogEndEvent(parsed_log, 3); |
498 | 498 |
499 // Clean up temporary file - can be pretty slow. | 499 // Clean up temporary file - can be pretty slow. |
500 remove(temp_filename.c_str()); | 500 remove(temp_filename.c_str()); |
501 } | 501 } |
502 | 502 |
| 503 TEST(RtcEventLogTest, LogLossBasedBweUpdateAndReadBack) { |
| 504 Random prng(1234); |
| 505 |
| 506 // Generate a random packet loss event. |
| 507 int32_t bitrate = prng.Rand(0, 10000000); |
| 508 uint8_t fraction_lost = prng.Rand<uint8_t>(); |
| 509 int32_t total_packets = prng.Rand(1, 1000); |
| 510 |
| 511 // Find the name of the current test, in order to use it as a temporary |
| 512 // filename. |
| 513 auto test_info = ::testing::UnitTest::GetInstance()->current_test_info(); |
| 514 const std::string temp_filename = |
| 515 test::OutputPath() + test_info->test_case_name() + test_info->name(); |
| 516 |
| 517 // Start logging, add the packet loss event and then stop logging. |
| 518 rtc::ScopedFakeClock fake_clock; |
| 519 fake_clock.SetTimeMicros(prng.Rand<uint32_t>()); |
| 520 std::unique_ptr<RtcEventLog> log_dumper(RtcEventLog::Create()); |
| 521 log_dumper->StartLogging(temp_filename, 10000000); |
| 522 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
| 523 log_dumper->LogLossBasedBweUpdate(bitrate, fraction_lost, total_packets); |
| 524 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
| 525 log_dumper->StopLogging(); |
| 526 |
| 527 // Read the generated file from disk. |
| 528 ParsedRtcEventLog parsed_log; |
| 529 ASSERT_TRUE(parsed_log.ParseFile(temp_filename)); |
| 530 |
| 531 // Verify that what we read back from the event log is the same as |
| 532 // what we wrote down. |
| 533 EXPECT_EQ(3u, parsed_log.GetNumberOfEvents()); |
| 534 RtcEventLogTestHelper::VerifyLogStartEvent(parsed_log, 0); |
| 535 RtcEventLogTestHelper::VerifyBweLossEvent(parsed_log, 1, bitrate, |
| 536 fraction_lost, total_packets); |
| 537 RtcEventLogTestHelper::VerifyLogEndEvent(parsed_log, 2); |
| 538 |
| 539 // Clean up temporary file - can be pretty slow. |
| 540 remove(temp_filename.c_str()); |
| 541 } |
| 542 |
| 543 TEST(RtcEventLogTest, LogDelayBasedBweUpdateAndReadBack) { |
| 544 Random prng(1234); |
| 545 |
| 546 // Generate 3 random packet delay event. |
| 547 int32_t bitrate1 = prng.Rand(0, 10000000); |
| 548 int32_t bitrate2 = prng.Rand(0, 10000000); |
| 549 int32_t bitrate3 = prng.Rand(0, 10000000); |
| 550 |
| 551 // Find the name of the current test, in order to use it as a temporary |
| 552 // filename. |
| 553 auto test_info = ::testing::UnitTest::GetInstance()->current_test_info(); |
| 554 const std::string temp_filename = |
| 555 test::OutputPath() + test_info->test_case_name() + test_info->name(); |
| 556 |
| 557 // Start logging, add the packet delay events and then stop logging. |
| 558 rtc::ScopedFakeClock fake_clock; |
| 559 fake_clock.SetTimeMicros(prng.Rand<uint32_t>()); |
| 560 std::unique_ptr<RtcEventLog> log_dumper(RtcEventLog::Create()); |
| 561 log_dumper->StartLogging(temp_filename, 10000000); |
| 562 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
| 563 log_dumper->LogDelayBasedBweUpdate(bitrate1, kBwNormal); |
| 564 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
| 565 log_dumper->LogDelayBasedBweUpdate(bitrate2, kBwOverusing); |
| 566 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
| 567 log_dumper->LogDelayBasedBweUpdate(bitrate3, kBwUnderusing); |
| 568 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
| 569 log_dumper->StopLogging(); |
| 570 |
| 571 // Read the generated file from disk. |
| 572 ParsedRtcEventLog parsed_log; |
| 573 ASSERT_TRUE(parsed_log.ParseFile(temp_filename)); |
| 574 |
| 575 // Verify that what we read back from the event log is the same as |
| 576 // what we wrote down. |
| 577 EXPECT_EQ(5u, parsed_log.GetNumberOfEvents()); |
| 578 RtcEventLogTestHelper::VerifyLogStartEvent(parsed_log, 0); |
| 579 RtcEventLogTestHelper::VerifyBweDelayEvent(parsed_log, 1, bitrate1, |
| 580 kBwNormal); |
| 581 RtcEventLogTestHelper::VerifyBweDelayEvent(parsed_log, 2, bitrate2, |
| 582 kBwOverusing); |
| 583 RtcEventLogTestHelper::VerifyBweDelayEvent(parsed_log, 3, bitrate3, |
| 584 kBwUnderusing); |
| 585 RtcEventLogTestHelper::VerifyLogEndEvent(parsed_log, 4); |
| 586 |
| 587 // Clean up temporary file - can be pretty slow. |
| 588 remove(temp_filename.c_str()); |
| 589 } |
| 590 |
503 class ConfigReadWriteTest { | 591 class ConfigReadWriteTest { |
504 public: | 592 public: |
505 ConfigReadWriteTest() : prng(987654321) {} | 593 ConfigReadWriteTest() : prng(987654321) {} |
506 virtual ~ConfigReadWriteTest() {} | 594 virtual ~ConfigReadWriteTest() {} |
507 virtual void GenerateConfig(uint32_t extensions_bitvector) = 0; | 595 virtual void GenerateConfig(uint32_t extensions_bitvector) = 0; |
508 virtual void VerifyConfig(const ParsedRtcEventLog& parsed_log, | 596 virtual void VerifyConfig(const ParsedRtcEventLog& parsed_log, |
509 size_t index) = 0; | 597 size_t index) = 0; |
510 virtual void LogConfig(RtcEventLog* event_log) = 0; | 598 virtual void LogConfig(RtcEventLog* event_log) = 0; |
511 | 599 |
512 void DoTest() { | 600 void DoTest() { |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 VideoSendConfigReadWriteTest test; | 739 VideoSendConfigReadWriteTest test; |
652 test.DoTest(); | 740 test.DoTest(); |
653 } | 741 } |
654 | 742 |
655 TEST(RtcEventLogTest, LogAudioNetworkAdaptation) { | 743 TEST(RtcEventLogTest, LogAudioNetworkAdaptation) { |
656 AudioNetworkAdaptationReadWriteTest test; | 744 AudioNetworkAdaptationReadWriteTest test; |
657 test.DoTest(); | 745 test.DoTest(); |
658 } | 746 } |
659 | 747 |
660 } // namespace webrtc | 748 } // namespace webrtc |
OLD | NEW |