webrtc_m130/modules/audio_device/win/audio_device_module_win.h
henrika ec9c745228 Adds support for new Windows ADM with limited API support.
Summary of what this CL does:

Existing users can keep using the old ADM for Windows as before.

A new ADM for Windows is created and a dedicated factory method is used
to create it. The old way (using AudioDeviceImpl) is not utilized.

The new ADM is based on a structure where most of the "action" takes
place in new AudioInput/AudioOutput implementations. This is inline
with our mobile platforms and also makes it easier to break out common
parts into a base class.

The AudioDevice unittest has always mainly focused on the "Start/Stop"-
parts of the ADM and not the complete ADM interface. This new ADM supports
all tests in AudioDeviceTest and is therefore tested in combination with
the old version. A value-parametrized test us added for Windows builds.

Improved readability, threading model and makes the code easier to maintain.

Uses the previously landed methods in webrtc::webrtc_win::core_audio_utility.

Bug: webrtc:9265
Change-Id: If2894b44528e74a181cf7ad1216f57386ee3a24d
Reviewed-on: https://webrtc-review.googlesource.com/78060
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Commit-Queue: Henrik Andreassson <henrika@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23554}
2018-06-08 14:44:38 +00:00

80 lines
2.6 KiB
C++

/*
* Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef MODULES_AUDIO_DEVICE_WIN_AUDIO_DEVICE_MODULE_WIN_H_
#define MODULES_AUDIO_DEVICE_WIN_AUDIO_DEVICE_MODULE_WIN_H_
#include <memory>
#include <string>
#include "modules/audio_device/include/audio_device.h"
#include "rtc_base/scoped_ref_ptr.h"
namespace webrtc {
class AudioDeviceBuffer;
namespace webrtc_win {
// This interface represents the main input-related parts of the complete
// AudioDeviceModule interface.
class AudioInput {
public:
virtual ~AudioInput() {}
virtual int Init() = 0;
virtual int Terminate() = 0;
virtual int NumDevices() const = 0;
virtual int SetDevice(int index) = 0;
virtual int SetDevice(AudioDeviceModule::WindowsDeviceType device) = 0;
virtual int DeviceName(int index, std::string* name, std::string* guid) = 0;
virtual void AttachAudioBuffer(AudioDeviceBuffer* audio_buffer) = 0;
virtual bool RecordingIsInitialized() const = 0;
virtual int InitRecording() = 0;
virtual int StartRecording() = 0;
virtual int StopRecording() = 0;
virtual bool Recording() = 0;
virtual int VolumeIsAvailable(bool* available) = 0;
};
// This interface represents the main output-related parts of the complete
// AudioDeviceModule interface.
class AudioOutput {
public:
virtual ~AudioOutput() {}
virtual int Init() = 0;
virtual int Terminate() = 0;
virtual int NumDevices() const = 0;
virtual int SetDevice(int index) = 0;
virtual int SetDevice(AudioDeviceModule::WindowsDeviceType device) = 0;
virtual int DeviceName(int index, std::string* name, std::string* guid) = 0;
virtual void AttachAudioBuffer(AudioDeviceBuffer* audio_buffer) = 0;
virtual bool PlayoutIsInitialized() const = 0;
virtual int InitPlayout() = 0;
virtual int StartPlayout() = 0;
virtual int StopPlayout() = 0;
virtual bool Playing() = 0;
virtual int VolumeIsAvailable(bool* available) = 0;
};
// Combines an AudioInput and an AudioOutput implementation to build an
// AudioDeviceModule. Hides most parts of the full ADM interface.
rtc::scoped_refptr<AudioDeviceModule>
CreateWindowsCoreAudioAudioDeviceModuleFromInputAndOutput(
std::unique_ptr<AudioInput> audio_input,
std::unique_ptr<AudioOutput> audio_output);
} // namespace webrtc_win
} // namespace webrtc
#endif // MODULES_AUDIO_DEVICE_WIN_AUDIO_DEVICE_MODULE_WIN_H_