Home | History | Annotate | Download | only in audio_processing
      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 
     11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CANCELLATION_IMPL_H_
     12 #define WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CANCELLATION_IMPL_H_
     13 
     14 #include "webrtc/modules/audio_processing/include/audio_processing.h"
     15 #include "webrtc/modules/audio_processing/processing_component.h"
     16 
     17 namespace webrtc {
     18 
     19 class AudioBuffer;
     20 class CriticalSectionWrapper;
     21 
     22 class EchoCancellationImpl : public EchoCancellation,
     23                              public ProcessingComponent {
     24  public:
     25   EchoCancellationImpl(const AudioProcessing* apm,
     26                        CriticalSectionWrapper* crit);
     27   virtual ~EchoCancellationImpl();
     28 
     29   int ProcessRenderAudio(const AudioBuffer* audio);
     30   int ProcessCaptureAudio(AudioBuffer* audio);
     31 
     32   // EchoCancellation implementation.
     33   virtual bool is_enabled() const OVERRIDE;
     34   virtual int stream_drift_samples() const OVERRIDE;
     35 
     36   // ProcessingComponent implementation.
     37   virtual int Initialize() OVERRIDE;
     38   virtual void SetExtraOptions(const Config& config) OVERRIDE;
     39 
     40  private:
     41   // EchoCancellation implementation.
     42   virtual int Enable(bool enable) OVERRIDE;
     43   virtual int enable_drift_compensation(bool enable) OVERRIDE;
     44   virtual bool is_drift_compensation_enabled() const OVERRIDE;
     45   virtual void set_stream_drift_samples(int drift) OVERRIDE;
     46   virtual int set_suppression_level(SuppressionLevel level) OVERRIDE;
     47   virtual SuppressionLevel suppression_level() const OVERRIDE;
     48   virtual int enable_metrics(bool enable) OVERRIDE;
     49   virtual bool are_metrics_enabled() const OVERRIDE;
     50   virtual bool stream_has_echo() const OVERRIDE;
     51   virtual int GetMetrics(Metrics* metrics) OVERRIDE;
     52   virtual int enable_delay_logging(bool enable) OVERRIDE;
     53   virtual bool is_delay_logging_enabled() const OVERRIDE;
     54   virtual int GetDelayMetrics(int* median, int* std) OVERRIDE;
     55   virtual struct AecCore* aec_core() const OVERRIDE;
     56 
     57   // ProcessingComponent implementation.
     58   virtual void* CreateHandle() const OVERRIDE;
     59   virtual int InitializeHandle(void* handle) const OVERRIDE;
     60   virtual int ConfigureHandle(void* handle) const OVERRIDE;
     61   virtual void DestroyHandle(void* handle) const OVERRIDE;
     62   virtual int num_handles_required() const OVERRIDE;
     63   virtual int GetHandleError(void* handle) const OVERRIDE;
     64 
     65   const AudioProcessing* apm_;
     66   CriticalSectionWrapper* crit_;
     67   bool drift_compensation_enabled_;
     68   bool metrics_enabled_;
     69   SuppressionLevel suppression_level_;
     70   int stream_drift_samples_;
     71   bool was_stream_drift_set_;
     72   bool stream_has_echo_;
     73   bool delay_logging_enabled_;
     74   bool delay_correction_enabled_;
     75   bool reported_delay_enabled_;
     76 };
     77 
     78 }  // namespace webrtc
     79 
     80 #endif  // WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CANCELLATION_IMPL_H_
     81