audio_state.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. #include "api/audio/audio_mixer.h"
  13. #include "api/scoped_refptr.h"
  14. #include "modules/audio_device/include/audio_device.h"
  15. #include "modules/audio_processing/include/audio_processing.h"
  16. #include "rtc_base/ref_count.h"
  17. namespace webrtc {
  18. class AudioTransport;
  19. // AudioState holds the state which must be shared between multiple instances of
  20. // webrtc::Call for audio processing purposes.
  21. class AudioState : public rtc::RefCountInterface {
  22. public:
  23. struct Config {
  24. Config();
  25. ~Config();
  26. // The audio mixer connected to active receive streams. One per
  27. // AudioState.
  28. rtc::scoped_refptr<AudioMixer> audio_mixer;
  29. // The audio processing module.
  30. rtc::scoped_refptr<webrtc::AudioProcessing> audio_processing;
  31. // TODO(solenberg): Temporary: audio device module.
  32. rtc::scoped_refptr<webrtc::AudioDeviceModule> audio_device_module;
  33. };
  34. virtual AudioProcessing* audio_processing() = 0;
  35. virtual AudioTransport* audio_transport() = 0;
  36. // Enable/disable playout of the audio channels. Enabled by default.
  37. // This will stop playout of the underlying audio device but start a task
  38. // which will poll for audio data every 10ms to ensure that audio processing
  39. // happens and the audio stats are updated.
  40. virtual void SetPlayout(bool enabled) = 0;
  41. // Enable/disable recording of the audio channels. Enabled by default.
  42. // This will stop recording of the underlying audio device and no audio
  43. // packets will be encoded or transmitted.
  44. virtual void SetRecording(bool enabled) = 0;
  45. virtual void SetStereoChannelSwapping(bool enable) = 0;
  46. static rtc::scoped_refptr<AudioState> Create(
  47. const AudioState::Config& config);
  48. ~AudioState() override {}
  49. };
  50. } // namespace webrtc
  51. #endif // CALL_AUDIO_STATE_H_