DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Header

Mercurial (c68fe15a81fc)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
/*
 *  Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

#include "modules/audio_processing/gain_control_for_experimental_agc.h"

#include "modules/audio_processing/include/audio_processing.h"
#include "modules/audio_processing/logging/apm_data_dumper.h"
#include "rtc_base/checks.h"
#include "rtc_base/criticalsection.h"

namespace webrtc {

int GainControlForExperimentalAgc::instance_counter_ = 0;

GainControlForExperimentalAgc::GainControlForExperimentalAgc(
    GainControl* gain_control,
    rtc::CriticalSection* crit_capture)
    : data_dumper_(new ApmDataDumper(instance_counter_)),
      real_gain_control_(gain_control),
      volume_(0),
      crit_capture_(crit_capture) {
  instance_counter_++;
}

GainControlForExperimentalAgc::~GainControlForExperimentalAgc() = default;

int GainControlForExperimentalAgc::Enable(bool enable) {
  return real_gain_control_->Enable(enable);
}

bool GainControlForExperimentalAgc::is_enabled() const {
  return real_gain_control_->is_enabled();
}

int GainControlForExperimentalAgc::set_stream_analog_level(int level) {
  rtc::CritScope cs_capture(crit_capture_);
  data_dumper_->DumpRaw("experimental_gain_control_set_stream_analog_level", 1,
                        &level);
  volume_ = level;
  return AudioProcessing::kNoError;
}

int GainControlForExperimentalAgc::stream_analog_level() {
  rtc::CritScope cs_capture(crit_capture_);
  data_dumper_->DumpRaw("experimental_gain_control_stream_analog_level", 1,
                        &volume_);
  return volume_;
}

int GainControlForExperimentalAgc::set_mode(Mode mode) {
  return AudioProcessing::kNoError;
}

GainControl::Mode GainControlForExperimentalAgc::mode() const {
  return GainControl::kAdaptiveAnalog;
}

int GainControlForExperimentalAgc::set_target_level_dbfs(int level) {
  return AudioProcessing::kNoError;
}

int GainControlForExperimentalAgc::target_level_dbfs() const {
  return real_gain_control_->target_level_dbfs();
}

int GainControlForExperimentalAgc::set_compression_gain_db(int gain) {
  return AudioProcessing::kNoError;
}

int GainControlForExperimentalAgc::compression_gain_db() const {
  return real_gain_control_->compression_gain_db();
}

int GainControlForExperimentalAgc::enable_limiter(bool enable) {
  return AudioProcessing::kNoError;
}

bool GainControlForExperimentalAgc::is_limiter_enabled() const {
  return real_gain_control_->is_limiter_enabled();
}

int GainControlForExperimentalAgc::set_analog_level_limits(int minimum,
                                                           int maximum) {
  return AudioProcessing::kNoError;
}

int GainControlForExperimentalAgc::analog_level_minimum() const {
  return real_gain_control_->analog_level_minimum();
}

int GainControlForExperimentalAgc::analog_level_maximum() const {
  return real_gain_control_->analog_level_maximum();
}

bool GainControlForExperimentalAgc::stream_is_saturated() const {
  return real_gain_control_->stream_is_saturated();
}

void GainControlForExperimentalAgc::SetMicVolume(int volume) {
  rtc::CritScope cs_capture(crit_capture_);
  volume_ = volume;
}

int GainControlForExperimentalAgc::GetMicVolume() {
  rtc::CritScope cs_capture(crit_capture_);
  return volume_;
}

void GainControlForExperimentalAgc::Initialize() {
  data_dumper_->InitiateNewSetOfRecordings();
}

}  // namespace webrtc