echo_control_mobile_impl.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
  3. *
  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
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #ifndef MODULES_AUDIO_PROCESSING_ECHO_CONTROL_MOBILE_IMPL_H_
  11. #define MODULES_AUDIO_PROCESSING_ECHO_CONTROL_MOBILE_IMPL_H_
  12. #include <stddef.h>
  13. #include <stdint.h>
  14. #include <memory>
  15. #include <vector>
  16. #include "api/array_view.h"
  17. namespace webrtc {
  18. class AudioBuffer;
  19. // The acoustic echo control for mobile (AECM) component is a low complexity
  20. // robust option intended for use on mobile devices.
  21. class EchoControlMobileImpl {
  22. public:
  23. EchoControlMobileImpl();
  24. ~EchoControlMobileImpl();
  25. // Recommended settings for particular audio routes. In general, the louder
  26. // the echo is expected to be, the higher this value should be set. The
  27. // preferred setting may vary from device to device.
  28. enum RoutingMode {
  29. kQuietEarpieceOrHeadset,
  30. kEarpiece,
  31. kLoudEarpiece,
  32. kSpeakerphone,
  33. kLoudSpeakerphone
  34. };
  35. // Sets echo control appropriate for the audio routing |mode| on the device.
  36. // It can and should be updated during a call if the audio routing changes.
  37. int set_routing_mode(RoutingMode mode);
  38. RoutingMode routing_mode() const;
  39. // Comfort noise replaces suppressed background noise to maintain a
  40. // consistent signal level.
  41. int enable_comfort_noise(bool enable);
  42. bool is_comfort_noise_enabled() const;
  43. void ProcessRenderAudio(rtc::ArrayView<const int16_t> packed_render_audio);
  44. int ProcessCaptureAudio(AudioBuffer* audio, int stream_delay_ms);
  45. void Initialize(int sample_rate_hz,
  46. size_t num_reverse_channels,
  47. size_t num_output_channels);
  48. static void PackRenderAudioBuffer(const AudioBuffer* audio,
  49. size_t num_output_channels,
  50. size_t num_channels,
  51. std::vector<int16_t>* packed_buffer);
  52. static size_t NumCancellersRequired(size_t num_output_channels,
  53. size_t num_reverse_channels);
  54. private:
  55. class Canceller;
  56. struct StreamProperties;
  57. int Configure();
  58. RoutingMode routing_mode_;
  59. bool comfort_noise_enabled_;
  60. std::vector<std::unique_ptr<Canceller>> cancellers_;
  61. std::unique_ptr<StreamProperties> stream_properties_;
  62. std::vector<std::array<int16_t, 160>> low_pass_reference_;
  63. bool reference_copied_ = false;
  64. };
  65. } // namespace webrtc
  66. #endif // MODULES_AUDIO_PROCESSING_ECHO_CONTROL_MOBILE_IMPL_H_