| 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, LogPacketLossEventAndReadBack) { | 503 TEST(RtcEventLogTest, LogLossBasedBweUpdateAndReadBack) { |
| 504 Random prng(1234); | 504 Random prng(1234); |
| 505 | 505 |
| 506 // Generate a random packet loss event. | 506 // Generate a random packet loss event. |
| 507 int32_t bitrate = prng.Rand(0, 10000000); | 507 int32_t bitrate = prng.Rand(0, 10000000); |
| 508 uint8_t fraction_lost = prng.Rand<uint8_t>(); | 508 uint8_t fraction_lost = prng.Rand<uint8_t>(); |
| 509 int32_t total_packets = prng.Rand(1, 1000); | 509 int32_t total_packets = prng.Rand(1, 1000); |
| 510 | 510 |
| 511 // Find the name of the current test, in order to use it as a temporary | 511 // Find the name of the current test, in order to use it as a temporary |
| 512 // filename. | 512 // filename. |
| 513 auto test_info = ::testing::UnitTest::GetInstance()->current_test_info(); | 513 auto test_info = ::testing::UnitTest::GetInstance()->current_test_info(); |
| 514 const std::string temp_filename = | 514 const std::string temp_filename = |
| 515 test::OutputPath() + test_info->test_case_name() + test_info->name(); | 515 test::OutputPath() + test_info->test_case_name() + test_info->name(); |
| 516 | 516 |
| 517 // Start logging, add the packet loss event and then stop logging. | 517 // Start logging, add the packet loss event and then stop logging. |
| 518 rtc::ScopedFakeClock fake_clock; | 518 rtc::ScopedFakeClock fake_clock; |
| 519 fake_clock.SetTimeMicros(prng.Rand<uint32_t>()); | 519 fake_clock.SetTimeMicros(prng.Rand<uint32_t>()); |
| 520 std::unique_ptr<RtcEventLog> log_dumper(RtcEventLog::Create()); | 520 std::unique_ptr<RtcEventLog> log_dumper(RtcEventLog::Create()); |
| 521 log_dumper->StartLogging(temp_filename, 10000000); | 521 log_dumper->StartLogging(temp_filename, 10000000); |
| 522 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); | 522 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
| 523 log_dumper->LogBwePacketLossEvent(bitrate, fraction_lost, total_packets); | 523 log_dumper->LogLossBasedBweUpdate(bitrate, fraction_lost, total_packets); |
| 524 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); | 524 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
| 525 log_dumper->StopLogging(); | 525 log_dumper->StopLogging(); |
| 526 | 526 |
| 527 // Read the generated file from disk. | 527 // Read the generated file from disk. |
| 528 ParsedRtcEventLog parsed_log; | 528 ParsedRtcEventLog parsed_log; |
| 529 ASSERT_TRUE(parsed_log.ParseFile(temp_filename)); | 529 ASSERT_TRUE(parsed_log.ParseFile(temp_filename)); |
| 530 | 530 |
| 531 // Verify that what we read back from the event log is the same as | 531 // Verify that what we read back from the event log is the same as |
| 532 // what we wrote down. | 532 // what we wrote down. |
| 533 EXPECT_EQ(3u, parsed_log.GetNumberOfEvents()); | 533 EXPECT_EQ(3u, parsed_log.GetNumberOfEvents()); |
| 534 RtcEventLogTestHelper::VerifyLogStartEvent(parsed_log, 0); | 534 RtcEventLogTestHelper::VerifyLogStartEvent(parsed_log, 0); |
| 535 RtcEventLogTestHelper::VerifyBweLossEvent(parsed_log, 1, bitrate, | 535 RtcEventLogTestHelper::VerifyBweLossEvent(parsed_log, 1, bitrate, |
| 536 fraction_lost, total_packets); | 536 fraction_lost, total_packets); |
| 537 RtcEventLogTestHelper::VerifyLogEndEvent(parsed_log, 2); | 537 RtcEventLogTestHelper::VerifyLogEndEvent(parsed_log, 2); |
| 538 | 538 |
| 539 // Clean up temporary file - can be pretty slow. | 539 // Clean up temporary file - can be pretty slow. |
| 540 remove(temp_filename.c_str()); | 540 remove(temp_filename.c_str()); |
| 541 } | 541 } |
| 542 | 542 |
| 543 TEST(RtcEventLogTest, LogPacketDelayEventAndReadBack) { | 543 TEST(RtcEventLogTest, LogDelayBasedBweUpdateAndReadBack) { |
| 544 Random prng(1234); | 544 Random prng(1234); |
| 545 | 545 |
| 546 // Generate 3 random packet delay event. | 546 // Generate 3 random packet delay event. |
| 547 int32_t bitrate1 = prng.Rand(0, 10000000); | 547 int32_t bitrate1 = prng.Rand(0, 10000000); |
| 548 int32_t bitrate2 = prng.Rand(0, 10000000); | 548 int32_t bitrate2 = prng.Rand(0, 10000000); |
| 549 int32_t bitrate3 = prng.Rand(0, 10000000); | 549 int32_t bitrate3 = prng.Rand(0, 10000000); |
| 550 | 550 |
| 551 // Find the name of the current test, in order to use it as a temporary | 551 // Find the name of the current test, in order to use it as a temporary |
| 552 // filename. | 552 // filename. |
| 553 auto test_info = ::testing::UnitTest::GetInstance()->current_test_info(); | 553 auto test_info = ::testing::UnitTest::GetInstance()->current_test_info(); |
| 554 const std::string temp_filename = | 554 const std::string temp_filename = |
| 555 test::OutputPath() + test_info->test_case_name() + test_info->name(); | 555 test::OutputPath() + test_info->test_case_name() + test_info->name(); |
| 556 | 556 |
| 557 // Start logging, add the packet delay events and then stop logging. | 557 // Start logging, add the packet delay events and then stop logging. |
| 558 rtc::ScopedFakeClock fake_clock; | 558 rtc::ScopedFakeClock fake_clock; |
| 559 fake_clock.SetTimeMicros(prng.Rand<uint32_t>()); | 559 fake_clock.SetTimeMicros(prng.Rand<uint32_t>()); |
| 560 std::unique_ptr<RtcEventLog> log_dumper(RtcEventLog::Create()); | 560 std::unique_ptr<RtcEventLog> log_dumper(RtcEventLog::Create()); |
| 561 log_dumper->StartLogging(temp_filename, 10000000); | 561 log_dumper->StartLogging(temp_filename, 10000000); |
| 562 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); | 562 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
| 563 log_dumper->LogBwePacketDelayEvent(bitrate1, kBwNormal); | 563 log_dumper->LogDelayBasedBweUpdate(bitrate1, kBwNormal); |
| 564 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); | 564 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
| 565 log_dumper->LogBwePacketDelayEvent(bitrate2, kBwOverusing); | 565 log_dumper->LogDelayBasedBweUpdate(bitrate2, kBwOverusing); |
| 566 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); | 566 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
| 567 log_dumper->LogBwePacketDelayEvent(bitrate3, kBwUnderusing); | 567 log_dumper->LogDelayBasedBweUpdate(bitrate3, kBwUnderusing); |
| 568 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); | 568 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); |
| 569 log_dumper->StopLogging(); | 569 log_dumper->StopLogging(); |
| 570 | 570 |
| 571 // Read the generated file from disk. | 571 // Read the generated file from disk. |
| 572 ParsedRtcEventLog parsed_log; | 572 ParsedRtcEventLog parsed_log; |
| 573 ASSERT_TRUE(parsed_log.ParseFile(temp_filename)); | 573 ASSERT_TRUE(parsed_log.ParseFile(temp_filename)); |
| 574 | 574 |
| 575 // Verify that what we read back from the event log is the same as | 575 // Verify that what we read back from the event log is the same as |
| 576 // what we wrote down. | 576 // what we wrote down. |
| 577 EXPECT_EQ(5u, parsed_log.GetNumberOfEvents()); | 577 EXPECT_EQ(5u, parsed_log.GetNumberOfEvents()); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 VideoSendConfigReadWriteTest test; | 739 VideoSendConfigReadWriteTest test; |
| 740 test.DoTest(); | 740 test.DoTest(); |
| 741 } | 741 } |
| 742 | 742 |
| 743 TEST(RtcEventLogTest, LogAudioNetworkAdaptation) { | 743 TEST(RtcEventLogTest, LogAudioNetworkAdaptation) { |
| 744 AudioNetworkAdaptationReadWriteTest test; | 744 AudioNetworkAdaptationReadWriteTest test; |
| 745 test.DoTest(); | 745 test.DoTest(); |
| 746 } | 746 } |
| 747 | 747 |
| 748 } // namespace webrtc | 748 } // namespace webrtc |
| OLD | NEW |