| OLD | NEW |
| 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 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 #define WEBRTC_STUB(method, args) \ | 39 #define WEBRTC_STUB(method, args) \ |
| 40 int method args override { return 0; } | 40 int method args override { return 0; } |
| 41 | 41 |
| 42 #define WEBRTC_STUB_CONST(method, args) \ | 42 #define WEBRTC_STUB_CONST(method, args) \ |
| 43 int method args const override { return 0; } | 43 int method args const override { return 0; } |
| 44 | 44 |
| 45 #define WEBRTC_BOOL_STUB(method, args) \ | 45 #define WEBRTC_BOOL_STUB(method, args) \ |
| 46 bool method args override { return true; } | 46 bool method args override { return true; } |
| 47 | 47 |
| 48 #define WEBRTC_BOOL_STUB_CONST(method, args) \ | |
| 49 bool method args const override { return true; } | |
| 50 | |
| 51 #define WEBRTC_VOID_STUB(method, args) \ | 48 #define WEBRTC_VOID_STUB(method, args) \ |
| 52 void method args override {} | 49 void method args override {} |
| 53 | 50 |
| 54 #define WEBRTC_FUNC(method, args) int method args override | 51 #define WEBRTC_FUNC(method, args) int method args override |
| 55 | 52 |
| 56 #define WEBRTC_VOID_FUNC(method, args) void method args override | |
| 57 | |
| 58 class FakeAudioProcessing : public webrtc::AudioProcessing { | |
| 59 public: | |
| 60 FakeAudioProcessing() : experimental_ns_enabled_(false) {} | |
| 61 | |
| 62 WEBRTC_STUB(Initialize, ()) | |
| 63 WEBRTC_STUB(Initialize, ( | |
| 64 int input_sample_rate_hz, | |
| 65 int output_sample_rate_hz, | |
| 66 int reverse_sample_rate_hz, | |
| 67 webrtc::AudioProcessing::ChannelLayout input_layout, | |
| 68 webrtc::AudioProcessing::ChannelLayout output_layout, | |
| 69 webrtc::AudioProcessing::ChannelLayout reverse_layout)); | |
| 70 WEBRTC_STUB(Initialize, ( | |
| 71 const webrtc::ProcessingConfig& processing_config)); | |
| 72 | |
| 73 WEBRTC_VOID_STUB(ApplyConfig, (const AudioProcessing::Config& config)); | |
| 74 WEBRTC_VOID_FUNC(SetExtraOptions, (const webrtc::Config& config)) { | |
| 75 experimental_ns_enabled_ = config.Get<webrtc::ExperimentalNs>().enabled; | |
| 76 } | |
| 77 | |
| 78 WEBRTC_STUB_CONST(proc_sample_rate_hz, ()); | |
| 79 WEBRTC_STUB_CONST(proc_split_sample_rate_hz, ()); | |
| 80 size_t num_input_channels() const override { return 0; } | |
| 81 size_t num_proc_channels() const override { return 0; } | |
| 82 size_t num_output_channels() const override { return 0; } | |
| 83 size_t num_reverse_channels() const override { return 0; } | |
| 84 WEBRTC_VOID_STUB(set_output_will_be_muted, (bool muted)); | |
| 85 WEBRTC_STUB(ProcessStream, (webrtc::AudioFrame* frame)); | |
| 86 WEBRTC_STUB(ProcessStream, ( | |
| 87 const float* const* src, | |
| 88 size_t samples_per_channel, | |
| 89 int input_sample_rate_hz, | |
| 90 webrtc::AudioProcessing::ChannelLayout input_layout, | |
| 91 int output_sample_rate_hz, | |
| 92 webrtc::AudioProcessing::ChannelLayout output_layout, | |
| 93 float* const* dest)); | |
| 94 WEBRTC_STUB(ProcessStream, | |
| 95 (const float* const* src, | |
| 96 const webrtc::StreamConfig& input_config, | |
| 97 const webrtc::StreamConfig& output_config, | |
| 98 float* const* dest)); | |
| 99 WEBRTC_STUB(ProcessReverseStream, (webrtc::AudioFrame * frame)); | |
| 100 WEBRTC_STUB(AnalyzeReverseStream, ( | |
| 101 const float* const* data, | |
| 102 size_t samples_per_channel, | |
| 103 int sample_rate_hz, | |
| 104 webrtc::AudioProcessing::ChannelLayout layout)); | |
| 105 WEBRTC_STUB(ProcessReverseStream, | |
| 106 (const float* const* src, | |
| 107 const webrtc::StreamConfig& reverse_input_config, | |
| 108 const webrtc::StreamConfig& reverse_output_config, | |
| 109 float* const* dest)); | |
| 110 WEBRTC_STUB(set_stream_delay_ms, (int delay)); | |
| 111 WEBRTC_STUB_CONST(stream_delay_ms, ()); | |
| 112 WEBRTC_BOOL_STUB_CONST(was_stream_delay_set, ()); | |
| 113 WEBRTC_VOID_STUB(set_stream_key_pressed, (bool key_pressed)); | |
| 114 WEBRTC_VOID_STUB(set_delay_offset_ms, (int offset)); | |
| 115 WEBRTC_STUB_CONST(delay_offset_ms, ()); | |
| 116 WEBRTC_STUB(StartDebugRecording, | |
| 117 (const char filename[kMaxFilenameSize], int64_t max_size_bytes)); | |
| 118 WEBRTC_STUB(StartDebugRecording, (FILE * handle, int64_t max_size_bytes)); | |
| 119 WEBRTC_STUB(StartDebugRecording, (FILE * handle)); | |
| 120 WEBRTC_STUB(StartDebugRecordingForPlatformFile, (rtc::PlatformFile handle)); | |
| 121 WEBRTC_STUB(StopDebugRecording, ()); | |
| 122 WEBRTC_VOID_STUB(UpdateHistogramsOnCallEnd, ()); | |
| 123 webrtc::EchoCancellation* echo_cancellation() const override { return NULL; } | |
| 124 webrtc::EchoControlMobile* echo_control_mobile() const override { | |
| 125 return NULL; | |
| 126 } | |
| 127 webrtc::GainControl* gain_control() const override { return NULL; } | |
| 128 webrtc::HighPassFilter* high_pass_filter() const override { return NULL; } | |
| 129 webrtc::LevelEstimator* level_estimator() const override { return NULL; } | |
| 130 webrtc::NoiseSuppression* noise_suppression() const override { return NULL; } | |
| 131 webrtc::VoiceDetection* voice_detection() const override { return NULL; } | |
| 132 | |
| 133 bool experimental_ns_enabled() { | |
| 134 return experimental_ns_enabled_; | |
| 135 } | |
| 136 | |
| 137 private: | |
| 138 bool experimental_ns_enabled_; | |
| 139 }; | |
| 140 | |
| 141 class FakeWebRtcVoiceEngine | 53 class FakeWebRtcVoiceEngine |
| 142 : public webrtc::VoEAudioProcessing, | 54 : public webrtc::VoEAudioProcessing, |
| 143 public webrtc::VoEBase, public webrtc::VoECodec, | 55 public webrtc::VoEBase, public webrtc::VoECodec, |
| 144 public webrtc::VoEHardware, | 56 public webrtc::VoEHardware, |
| 145 public webrtc::VoEVolumeControl { | 57 public webrtc::VoEVolumeControl { |
| 146 public: | 58 public: |
| 147 struct Channel { | 59 struct Channel { |
| 148 int associate_send_channel = -1; | 60 int associate_send_channel = -1; |
| 149 std::vector<webrtc::CodecInst> recv_codecs; | 61 std::vector<webrtc::CodecInst> recv_codecs; |
| 150 size_t neteq_capacity = 0; | 62 size_t neteq_capacity = 0; |
| 151 bool neteq_fast_accelerate = false; | 63 bool neteq_fast_accelerate = false; |
| 152 }; | 64 }; |
| 153 | 65 |
| 154 FakeWebRtcVoiceEngine() { | 66 explicit FakeWebRtcVoiceEngine(webrtc::AudioProcessing* apm) : apm_(apm) { |
| 155 memset(&agc_config_, 0, sizeof(agc_config_)); | 67 memset(&agc_config_, 0, sizeof(agc_config_)); |
| 156 } | 68 } |
| 157 ~FakeWebRtcVoiceEngine() override { | 69 ~FakeWebRtcVoiceEngine() override { |
| 158 RTC_CHECK(channels_.empty()); | 70 RTC_CHECK(channels_.empty()); |
| 159 } | 71 } |
| 160 | 72 |
| 161 bool ec_metrics_enabled() const { return ec_metrics_enabled_; } | 73 bool ec_metrics_enabled() const { return ec_metrics_enabled_; } |
| 162 | 74 |
| 163 bool IsInited() const { return inited_; } | 75 bool IsInited() const { return inited_; } |
| 164 int GetLastChannel() const { return last_channel_; } | 76 int GetLastChannel() const { return last_channel_; } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 183 const rtc::scoped_refptr<webrtc::AudioDecoderFactory>& | 95 const rtc::scoped_refptr<webrtc::AudioDecoderFactory>& |
| 184 decoder_factory)) { | 96 decoder_factory)) { |
| 185 inited_ = true; | 97 inited_ = true; |
| 186 return 0; | 98 return 0; |
| 187 } | 99 } |
| 188 WEBRTC_FUNC(Terminate, ()) { | 100 WEBRTC_FUNC(Terminate, ()) { |
| 189 inited_ = false; | 101 inited_ = false; |
| 190 return 0; | 102 return 0; |
| 191 } | 103 } |
| 192 webrtc::AudioProcessing* audio_processing() override { | 104 webrtc::AudioProcessing* audio_processing() override { |
| 193 return &audio_processing_; | 105 return apm_; |
| 194 } | 106 } |
| 195 webrtc::AudioDeviceModule* audio_device_module() override { | 107 webrtc::AudioDeviceModule* audio_device_module() override { |
| 196 return nullptr; | 108 return nullptr; |
| 197 } | 109 } |
| 198 WEBRTC_FUNC(CreateChannel, ()) { | 110 WEBRTC_FUNC(CreateChannel, ()) { |
| 199 return CreateChannel(webrtc::VoEBase::ChannelConfig()); | 111 return CreateChannel(webrtc::VoEBase::ChannelConfig()); |
| 200 } | 112 } |
| 201 WEBRTC_FUNC(CreateChannel, (const webrtc::VoEBase::ChannelConfig& config)) { | 113 WEBRTC_FUNC(CreateChannel, (const webrtc::VoEBase::ChannelConfig& config)) { |
| 202 if (fail_create_channel_) { | 114 if (fail_create_channel_) { |
| 203 return -1; | 115 return -1; |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 WEBRTC_FUNC(SetNsStatus, (bool enable, webrtc::NsModes mode)) { | 249 WEBRTC_FUNC(SetNsStatus, (bool enable, webrtc::NsModes mode)) { |
| 338 ns_enabled_ = enable; | 250 ns_enabled_ = enable; |
| 339 ns_mode_ = mode; | 251 ns_mode_ = mode; |
| 340 return 0; | 252 return 0; |
| 341 } | 253 } |
| 342 WEBRTC_FUNC(GetNsStatus, (bool& enabled, webrtc::NsModes& mode)) { | 254 WEBRTC_FUNC(GetNsStatus, (bool& enabled, webrtc::NsModes& mode)) { |
| 343 enabled = ns_enabled_; | 255 enabled = ns_enabled_; |
| 344 mode = ns_mode_; | 256 mode = ns_mode_; |
| 345 return 0; | 257 return 0; |
| 346 } | 258 } |
| 347 | |
| 348 WEBRTC_FUNC(SetAgcStatus, (bool enable, webrtc::AgcModes mode)) { | 259 WEBRTC_FUNC(SetAgcStatus, (bool enable, webrtc::AgcModes mode)) { |
| 349 agc_enabled_ = enable; | 260 agc_enabled_ = enable; |
| 350 agc_mode_ = mode; | 261 agc_mode_ = mode; |
| 351 return 0; | 262 return 0; |
| 352 } | 263 } |
| 353 WEBRTC_FUNC(GetAgcStatus, (bool& enabled, webrtc::AgcModes& mode)) { | 264 WEBRTC_FUNC(GetAgcStatus, (bool& enabled, webrtc::AgcModes& mode)) { |
| 354 enabled = agc_enabled_; | 265 enabled = agc_enabled_; |
| 355 mode = agc_mode_; | 266 mode = agc_mode_; |
| 356 return 0; | 267 return 0; |
| 357 } | 268 } |
| 358 | |
| 359 WEBRTC_FUNC(SetAgcConfig, (webrtc::AgcConfig config)) { | 269 WEBRTC_FUNC(SetAgcConfig, (webrtc::AgcConfig config)) { |
| 360 agc_config_ = config; | 270 agc_config_ = config; |
| 361 return 0; | 271 return 0; |
| 362 } | 272 } |
| 363 WEBRTC_FUNC(GetAgcConfig, (webrtc::AgcConfig& config)) { | 273 WEBRTC_FUNC(GetAgcConfig, (webrtc::AgcConfig& config)) { |
| 364 config = agc_config_; | 274 config = agc_config_; |
| 365 return 0; | 275 return 0; |
| 366 } | 276 } |
| 367 WEBRTC_FUNC(SetEcStatus, (bool enable, webrtc::EcModes mode)) { | 277 WEBRTC_FUNC(SetEcStatus, (bool enable, webrtc::EcModes mode)) { |
| 368 ec_enabled_ = enable; | 278 ec_enabled_ = enable; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 390 } | 300 } |
| 391 WEBRTC_STUB(VoiceActivityIndicator, (int channel)); | 301 WEBRTC_STUB(VoiceActivityIndicator, (int channel)); |
| 392 WEBRTC_FUNC(SetEcMetricsStatus, (bool enable)) { | 302 WEBRTC_FUNC(SetEcMetricsStatus, (bool enable)) { |
| 393 ec_metrics_enabled_ = enable; | 303 ec_metrics_enabled_ = enable; |
| 394 return 0; | 304 return 0; |
| 395 } | 305 } |
| 396 WEBRTC_STUB(GetEcMetricsStatus, (bool& enabled)); | 306 WEBRTC_STUB(GetEcMetricsStatus, (bool& enabled)); |
| 397 WEBRTC_STUB(GetEchoMetrics, (int& ERL, int& ERLE, int& RERL, int& A_NLP)); | 307 WEBRTC_STUB(GetEchoMetrics, (int& ERL, int& ERLE, int& RERL, int& A_NLP)); |
| 398 WEBRTC_STUB(GetEcDelayMetrics, (int& delay_median, int& delay_std, | 308 WEBRTC_STUB(GetEcDelayMetrics, (int& delay_median, int& delay_std, |
| 399 float& fraction_poor_delays)); | 309 float& fraction_poor_delays)); |
| 400 | |
| 401 WEBRTC_STUB(StartDebugRecording, (const char* fileNameUTF8)); | 310 WEBRTC_STUB(StartDebugRecording, (const char* fileNameUTF8)); |
| 402 WEBRTC_STUB(StartDebugRecording, (FILE* handle)); | 311 WEBRTC_STUB(StartDebugRecording, (FILE* handle)); |
| 403 WEBRTC_STUB(StopDebugRecording, ()); | 312 WEBRTC_STUB(StopDebugRecording, ()); |
| 404 | |
| 405 WEBRTC_FUNC(SetTypingDetectionStatus, (bool enable)) { | 313 WEBRTC_FUNC(SetTypingDetectionStatus, (bool enable)) { |
| 406 typing_detection_enabled_ = enable; | 314 typing_detection_enabled_ = enable; |
| 407 return 0; | 315 return 0; |
| 408 } | 316 } |
| 409 WEBRTC_FUNC(GetTypingDetectionStatus, (bool& enabled)) { | 317 WEBRTC_FUNC(GetTypingDetectionStatus, (bool& enabled)) { |
| 410 enabled = typing_detection_enabled_; | 318 enabled = typing_detection_enabled_; |
| 411 return 0; | 319 return 0; |
| 412 } | 320 } |
| 413 | |
| 414 WEBRTC_STUB(TimeSinceLastTyping, (int& seconds)); | 321 WEBRTC_STUB(TimeSinceLastTyping, (int& seconds)); |
| 415 WEBRTC_STUB(SetTypingDetectionParameters, (int timeWindow, | 322 WEBRTC_STUB(SetTypingDetectionParameters, (int timeWindow, |
| 416 int costPerTyping, | 323 int costPerTyping, |
| 417 int reportingThreshold, | 324 int reportingThreshold, |
| 418 int penaltyDecay, | 325 int penaltyDecay, |
| 419 int typeEventDelay)); | 326 int typeEventDelay)); |
| 420 int EnableHighPassFilter(bool enable) override { | 327 int EnableHighPassFilter(bool enable) override { |
| 421 highpass_filter_enabled_ = enable; | 328 highpass_filter_enabled_ = enable; |
| 422 return 0; | 329 return 0; |
| 423 } | 330 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 452 bool ns_enabled_ = false; | 359 bool ns_enabled_ = false; |
| 453 bool agc_enabled_ = false; | 360 bool agc_enabled_ = false; |
| 454 bool highpass_filter_enabled_ = false; | 361 bool highpass_filter_enabled_ = false; |
| 455 bool stereo_swapping_enabled_ = false; | 362 bool stereo_swapping_enabled_ = false; |
| 456 bool typing_detection_enabled_ = false; | 363 bool typing_detection_enabled_ = false; |
| 457 webrtc::EcModes ec_mode_ = webrtc::kEcDefault; | 364 webrtc::EcModes ec_mode_ = webrtc::kEcDefault; |
| 458 webrtc::AecmModes aecm_mode_ = webrtc::kAecmSpeakerphone; | 365 webrtc::AecmModes aecm_mode_ = webrtc::kAecmSpeakerphone; |
| 459 webrtc::NsModes ns_mode_ = webrtc::kNsDefault; | 366 webrtc::NsModes ns_mode_ = webrtc::kNsDefault; |
| 460 webrtc::AgcModes agc_mode_ = webrtc::kAgcDefault; | 367 webrtc::AgcModes agc_mode_ = webrtc::kAgcDefault; |
| 461 webrtc::AgcConfig agc_config_; | 368 webrtc::AgcConfig agc_config_; |
| 462 FakeAudioProcessing audio_processing_; | 369 webrtc::AudioProcessing* apm_ = nullptr; |
| 370 |
| 371 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(FakeWebRtcVoiceEngine); |
| 463 }; | 372 }; |
| 464 | 373 |
| 465 } // namespace cricket | 374 } // namespace cricket |
| 466 | 375 |
| 467 #endif // WEBRTC_MEDIA_ENGINE_FAKEWEBRTCVOICEENGINE_H_ | 376 #endif // WEBRTC_MEDIA_ENGINE_FAKEWEBRTCVOICEENGINE_H_ |
| OLD | NEW |