xref: /aosp_15_r20/external/webrtc/call/audio_state.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
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  */
10 #ifndef CALL_AUDIO_STATE_H_
11 #define CALL_AUDIO_STATE_H_
12 
13 #include "api/audio/audio_mixer.h"
14 #include "api/scoped_refptr.h"
15 #include "modules/async_audio_processing/async_audio_processing.h"
16 #include "modules/audio_device/include/audio_device.h"
17 #include "modules/audio_processing/include/audio_processing.h"
18 #include "rtc_base/ref_count.h"
19 
20 namespace webrtc {
21 
22 class AudioTransport;
23 
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 {
29     Config();
30     ~Config();
31 
32     // The audio mixer connected to active receive streams. One per
33     // AudioState.
34     rtc::scoped_refptr<AudioMixer> audio_mixer;
35 
36     // The audio processing module.
37     rtc::scoped_refptr<webrtc::AudioProcessing> audio_processing;
38 
39     // TODO(solenberg): Temporary: audio device module.
40     rtc::scoped_refptr<webrtc::AudioDeviceModule> audio_device_module;
41 
42     rtc::scoped_refptr<AsyncAudioProcessing::Factory>
43         async_audio_processing_factory;
44   };
45 
46   virtual AudioProcessing* audio_processing() = 0;
47   virtual AudioTransport* audio_transport() = 0;
48 
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 
60   virtual void SetStereoChannelSwapping(bool enable) = 0;
61 
62   static rtc::scoped_refptr<AudioState> Create(
63       const AudioState::Config& config);
64 
~AudioState()65   ~AudioState() override {}
66 };
67 }  // namespace webrtc
68 
69 #endif  // CALL_AUDIO_STATE_H_
70