blob: 89267c5ab378141a2d0fb4e2da708702a0768464 [file] [log] [blame]
solenberg566ef242015-11-06 15:34:49 -08001/*
2 * Copyright (c) 2015 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 */
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020010#ifndef CALL_AUDIO_STATE_H_
11#define CALL_AUDIO_STATE_H_
solenberg566ef242015-11-06 15:34:49 -080012
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020013#include "api/audio/audio_mixer.h"
Mirko Bonadeid9708072019-01-25 20:26:48 +010014#include "api/scoped_refptr.h"
Paulina Hensman11b34f42018-04-09 14:24:52 +020015#include "modules/audio_device/include/audio_device.h"
16#include "modules/audio_processing/include/audio_processing.h"
Steve Anton10542f22019-01-11 09:11:00 -080017#include "rtc_base/ref_count.h"
solenberg566ef242015-11-06 15:34:49 -080018
19namespace webrtc {
20
Fredrik Solenberg63e60722017-11-20 22:12:21 +010021class AudioTransport;
solenberg566ef242015-11-06 15:34:49 -080022
solenberg566ef242015-11-06 15:34:49 -080023// AudioState holds the state which must be shared between multiple instances of
24// webrtc::Call for audio processing purposes.
25class AudioState : public rtc::RefCountInterface {
26 public:
27 struct Config {
Paulina Hensman11b34f42018-04-09 14:24:52 +020028 Config();
29 ~Config();
30
aleloi81da4882016-11-08 04:26:30 -080031 // The audio mixer connected to active receive streams. One per
32 // AudioState.
33 rtc::scoped_refptr<AudioMixer> audio_mixer;
peaha9cc40b2017-06-29 08:32:09 -070034
35 // The audio processing module.
36 rtc::scoped_refptr<webrtc::AudioProcessing> audio_processing;
Fredrik Solenbergcf73c962017-12-01 20:09:56 +010037
38 // TODO(solenberg): Temporary: audio device module.
39 rtc::scoped_refptr<webrtc::AudioDeviceModule> audio_device_module;
solenberg566ef242015-11-06 15:34:49 -080040 };
41
peaha9cc40b2017-06-29 08:32:09 -070042 virtual AudioProcessing* audio_processing() = 0;
Fredrik Solenberg63e60722017-11-20 22:12:21 +010043 virtual AudioTransport* audio_transport() = 0;
peaha9cc40b2017-06-29 08:32:09 -070044
henrika5f6bf242017-11-01 11:06:56 +010045 // Enable/disable playout of the audio channels. Enabled by default.
46 // This will stop playout of the underlying audio device but start a task
47 // which will poll for audio data every 10ms to ensure that audio processing
48 // happens and the audio stats are updated.
49 virtual void SetPlayout(bool enabled) = 0;
50
51 // Enable/disable recording of the audio channels. Enabled by default.
52 // This will stop recording of the underlying audio device and no audio
53 // packets will be encoded or transmitted.
54 virtual void SetRecording(bool enabled) = 0;
55
Fredrik Solenberg2a877972017-12-15 16:42:15 +010056 virtual void SetStereoChannelSwapping(bool enable) = 0;
57
solenberg566ef242015-11-06 15:34:49 -080058 static rtc::scoped_refptr<AudioState> Create(
59 const AudioState::Config& config);
60
Paulina Hensman11b34f42018-04-09 14:24:52 +020061 ~AudioState() override {}
solenberg566ef242015-11-06 15:34:49 -080062};
63} // namespace webrtc
64
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020065#endif // CALL_AUDIO_STATE_H_