Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: webrtc/logging/rtc_event_log/rtc_event_log_unittest.cc

Issue 3016473002: Remove encoding code from RtcEventLogImpl and use RtcEventLogEncoder instead (Closed)
Patch Set: Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 #include <map> 11 #include <map>
12 #include <memory> 12 #include <memory>
13 #include <string> 13 #include <string>
14 #include <utility> 14 #include <utility>
15 #include <vector> 15 #include <vector>
16 16
17 #include "webrtc/call/call.h" 17 #include "webrtc/call/call.h"
18 #include "webrtc/logging/rtc_event_log/events/rtc_event_audio_network_adaptation .h"
19 #include "webrtc/logging/rtc_event_log/events/rtc_event_audio_playout.h"
20 #include "webrtc/logging/rtc_event_log/events/rtc_event_audio_receive_stream_con fig.h"
21 #include "webrtc/logging/rtc_event_log/events/rtc_event_audio_send_stream_config .h"
22 #include "webrtc/logging/rtc_event_log/events/rtc_event_bwe_update_delay_based.h "
23 #include "webrtc/logging/rtc_event_log/events/rtc_event_bwe_update_loss_based.h"
24 #include "webrtc/logging/rtc_event_log/events/rtc_event_logging_started.h"
25 #include "webrtc/logging/rtc_event_log/events/rtc_event_logging_stopped.h"
26 #include "webrtc/logging/rtc_event_log/events/rtc_event_probe_cluster_created.h"
27 #include "webrtc/logging/rtc_event_log/events/rtc_event_probe_result_failure.h"
28 #include "webrtc/logging/rtc_event_log/events/rtc_event_probe_result_success.h"
29 #include "webrtc/logging/rtc_event_log/events/rtc_event_rtcp_packet_incoming.h"
30 #include "webrtc/logging/rtc_event_log/events/rtc_event_rtcp_packet_outgoing.h"
31 #include "webrtc/logging/rtc_event_log/events/rtc_event_rtp_packet_incoming.h"
32 #include "webrtc/logging/rtc_event_log/events/rtc_event_rtp_packet_outgoing.h"
33 #include "webrtc/logging/rtc_event_log/events/rtc_event_video_receive_stream_con fig.h"
34 #include "webrtc/logging/rtc_event_log/events/rtc_event_video_send_stream_config .h"
18 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" 35 #include "webrtc/logging/rtc_event_log/rtc_event_log.h"
19 #include "webrtc/logging/rtc_event_log/rtc_event_log_parser.h" 36 #include "webrtc/logging/rtc_event_log/rtc_event_log_parser.h"
20 #include "webrtc/logging/rtc_event_log/rtc_event_log_unittest_helper.h" 37 #include "webrtc/logging/rtc_event_log/rtc_event_log_unittest_helper.h"
21 #include "webrtc/logging/rtc_event_log/rtc_stream_config.h" 38 #include "webrtc/logging/rtc_event_log/rtc_stream_config.h"
22 #include "webrtc/modules/audio_coding/audio_network_adaptor/include/audio_networ k_adaptor.h" 39 #include "webrtc/modules/audio_coding/audio_network_adaptor/include/audio_networ k_adaptor.h"
23 #include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h" 40 #include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h"
24 #include "webrtc/modules/rtp_rtcp/include/rtp_header_extension_map.h" 41 #include "webrtc/modules/rtp_rtcp/include/rtp_header_extension_map.h"
25 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h" 42 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h"
26 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sender_report.h" 43 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sender_report.h"
27 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extensions.h" 44 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extensions.h"
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 size_t bwe_delay_written = 0; 384 size_t bwe_delay_written = 0;
368 size_t recv_configs_written = 0; 385 size_t recv_configs_written = 0;
369 size_t send_configs_written = 0; 386 size_t send_configs_written = 0;
370 387
371 for (size_t i = 0; i < event_types.size(); i++) { 388 for (size_t i = 0; i < event_types.size(); i++) {
372 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); 389 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000));
373 if (i == event_types.size() / 2) 390 if (i == event_types.size() / 2)
374 log_dumper->StartLogging(temp_filename, 10000000); 391 log_dumper->StartLogging(temp_filename, 10000000);
375 switch (event_types[i]) { 392 switch (event_types[i]) {
376 case EventType::INCOMING_RTP: 393 case EventType::INCOMING_RTP:
377 log_dumper->LogIncomingRtpHeader( 394 log_dumper->Log(rtc::MakeUnique<RtcEventRtpPacketIncoming>(
378 incoming_rtp_packets[incoming_rtp_written++]); 395 incoming_rtp_packets[incoming_rtp_written++]));
379 break; 396 break;
380 case EventType::OUTGOING_RTP: 397 case EventType::OUTGOING_RTP: {
381 log_dumper->LogOutgoingRtpHeader( 398 constexpr int kNotAProble = PacedPacketInfo::kNotAProbe; // Compiler...
382 outgoing_rtp_packets[outgoing_rtp_written++], 399 log_dumper->Log(rtc::MakeUnique<RtcEventRtpPacketOutgoing>(
383 PacedPacketInfo::kNotAProbe); 400 outgoing_rtp_packets[outgoing_rtp_written++], kNotAProble));
384 break; 401 break;
402 }
385 case EventType::INCOMING_RTCP: 403 case EventType::INCOMING_RTCP:
386 log_dumper->LogIncomingRtcpPacket( 404 log_dumper->Log(rtc::MakeUnique<RtcEventRtcpPacketIncoming>(
387 incoming_rtcp_packets[incoming_rtcp_written++]); 405 incoming_rtcp_packets[incoming_rtcp_written++]));
388 break; 406 break;
389 case EventType::OUTGOING_RTCP: 407 case EventType::OUTGOING_RTCP:
390 log_dumper->LogOutgoingRtcpPacket( 408 log_dumper->Log(rtc::MakeUnique<RtcEventRtcpPacketOutgoing>(
391 outgoing_rtcp_packets[outgoing_rtcp_written++]); 409 outgoing_rtcp_packets[outgoing_rtcp_written++]));
392 break; 410 break;
393 case EventType::AUDIO_PLAYOUT: 411 case EventType::AUDIO_PLAYOUT:
394 log_dumper->LogAudioPlayout(playout_ssrcs[playouts_written++]); 412 log_dumper->Log(rtc::MakeUnique<RtcEventAudioPlayout>(
413 playout_ssrcs[playouts_written++]));
395 break; 414 break;
396 case EventType::BWE_LOSS_UPDATE: 415 case EventType::BWE_LOSS_UPDATE:
397 log_dumper->LogLossBasedBweUpdate( 416 log_dumper->Log(rtc::MakeUnique<RtcEventBweUpdateLossBased>(
398 bwe_loss_updates[bwe_loss_written].bitrate_bps, 417 bwe_loss_updates[bwe_loss_written].bitrate_bps,
399 bwe_loss_updates[bwe_loss_written].fraction_loss, 418 bwe_loss_updates[bwe_loss_written].fraction_loss,
400 bwe_loss_updates[bwe_loss_written].total_packets); 419 bwe_loss_updates[bwe_loss_written].total_packets));
401 bwe_loss_written++; 420 bwe_loss_written++;
402 break; 421 break;
403 case EventType::BWE_DELAY_UPDATE: 422 case EventType::BWE_DELAY_UPDATE:
404 log_dumper->LogDelayBasedBweUpdate( 423 log_dumper->Log(rtc::MakeUnique<RtcEventBweUpdateDelayBased>(
405 bwe_delay_updates[bwe_delay_written].first, 424 bwe_delay_updates[bwe_delay_written].first,
406 bwe_delay_updates[bwe_delay_written].second); 425 bwe_delay_updates[bwe_delay_written].second));
407 bwe_delay_written++; 426 bwe_delay_written++;
408 break; 427 break;
409 case EventType::VIDEO_RECV_CONFIG: 428 case EventType::VIDEO_RECV_CONFIG:
410 log_dumper->LogVideoReceiveStreamConfig( 429 log_dumper->Log(rtc::MakeUnique<RtcEventVideoReceiveStreamConfig>(
411 receiver_configs[recv_configs_written++]); 430 rtc::MakeUnique<rtclog::StreamConfig>(
431 receiver_configs[recv_configs_written++])));
412 break; 432 break;
413 case EventType::VIDEO_SEND_CONFIG: 433 case EventType::VIDEO_SEND_CONFIG:
414 log_dumper->LogVideoSendStreamConfig( 434 log_dumper->Log(rtc::MakeUnique<RtcEventVideoSendStreamConfig>(
415 sender_configs[send_configs_written++]); 435 rtc::MakeUnique<rtclog::StreamConfig>(
436 sender_configs[send_configs_written++])));
416 break; 437 break;
417 case EventType::AUDIO_RECV_CONFIG: 438 case EventType::AUDIO_RECV_CONFIG:
418 // Not implemented 439 // Not implemented
419 RTC_NOTREACHED(); 440 RTC_NOTREACHED();
420 break; 441 break;
421 case EventType::AUDIO_SEND_CONFIG: 442 case EventType::AUDIO_SEND_CONFIG:
422 // Not implemented 443 // Not implemented
423 RTC_NOTREACHED(); 444 RTC_NOTREACHED();
424 break; 445 break;
425 case EventType::AUDIO_NETWORK_ADAPTATION: 446 case EventType::AUDIO_NETWORK_ADAPTATION:
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 // filename. 754 // filename.
734 auto test_info = ::testing::UnitTest::GetInstance()->current_test_info(); 755 auto test_info = ::testing::UnitTest::GetInstance()->current_test_info();
735 const std::string temp_filename = 756 const std::string temp_filename =
736 test::OutputPath() + test_info->test_case_name() + test_info->name(); 757 test::OutputPath() + test_info->test_case_name() + test_info->name();
737 758
738 // Add RTP, start logging, add RTCP and then stop logging 759 // Add RTP, start logging, add RTCP and then stop logging
739 rtc::ScopedFakeClock fake_clock; 760 rtc::ScopedFakeClock fake_clock;
740 fake_clock.SetTimeMicros(prng.Rand<uint32_t>()); 761 fake_clock.SetTimeMicros(prng.Rand<uint32_t>());
741 std::unique_ptr<RtcEventLog> log_dumper(RtcEventLog::Create()); 762 std::unique_ptr<RtcEventLog> log_dumper(RtcEventLog::Create());
742 763
743 log_dumper->LogIncomingRtpHeader(rtp_packet); 764 log_dumper->Log(rtc::MakeUnique<RtcEventRtpPacketIncoming>(rtp_packet));
744 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); 765 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000));
745 766
746 log_dumper->StartLogging(temp_filename, 10000000); 767 log_dumper->StartLogging(temp_filename, 10000000);
747 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); 768 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000));
748 769
749 log_dumper->LogOutgoingRtcpPacket(rtcp_packet); 770 log_dumper->Log(rtc::MakeUnique<RtcEventRtcpPacketOutgoing>(rtcp_packet));
750 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); 771 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000));
751 772
752 log_dumper->StopLogging(); 773 log_dumper->StopLogging();
753 774
754 // Read the generated file from disk. 775 // Read the generated file from disk.
755 ParsedRtcEventLog parsed_log; 776 ParsedRtcEventLog parsed_log;
756 ASSERT_TRUE(parsed_log.ParseFile(temp_filename)); 777 ASSERT_TRUE(parsed_log.ParseFile(temp_filename));
757 778
758 // Verify that what we read back from the event log is the same as 779 // Verify that what we read back from the event log is the same as
759 // what we wrote down. 780 // what we wrote down.
(...skipping 26 matching lines...) Expand all
786 auto test_info = ::testing::UnitTest::GetInstance()->current_test_info(); 807 auto test_info = ::testing::UnitTest::GetInstance()->current_test_info();
787 const std::string temp_filename = 808 const std::string temp_filename =
788 test::OutputPath() + test_info->test_case_name() + test_info->name(); 809 test::OutputPath() + test_info->test_case_name() + test_info->name();
789 810
790 // Start logging, add the packet loss event and then stop logging. 811 // Start logging, add the packet loss event and then stop logging.
791 rtc::ScopedFakeClock fake_clock; 812 rtc::ScopedFakeClock fake_clock;
792 fake_clock.SetTimeMicros(prng.Rand<uint32_t>()); 813 fake_clock.SetTimeMicros(prng.Rand<uint32_t>());
793 std::unique_ptr<RtcEventLog> log_dumper(RtcEventLog::Create()); 814 std::unique_ptr<RtcEventLog> log_dumper(RtcEventLog::Create());
794 log_dumper->StartLogging(temp_filename, 10000000); 815 log_dumper->StartLogging(temp_filename, 10000000);
795 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); 816 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000));
796 log_dumper->LogLossBasedBweUpdate(bitrate, fraction_lost, total_packets); 817 log_dumper->Log(rtc::MakeUnique<RtcEventBweUpdateLossBased>(
818 bitrate, fraction_lost, total_packets));
797 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); 819 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000));
798 log_dumper->StopLogging(); 820 log_dumper->StopLogging();
799 821
800 // Read the generated file from disk. 822 // Read the generated file from disk.
801 ParsedRtcEventLog parsed_log; 823 ParsedRtcEventLog parsed_log;
802 ASSERT_TRUE(parsed_log.ParseFile(temp_filename)); 824 ASSERT_TRUE(parsed_log.ParseFile(temp_filename));
803 825
804 // Verify that what we read back from the event log is the same as 826 // Verify that what we read back from the event log is the same as
805 // what we wrote down. 827 // what we wrote down.
806 EXPECT_EQ(3u, parsed_log.GetNumberOfEvents()); 828 EXPECT_EQ(3u, parsed_log.GetNumberOfEvents());
(...skipping 19 matching lines...) Expand all
826 auto test_info = ::testing::UnitTest::GetInstance()->current_test_info(); 848 auto test_info = ::testing::UnitTest::GetInstance()->current_test_info();
827 const std::string temp_filename = 849 const std::string temp_filename =
828 test::OutputPath() + test_info->test_case_name() + test_info->name(); 850 test::OutputPath() + test_info->test_case_name() + test_info->name();
829 851
830 // Start logging, add the packet delay events and then stop logging. 852 // Start logging, add the packet delay events and then stop logging.
831 rtc::ScopedFakeClock fake_clock; 853 rtc::ScopedFakeClock fake_clock;
832 fake_clock.SetTimeMicros(prng.Rand<uint32_t>()); 854 fake_clock.SetTimeMicros(prng.Rand<uint32_t>());
833 std::unique_ptr<RtcEventLog> log_dumper(RtcEventLog::Create()); 855 std::unique_ptr<RtcEventLog> log_dumper(RtcEventLog::Create());
834 log_dumper->StartLogging(temp_filename, 10000000); 856 log_dumper->StartLogging(temp_filename, 10000000);
835 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); 857 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000));
836 log_dumper->LogDelayBasedBweUpdate(bitrate1, BandwidthUsage::kBwNormal); 858 log_dumper->Log(rtc::MakeUnique<RtcEventBweUpdateDelayBased>(
859 bitrate1, BandwidthUsage::kBwNormal));
837 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); 860 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000));
838 log_dumper->LogDelayBasedBweUpdate(bitrate2, BandwidthUsage::kBwOverusing); 861 log_dumper->Log(rtc::MakeUnique<RtcEventBweUpdateDelayBased>(
862 bitrate2, BandwidthUsage::kBwOverusing));
839 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); 863 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000));
840 log_dumper->LogDelayBasedBweUpdate(bitrate3, BandwidthUsage::kBwUnderusing); 864 log_dumper->Log(rtc::MakeUnique<RtcEventBweUpdateDelayBased>(
865 bitrate3, BandwidthUsage::kBwUnderusing));
841 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); 866 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000));
842 log_dumper->StopLogging(); 867 log_dumper->StopLogging();
843 868
844 // Read the generated file from disk. 869 // Read the generated file from disk.
845 ParsedRtcEventLog parsed_log; 870 ParsedRtcEventLog parsed_log;
846 ASSERT_TRUE(parsed_log.ParseFile(temp_filename)); 871 ASSERT_TRUE(parsed_log.ParseFile(temp_filename));
847 872
848 // Verify that what we read back from the event log is the same as 873 // Verify that what we read back from the event log is the same as
849 // what we wrote down. 874 // what we wrote down.
850 EXPECT_EQ(5u, parsed_log.GetNumberOfEvents()); 875 EXPECT_EQ(5u, parsed_log.GetNumberOfEvents());
(...skipping 27 matching lines...) Expand all
878 // filename. 903 // filename.
879 auto test_info = ::testing::UnitTest::GetInstance()->current_test_info(); 904 auto test_info = ::testing::UnitTest::GetInstance()->current_test_info();
880 const std::string temp_filename = 905 const std::string temp_filename =
881 test::OutputPath() + test_info->test_case_name() + test_info->name(); 906 test::OutputPath() + test_info->test_case_name() + test_info->name();
882 907
883 rtc::ScopedFakeClock fake_clock; 908 rtc::ScopedFakeClock fake_clock;
884 fake_clock.SetTimeMicros(prng.Rand<uint32_t>()); 909 fake_clock.SetTimeMicros(prng.Rand<uint32_t>());
885 std::unique_ptr<RtcEventLog> log_dumper(RtcEventLog::Create()); 910 std::unique_ptr<RtcEventLog> log_dumper(RtcEventLog::Create());
886 911
887 log_dumper->StartLogging(temp_filename, 10000000); 912 log_dumper->StartLogging(temp_filename, 10000000);
888 log_dumper->LogProbeClusterCreated(0, bitrate_bps0, min_probes0, min_bytes0); 913 log_dumper->Log(rtc::MakeUnique<RtcEventProbeClusterCreated>(
914 0, bitrate_bps0, min_probes0, min_bytes0));
889 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); 915 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000));
890 log_dumper->LogProbeClusterCreated(1, bitrate_bps1, min_probes1, min_bytes1); 916 log_dumper->Log(rtc::MakeUnique<RtcEventProbeClusterCreated>(
917 1, bitrate_bps1, min_probes1, min_bytes1));
891 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); 918 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000));
892 log_dumper->LogProbeClusterCreated(2, bitrate_bps2, min_probes2, min_bytes2); 919 log_dumper->Log(rtc::MakeUnique<RtcEventProbeClusterCreated>(
920 2, bitrate_bps2, min_probes2, min_bytes2));
893 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); 921 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000));
894 log_dumper->StopLogging(); 922 log_dumper->StopLogging();
895 923
896 // Read the generated file from disk. 924 // Read the generated file from disk.
897 ParsedRtcEventLog parsed_log; 925 ParsedRtcEventLog parsed_log;
898 ASSERT_TRUE(parsed_log.ParseFile(temp_filename)); 926 ASSERT_TRUE(parsed_log.ParseFile(temp_filename));
899 927
900 // Verify that what we read back from the event log is the same as 928 // Verify that what we read back from the event log is the same as
901 // what we wrote down. 929 // what we wrote down.
902 EXPECT_EQ(5u, parsed_log.GetNumberOfEvents()); 930 EXPECT_EQ(5u, parsed_log.GetNumberOfEvents());
(...skipping 21 matching lines...) Expand all
924 // filename. 952 // filename.
925 auto test_info = ::testing::UnitTest::GetInstance()->current_test_info(); 953 auto test_info = ::testing::UnitTest::GetInstance()->current_test_info();
926 const std::string temp_filename = 954 const std::string temp_filename =
927 test::OutputPath() + test_info->test_case_name() + test_info->name(); 955 test::OutputPath() + test_info->test_case_name() + test_info->name();
928 956
929 rtc::ScopedFakeClock fake_clock; 957 rtc::ScopedFakeClock fake_clock;
930 fake_clock.SetTimeMicros(prng.Rand<uint32_t>()); 958 fake_clock.SetTimeMicros(prng.Rand<uint32_t>());
931 std::unique_ptr<RtcEventLog> log_dumper(RtcEventLog::Create()); 959 std::unique_ptr<RtcEventLog> log_dumper(RtcEventLog::Create());
932 960
933 log_dumper->StartLogging(temp_filename, 10000000); 961 log_dumper->StartLogging(temp_filename, 10000000);
934 log_dumper->LogProbeResultSuccess(0, bitrate_bps0); 962 log_dumper->Log(rtc::MakeUnique<RtcEventProbeResultSuccess>(0, bitrate_bps0));
935 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); 963 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000));
936 log_dumper->LogProbeResultSuccess(1, bitrate_bps1); 964 log_dumper->Log(rtc::MakeUnique<RtcEventProbeResultSuccess>(1, bitrate_bps1));
937 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); 965 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000));
938 log_dumper->LogProbeResultSuccess(2, bitrate_bps2); 966 log_dumper->Log(rtc::MakeUnique<RtcEventProbeResultSuccess>(2, bitrate_bps2));
939 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); 967 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000));
940 log_dumper->StopLogging(); 968 log_dumper->StopLogging();
941 969
942 // Read the generated file from disk. 970 // Read the generated file from disk.
943 ParsedRtcEventLog parsed_log; 971 ParsedRtcEventLog parsed_log;
944 ASSERT_TRUE(parsed_log.ParseFile(temp_filename)); 972 ASSERT_TRUE(parsed_log.ParseFile(temp_filename));
945 973
946 // Verify that what we read back from the event log is the same as 974 // Verify that what we read back from the event log is the same as
947 // what we wrote down. 975 // what we wrote down.
948 EXPECT_EQ(5u, parsed_log.GetNumberOfEvents()); 976 EXPECT_EQ(5u, parsed_log.GetNumberOfEvents());
(...skipping 17 matching lines...) Expand all
966 // filename. 994 // filename.
967 auto test_info = ::testing::UnitTest::GetInstance()->current_test_info(); 995 auto test_info = ::testing::UnitTest::GetInstance()->current_test_info();
968 const std::string temp_filename = 996 const std::string temp_filename =
969 test::OutputPath() + test_info->test_case_name() + test_info->name(); 997 test::OutputPath() + test_info->test_case_name() + test_info->name();
970 998
971 rtc::ScopedFakeClock fake_clock; 999 rtc::ScopedFakeClock fake_clock;
972 fake_clock.SetTimeMicros(prng.Rand<uint32_t>()); 1000 fake_clock.SetTimeMicros(prng.Rand<uint32_t>());
973 std::unique_ptr<RtcEventLog> log_dumper(RtcEventLog::Create()); 1001 std::unique_ptr<RtcEventLog> log_dumper(RtcEventLog::Create());
974 1002
975 log_dumper->StartLogging(temp_filename, 10000000); 1003 log_dumper->StartLogging(temp_filename, 10000000);
976 log_dumper->LogProbeResultFailure( 1004 log_dumper->Log(rtc::MakeUnique<RtcEventProbeResultFailure>(
977 0, ProbeFailureReason::kInvalidSendReceiveInterval); 1005 0, ProbeFailureReason::kInvalidSendReceiveInterval));
978 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); 1006 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000));
979 log_dumper->LogProbeResultFailure( 1007 log_dumper->Log(rtc::MakeUnique<RtcEventProbeResultFailure>(
980 1, ProbeFailureReason::kInvalidSendReceiveRatio); 1008 1, ProbeFailureReason::kInvalidSendReceiveRatio));
981 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); 1009 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000));
982 log_dumper->LogProbeResultFailure(2, ProbeFailureReason::kTimeout); 1010 log_dumper->Log(rtc::MakeUnique<RtcEventProbeResultFailure>(
1011 2, ProbeFailureReason::kTimeout));
983 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000)); 1012 fake_clock.AdvanceTimeMicros(prng.Rand(1, 1000));
984 log_dumper->StopLogging(); 1013 log_dumper->StopLogging();
985 1014
986 // Read the generated file from disk. 1015 // Read the generated file from disk.
987 ParsedRtcEventLog parsed_log; 1016 ParsedRtcEventLog parsed_log;
988 ASSERT_TRUE(parsed_log.ParseFile(temp_filename)); 1017 ASSERT_TRUE(parsed_log.ParseFile(temp_filename));
989 1018
990 // Verify that what we read back from the event log is the same as 1019 // Verify that what we read back from the event log is the same as
991 // what we wrote down. 1020 // what we wrote down.
992 EXPECT_EQ(5u, parsed_log.GetNumberOfEvents()); 1021 EXPECT_EQ(5u, parsed_log.GetNumberOfEvents());
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 } 1083 }
1055 Random prng; 1084 Random prng;
1056 }; 1085 };
1057 1086
1058 class AudioReceiveConfigReadWriteTest : public ConfigReadWriteTest { 1087 class AudioReceiveConfigReadWriteTest : public ConfigReadWriteTest {
1059 public: 1088 public:
1060 void GenerateConfig(const RtpHeaderExtensionMap& extensions) override { 1089 void GenerateConfig(const RtpHeaderExtensionMap& extensions) override {
1061 GenerateAudioReceiveConfig(extensions, &config, &prng); 1090 GenerateAudioReceiveConfig(extensions, &config, &prng);
1062 } 1091 }
1063 void LogConfig(RtcEventLog* event_log) override { 1092 void LogConfig(RtcEventLog* event_log) override {
1064 event_log->LogAudioReceiveStreamConfig(config); 1093 event_log->Log(rtc::MakeUnique<RtcEventAudioReceiveStreamConfig>(
1094 rtc::MakeUnique<rtclog::StreamConfig>(config)));
1065 } 1095 }
1066 void VerifyConfig(const ParsedRtcEventLog& parsed_log, 1096 void VerifyConfig(const ParsedRtcEventLog& parsed_log,
1067 size_t index) override { 1097 size_t index) override {
1068 RtcEventLogTestHelper::VerifyAudioReceiveStreamConfig(parsed_log, index, 1098 RtcEventLogTestHelper::VerifyAudioReceiveStreamConfig(parsed_log, index,
1069 config); 1099 config);
1070 } 1100 }
1071 rtclog::StreamConfig config; 1101 rtclog::StreamConfig config;
1072 }; 1102 };
1073 1103
1074 class AudioSendConfigReadWriteTest : public ConfigReadWriteTest { 1104 class AudioSendConfigReadWriteTest : public ConfigReadWriteTest {
1075 public: 1105 public:
1076 AudioSendConfigReadWriteTest() {} 1106 AudioSendConfigReadWriteTest() {}
1077 void GenerateConfig(const RtpHeaderExtensionMap& extensions) override { 1107 void GenerateConfig(const RtpHeaderExtensionMap& extensions) override {
1078 GenerateAudioSendConfig(extensions, &config, &prng); 1108 GenerateAudioSendConfig(extensions, &config, &prng);
1079 } 1109 }
1080 void LogConfig(RtcEventLog* event_log) override { 1110 void LogConfig(RtcEventLog* event_log) override {
1081 event_log->LogAudioSendStreamConfig(config); 1111 event_log->Log(rtc::MakeUnique<RtcEventAudioSendStreamConfig>(
1112 rtc::MakeUnique<rtclog::StreamConfig>(config)));
1082 } 1113 }
1083 void VerifyConfig(const ParsedRtcEventLog& parsed_log, 1114 void VerifyConfig(const ParsedRtcEventLog& parsed_log,
1084 size_t index) override { 1115 size_t index) override {
1085 RtcEventLogTestHelper::VerifyAudioSendStreamConfig(parsed_log, index, 1116 RtcEventLogTestHelper::VerifyAudioSendStreamConfig(parsed_log, index,
1086 config); 1117 config);
1087 } 1118 }
1088 rtclog::StreamConfig config; 1119 rtclog::StreamConfig config;
1089 }; 1120 };
1090 1121
1091 class VideoReceiveConfigReadWriteTest : public ConfigReadWriteTest { 1122 class VideoReceiveConfigReadWriteTest : public ConfigReadWriteTest {
1092 public: 1123 public:
1093 VideoReceiveConfigReadWriteTest() {} 1124 VideoReceiveConfigReadWriteTest() {}
1094 void GenerateConfig(const RtpHeaderExtensionMap& extensions) override { 1125 void GenerateConfig(const RtpHeaderExtensionMap& extensions) override {
1095 GenerateVideoReceiveConfig(extensions, &config, &prng); 1126 GenerateVideoReceiveConfig(extensions, &config, &prng);
1096 } 1127 }
1097 void LogConfig(RtcEventLog* event_log) override { 1128 void LogConfig(RtcEventLog* event_log) override {
1098 event_log->LogVideoReceiveStreamConfig(config); 1129 event_log->Log(rtc::MakeUnique<RtcEventVideoReceiveStreamConfig>(
1130 rtc::MakeUnique<rtclog::StreamConfig>(config)));
1099 } 1131 }
1100 void VerifyConfig(const ParsedRtcEventLog& parsed_log, 1132 void VerifyConfig(const ParsedRtcEventLog& parsed_log,
1101 size_t index) override { 1133 size_t index) override {
1102 RtcEventLogTestHelper::VerifyVideoReceiveStreamConfig(parsed_log, index, 1134 RtcEventLogTestHelper::VerifyVideoReceiveStreamConfig(parsed_log, index,
1103 config); 1135 config);
1104 } 1136 }
1105 rtclog::StreamConfig config; 1137 rtclog::StreamConfig config;
1106 }; 1138 };
1107 1139
1108 class VideoSendConfigReadWriteTest : public ConfigReadWriteTest { 1140 class VideoSendConfigReadWriteTest : public ConfigReadWriteTest {
1109 public: 1141 public:
1110 VideoSendConfigReadWriteTest() {} 1142 VideoSendConfigReadWriteTest() {}
1111 void GenerateConfig(const RtpHeaderExtensionMap& extensions) override { 1143 void GenerateConfig(const RtpHeaderExtensionMap& extensions) override {
1112 GenerateVideoSendConfig(extensions, &config, &prng); 1144 GenerateVideoSendConfig(extensions, &config, &prng);
1113 } 1145 }
1114 void LogConfig(RtcEventLog* event_log) override { 1146 void LogConfig(RtcEventLog* event_log) override {
1115 event_log->LogVideoSendStreamConfig(config); 1147 event_log->Log(rtc::MakeUnique<RtcEventVideoSendStreamConfig>(
1148 rtc::MakeUnique<rtclog::StreamConfig>(config)));
1116 } 1149 }
1117 void VerifyConfig(const ParsedRtcEventLog& parsed_log, 1150 void VerifyConfig(const ParsedRtcEventLog& parsed_log,
1118 size_t index) override { 1151 size_t index) override {
1119 RtcEventLogTestHelper::VerifyVideoSendStreamConfig(parsed_log, index, 1152 RtcEventLogTestHelper::VerifyVideoSendStreamConfig(parsed_log, index,
1120 config); 1153 config);
1121 } 1154 }
1122 rtclog::StreamConfig config; 1155 rtclog::StreamConfig config;
1123 }; 1156 };
1124 1157
1125 class AudioNetworkAdaptationReadWriteTest : public ConfigReadWriteTest { 1158 class AudioNetworkAdaptationReadWriteTest : public ConfigReadWriteTest {
1126 public: 1159 public:
1127 void GenerateConfig(const RtpHeaderExtensionMap& extensions) override { 1160 void GenerateConfig(const RtpHeaderExtensionMap& extensions) override {
1128 GenerateAudioNetworkAdaptation(extensions, &config, &prng); 1161 GenerateAudioNetworkAdaptation(extensions, &config, &prng);
1129 } 1162 }
1130 void LogConfig(RtcEventLog* event_log) override { 1163 void LogConfig(RtcEventLog* event_log) override {
1131 event_log->LogAudioNetworkAdaptation(config); 1164 event_log->Log(rtc::MakeUnique<RtcEventAudioNetworkAdaptation>(
1165 rtc::MakeUnique<AudioEncoderRuntimeConfig>(config)));
1132 } 1166 }
1133 void VerifyConfig(const ParsedRtcEventLog& parsed_log, 1167 void VerifyConfig(const ParsedRtcEventLog& parsed_log,
1134 size_t index) override { 1168 size_t index) override {
1135 RtcEventLogTestHelper::VerifyAudioNetworkAdaptation(parsed_log, index, 1169 RtcEventLogTestHelper::VerifyAudioNetworkAdaptation(parsed_log, index,
1136 config); 1170 config);
1137 } 1171 }
1138 AudioEncoderRuntimeConfig config; 1172 AudioEncoderRuntimeConfig config;
1139 }; 1173 };
1140 1174
1141 TEST(RtcEventLogTest, LogAudioReceiveConfig) { 1175 TEST(RtcEventLogTest, LogAudioReceiveConfig) {
(...skipping 15 matching lines...) Expand all
1157 VideoSendConfigReadWriteTest test; 1191 VideoSendConfigReadWriteTest test;
1158 test.DoTest(); 1192 test.DoTest();
1159 } 1193 }
1160 1194
1161 TEST(RtcEventLogTest, LogAudioNetworkAdaptation) { 1195 TEST(RtcEventLogTest, LogAudioNetworkAdaptation) {
1162 AudioNetworkAdaptationReadWriteTest test; 1196 AudioNetworkAdaptationReadWriteTest test;
1163 test.DoTest(); 1197 test.DoTest();
1164 } 1198 }
1165 1199
1166 } // namespace webrtc 1200 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/logging/rtc_event_log/rtc_event_log.cc ('k') | webrtc/modules/audio_coding/audio_network_adaptor/event_log_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698