blob: a78ca187a85840d0440cc175413263040a74503e [file] [log] [blame]
Alex Loiko62347222018-09-10 10:18:07 +02001/*
2 * Copyright (c) 2018 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#include "modules/audio_processing/test/runtime_setting_util.h"
Per Åhgren6ee75fd2019-04-26 11:33:37 +020012
Alex Loiko62347222018-09-10 10:18:07 +020013#include "rtc_base/checks.h"
14
15namespace webrtc {
16
17void ReplayRuntimeSetting(AudioProcessing* apm,
18 const webrtc::audioproc::RuntimeSetting& setting) {
19 RTC_CHECK(apm);
20 // TODO(bugs.webrtc.org/9138): Add ability to handle different types
Fredrik Hernqvistca362852019-05-10 15:50:02 +020021 // of settings. Currently CapturePreGain, CaptureFixedPostGain and
22 // PlayoutVolumeChange are supported.
Per Åhgren6ee75fd2019-04-26 11:33:37 +020023 RTC_CHECK(setting.has_capture_pre_gain() ||
Fredrik Hernqvistca362852019-05-10 15:50:02 +020024 setting.has_capture_fixed_post_gain() ||
25 setting.has_playout_volume_change());
Per Åhgren6ee75fd2019-04-26 11:33:37 +020026
27 if (setting.has_capture_pre_gain()) {
28 apm->SetRuntimeSetting(
29 AudioProcessing::RuntimeSetting::CreateCapturePreGain(
30 setting.capture_pre_gain()));
31 } else if (setting.has_capture_fixed_post_gain()) {
32 apm->SetRuntimeSetting(
33 AudioProcessing::RuntimeSetting::CreateCaptureFixedPostGain(
34 setting.capture_fixed_post_gain()));
Fredrik Hernqvistca362852019-05-10 15:50:02 +020035 } else if (setting.has_playout_volume_change()) {
36 apm->SetRuntimeSetting(
37 AudioProcessing::RuntimeSetting::CreatePlayoutVolumeChange(
38 setting.playout_volume_change()));
Per Åhgren6ee75fd2019-04-26 11:33:37 +020039 }
Alex Loiko62347222018-09-10 10:18:07 +020040}
41} // namespace webrtc