xref: /aosp_15_r20/external/webrtc/call/audio_state.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1*d9f75844SAndroid Build Coastguard Worker /*
2*d9f75844SAndroid Build Coastguard Worker  *  Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3*d9f75844SAndroid Build Coastguard Worker  *
4*d9f75844SAndroid Build Coastguard Worker  *  Use of this source code is governed by a BSD-style license
5*d9f75844SAndroid Build Coastguard Worker  *  that can be found in the LICENSE file in the root of the source
6*d9f75844SAndroid Build Coastguard Worker  *  tree. An additional intellectual property rights grant can be found
7*d9f75844SAndroid Build Coastguard Worker  *  in the file PATENTS.  All contributing project authors may
8*d9f75844SAndroid Build Coastguard Worker  *  be found in the AUTHORS file in the root of the source tree.
9*d9f75844SAndroid Build Coastguard Worker  */
10*d9f75844SAndroid Build Coastguard Worker #ifndef CALL_AUDIO_STATE_H_
11*d9f75844SAndroid Build Coastguard Worker #define CALL_AUDIO_STATE_H_
12*d9f75844SAndroid Build Coastguard Worker 
13*d9f75844SAndroid Build Coastguard Worker #include "api/audio/audio_mixer.h"
14*d9f75844SAndroid Build Coastguard Worker #include "api/scoped_refptr.h"
15*d9f75844SAndroid Build Coastguard Worker #include "modules/async_audio_processing/async_audio_processing.h"
16*d9f75844SAndroid Build Coastguard Worker #include "modules/audio_device/include/audio_device.h"
17*d9f75844SAndroid Build Coastguard Worker #include "modules/audio_processing/include/audio_processing.h"
18*d9f75844SAndroid Build Coastguard Worker #include "rtc_base/ref_count.h"
19*d9f75844SAndroid Build Coastguard Worker 
20*d9f75844SAndroid Build Coastguard Worker namespace webrtc {
21*d9f75844SAndroid Build Coastguard Worker 
22*d9f75844SAndroid Build Coastguard Worker class AudioTransport;
23*d9f75844SAndroid Build Coastguard Worker 
24*d9f75844SAndroid Build Coastguard Worker // AudioState holds the state which must be shared between multiple instances of
25*d9f75844SAndroid Build Coastguard Worker // webrtc::Call for audio processing purposes.
26*d9f75844SAndroid Build Coastguard Worker class AudioState : public rtc::RefCountInterface {
27*d9f75844SAndroid Build Coastguard Worker  public:
28*d9f75844SAndroid Build Coastguard Worker   struct Config {
29*d9f75844SAndroid Build Coastguard Worker     Config();
30*d9f75844SAndroid Build Coastguard Worker     ~Config();
31*d9f75844SAndroid Build Coastguard Worker 
32*d9f75844SAndroid Build Coastguard Worker     // The audio mixer connected to active receive streams. One per
33*d9f75844SAndroid Build Coastguard Worker     // AudioState.
34*d9f75844SAndroid Build Coastguard Worker     rtc::scoped_refptr<AudioMixer> audio_mixer;
35*d9f75844SAndroid Build Coastguard Worker 
36*d9f75844SAndroid Build Coastguard Worker     // The audio processing module.
37*d9f75844SAndroid Build Coastguard Worker     rtc::scoped_refptr<webrtc::AudioProcessing> audio_processing;
38*d9f75844SAndroid Build Coastguard Worker 
39*d9f75844SAndroid Build Coastguard Worker     // TODO(solenberg): Temporary: audio device module.
40*d9f75844SAndroid Build Coastguard Worker     rtc::scoped_refptr<webrtc::AudioDeviceModule> audio_device_module;
41*d9f75844SAndroid Build Coastguard Worker 
42*d9f75844SAndroid Build Coastguard Worker     rtc::scoped_refptr<AsyncAudioProcessing::Factory>
43*d9f75844SAndroid Build Coastguard Worker         async_audio_processing_factory;
44*d9f75844SAndroid Build Coastguard Worker   };
45*d9f75844SAndroid Build Coastguard Worker 
46*d9f75844SAndroid Build Coastguard Worker   virtual AudioProcessing* audio_processing() = 0;
47*d9f75844SAndroid Build Coastguard Worker   virtual AudioTransport* audio_transport() = 0;
48*d9f75844SAndroid Build Coastguard Worker 
49*d9f75844SAndroid Build Coastguard Worker   // Enable/disable playout of the audio channels. Enabled by default.
50*d9f75844SAndroid Build Coastguard Worker   // This will stop playout of the underlying audio device but start a task
51*d9f75844SAndroid Build Coastguard Worker   // which will poll for audio data every 10ms to ensure that audio processing
52*d9f75844SAndroid Build Coastguard Worker   // happens and the audio stats are updated.
53*d9f75844SAndroid Build Coastguard Worker   virtual void SetPlayout(bool enabled) = 0;
54*d9f75844SAndroid Build Coastguard Worker 
55*d9f75844SAndroid Build Coastguard Worker   // Enable/disable recording of the audio channels. Enabled by default.
56*d9f75844SAndroid Build Coastguard Worker   // This will stop recording of the underlying audio device and no audio
57*d9f75844SAndroid Build Coastguard Worker   // packets will be encoded or transmitted.
58*d9f75844SAndroid Build Coastguard Worker   virtual void SetRecording(bool enabled) = 0;
59*d9f75844SAndroid Build Coastguard Worker 
60*d9f75844SAndroid Build Coastguard Worker   virtual void SetStereoChannelSwapping(bool enable) = 0;
61*d9f75844SAndroid Build Coastguard Worker 
62*d9f75844SAndroid Build Coastguard Worker   static rtc::scoped_refptr<AudioState> Create(
63*d9f75844SAndroid Build Coastguard Worker       const AudioState::Config& config);
64*d9f75844SAndroid Build Coastguard Worker 
~AudioState()65*d9f75844SAndroid Build Coastguard Worker   ~AudioState() override {}
66*d9f75844SAndroid Build Coastguard Worker };
67*d9f75844SAndroid Build Coastguard Worker }  // namespace webrtc
68*d9f75844SAndroid Build Coastguard Worker 
69*d9f75844SAndroid Build Coastguard Worker #endif  // CALL_AUDIO_STATE_H_
70