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

Side by Side Diff: webrtc/audio/audio_send_stream.cc

Issue 1442483003: Converted a bunch of error checking in Audio[Receive|Send]Stream to RTC_CHECKs instead. They should… (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@wvoe_send_config
Patch Set: rebase Created 5 years, 1 month 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 } 112 }
113 113
114 webrtc::AudioSendStream::Stats AudioSendStream::GetStats() const { 114 webrtc::AudioSendStream::Stats AudioSendStream::GetStats() const {
115 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 115 RTC_DCHECK(thread_checker_.CalledOnValidThread());
116 webrtc::AudioSendStream::Stats stats; 116 webrtc::AudioSendStream::Stats stats;
117 stats.local_ssrc = config_.rtp.ssrc; 117 stats.local_ssrc = config_.rtp.ssrc;
118 ScopedVoEInterface<VoEAudioProcessing> processing(voice_engine()); 118 ScopedVoEInterface<VoEAudioProcessing> processing(voice_engine());
119 ScopedVoEInterface<VoECodec> codec(voice_engine()); 119 ScopedVoEInterface<VoECodec> codec(voice_engine());
120 ScopedVoEInterface<VoERTP_RTCP> rtp(voice_engine()); 120 ScopedVoEInterface<VoERTP_RTCP> rtp(voice_engine());
121 ScopedVoEInterface<VoEVolumeControl> volume(voice_engine()); 121 ScopedVoEInterface<VoEVolumeControl> volume(voice_engine());
122 unsigned int ssrc = 0; 122
123 webrtc::CallStatistics call_stats = {0}; 123 webrtc::CallStatistics call_stats = {0};
124 // TODO(solenberg): Change error code checking to RTC_CHECK_EQ(..., -1), if 124 int error = rtp->GetRTCPStatistics(config_.voe_channel_id, call_stats);
125 // possible... 125 RTC_DCHECK_EQ(0, error);
126 if (rtp->GetLocalSSRC(config_.voe_channel_id, ssrc) == -1 ||
127 rtp->GetRTCPStatistics(config_.voe_channel_id, call_stats) == -1) {
128 return stats;
129 }
130
131 stats.bytes_sent = call_stats.bytesSent; 126 stats.bytes_sent = call_stats.bytesSent;
132 stats.packets_sent = call_stats.packetsSent; 127 stats.packets_sent = call_stats.packetsSent;
128 // RTT isn't known until a RTCP report is received. Until then, VoiceEngine
129 // returns 0 to indicate an error value.
130 if (call_stats.rttMs > 0) {
131 stats.rtt_ms = call_stats.rttMs;
132 }
133 // TODO(solenberg): [was ajm]: Re-enable this metric once we have a reliable
134 // implementation.
135 stats.aec_quality_min = -1;
133 136
134 webrtc::CodecInst codec_inst = {0}; 137 webrtc::CodecInst codec_inst = {0};
135 if (codec->GetSendCodec(config_.voe_channel_id, codec_inst) != -1) { 138 if (codec->GetSendCodec(config_.voe_channel_id, codec_inst) != -1) {
136 RTC_DCHECK_NE(codec_inst.pltype, -1); 139 RTC_DCHECK_NE(codec_inst.pltype, -1);
137 stats.codec_name = codec_inst.plname; 140 stats.codec_name = codec_inst.plname;
138 141
139 // Get data from the last remote RTCP report. 142 // Get data from the last remote RTCP report.
140 std::vector<webrtc::ReportBlock> blocks; 143 std::vector<webrtc::ReportBlock> blocks;
141 if (rtp->GetRemoteRTCPReportBlocks(config_.voe_channel_id, &blocks) != -1) { 144 error = rtp->GetRemoteRTCPReportBlocks(config_.voe_channel_id, &blocks);
142 for (const webrtc::ReportBlock& block : blocks) { 145 RTC_DCHECK_EQ(0, error);
143 // Lookup report for send ssrc only. 146 for (const webrtc::ReportBlock& block : blocks) {
144 if (block.source_SSRC == stats.local_ssrc) { 147 // Lookup report for send ssrc only.
145 stats.packets_lost = block.cumulative_num_packets_lost; 148 if (block.source_SSRC == stats.local_ssrc) {
146 stats.fraction_lost = Q8ToFloat(block.fraction_lost); 149 stats.packets_lost = block.cumulative_num_packets_lost;
147 stats.ext_seqnum = block.extended_highest_sequence_number; 150 stats.fraction_lost = Q8ToFloat(block.fraction_lost);
148 // Convert samples to milliseconds. 151 stats.ext_seqnum = block.extended_highest_sequence_number;
149 if (codec_inst.plfreq / 1000 > 0) { 152 // Convert samples to milliseconds.
150 stats.jitter_ms = 153 if (codec_inst.plfreq / 1000 > 0) {
151 block.interarrival_jitter / (codec_inst.plfreq / 1000); 154 stats.jitter_ms =
152 } 155 block.interarrival_jitter / (codec_inst.plfreq / 1000);
153 break;
154 } 156 }
157 break;
155 } 158 }
156 } 159 }
157 } 160 }
158 161
159 // RTT isn't known until a RTCP report is received. Until then, VoiceEngine
160 // returns 0 to indicate an error value.
161 if (call_stats.rttMs > 0) {
162 stats.rtt_ms = call_stats.rttMs;
163 }
164
165 // Local speech level. 162 // Local speech level.
166 { 163 {
167 unsigned int level = 0; 164 unsigned int level = 0;
168 if (volume->GetSpeechInputLevelFullRange(level) != -1) { 165 error = volume->GetSpeechInputLevelFullRange(level);
169 stats.audio_level = static_cast<int32_t>(level); 166 RTC_DCHECK_EQ(0, error);
170 } 167 stats.audio_level = static_cast<int32_t>(level);
171 } 168 }
172 169
173 // TODO(ajm): Re-enable this metric once we have a reliable implementation.
174 stats.aec_quality_min = -1;
175
176 bool echo_metrics_on = false; 170 bool echo_metrics_on = false;
177 if (processing->GetEcMetricsStatus(echo_metrics_on) != -1 && 171 error = processing->GetEcMetricsStatus(echo_metrics_on);
178 echo_metrics_on) { 172 RTC_DCHECK_EQ(0, error);
173 if (echo_metrics_on) {
179 // These can also be negative, but in practice -1 is only used to signal 174 // These can also be negative, but in practice -1 is only used to signal
180 // insufficient data, since the resolution is limited to multiples of 4 ms. 175 // insufficient data, since the resolution is limited to multiples of 4 ms.
181 int median = -1; 176 int median = -1;
182 int std = -1; 177 int std = -1;
183 float dummy = 0.0f; 178 float dummy = 0.0f;
184 if (processing->GetEcDelayMetrics(median, std, dummy) != -1) { 179 error = processing->GetEcDelayMetrics(median, std, dummy);
185 stats.echo_delay_median_ms = median; 180 RTC_DCHECK_EQ(0, error);
186 stats.echo_delay_std_ms = std; 181 stats.echo_delay_median_ms = median;
187 } 182 stats.echo_delay_std_ms = std;
188 183
189 // These can take on valid negative values, so use the lowest possible level 184 // These can take on valid negative values, so use the lowest possible level
190 // as default rather than -1. 185 // as default rather than -1.
191 int erl = -100; 186 int erl = -100;
192 int erle = -100; 187 int erle = -100;
193 int dummy1 = 0; 188 int dummy1 = 0;
194 int dummy2 = 0; 189 int dummy2 = 0;
195 if (processing->GetEchoMetrics(erl, erle, dummy1, dummy2) != -1) { 190 error = processing->GetEchoMetrics(erl, erle, dummy1, dummy2);
196 stats.echo_return_loss = erl; 191 RTC_DCHECK_EQ(0, error);
197 stats.echo_return_loss_enhancement = erle; 192 stats.echo_return_loss = erl;
198 } 193 stats.echo_return_loss_enhancement = erle;
199 } 194 }
200 195
201 internal::AudioState* audio_state = 196 internal::AudioState* audio_state =
202 static_cast<internal::AudioState*>(audio_state_.get()); 197 static_cast<internal::AudioState*>(audio_state_.get());
203 stats.typing_noise_detected = audio_state->typing_noise_detected(); 198 stats.typing_noise_detected = audio_state->typing_noise_detected();
204 199
205 return stats; 200 return stats;
206 } 201 }
207 202
208 const webrtc::AudioSendStream::Config& AudioSendStream::config() const { 203 const webrtc::AudioSendStream::Config& AudioSendStream::config() const {
209 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 204 RTC_DCHECK(thread_checker_.CalledOnValidThread());
210 return config_; 205 return config_;
211 } 206 }
212 207
213 VoiceEngine* AudioSendStream::voice_engine() const { 208 VoiceEngine* AudioSendStream::voice_engine() const {
214 internal::AudioState* audio_state = 209 internal::AudioState* audio_state =
215 static_cast<internal::AudioState*>(audio_state_.get()); 210 static_cast<internal::AudioState*>(audio_state_.get());
216 VoiceEngine* voice_engine = audio_state->voice_engine(); 211 VoiceEngine* voice_engine = audio_state->voice_engine();
217 RTC_DCHECK(voice_engine); 212 RTC_DCHECK(voice_engine);
218 return voice_engine; 213 return voice_engine;
219 } 214 }
220 } // namespace internal 215 } // namespace internal
221 } // namespace webrtc 216 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/audio/audio_receive_stream_unittest.cc ('k') | webrtc/audio/audio_send_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698