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

Side by Side Diff: webrtc/pc/statscollector_unittest.cc

Issue 2943073002: Fix uploading of available send bitrate statistics. (Closed)
Patch Set: Fixes uploading of available send bitrate statistics and adds unit test verifying audio BWE reportiā€¦ Created 3 years, 6 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
« no previous file with comments | « webrtc/pc/statscollector.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2014 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 882 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 EXPECT_CALL(*media_channel, GetStats(_)) 893 EXPECT_CALL(*media_channel, GetStats(_))
894 .WillOnce(DoAll(SetArgPointee<0>(stats_read), 894 .WillOnce(DoAll(SetArgPointee<0>(stats_read),
895 Return(true))); 895 Return(true)));
896 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); 896 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard);
897 stats.GetStats(NULL, &reports); 897 stats.GetStats(NULL, &reports);
898 std::string result = ExtractSsrcStatsValue(reports, 898 std::string result = ExtractSsrcStatsValue(reports,
899 StatsReport::kStatsValueNameBytesSent); 899 StatsReport::kStatsValueNameBytesSent);
900 EXPECT_EQ(kBytesSentString, result); 900 EXPECT_EQ(kBytesSentString, result);
901 } 901 }
902 902
903 // Test that BWE information is reported via stats. 903 // Test that audio BWE information is reported via stats.
904 TEST_F(StatsCollectorTest, BandwidthEstimationInfoIsReported) { 904 TEST_F(StatsCollectorTest, AudioBandwidthEstimationInfoIsReported) {
905 StatsCollectorForTest stats(&pc_); 905 StatsCollectorForTest stats(&pc_);
906 906
907 EXPECT_CALL(session_, GetLocalCertificate(_, _)) 907 EXPECT_CALL(session_, GetLocalCertificate(_, _))
908 .WillRepeatedly(Return(false));
909 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_))
910 .WillRepeatedly(Return(nullptr));
911
912 const char kAudioChannelName[] = "audio";
913
914 InitSessionStats(kAudioChannelName);
915 EXPECT_CALL(session_, GetStats(_))
916 .WillRepeatedly(Invoke([this](const ChannelNamePairs&) {
917 return std::unique_ptr<SessionStats>(new SessionStats(session_stats_));
918 }));
919
920 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel();
921 cricket::VoiceChannel voice_channel(
922 worker_thread_, network_thread_, nullptr, nullptr, media_channel,
923 kAudioChannelName, kDefaultRtcpMuxRequired, kDefaultSrtpRequired);
924
925 StatsReports reports; // returned values.
926 cricket::VoiceSenderInfo voice_sender_info;
927 cricket::VoiceMediaInfo stats_read;
928 // Set up an SSRC just to test that we get both kinds of stats back: SSRC and
929 // BWE.
930 const int64_t kBytesSent = 12345678901234LL;
931 const std::string kBytesSentString("12345678901234");
932
933 AddOutgoingAudioTrackStats();
934 stats.AddStream(stream_);
935
936 // Construct a stats value to read.
937 voice_sender_info.add_ssrc(1234);
938 voice_sender_info.bytes_sent = kBytesSent;
939 stats_read.senders.push_back(voice_sender_info);
940
941 webrtc::Call::Stats call_stats;
942 const int kSendBandwidth = 1234567;
943 const int kRecvBandwidth = 12345678;
944 const int kPacerDelay = 123;
945 call_stats.send_bandwidth_bps = kSendBandwidth;
946 call_stats.recv_bandwidth_bps = kRecvBandwidth;
947 call_stats.pacer_delay_ms = kPacerDelay;
948 EXPECT_CALL(session_, GetCallStats()).WillRepeatedly(Return(call_stats));
949 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(Return(&voice_channel));
950 EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull());
951 EXPECT_CALL(*media_channel, GetStats(_))
952 .WillOnce(DoAll(SetArgPointee<0>(stats_read), Return(true)));
953
954 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard);
955 stats.GetStats(NULL, &reports);
956 std::string result =
957 ExtractSsrcStatsValue(reports, StatsReport::kStatsValueNameBytesSent);
958 EXPECT_EQ(kBytesSentString, result);
959 result = ExtractBweStatsValue(
960 reports, StatsReport::kStatsValueNameAvailableSendBandwidth);
961 EXPECT_EQ(rtc::ToString(kSendBandwidth), result);
962 result = ExtractBweStatsValue(
963 reports, StatsReport::kStatsValueNameAvailableReceiveBandwidth);
964 EXPECT_EQ(rtc::ToString(kRecvBandwidth), result);
965 result =
966 ExtractBweStatsValue(reports, StatsReport::kStatsValueNameBucketDelay);
967 EXPECT_EQ(rtc::ToString(kPacerDelay), result);
968 }
969
970 // Test that video BWE information is reported via stats.
971 TEST_F(StatsCollectorTest, VideoBandwidthEstimationInfoIsReported) {
972 StatsCollectorForTest stats(&pc_);
973
974 EXPECT_CALL(session_, GetLocalCertificate(_, _))
908 .WillRepeatedly(Return(false)); 975 .WillRepeatedly(Return(false));
909 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) 976 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_))
910 .WillRepeatedly(Return(nullptr)); 977 .WillRepeatedly(Return(nullptr));
911 978
912 const char kVideoChannelName[] = "video"; 979 const char kVideoChannelName[] = "video";
913 980
914 InitSessionStats(kVideoChannelName); 981 InitSessionStats(kVideoChannelName);
915 EXPECT_CALL(session_, GetStats(_)).WillRepeatedly(Invoke( 982 EXPECT_CALL(session_, GetStats(_)).WillRepeatedly(Invoke(
916 [this](const ChannelNamePairs&) { 983 [this](const ChannelNamePairs&) {
917 return std::unique_ptr<SessionStats>( 984 return std::unique_ptr<SessionStats>(
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after
2034 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); 2101 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard);
2035 stats.GetStats(NULL, &reports); 2102 stats.GetStats(NULL, &reports);
2036 EXPECT_EQ(rtc::ToString(video_receiver_info.frames_decoded), 2103 EXPECT_EQ(rtc::ToString(video_receiver_info.frames_decoded),
2037 ExtractSsrcStatsValue(reports, 2104 ExtractSsrcStatsValue(reports,
2038 StatsReport::kStatsValueNameFramesDecoded)); 2105 StatsReport::kStatsValueNameFramesDecoded));
2039 EXPECT_EQ(rtc::ToString(*video_receiver_info.qp_sum), 2106 EXPECT_EQ(rtc::ToString(*video_receiver_info.qp_sum),
2040 ExtractSsrcStatsValue(reports, StatsReport::kStatsValueNameQpSum)); 2107 ExtractSsrcStatsValue(reports, StatsReport::kStatsValueNameQpSum));
2041 } 2108 }
2042 2109
2043 } // namespace webrtc 2110 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/pc/statscollector.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698