LCOV - code coverage report
Current view: top level - media/webrtc/trunk/webrtc/modules/audio_processing/aec3 - echo_canceller3.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 10 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  *  Copyright (c) 2016 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_AEC3_ECHO_CANCELLER3_H_
      12             : #define WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_ECHO_CANCELLER3_H_
      13             : 
      14             : #include "webrtc/base/constructormagic.h"
      15             : #include "webrtc/base/race_checker.h"
      16             : #include "webrtc/base/swap_queue.h"
      17             : #include "webrtc/modules/audio_processing/aec3/block_framer.h"
      18             : #include "webrtc/modules/audio_processing/aec3/block_processor.h"
      19             : #include "webrtc/modules/audio_processing/aec3/cascaded_biquad_filter.h"
      20             : #include "webrtc/modules/audio_processing/aec3/frame_blocker.h"
      21             : #include "webrtc/modules/audio_processing/audio_buffer.h"
      22             : #include "webrtc/modules/audio_processing/include/audio_processing.h"
      23             : #include "webrtc/modules/audio_processing/logging/apm_data_dumper.h"
      24             : 
      25             : namespace webrtc {
      26             : 
      27             : // Functor for verifying the invariance of the frames being put into the render
      28             : // queue.
      29             : class Aec3RenderQueueItemVerifier {
      30             :  public:
      31           0 :   explicit Aec3RenderQueueItemVerifier(size_t num_bands, size_t frame_length)
      32           0 :       : num_bands_(num_bands), frame_length_(frame_length) {}
      33             : 
      34           0 :   bool operator()(const std::vector<std::vector<float>>& v) const {
      35           0 :     if (v.size() != num_bands_) {
      36           0 :       return false;
      37             :     }
      38           0 :     for (const auto& v_k : v) {
      39           0 :       if (v_k.size() != frame_length_) {
      40           0 :         return false;
      41             :       }
      42             :     }
      43           0 :     return true;
      44             :   }
      45             : 
      46             :  private:
      47             :   const size_t num_bands_;
      48             :   const size_t frame_length_;
      49             : };
      50             : 
      51             : // Main class for the echo canceller3.
      52             : // It does 4 things:
      53             : // -Receives 10 ms frames of band-split audio.
      54             : // -Optionally applies an anti-hum (high-pass) filter on the
      55             : // received signals.
      56             : // -Provides the lower level echo canceller functionality with
      57             : // blocks of 64 samples of audio data.
      58             : // -Partially handles the jitter in the render and capture API
      59             : // call sequence.
      60             : //
      61             : // The class is supposed to be used in a non-concurrent manner apart from the
      62             : // AnalyzeRender call which can be called concurrently with the other methods.
      63           0 : class EchoCanceller3 {
      64             :  public:
      65             :   // Normal c-tor to use.
      66             :   EchoCanceller3(int sample_rate_hz, bool use_highpass_filter);
      67             :   // Testing c-tor that is used only for testing purposes.
      68             :   EchoCanceller3(int sample_rate_hz,
      69             :                  bool use_highpass_filter,
      70             :                  std::unique_ptr<BlockProcessor> block_processor);
      71             :   ~EchoCanceller3();
      72             :   // Analyzes and stores an internal copy of the split-band domain render
      73             :   // signal.
      74             :   bool AnalyzeRender(AudioBuffer* farend);
      75             :   // Analyzes the full-band domain capture signal to detect signal saturation.
      76             :   void AnalyzeCapture(AudioBuffer* capture);
      77             :   // Processes the split-band domain capture signal in order to remove any echo
      78             :   // present in the signal.
      79             :   void ProcessCapture(AudioBuffer* capture, bool known_echo_path_change);
      80             : 
      81             :   // Signals whether an external detector has detected echo leakage from the
      82             :   // echo canceller.
      83             :   // Note that in the case echo leakage has been flagged, it should be unflagged
      84             :   // once it is no longer occurring.
      85             :   void ReportEchoLeakage(bool leakage_detected) {
      86             :     RTC_DCHECK_RUNS_SERIALIZED(&capture_race_checker_);
      87             :     block_processor_->ReportEchoLeakage(leakage_detected);
      88             :   }
      89             : 
      90             :   // Validates a config.
      91             :   static bool Validate(const AudioProcessing::Config::EchoCanceller3& config);
      92             :   // Dumps a config to a string.
      93             :   static std::string ToString(
      94             :       const AudioProcessing::Config::EchoCanceller3& config);
      95             : 
      96             :  private:
      97             :   class RenderWriter;
      98             : 
      99             :   bool EmptyRenderQueue();
     100             : 
     101             :   rtc::RaceChecker capture_race_checker_;
     102             :   rtc::RaceChecker render_race_checker_;
     103             : 
     104             :   // State that is accessed by the AnalyzeRender call.
     105             :   std::unique_ptr<RenderWriter> render_writer_ GUARDED_BY(render_race_checker_);
     106             : 
     107             :   // State that may be accessed by the capture thread.
     108             :   static int instance_count_;
     109             :   std::unique_ptr<ApmDataDumper> data_dumper_;
     110             :   const int sample_rate_hz_;
     111             :   const int num_bands_;
     112             :   const size_t frame_length_;
     113             :   BlockFramer output_framer_ GUARDED_BY(capture_race_checker_);
     114             :   FrameBlocker capture_blocker_ GUARDED_BY(capture_race_checker_);
     115             :   FrameBlocker render_blocker_ GUARDED_BY(capture_race_checker_);
     116             :   SwapQueue<std::vector<std::vector<float>>, Aec3RenderQueueItemVerifier>
     117             :       render_transfer_queue_;
     118             :   std::unique_ptr<BlockProcessor> block_processor_
     119             :       GUARDED_BY(capture_race_checker_);
     120             :   std::vector<std::vector<float>> render_queue_output_frame_
     121             :       GUARDED_BY(capture_race_checker_);
     122             :   std::unique_ptr<CascadedBiQuadFilter> capture_highpass_filter_
     123             :       GUARDED_BY(capture_race_checker_);
     124             :   bool saturated_microphone_signal_ GUARDED_BY(capture_race_checker_) = false;
     125             :   std::vector<std::vector<float>> block_ GUARDED_BY(capture_race_checker_);
     126             :   std::vector<rtc::ArrayView<float>> sub_frame_view_
     127             :       GUARDED_BY(capture_race_checker_);
     128             : 
     129             :   RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(EchoCanceller3);
     130             : };
     131             : }  // namespace webrtc
     132             : 
     133             : #endif  // WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_ECHO_CANCELLER3_H_

Generated by: LCOV version 1.13