solenberg | 566ef24 | 2015-11-06 23:34:49 | [diff] [blame] | 1 | /* |
| 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 Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 10 | #ifndef CALL_AUDIO_STATE_H_ |
| 11 | #define CALL_AUDIO_STATE_H_ |
solenberg | 566ef24 | 2015-11-06 23:34:49 | [diff] [blame] | 12 | |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 13 | #include "api/audio/audio_mixer.h" |
Mirko Bonadei | d970807 | 2019-01-25 19:26:48 | [diff] [blame] | 14 | #include "api/scoped_refptr.h" |
Olga Sharonova | 09ceed2 | 2020-09-30 16:27:39 | [diff] [blame] | 15 | #include "modules/async_audio_processing/async_audio_processing.h" |
Paulina Hensman | 11b34f4 | 2018-04-09 12:24:52 | [diff] [blame] | 16 | #include "modules/audio_device/include/audio_device.h" |
| 17 | #include "modules/audio_processing/include/audio_processing.h" |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 18 | #include "rtc_base/ref_count.h" |
solenberg | 566ef24 | 2015-11-06 23:34:49 | [diff] [blame] | 19 | |
| 20 | namespace webrtc { |
| 21 | |
Fredrik Solenberg | 63e6072 | 2017-11-20 21:12:21 | [diff] [blame] | 22 | class AudioTransport; |
solenberg | 566ef24 | 2015-11-06 23:34:49 | [diff] [blame] | 23 | |
solenberg | 566ef24 | 2015-11-06 23:34:49 | [diff] [blame] | 24 | // AudioState holds the state which must be shared between multiple instances of |
| 25 | // webrtc::Call for audio processing purposes. |
| 26 | class AudioState : public rtc::RefCountInterface { |
| 27 | public: |
| 28 | struct Config { |
Paulina Hensman | 11b34f4 | 2018-04-09 12:24:52 | [diff] [blame] | 29 | Config(); |
| 30 | ~Config(); |
| 31 | |
aleloi | 81da488 | 2016-11-08 12:26:30 | [diff] [blame] | 32 | // The audio mixer connected to active receive streams. One per |
| 33 | // AudioState. |
| 34 | rtc::scoped_refptr<AudioMixer> audio_mixer; |
peah | a9cc40b | 2017-06-29 15:32:09 | [diff] [blame] | 35 | |
| 36 | // The audio processing module. |
| 37 | rtc::scoped_refptr<webrtc::AudioProcessing> audio_processing; |
Fredrik Solenberg | cf73c96 | 2017-12-01 19:09:56 | [diff] [blame] | 38 | |
| 39 | // TODO(solenberg): Temporary: audio device module. |
| 40 | rtc::scoped_refptr<webrtc::AudioDeviceModule> audio_device_module; |
Olga Sharonova | 09ceed2 | 2020-09-30 16:27:39 | [diff] [blame] | 41 | |
| 42 | rtc::scoped_refptr<AsyncAudioProcessing::Factory> |
| 43 | async_audio_processing_factory; |
solenberg | 566ef24 | 2015-11-06 23:34:49 | [diff] [blame] | 44 | }; |
| 45 | |
peah | a9cc40b | 2017-06-29 15:32:09 | [diff] [blame] | 46 | virtual AudioProcessing* audio_processing() = 0; |
Fredrik Solenberg | 63e6072 | 2017-11-20 21:12:21 | [diff] [blame] | 47 | virtual AudioTransport* audio_transport() = 0; |
peah | a9cc40b | 2017-06-29 15:32:09 | [diff] [blame] | 48 | |
henrika | 5f6bf24 | 2017-11-01 10:06:56 | [diff] [blame] | 49 | // Enable/disable playout of the audio channels. Enabled by default. |
| 50 | // This will stop playout of the underlying audio device but start a task |
| 51 | // which will poll for audio data every 10ms to ensure that audio processing |
| 52 | // happens and the audio stats are updated. |
| 53 | virtual void SetPlayout(bool enabled) = 0; |
| 54 | |
| 55 | // Enable/disable recording of the audio channels. Enabled by default. |
| 56 | // This will stop recording of the underlying audio device and no audio |
| 57 | // packets will be encoded or transmitted. |
| 58 | virtual void SetRecording(bool enabled) = 0; |
| 59 | |
Fredrik Solenberg | 2a87797 | 2017-12-15 15:42:15 | [diff] [blame] | 60 | virtual void SetStereoChannelSwapping(bool enable) = 0; |
| 61 | |
solenberg | 566ef24 | 2015-11-06 23:34:49 | [diff] [blame] | 62 | static rtc::scoped_refptr<AudioState> Create( |
| 63 | const AudioState::Config& config); |
| 64 | |
Paulina Hensman | 11b34f4 | 2018-04-09 12:24:52 | [diff] [blame] | 65 | ~AudioState() override {} |
solenberg | 566ef24 | 2015-11-06 23:34:49 | [diff] [blame] | 66 | }; |
| 67 | } // namespace webrtc |
| 68 | |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 69 | #endif // CALL_AUDIO_STATE_H_ |