LCOV - code coverage report
Current view: top level - media/webrtc/trunk/webrtc/modules/audio_processing/agc - agc_manager_direct.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 2 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) 2013 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_AGC_AGC_MANAGER_DIRECT_H_
      12             : #define WEBRTC_MODULES_AUDIO_PROCESSING_AGC_AGC_MANAGER_DIRECT_H_
      13             : 
      14             : #include <memory>
      15             : 
      16             : #include "webrtc/base/constructormagic.h"
      17             : #include "webrtc/modules/audio_processing/agc/agc.h"
      18             : 
      19             : namespace webrtc {
      20             : 
      21             : class AudioFrame;
      22             : class DebugFile;
      23             : class GainControl;
      24             : 
      25             : // Callbacks that need to be injected into AgcManagerDirect to read and control
      26             : // the volume values. This is done to remove the VoiceEngine dependency in
      27             : // AgcManagerDirect.
      28             : // TODO(aluebs): Remove VolumeCallbacks.
      29           0 : class VolumeCallbacks {
      30             :  public:
      31           0 :   virtual ~VolumeCallbacks() {}
      32             :   virtual void SetMicVolume(int volume) = 0;
      33             :   virtual int GetMicVolume() = 0;
      34             : };
      35             : 
      36             : // Direct interface to use AGC to set volume and compression values.
      37             : // AudioProcessing uses this interface directly to integrate the callback-less
      38             : // AGC.
      39             : //
      40             : // This class is not thread-safe.
      41             : class AgcManagerDirect final {
      42             :  public:
      43             :   // AgcManagerDirect will configure GainControl internally. The user is
      44             :   // responsible for processing the audio using it after the call to Process.
      45             :   // The operating range of startup_min_level is [12, 255] and any input value
      46             :   // outside that range will be clamped.
      47             :   AgcManagerDirect(GainControl* gctrl,
      48             :                    VolumeCallbacks* volume_callbacks,
      49             :                    int startup_min_level,
      50             :                    int clipped_level_min);
      51             :   // Dependency injection for testing. Don't delete |agc| as the memory is owned
      52             :   // by the manager.
      53             :   AgcManagerDirect(Agc* agc,
      54             :                    GainControl* gctrl,
      55             :                    VolumeCallbacks* volume_callbacks,
      56             :                    int startup_min_level,
      57             :                    int clipped_level_min);
      58             :   ~AgcManagerDirect();
      59             : 
      60             :   int Initialize();
      61             :   void AnalyzePreProcess(int16_t* audio,
      62             :                          int num_channels,
      63             :                          size_t samples_per_channel);
      64             :   void Process(const int16_t* audio, size_t length, int sample_rate_hz);
      65             : 
      66             :   // Call when the capture stream has been muted/unmuted. This causes the
      67             :   // manager to disregard all incoming audio; chances are good it's background
      68             :   // noise to which we'd like to avoid adapting.
      69             :   void SetCaptureMuted(bool muted);
      70             :   bool capture_muted() { return capture_muted_; }
      71             : 
      72             :   float voice_probability();
      73             : 
      74             :  private:
      75             :   // Sets a new microphone level, after first checking that it hasn't been
      76             :   // updated by the user, in which case no action is taken.
      77             :   void SetLevel(int new_level);
      78             : 
      79             :   // Set the maximum level the AGC is allowed to apply. Also updates the
      80             :   // maximum compression gain to compensate. The level must be at least
      81             :   // |kClippedLevelMin|.
      82             :   void SetMaxLevel(int level);
      83             : 
      84             :   int CheckVolumeAndReset();
      85             :   void UpdateGain();
      86             :   void UpdateCompressor();
      87             : 
      88             :   std::unique_ptr<Agc> agc_;
      89             :   GainControl* gctrl_;
      90             :   VolumeCallbacks* volume_callbacks_;
      91             : 
      92             :   int frames_since_clipped_;
      93             :   int level_;
      94             :   int max_level_;
      95             :   int max_compression_gain_;
      96             :   int target_compression_;
      97             :   int compression_;
      98             :   float compression_accumulator_;
      99             :   bool capture_muted_;
     100             :   bool check_volume_on_next_process_;
     101             :   bool startup_;
     102             :   int startup_min_level_;
     103             :   const int clipped_level_min_;
     104             : 
     105             :   std::unique_ptr<DebugFile> file_preproc_;
     106             :   std::unique_ptr<DebugFile> file_postproc_;
     107             : 
     108             :   RTC_DISALLOW_COPY_AND_ASSIGN(AgcManagerDirect);
     109             : };
     110             : 
     111             : }  // namespace webrtc
     112             : 
     113             : #endif  // WEBRTC_MODULES_AUDIO_PROCESSING_AGC_AGC_MANAGER_DIRECT_H_

Generated by: LCOV version 1.13