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

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(_)).WillRepeatedly(Invoke(
916 [this](const ChannelN amePairs&) {
917 return std::unique_ ptr<SessionStats>(
918 new SessionStats(session_stats_));
919 }));
stefan-webrtc 2017/06/19 13:07:05 Run 'git cl format' to get nice formatting of this
alexnarest1 2017/06/19 13:55:22 Done.
920
921 MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel();
stefan-webrtc 2017/06/19 13:07:05 I believe this is leaking. Either use "std::unique
alexnarest1 2017/06/19 13:55:22 It will not leak because BaseChannel will release
922 cricket::VoiceChannel voice_channel(
923 worker_thread_, network_thread_, nullptr, nullptr, media_channel,
924 kAudioChannelName, kDefaultRtcpMuxRequired , kDefaultSrtpRequired);
925
926 StatsReports reports; // returned values.
927 cricket::VoiceSenderInfo voice_sender_info;
928 cricket::VoiceMediaInfo stats_read;
929 // Set up an SSRC just to test that we get both kinds of stats back: SSRC and
930 // BWE.
931 const int64_t kBytesSent = 12345678901234LL;
932 const std::string kBytesSentString("12345678901234");
933
934 AddOutgoingAudioTrackStats();
935 stats.AddStream(stream_);
936
937 // Construct a stats value to read.
938 voice_sender_info.add_ssrc(1234);
939 voice_sender_info.bytes_sent = kBytesSent;
940 stats_read.senders.push_back(voice_sender_info);
941
942 webrtc::Call::Stats call_stats;
943 const int kSendBandwidth = 1234567;
944 const int kRecvBandwidth = 12345678;
945 const int kPacerDelay = 123;
946 call_stats.send_bandwidth_bps = kSendBandwidth;
947 call_stats.recv_bandwidth_bps = kRecvBandwidth;
948 call_stats.pacer_delay_ms = kPacerDelay;
949 EXPECT_CALL(session_, GetCallStats()).WillRepeatedly(Return(call_stats));
950 EXPECT_CALL(session_, voice_channel()).WillRepeatedly(Return(&voice_channel));
951 EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull());
952 EXPECT_CALL(*media_channel, GetStats(_))
953 .WillOnce(DoAll(SetArgPointee<0>(stats_read), Return(true)));
954
955 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard);
956 stats.GetStats(NULL, &reports);
957 std::string result = ExtractSsrcStatsValue(reports,
958 StatsReport::kStatsValueNameBytesSe nt);
959 EXPECT_EQ(kBytesSentString, result);
960 result = ExtractBweStatsValue(
961 reports, StatsReport::kStatsValueNameAvailableSe ndBandwidth);
962 EXPECT_EQ(rtc::ToString(kSendBandwidth), result);
963 result = ExtractBweStatsValue(
964 reports, StatsReport::kStatsValueNameAvailableRe ceiveBandwidth);
965 EXPECT_EQ(rtc::ToString(kRecvBandwidth), result);
966 result =
967 ExtractBweStatsValue(reports, StatsReport::kStatsValueNameBucketDelay);
968 EXPECT_EQ(rtc::ToString(kPacerDelay), result);
969 }
970
971 // Test that video BWE information is reported via stats.
972 TEST_F(StatsCollectorTest, VideoBandwidthEstimationInfoIsReported) {
973 StatsCollectorForTest stats(&pc_);
974
975 EXPECT_CALL(session_, GetLocalCertificate(_, _))
908 .WillRepeatedly(Return(false)); 976 .WillRepeatedly(Return(false));
909 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_)) 977 EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_))
910 .WillRepeatedly(Return(nullptr)); 978 .WillRepeatedly(Return(nullptr));
911 979
912 const char kVideoChannelName[] = "video"; 980 const char kVideoChannelName[] = "video";
913 981
914 InitSessionStats(kVideoChannelName); 982 InitSessionStats(kVideoChannelName);
915 EXPECT_CALL(session_, GetStats(_)).WillRepeatedly(Invoke( 983 EXPECT_CALL(session_, GetStats(_)).WillRepeatedly(Invoke(
916 [this](const ChannelNamePairs&) { 984 [this](const ChannelNamePairs&) {
917 return std::unique_ptr<SessionStats>( 985 return std::unique_ptr<SessionStats>(
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after
2034 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard); 2102 stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard);
2035 stats.GetStats(NULL, &reports); 2103 stats.GetStats(NULL, &reports);
2036 EXPECT_EQ(rtc::ToString(video_receiver_info.frames_decoded), 2104 EXPECT_EQ(rtc::ToString(video_receiver_info.frames_decoded),
2037 ExtractSsrcStatsValue(reports, 2105 ExtractSsrcStatsValue(reports,
2038 StatsReport::kStatsValueNameFramesDecoded)); 2106 StatsReport::kStatsValueNameFramesDecoded));
2039 EXPECT_EQ(rtc::ToString(*video_receiver_info.qp_sum), 2107 EXPECT_EQ(rtc::ToString(*video_receiver_info.qp_sum),
2040 ExtractSsrcStatsValue(reports, StatsReport::kStatsValueNameQpSum)); 2108 ExtractSsrcStatsValue(reports, StatsReport::kStatsValueNameQpSum));
2041 } 2109 }
2042 2110
2043 } // namespace webrtc 2111 } // 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