solenberg | 566ef24 | 2015-11-06 15:34:49 -0800 | [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 06:47:31 +0200 | [diff] [blame] | 10 | #ifndef CALL_AUDIO_STATE_H_ |
| 11 | #define CALL_AUDIO_STATE_H_ |
solenberg | 566ef24 | 2015-11-06 15:34:49 -0800 | [diff] [blame] | 12 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 13 | #include "api/audio/audio_mixer.h" |
| 14 | #include "rtc_base/refcount.h" |
| 15 | #include "rtc_base/scoped_ref_ptr.h" |
solenberg | 566ef24 | 2015-11-06 15:34:49 -0800 | [diff] [blame] | 16 | |
| 17 | namespace webrtc { |
| 18 | |
peah | a9cc40b | 2017-06-29 08:32:09 -0700 | [diff] [blame] | 19 | class AudioProcessing; |
Fredrik Solenberg | 63e6072 | 2017-11-20 22:12:21 +0100 | [diff] [blame^] | 20 | class AudioTransport; |
solenberg | 566ef24 | 2015-11-06 15:34:49 -0800 | [diff] [blame] | 21 | class VoiceEngine; |
| 22 | |
Fredrik Solenberg | a4527c8 | 2015-12-03 13:06:20 +0100 | [diff] [blame] | 23 | // WORK IN PROGRESS |
| 24 | // This class is under development and is not yet intended for for use outside |
| 25 | // of WebRtc/Libjingle. Please use the VoiceEngine API instead. |
| 26 | // See: https://bugs.chromium.org/p/webrtc/issues/detail?id=4690 |
| 27 | |
solenberg | 566ef24 | 2015-11-06 15:34:49 -0800 | [diff] [blame] | 28 | // AudioState holds the state which must be shared between multiple instances of |
| 29 | // webrtc::Call for audio processing purposes. |
| 30 | class AudioState : public rtc::RefCountInterface { |
| 31 | public: |
| 32 | struct Config { |
| 33 | // VoiceEngine used for audio streams and audio/video synchronization. |
| 34 | // AudioState will tickle the VoE refcount to keep it alive for as long as |
| 35 | // the AudioState itself. |
| 36 | VoiceEngine* voice_engine = nullptr; |
| 37 | |
aleloi | 81da488 | 2016-11-08 04:26:30 -0800 | [diff] [blame] | 38 | // The audio mixer connected to active receive streams. One per |
| 39 | // AudioState. |
| 40 | rtc::scoped_refptr<AudioMixer> audio_mixer; |
peah | a9cc40b | 2017-06-29 08:32:09 -0700 | [diff] [blame] | 41 | |
| 42 | // The audio processing module. |
| 43 | rtc::scoped_refptr<webrtc::AudioProcessing> audio_processing; |
solenberg | 566ef24 | 2015-11-06 15:34:49 -0800 | [diff] [blame] | 44 | }; |
| 45 | |
peah | a9cc40b | 2017-06-29 08:32:09 -0700 | [diff] [blame] | 46 | virtual AudioProcessing* audio_processing() = 0; |
Fredrik Solenberg | 63e6072 | 2017-11-20 22:12:21 +0100 | [diff] [blame^] | 47 | virtual AudioTransport* audio_transport() = 0; |
peah | a9cc40b | 2017-06-29 08:32:09 -0700 | [diff] [blame] | 48 | |
henrika | 5f6bf24 | 2017-11-01 11:06:56 +0100 | [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 | |
solenberg | 566ef24 | 2015-11-06 15:34:49 -0800 | [diff] [blame] | 60 | // TODO(solenberg): Replace scoped_refptr with shared_ptr once we can use it. |
| 61 | static rtc::scoped_refptr<AudioState> Create( |
| 62 | const AudioState::Config& config); |
| 63 | |
| 64 | virtual ~AudioState() {} |
| 65 | }; |
| 66 | } // namespace webrtc |
| 67 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 68 | #endif // CALL_AUDIO_STATE_H_ |