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

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: Add DCHECK for audio level. 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
190 RTC_DCHECK_GE(info.audio_level, 0);
189 const IntForAdd ints[] = { 191 const IntForAdd ints[] = {
192 { StatsReport::kStatsValueNameAudioInputLevel, info.audio_level},
190 { StatsReport::kStatsValueNameJitterReceived, info.jitter_ms }, 193 { StatsReport::kStatsValueNameJitterReceived, info.jitter_ms },
191 { StatsReport::kStatsValueNamePacketsLost, info.packets_lost }, 194 { StatsReport::kStatsValueNamePacketsLost, info.packets_lost },
192 { StatsReport::kStatsValueNamePacketsSent, info.packets_sent }, 195 { StatsReport::kStatsValueNamePacketsSent, info.packets_sent },
193 }; 196 };
194 197
195 for (const auto& i : ints) 198 for (const auto& i : ints)
196 report->AddInt(i.name, i.value); 199 report->AddInt(i.name, i.value);
197 } 200 }
198 201
199 void ExtractStats(const cricket::VideoReceiverInfo& info, StatsReport* report) { 202 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_); 887 report->set_timestamp(stats_gathering_started_);
885 UpdateReportFromAudioTrack(track, report); 888 UpdateReportFromAudioTrack(track, report);
886 } 889 }
887 } 890 }
888 891
889 void StatsCollector::UpdateReportFromAudioTrack(AudioTrackInterface* track, 892 void StatsCollector::UpdateReportFromAudioTrack(AudioTrackInterface* track,
890 StatsReport* report) { 893 StatsReport* report) {
891 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); 894 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
892 RTC_DCHECK(track != NULL); 895 RTC_DCHECK(track != NULL);
893 896
894 int signal_level = 0; 897 // Don't overwrite report values if they're not available.
895 if (!track->GetSignalLevel(&signal_level)) 898 int signal_level;
896 signal_level = -1; 899 if (track->GetSignalLevel(&signal_level)) {
900 RTC_DCHECK_GE(signal_level, 0);
901 report->AddInt(StatsReport::kStatsValueNameAudioInputLevel, signal_level);
902 }
897 903
898 rtc::scoped_refptr<AudioProcessorInterface> audio_processor( 904 auto audio_processor(track->GetAudioProcessor());
899 track->GetAudioProcessor());
900 905
901 AudioProcessorInterface::AudioProcessorStats stats; 906 if (audio_processor.get()) {
902 if (audio_processor.get()) 907 AudioProcessorInterface::AudioProcessorStats stats;
903 audio_processor->GetStats(&stats); 908 audio_processor->GetStats(&stats);
904 909
905 SetAudioProcessingStats(report, signal_level, stats.typing_noise_detected, 910 SetAudioProcessingStats(
906 stats.echo_return_loss, stats.echo_return_loss_enhancement, 911 report, stats.typing_noise_detected, stats.echo_return_loss,
907 stats.echo_delay_median_ms, stats.aec_quality_min, 912 stats.echo_return_loss_enhancement, stats.echo_delay_median_ms,
908 stats.echo_delay_std_ms); 913 stats.aec_quality_min, stats.echo_delay_std_ms);
914 }
909 } 915 }
910 916
911 bool StatsCollector::GetTrackIdBySsrc(uint32_t ssrc, 917 bool StatsCollector::GetTrackIdBySsrc(uint32_t ssrc,
912 std::string* track_id, 918 std::string* track_id,
913 StatsReport::Direction direction) { 919 StatsReport::Direction direction) {
914 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); 920 RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
915 if (direction == StatsReport::kSend) { 921 if (direction == StatsReport::kSend) {
916 if (!pc_->session()->GetLocalTrackIdBySsrc(ssrc, track_id)) { 922 if (!pc_->session()->GetLocalTrackIdBySsrc(ssrc, track_id)) {
917 LOG(LS_WARNING) << "The SSRC " << ssrc 923 LOG(LS_WARNING) << "The SSRC " << ssrc
918 << " is not associated with a sending track"; 924 << " is not associated with a sending track";
(...skipping 20 matching lines...) Expand all
939 StatsReport* report = entry.second; 945 StatsReport* report = entry.second;
940 report->set_timestamp(stats_gathering_started_); 946 report->set_timestamp(stats_gathering_started_);
941 } 947 }
942 } 948 }
943 949
944 void StatsCollector::ClearUpdateStatsCacheForTest() { 950 void StatsCollector::ClearUpdateStatsCacheForTest() {
945 stats_gathering_started_ = 0; 951 stats_gathering_started_ = 0;
946 } 952 }
947 953
948 } // namespace webrtc 954 } // 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