Fix uploading of available send bitrate statistics.

BUG=webrtc:5079
R=stefan@webrtc.org

Review-Url: https://codereview.webrtc.org/2943073002 .
Cr-Commit-Position: refs/heads/master@{#18664}
This commit is contained in:
Alex Narest 2017-06-19 17:58:12 +02:00
parent ce433fafc1
commit 42308f615c
2 changed files with 71 additions and 5 deletions

View File

@ -782,10 +782,9 @@ void StatsCollector::ExtractBweInfo() {
bwe_info.bucket_delay = call_stats.pacer_delay_ms;
// Fill in target encoder bitrate, actual encoder bitrate, rtx bitrate, etc.
// TODO(holmer): Also fill this in for audio.
if (!pc_->session()->video_channel()) {
return;
if (pc_->session()->video_channel()) {
pc_->session()->video_channel()->FillBitrateInfo(&bwe_info);
}
pc_->session()->video_channel()->FillBitrateInfo(&bwe_info);
StatsReport::Id report_id(StatsReport::NewBandwidthEstimationId());
StatsReport* report = reports_.FindOrAddNew(report_id);
ExtractStats(bwe_info, stats_gathering_started_, report);

View File

@ -900,8 +900,75 @@ TEST_F(StatsCollectorTest, BytesCounterHandles64Bits) {
EXPECT_EQ(kBytesSentString, result);
}
// Test that BWE information is reported via stats.
TEST_F(StatsCollectorTest, BandwidthEstimationInfoIsReported) {
// Test that audio BWE information is reported via stats.
TEST_F(StatsCollectorTest, AudioBandwidthEstimationInfoIsReported) {
StatsCollectorForTest stats(&pc_);
EXPECT_CALL(session_, GetLocalCertificate(_, _))
.WillRepeatedly(Return(false));
EXPECT_CALL(session_, GetRemoteSSLCertificate_ReturnsRawPointer(_))
.WillRepeatedly(Return(nullptr));
const char kAudioChannelName[] = "audio";
InitSessionStats(kAudioChannelName);
EXPECT_CALL(session_, GetStats(_))
.WillRepeatedly(Invoke([this](const ChannelNamePairs&) {
return std::unique_ptr<SessionStats>(new SessionStats(session_stats_));
}));
MockVoiceMediaChannel* media_channel = new MockVoiceMediaChannel();
cricket::VoiceChannel voice_channel(
worker_thread_, network_thread_, nullptr, nullptr, media_channel,
kAudioChannelName, kDefaultRtcpMuxRequired, kDefaultSrtpRequired);
StatsReports reports; // returned values.
cricket::VoiceSenderInfo voice_sender_info;
cricket::VoiceMediaInfo stats_read;
// Set up an SSRC just to test that we get both kinds of stats back: SSRC and
// BWE.
const int64_t kBytesSent = 12345678901234LL;
const std::string kBytesSentString("12345678901234");
AddOutgoingAudioTrackStats();
stats.AddStream(stream_);
// Construct a stats value to read.
voice_sender_info.add_ssrc(1234);
voice_sender_info.bytes_sent = kBytesSent;
stats_read.senders.push_back(voice_sender_info);
webrtc::Call::Stats call_stats;
const int kSendBandwidth = 1234567;
const int kRecvBandwidth = 12345678;
const int kPacerDelay = 123;
call_stats.send_bandwidth_bps = kSendBandwidth;
call_stats.recv_bandwidth_bps = kRecvBandwidth;
call_stats.pacer_delay_ms = kPacerDelay;
EXPECT_CALL(session_, GetCallStats()).WillRepeatedly(Return(call_stats));
EXPECT_CALL(session_, voice_channel()).WillRepeatedly(Return(&voice_channel));
EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull());
EXPECT_CALL(*media_channel, GetStats(_))
.WillOnce(DoAll(SetArgPointee<0>(stats_read), Return(true)));
stats.UpdateStats(PeerConnectionInterface::kStatsOutputLevelStandard);
stats.GetStats(NULL, &reports);
std::string result =
ExtractSsrcStatsValue(reports, StatsReport::kStatsValueNameBytesSent);
EXPECT_EQ(kBytesSentString, result);
result = ExtractBweStatsValue(
reports, StatsReport::kStatsValueNameAvailableSendBandwidth);
EXPECT_EQ(rtc::ToString(kSendBandwidth), result);
result = ExtractBweStatsValue(
reports, StatsReport::kStatsValueNameAvailableReceiveBandwidth);
EXPECT_EQ(rtc::ToString(kRecvBandwidth), result);
result =
ExtractBweStatsValue(reports, StatsReport::kStatsValueNameBucketDelay);
EXPECT_EQ(rtc::ToString(kPacerDelay), result);
}
// Test that video BWE information is reported via stats.
TEST_F(StatsCollectorTest, VideoBandwidthEstimationInfoIsReported) {
StatsCollectorForTest stats(&pc_);
EXPECT_CALL(session_, GetLocalCertificate(_, _))