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

Side by Side Diff: talk/app/webrtc/statscollector.cc

Issue 1469803004: Don't overwrite audio stats when they're not available. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Move audio level to list. Created 5 years 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 | « no previous file | 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 * libjingle 2 * libjingle
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 report->AddString(StatsReport::kStatsValueNameCodecName, info.codec_name); 108 report->AddString(StatsReport::kStatsValueNameCodecName, info.codec_name);
109 report->AddInt64(StatsReport::kStatsValueNameBytesSent, info.bytes_sent); 109 report->AddInt64(StatsReport::kStatsValueNameBytesSent, info.bytes_sent);
110 report->AddInt64(StatsReport::kStatsValueNameRtt, info.rtt_ms); 110 report->AddInt64(StatsReport::kStatsValueNameRtt, info.rtt_ms);
111 } 111 }
112 112
113 void ExtractCommonReceiveProperties(const cricket::MediaReceiverInfo& info, 113 void ExtractCommonReceiveProperties(const cricket::MediaReceiverInfo& info,
114 StatsReport* report) { 114 StatsReport* report) {
115 report->AddString(StatsReport::kStatsValueNameCodecName, info.codec_name); 115 report->AddString(StatsReport::kStatsValueNameCodecName, info.codec_name);
116 } 116 }
117 117
118 void SetAudioProcessingStats(StatsReport* report, int signal_level, 118 void SetAudioProcessingStats(StatsReport* report,
119 bool typing_noise_detected, int echo_return_loss, 119 bool typing_noise_detected,
120 int echo_return_loss_enhancement, int echo_delay_median_ms, 120 int echo_return_loss,
121 float aec_quality_min, int echo_delay_std_ms) { 121 int echo_return_loss_enhancement,
122 int echo_delay_median_ms,
123 float aec_quality_min,
124 int echo_delay_std_ms) {
122 report->AddBoolean(StatsReport::kStatsValueNameTypingNoiseState, 125 report->AddBoolean(StatsReport::kStatsValueNameTypingNoiseState,
123 typing_noise_detected); 126 typing_noise_detected);
124 report->AddFloat(StatsReport::kStatsValueNameEchoCancellationQualityMin, 127 report->AddFloat(StatsReport::kStatsValueNameEchoCancellationQualityMin,
125 aec_quality_min); 128 aec_quality_min);
126 // Don't overwrite the previous signal level if it's not available now.
127 if (signal_level >= 0)
128 report->AddInt(StatsReport::kStatsValueNameAudioInputLevel, signal_level);
129 const IntForAdd ints[] = { 129 const IntForAdd ints[] = {
130 { StatsReport::kStatsValueNameEchoReturnLoss, echo_return_loss }, 130 { StatsReport::kStatsValueNameEchoReturnLoss, echo_return_loss },
131 { StatsReport::kStatsValueNameEchoReturnLossEnhancement, 131 { StatsReport::kStatsValueNameEchoReturnLossEnhancement,
132 echo_return_loss_enhancement }, 132 echo_return_loss_enhancement },
133 { StatsReport::kStatsValueNameEchoDelayMedian, echo_delay_median_ms }, 133 { StatsReport::kStatsValueNameEchoDelayMedian, echo_delay_median_ms },
134 { StatsReport::kStatsValueNameEchoDelayStdDev, echo_delay_std_ms }, 134 { StatsReport::kStatsValueNameEchoDelayStdDev, echo_delay_std_ms },
135 }; 135 };
136 for (const auto& i : ints) 136 for (const auto& i : ints)
137 report->AddInt(i.name, i.value); 137 report->AddInt(i.name, i.value);
138 } 138 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 175
176 report->AddInt64(StatsReport::kStatsValueNameBytesReceived, 176 report->AddInt64(StatsReport::kStatsValueNameBytesReceived,
177 info.bytes_rcvd); 177 info.bytes_rcvd);
178 report->AddInt64(StatsReport::kStatsValueNameCaptureStartNtpTimeMs, 178 report->AddInt64(StatsReport::kStatsValueNameCaptureStartNtpTimeMs,
179 info.capture_start_ntp_time_ms); 179 info.capture_start_ntp_time_ms);
180 } 180 }
181 181
182 void ExtractStats(const cricket::VoiceSenderInfo& info, StatsReport* report) { 182 void ExtractStats(const cricket::VoiceSenderInfo& info, StatsReport* report) {
183 ExtractCommonSendProperties(info, report); 183 ExtractCommonSendProperties(info, report);
184 184
185 SetAudioProcessingStats(report, info.audio_level, info.typing_noise_detected, 185 SetAudioProcessingStats(
186 info.echo_return_loss, info.echo_return_loss_enhancement, 186 report, info.typing_noise_detected, info.echo_return_loss,
187 info.echo_delay_median_ms, info.aec_quality_min, info.echo_delay_std_ms); 187 info.echo_return_loss_enhancement, info.echo_delay_median_ms,
188 info.aec_quality_min, info.echo_delay_std_ms);
188 189
189 const IntForAdd ints[] = { 190 const IntForAdd ints[] = {
191 { StatsReport::kStatsValueNameAudioInputLevel, info.audio_level},
tommi 2015/11/24 20:29:59 this doesn't handle (or rather, ignore) negative s
Andrew MacDonald 2015/11/24 22:43:54 Yes. I assumed (perhaps incorrectly) that this was
the sun 2015/11/25 13:02:17 AFAICT VoiceSenderInfo::audio_level cannot be nega
tommi 2015/11/25 13:11:09 Thanks Fredrik. Can we have a DCHECK() here then
Andrew MacDonald 2015/11/25 18:50:00 Sure, done.
190 { StatsReport::kStatsValueNameJitterReceived, info.jitter_ms }, 192 { StatsReport::kStatsValueNameJitterReceived, info.jitter_ms },
191 { StatsReport::kStatsValueNamePacketsLost, info.packets_lost }, 193 { StatsReport::kStatsValueNamePacketsLost, info.packets_lost },
192 { StatsReport::kStatsValueNamePacketsSent, info.packets_sent }, 194 { StatsReport::kStatsValueNamePacketsSent, info.packets_sent },
193 }; 195 };
194 196
195 for (const auto& i : ints) 197 for (const auto& i : ints)
196 report->AddInt(i.name, i.value); 198 report->AddInt(i.name, i.value);
197 } 199 }
198 200
199 void ExtractStats(const cricket::VideoReceiverInfo& info, StatsReport* report) { 201 void ExtractStats(const cricket::VideoReceiverInfo& info, StatsReport* report) {
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 report->set_timestamp(stats_gathering_started_); 886 report->set_timestamp(stats_gathering_started_);
885 UpdateReportFromAudioTrack(track, report); 887 UpdateReportFromAudioTrack(track, report);
886 } 888 }
887 } 889 }
888 890
889 void StatsCollector::UpdateReportFromAudioTrack(AudioTrackInterface* track, 891 void StatsCollector::UpdateReportFromAudioTrack(AudioTrackInterface* track,
890 StatsReport* report) { 892 StatsReport* report) {
891 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); 893 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
892 RTC_DCHECK(track != NULL); 894 RTC_DCHECK(track != NULL);
893 895
894 int signal_level = 0; 896 // Don't overwrite report values if they're not available.
895 if (!track->GetSignalLevel(&signal_level)) 897 int signal_level;
896 signal_level = -1; 898 if (track->GetSignalLevel(&signal_level))
the sun 2015/11/25 13:02:17 AudioTrackInterface::GetSignalLevel() doesn't have
tommi 2015/11/25 13:11:09 Here it is: https://code.google.com/p/chromium/cod
the sun 2015/11/26 09:20:03 Ah, thanks
899 report->AddInt(StatsReport::kStatsValueNameAudioInputLevel, signal_level);
897 900
898 rtc::scoped_refptr<AudioProcessorInterface> audio_processor( 901 auto audio_processor(track->GetAudioProcessor());
899 track->GetAudioProcessor());
900 902
901 AudioProcessorInterface::AudioProcessorStats stats; 903 if (audio_processor.get()) {
902 if (audio_processor.get()) 904 AudioProcessorInterface::AudioProcessorStats stats;
903 audio_processor->GetStats(&stats); 905 audio_processor->GetStats(&stats);
904 906
905 SetAudioProcessingStats(report, signal_level, stats.typing_noise_detected, 907 SetAudioProcessingStats(
906 stats.echo_return_loss, stats.echo_return_loss_enhancement, 908 report, stats.typing_noise_detected, stats.echo_return_loss,
907 stats.echo_delay_median_ms, stats.aec_quality_min, 909 stats.echo_return_loss_enhancement, stats.echo_delay_median_ms,
908 stats.echo_delay_std_ms); 910 stats.aec_quality_min, stats.echo_delay_std_ms);
911 }
909 } 912 }
910 913
911 bool StatsCollector::GetTrackIdBySsrc(uint32_t ssrc, 914 bool StatsCollector::GetTrackIdBySsrc(uint32_t ssrc,
912 std::string* track_id, 915 std::string* track_id,
913 StatsReport::Direction direction) { 916 StatsReport::Direction direction) {
914 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); 917 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
915 if (direction == StatsReport::kSend) { 918 if (direction == StatsReport::kSend) {
916 if (!pc_->session()->GetLocalTrackIdBySsrc(ssrc, track_id)) { 919 if (!pc_->session()->GetLocalTrackIdBySsrc(ssrc, track_id)) {
917 LOG(LS_WARNING) << "The SSRC " << ssrc 920 LOG(LS_WARNING) << "The SSRC " << ssrc
918 << " is not associated with a sending track"; 921 << " is not associated with a sending track";
(...skipping 20 matching lines...) Expand all
939 StatsReport* report = entry.second; 942 StatsReport* report = entry.second;
940 report->set_timestamp(stats_gathering_started_); 943 report->set_timestamp(stats_gathering_started_);
941 } 944 }
942 } 945 }
943 946
944 void StatsCollector::ClearUpdateStatsCacheForTest() { 947 void StatsCollector::ClearUpdateStatsCacheForTest() {
945 stats_gathering_started_ = 0; 948 stats_gathering_started_ = 0;
946 } 949 }
947 950
948 } // namespace webrtc 951 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698