• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2018 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 
11 #ifndef MODULES_AUDIO_DEVICE_WIN_AUDIO_DEVICE_MODULE_WIN_H_
12 #define MODULES_AUDIO_DEVICE_WIN_AUDIO_DEVICE_MODULE_WIN_H_
13 
14 #include <memory>
15 #include <string>
16 
17 #include "api/scoped_refptr.h"
18 #include "api/task_queue/task_queue_factory.h"
19 #include "modules/audio_device/include/audio_device.h"
20 
21 namespace webrtc {
22 
23 class AudioDeviceBuffer;
24 
25 namespace webrtc_win {
26 
27 // This interface represents the main input-related parts of the complete
28 // AudioDeviceModule interface.
29 class AudioInput {
30  public:
~AudioInput()31   virtual ~AudioInput() {}
32 
33   virtual int Init() = 0;
34   virtual int Terminate() = 0;
35   virtual int NumDevices() const = 0;
36   virtual int SetDevice(int index) = 0;
37   virtual int SetDevice(AudioDeviceModule::WindowsDeviceType device) = 0;
38   virtual int DeviceName(int index, std::string* name, std::string* guid) = 0;
39   virtual void AttachAudioBuffer(AudioDeviceBuffer* audio_buffer) = 0;
40   virtual bool RecordingIsInitialized() const = 0;
41   virtual int InitRecording() = 0;
42   virtual int StartRecording() = 0;
43   virtual int StopRecording() = 0;
44   virtual bool Recording() = 0;
45   virtual int VolumeIsAvailable(bool* available) = 0;
46   virtual int RestartRecording() = 0;
47   virtual bool Restarting() const = 0;
48   virtual int SetSampleRate(uint32_t sample_rate) = 0;
49 };
50 
51 // This interface represents the main output-related parts of the complete
52 // AudioDeviceModule interface.
53 class AudioOutput {
54  public:
~AudioOutput()55   virtual ~AudioOutput() {}
56 
57   virtual int Init() = 0;
58   virtual int Terminate() = 0;
59   virtual int NumDevices() const = 0;
60   virtual int SetDevice(int index) = 0;
61   virtual int SetDevice(AudioDeviceModule::WindowsDeviceType device) = 0;
62   virtual int DeviceName(int index, std::string* name, std::string* guid) = 0;
63   virtual void AttachAudioBuffer(AudioDeviceBuffer* audio_buffer) = 0;
64   virtual bool PlayoutIsInitialized() const = 0;
65   virtual int InitPlayout() = 0;
66   virtual int StartPlayout() = 0;
67   virtual int StopPlayout() = 0;
68   virtual bool Playing() = 0;
69   virtual int VolumeIsAvailable(bool* available) = 0;
70   virtual int RestartPlayout() = 0;
71   virtual bool Restarting() const = 0;
72   virtual int SetSampleRate(uint32_t sample_rate) = 0;
73 };
74 
75 // Combines an AudioInput and an AudioOutput implementation to build an
76 // AudioDeviceModule. Hides most parts of the full ADM interface.
77 rtc::scoped_refptr<AudioDeviceModuleForTest>
78 CreateWindowsCoreAudioAudioDeviceModuleFromInputAndOutput(
79     std::unique_ptr<AudioInput> audio_input,
80     std::unique_ptr<AudioOutput> audio_output,
81     TaskQueueFactory* task_queue_factory);
82 
83 }  // namespace webrtc_win
84 
85 }  // namespace webrtc
86 
87 #endif  // MODULES_AUDIO_DEVICE_WIN_AUDIO_DEVICE_MODULE_WIN_H_
88