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

Side by Side Diff: webrtc/media/engine/fakewebrtcvoiceengine.h

Issue 2440353003: Remove unused function implementations from FakeWebRtcVoiceEngine. (Closed)
Patch Set: Created 4 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
« 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 * Copyright (c) 2010 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2010 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 bool experimental_ns_enabled_; 138 bool experimental_ns_enabled_;
139 }; 139 };
140 140
141 class FakeWebRtcVoiceEngine 141 class FakeWebRtcVoiceEngine
142 : public webrtc::VoEAudioProcessing, 142 : public webrtc::VoEAudioProcessing,
143 public webrtc::VoEBase, public webrtc::VoECodec, 143 public webrtc::VoEBase, public webrtc::VoECodec,
144 public webrtc::VoEHardware, 144 public webrtc::VoEHardware,
145 public webrtc::VoEVolumeControl { 145 public webrtc::VoEVolumeControl {
146 public: 146 public:
147 struct Channel { 147 struct Channel {
148 Channel() {
149 memset(&send_codec, 0, sizeof(send_codec));
150 }
151 bool vad = false;
152 bool codec_fec = false;
153 int max_encoding_bandwidth = 0;
154 bool opus_dtx = false;
155 int cn8_type = 13;
156 int cn16_type = 105;
157 int associate_send_channel = -1; 148 int associate_send_channel = -1;
158 std::vector<webrtc::CodecInst> recv_codecs; 149 std::vector<webrtc::CodecInst> recv_codecs;
159 webrtc::CodecInst send_codec;
160 size_t neteq_capacity = 0; 150 size_t neteq_capacity = 0;
161 bool neteq_fast_accelerate = false; 151 bool neteq_fast_accelerate = false;
162 }; 152 };
163 153
164 FakeWebRtcVoiceEngine() { 154 FakeWebRtcVoiceEngine() {
165 memset(&agc_config_, 0, sizeof(agc_config_)); 155 memset(&agc_config_, 0, sizeof(agc_config_));
166 } 156 }
167 ~FakeWebRtcVoiceEngine() override { 157 ~FakeWebRtcVoiceEngine() override {
168 RTC_CHECK(channels_.empty()); 158 RTC_CHECK(channels_.empty());
169 } 159 }
170 160
171 bool ec_metrics_enabled() const { return ec_metrics_enabled_; } 161 bool ec_metrics_enabled() const { return ec_metrics_enabled_; }
172 162
173 bool IsInited() const { return inited_; } 163 bool IsInited() const { return inited_; }
174 int GetLastChannel() const { return last_channel_; } 164 int GetLastChannel() const { return last_channel_; }
175 int GetNumChannels() const { return static_cast<int>(channels_.size()); } 165 int GetNumChannels() const { return static_cast<int>(channels_.size()); }
176 bool GetVAD(int channel) {
177 return channels_[channel]->vad;
178 }
179 bool GetOpusDtx(int channel) {
180 return channels_[channel]->opus_dtx;
181 }
182 bool GetCodecFEC(int channel) {
183 return channels_[channel]->codec_fec;
184 }
185 int GetMaxEncodingBandwidth(int channel) {
186 return channels_[channel]->max_encoding_bandwidth;
187 }
188 int GetSendCNPayloadType(int channel, bool wideband) {
189 return (wideband) ?
190 channels_[channel]->cn16_type :
191 channels_[channel]->cn8_type;
192 }
193 void set_fail_create_channel(bool fail_create_channel) { 166 void set_fail_create_channel(bool fail_create_channel) {
194 fail_create_channel_ = fail_create_channel; 167 fail_create_channel_ = fail_create_channel;
195 } 168 }
196 169
197 int GetNumSetSendCodecs() const { return num_set_send_codecs_; }
198
199 int GetAssociateSendChannel(int channel) { 170 int GetAssociateSendChannel(int channel) {
200 return channels_[channel]->associate_send_channel; 171 return channels_[channel]->associate_send_channel;
201 } 172 }
202 173
203 WEBRTC_STUB(Release, ()); 174 WEBRTC_STUB(Release, ());
204 175
205 // webrtc::VoEBase 176 // webrtc::VoEBase
206 WEBRTC_STUB(RegisterVoiceEngineObserver, ( 177 WEBRTC_STUB(RegisterVoiceEngineObserver, (
207 webrtc::VoiceEngineObserver& observer)); 178 webrtc::VoiceEngineObserver& observer));
208 WEBRTC_STUB(DeRegisterVoiceEngineObserver, ()); 179 WEBRTC_STUB(DeRegisterVoiceEngineObserver, ());
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 WEBRTC_FUNC(AssociateSendChannel, (int channel, 233 WEBRTC_FUNC(AssociateSendChannel, (int channel,
263 int accociate_send_channel)) { 234 int accociate_send_channel)) {
264 WEBRTC_CHECK_CHANNEL(channel); 235 WEBRTC_CHECK_CHANNEL(channel);
265 channels_[channel]->associate_send_channel = accociate_send_channel; 236 channels_[channel]->associate_send_channel = accociate_send_channel;
266 return 0; 237 return 0;
267 } 238 }
268 239
269 // webrtc::VoECodec 240 // webrtc::VoECodec
270 WEBRTC_STUB(NumOfCodecs, ()); 241 WEBRTC_STUB(NumOfCodecs, ());
271 WEBRTC_STUB(GetCodec, (int index, webrtc::CodecInst& codec)); 242 WEBRTC_STUB(GetCodec, (int index, webrtc::CodecInst& codec));
272 WEBRTC_FUNC(SetSendCodec, (int channel, const webrtc::CodecInst& codec)) { 243 WEBRTC_STUB(SetSendCodec, (int channel, const webrtc::CodecInst& codec));
273 WEBRTC_CHECK_CHANNEL(channel); 244 WEBRTC_STUB(GetSendCodec, (int channel, webrtc::CodecInst& codec));
274 // To match the behavior of the real implementation.
275 if (_stricmp(codec.plname, "telephone-event") == 0 ||
276 _stricmp(codec.plname, "audio/telephone-event") == 0 ||
277 _stricmp(codec.plname, "CN") == 0 ||
278 _stricmp(codec.plname, "red") == 0) {
279 return -1;
280 }
281 channels_[channel]->send_codec = codec;
282 ++num_set_send_codecs_;
283 return 0;
284 }
285 WEBRTC_FUNC(GetSendCodec, (int channel, webrtc::CodecInst& codec)) {
286 WEBRTC_CHECK_CHANNEL(channel);
287 codec = channels_[channel]->send_codec;
288 return 0;
289 }
290 WEBRTC_STUB(SetBitRate, (int channel, int bitrate_bps)); 245 WEBRTC_STUB(SetBitRate, (int channel, int bitrate_bps));
291 WEBRTC_STUB(GetRecCodec, (int channel, webrtc::CodecInst& codec)); 246 WEBRTC_STUB(GetRecCodec, (int channel, webrtc::CodecInst& codec));
292 WEBRTC_FUNC(SetRecPayloadType, (int channel, 247 WEBRTC_FUNC(SetRecPayloadType, (int channel,
293 const webrtc::CodecInst& codec)) { 248 const webrtc::CodecInst& codec)) {
294 WEBRTC_CHECK_CHANNEL(channel); 249 WEBRTC_CHECK_CHANNEL(channel);
295 Channel* ch = channels_[channel]; 250 Channel* ch = channels_[channel];
296 // Check if something else already has this slot. 251 // Check if something else already has this slot.
297 if (codec.pltype != -1) { 252 if (codec.pltype != -1) {
298 for (std::vector<webrtc::CodecInst>::iterator it = 253 for (std::vector<webrtc::CodecInst>::iterator it =
299 ch->recv_codecs.begin(); it != ch->recv_codecs.end(); ++it) { 254 ch->recv_codecs.begin(); it != ch->recv_codecs.end(); ++it) {
300 if (it->pltype == codec.pltype && 255 if (it->pltype == codec.pltype &&
301 _stricmp(it->plname, codec.plname) != 0) { 256 _stricmp(it->plname, codec.plname) != 0) {
302 return -1; 257 return -1;
303 } 258 }
304 } 259 }
305 } 260 }
306 // Otherwise try to find this codec and update its payload type. 261 // Otherwise try to find this codec and update its payload type.
307 int result = -1; // not found 262 int result = -1; // not found
308 for (std::vector<webrtc::CodecInst>::iterator it = ch->recv_codecs.begin(); 263 for (std::vector<webrtc::CodecInst>::iterator it = ch->recv_codecs.begin();
309 it != ch->recv_codecs.end(); ++it) { 264 it != ch->recv_codecs.end(); ++it) {
310 if (strcmp(it->plname, codec.plname) == 0 && 265 if (strcmp(it->plname, codec.plname) == 0 &&
311 it->plfreq == codec.plfreq && 266 it->plfreq == codec.plfreq &&
312 it->channels == codec.channels) { 267 it->channels == codec.channels) {
313 it->pltype = codec.pltype; 268 it->pltype = codec.pltype;
314 result = 0; 269 result = 0;
315 } 270 }
316 } 271 }
317 return result; 272 return result;
318 } 273 }
319 WEBRTC_FUNC(SetSendCNPayloadType, (int channel, int type, 274 WEBRTC_STUB(SetSendCNPayloadType, (int channel, int type,
320 webrtc::PayloadFrequencies frequency)) { 275 webrtc::PayloadFrequencies frequency));
321 WEBRTC_CHECK_CHANNEL(channel);
322 if (frequency == webrtc::kFreq8000Hz) {
323 channels_[channel]->cn8_type = type;
324 } else if (frequency == webrtc::kFreq16000Hz) {
325 channels_[channel]->cn16_type = type;
326 }
327 return 0;
328 }
329 WEBRTC_FUNC(GetRecPayloadType, (int channel, webrtc::CodecInst& codec)) { 276 WEBRTC_FUNC(GetRecPayloadType, (int channel, webrtc::CodecInst& codec)) {
330 WEBRTC_CHECK_CHANNEL(channel); 277 WEBRTC_CHECK_CHANNEL(channel);
331 Channel* ch = channels_[channel]; 278 Channel* ch = channels_[channel];
332 for (std::vector<webrtc::CodecInst>::iterator it = ch->recv_codecs.begin(); 279 for (std::vector<webrtc::CodecInst>::iterator it = ch->recv_codecs.begin();
333 it != ch->recv_codecs.end(); ++it) { 280 it != ch->recv_codecs.end(); ++it) {
334 if (strcmp(it->plname, codec.plname) == 0 && 281 if (strcmp(it->plname, codec.plname) == 0 &&
335 it->plfreq == codec.plfreq && 282 it->plfreq == codec.plfreq &&
336 it->channels == codec.channels && 283 it->channels == codec.channels &&
337 it->pltype != -1) { 284 it->pltype != -1) {
338 codec.pltype = it->pltype; 285 codec.pltype = it->pltype;
339 return 0; 286 return 0;
340 } 287 }
341 } 288 }
342 return -1; // not found 289 return -1; // not found
343 } 290 }
344 WEBRTC_FUNC(SetVADStatus, (int channel, bool enable, webrtc::VadModes mode, 291 WEBRTC_STUB(SetVADStatus, (int channel, bool enable, webrtc::VadModes mode,
345 bool disableDTX)) { 292 bool disableDTX));
346 WEBRTC_CHECK_CHANNEL(channel);
347 if (channels_[channel]->send_codec.channels == 2) {
348 // Replicating VoE behavior; VAD cannot be enabled for stereo.
349 return -1;
350 }
351 channels_[channel]->vad = enable;
352 return 0;
353 }
354 WEBRTC_STUB(GetVADStatus, (int channel, bool& enabled, 293 WEBRTC_STUB(GetVADStatus, (int channel, bool& enabled,
355 webrtc::VadModes& mode, bool& disabledDTX)); 294 webrtc::VadModes& mode, bool& disabledDTX));
356 295 WEBRTC_STUB(SetFECStatus, (int channel, bool enable));
357 WEBRTC_FUNC(SetFECStatus, (int channel, bool enable)) { 296 WEBRTC_STUB(GetFECStatus, (int channel, bool& enable));
358 WEBRTC_CHECK_CHANNEL(channel); 297 WEBRTC_STUB(SetOpusMaxPlaybackRate, (int channel, int frequency_hz));
359 if (_stricmp(channels_[channel]->send_codec.plname, "opus") != 0) { 298 WEBRTC_STUB(SetOpusDtx, (int channel, bool enable_dtx));
360 // Return -1 if current send codec is not Opus.
361 // TODO(minyue): Excludes other codecs if they support inband FEC.
362 return -1;
363 }
364 channels_[channel]->codec_fec = enable;
365 return 0;
366 }
367 WEBRTC_FUNC(GetFECStatus, (int channel, bool& enable)) {
368 WEBRTC_CHECK_CHANNEL(channel);
369 enable = channels_[channel]->codec_fec;
370 return 0;
371 }
372
373 WEBRTC_FUNC(SetOpusMaxPlaybackRate, (int channel, int frequency_hz)) {
374 WEBRTC_CHECK_CHANNEL(channel);
375 if (_stricmp(channels_[channel]->send_codec.plname, "opus") != 0) {
376 // Return -1 if current send codec is not Opus.
377 return -1;
378 }
379 if (frequency_hz <= 8000)
380 channels_[channel]->max_encoding_bandwidth = kOpusBandwidthNb;
381 else if (frequency_hz <= 12000)
382 channels_[channel]->max_encoding_bandwidth = kOpusBandwidthMb;
383 else if (frequency_hz <= 16000)
384 channels_[channel]->max_encoding_bandwidth = kOpusBandwidthWb;
385 else if (frequency_hz <= 24000)
386 channels_[channel]->max_encoding_bandwidth = kOpusBandwidthSwb;
387 else
388 channels_[channel]->max_encoding_bandwidth = kOpusBandwidthFb;
389 return 0;
390 }
391
392 WEBRTC_FUNC(SetOpusDtx, (int channel, bool enable_dtx)) {
393 WEBRTC_CHECK_CHANNEL(channel);
394 if (_stricmp(channels_[channel]->send_codec.plname, "opus") != 0) {
395 // Return -1 if current send codec is not Opus.
396 return -1;
397 }
398 channels_[channel]->opus_dtx = enable_dtx;
399 return 0;
400 }
401 299
402 // webrtc::VoEHardware 300 // webrtc::VoEHardware
403 WEBRTC_STUB(GetNumOfRecordingDevices, (int& num)); 301 WEBRTC_STUB(GetNumOfRecordingDevices, (int& num));
404 WEBRTC_STUB(GetNumOfPlayoutDevices, (int& num)); 302 WEBRTC_STUB(GetNumOfPlayoutDevices, (int& num));
405 WEBRTC_STUB(GetRecordingDeviceName, (int i, char* name, char* guid)); 303 WEBRTC_STUB(GetRecordingDeviceName, (int i, char* name, char* guid));
406 WEBRTC_STUB(GetPlayoutDeviceName, (int i, char* name, char* guid)); 304 WEBRTC_STUB(GetPlayoutDeviceName, (int i, char* name, char* guid));
407 WEBRTC_STUB(SetRecordingDevice, (int, webrtc::StereoChannel)); 305 WEBRTC_STUB(SetRecordingDevice, (int, webrtc::StereoChannel));
408 WEBRTC_STUB(SetPlayoutDevice, (int)); 306 WEBRTC_STUB(SetPlayoutDevice, (int));
409 WEBRTC_STUB(SetAudioDeviceLayer, (webrtc::AudioLayers)); 307 WEBRTC_STUB(SetAudioDeviceLayer, (webrtc::AudioLayers));
410 WEBRTC_STUB(GetAudioDeviceLayer, (webrtc::AudioLayers&)); 308 WEBRTC_STUB(GetAudioDeviceLayer, (webrtc::AudioLayers&));
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 auto ch = channels_.find(last_channel_); 439 auto ch = channels_.find(last_channel_);
542 ASSERT(ch != channels_.end()); 440 ASSERT(ch != channels_.end());
543 return ch->second->neteq_fast_accelerate; 441 return ch->second->neteq_fast_accelerate;
544 } 442 }
545 443
546 private: 444 private:
547 bool inited_ = false; 445 bool inited_ = false;
548 int last_channel_ = -1; 446 int last_channel_ = -1;
549 std::map<int, Channel*> channels_; 447 std::map<int, Channel*> channels_;
550 bool fail_create_channel_ = false; 448 bool fail_create_channel_ = false;
551 int num_set_send_codecs_ = 0; // how many times we call SetSendCodec().
552 bool ec_enabled_ = false; 449 bool ec_enabled_ = false;
553 bool ec_metrics_enabled_ = false; 450 bool ec_metrics_enabled_ = false;
554 bool cng_enabled_ = false; 451 bool cng_enabled_ = false;
555 bool ns_enabled_ = false; 452 bool ns_enabled_ = false;
556 bool agc_enabled_ = false; 453 bool agc_enabled_ = false;
557 bool highpass_filter_enabled_ = false; 454 bool highpass_filter_enabled_ = false;
558 bool stereo_swapping_enabled_ = false; 455 bool stereo_swapping_enabled_ = false;
559 bool typing_detection_enabled_ = false; 456 bool typing_detection_enabled_ = false;
560 webrtc::EcModes ec_mode_ = webrtc::kEcDefault; 457 webrtc::EcModes ec_mode_ = webrtc::kEcDefault;
561 webrtc::AecmModes aecm_mode_ = webrtc::kAecmSpeakerphone; 458 webrtc::AecmModes aecm_mode_ = webrtc::kAecmSpeakerphone;
562 webrtc::NsModes ns_mode_ = webrtc::kNsDefault; 459 webrtc::NsModes ns_mode_ = webrtc::kNsDefault;
563 webrtc::AgcModes agc_mode_ = webrtc::kAgcDefault; 460 webrtc::AgcModes agc_mode_ = webrtc::kAgcDefault;
564 webrtc::AgcConfig agc_config_; 461 webrtc::AgcConfig agc_config_;
565 FakeAudioProcessing audio_processing_; 462 FakeAudioProcessing audio_processing_;
566 }; 463 };
567 464
568 } // namespace cricket 465 } // namespace cricket
569 466
570 #endif // WEBRTC_MEDIA_ENGINE_FAKEWEBRTCVOICEENGINE_H_ 467 #endif // WEBRTC_MEDIA_ENGINE_FAKEWEBRTCVOICEENGINE_H_
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