blob: ad411d1faad90bf19f0bb8e49347881ab847fc5a [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"
14#include "rtc_base/refcount.h"
15#include "rtc_base/scoped_ref_ptr.h"
solenberg566ef242015-11-06 15:34:49 -080016
17namespace webrtc {
18
peaha9cc40b2017-06-29 08:32:09 -070019class AudioProcessing;
solenberg566ef242015-11-06 15:34:49 -080020class VoiceEngine;
21
Fredrik Solenberga4527c82015-12-03 13:06:20 +010022// WORK IN PROGRESS
23// This class is under development and is not yet intended for for use outside
24// of WebRtc/Libjingle. Please use the VoiceEngine API instead.
25// See: https://bugs.chromium.org/p/webrtc/issues/detail?id=4690
26
solenberg566ef242015-11-06 15:34:49 -080027// AudioState holds the state which must be shared between multiple instances of
28// webrtc::Call for audio processing purposes.
29class AudioState : public rtc::RefCountInterface {
30 public:
31 struct Config {
32 // VoiceEngine used for audio streams and audio/video synchronization.
33 // AudioState will tickle the VoE refcount to keep it alive for as long as
34 // the AudioState itself.
35 VoiceEngine* voice_engine = nullptr;
36
aleloi81da4882016-11-08 04:26:30 -080037 // The audio mixer connected to active receive streams. One per
38 // AudioState.
39 rtc::scoped_refptr<AudioMixer> audio_mixer;
peaha9cc40b2017-06-29 08:32:09 -070040
41 // The audio processing module.
42 rtc::scoped_refptr<webrtc::AudioProcessing> audio_processing;
solenberg566ef242015-11-06 15:34:49 -080043 };
44
peaha9cc40b2017-06-29 08:32:09 -070045 virtual AudioProcessing* audio_processing() = 0;
46
henrika5f6bf242017-11-01 11:06:56 +010047 // Enable/disable playout of the audio channels. Enabled by default.
48 // This will stop playout of the underlying audio device but start a task
49 // which will poll for audio data every 10ms to ensure that audio processing
50 // happens and the audio stats are updated.
51 virtual void SetPlayout(bool enabled) = 0;
52
53 // Enable/disable recording of the audio channels. Enabled by default.
54 // This will stop recording of the underlying audio device and no audio
55 // packets will be encoded or transmitted.
56 virtual void SetRecording(bool enabled) = 0;
57
solenberg566ef242015-11-06 15:34:49 -080058 // TODO(solenberg): Replace scoped_refptr with shared_ptr once we can use it.
59 static rtc::scoped_refptr<AudioState> Create(
60 const AudioState::Config& config);
61
62 virtual ~AudioState() {}
63};
64} // namespace webrtc
65
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020066#endif // CALL_AUDIO_STATE_H_