219 lines
6.0 KiB
C
Raw Normal View History

/*
* Copyright (c) 2012 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 WEBRTC_AUDIO_DEVICE_FUNC_TEST_MANAGER_H
#define WEBRTC_AUDIO_DEVICE_FUNC_TEST_MANAGER_H
#include <list>
#include <memory>
#include <string>
#include "webrtc/common_audio/resampler/include/resampler.h"
#include "webrtc/modules/audio_device/include/audio_device.h"
#include "webrtc/modules/audio_device/test/audio_device_test_defines.h"
#include "webrtc/system_wrappers/include/file_wrapper.h"
#include "webrtc/typedefs.h"
#define ADM_AUDIO_LAYER AudioDeviceModule::kPlatformDefaultAudio
//#define ADM_AUDIO_LAYER AudioDeviceModule::kLinuxPulseAudio
enum TestType
{
TTInvalid = -1,
TTAll = 0,
TTAudioLayerSelection = 1,
TTDeviceEnumeration = 2,
TTDeviceSelection = 3,
TTAudioTransport = 4,
TTSpeakerVolume = 5,
TTMicrophoneVolume = 6,
TTSpeakerMute = 7,
TTMicrophoneMute = 8,
TTMicrophoneBoost = 9,
TTMicrophoneAGC = 10,
TTLoopback = 11,
TTDeviceRemoval = 13,
TTMobileAPI = 14,
TTTest = 66,
};
struct AudioPacket
{
uint8_t dataBuffer[4 * 960];
Update a ton of audio code to use size_t more correctly and in general reduce use of int16_t/uint16_t. This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects. This was be reviewed and approved in pieces: https://codereview.webrtc.org/1224093003 https://codereview.webrtc.org/1224123002 https://codereview.webrtc.org/1224163002 https://codereview.webrtc.org/1225133003 https://codereview.webrtc.org/1225173002 https://codereview.webrtc.org/1227163003 https://codereview.webrtc.org/1227203003 https://codereview.webrtc.org/1227213002 https://codereview.webrtc.org/1227893002 https://codereview.webrtc.org/1228793004 https://codereview.webrtc.org/1228803003 https://codereview.webrtc.org/1228823002 https://codereview.webrtc.org/1228823003 https://codereview.webrtc.org/1228843002 https://codereview.webrtc.org/1230693002 https://codereview.webrtc.org/1231713002 The change is being landed as TBR to all the folks who reviewed the above. BUG=chromium:81439 TEST=none R=andrew@webrtc.org, pbos@webrtc.org TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher Review URL: https://codereview.webrtc.org/1230503003 . Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
size_t nSamples;
size_t nBytesPerSample;
size_t nChannels;
uint32_t samplesPerSec;
};
class ProcessThread;
namespace webrtc
{
class AudioDeviceModule;
class AudioEventObserver;
class AudioTransport;
// ----------------------------------------------------------------------------
// AudioEventObserver
// ----------------------------------------------------------------------------
class AudioEventObserver: public AudioDeviceObserver
{
public:
virtual void OnErrorIsReported(const ErrorCode error);
virtual void OnWarningIsReported(const WarningCode warning);
AudioEventObserver(AudioDeviceModule* audioDevice);
~AudioEventObserver();
public:
ErrorCode _error;
WarningCode _warning;
};
// ----------------------------------------------------------------------------
// AudioTransport
// ----------------------------------------------------------------------------
class AudioTransportImpl: public AudioTransport
{
public:
int32_t RecordedDataIsAvailable(const void* audioSamples,
Update a ton of audio code to use size_t more correctly and in general reduce use of int16_t/uint16_t. This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects. This was be reviewed and approved in pieces: https://codereview.webrtc.org/1224093003 https://codereview.webrtc.org/1224123002 https://codereview.webrtc.org/1224163002 https://codereview.webrtc.org/1225133003 https://codereview.webrtc.org/1225173002 https://codereview.webrtc.org/1227163003 https://codereview.webrtc.org/1227203003 https://codereview.webrtc.org/1227213002 https://codereview.webrtc.org/1227893002 https://codereview.webrtc.org/1228793004 https://codereview.webrtc.org/1228803003 https://codereview.webrtc.org/1228823002 https://codereview.webrtc.org/1228823003 https://codereview.webrtc.org/1228843002 https://codereview.webrtc.org/1230693002 https://codereview.webrtc.org/1231713002 The change is being landed as TBR to all the folks who reviewed the above. BUG=chromium:81439 TEST=none R=andrew@webrtc.org, pbos@webrtc.org TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher Review URL: https://codereview.webrtc.org/1230503003 . Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
const size_t nSamples,
const size_t nBytesPerSample,
const size_t nChannels,
const uint32_t samplesPerSec,
const uint32_t totalDelayMS,
const int32_t clockDrift,
const uint32_t currentMicLevel,
const bool keyPressed,
uint32_t& newMicLevel) override;
Update a ton of audio code to use size_t more correctly and in general reduce use of int16_t/uint16_t. This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects. This was be reviewed and approved in pieces: https://codereview.webrtc.org/1224093003 https://codereview.webrtc.org/1224123002 https://codereview.webrtc.org/1224163002 https://codereview.webrtc.org/1225133003 https://codereview.webrtc.org/1225173002 https://codereview.webrtc.org/1227163003 https://codereview.webrtc.org/1227203003 https://codereview.webrtc.org/1227213002 https://codereview.webrtc.org/1227893002 https://codereview.webrtc.org/1228793004 https://codereview.webrtc.org/1228803003 https://codereview.webrtc.org/1228823002 https://codereview.webrtc.org/1228823003 https://codereview.webrtc.org/1228843002 https://codereview.webrtc.org/1230693002 https://codereview.webrtc.org/1231713002 The change is being landed as TBR to all the folks who reviewed the above. BUG=chromium:81439 TEST=none R=andrew@webrtc.org, pbos@webrtc.org TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher Review URL: https://codereview.webrtc.org/1230503003 . Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
int32_t NeedMorePlayData(const size_t nSamples,
const size_t nBytesPerSample,
const size_t nChannels,
const uint32_t samplesPerSec,
void* audioSamples,
Update a ton of audio code to use size_t more correctly and in general reduce use of int16_t/uint16_t. This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects. This was be reviewed and approved in pieces: https://codereview.webrtc.org/1224093003 https://codereview.webrtc.org/1224123002 https://codereview.webrtc.org/1224163002 https://codereview.webrtc.org/1225133003 https://codereview.webrtc.org/1225173002 https://codereview.webrtc.org/1227163003 https://codereview.webrtc.org/1227203003 https://codereview.webrtc.org/1227213002 https://codereview.webrtc.org/1227893002 https://codereview.webrtc.org/1228793004 https://codereview.webrtc.org/1228803003 https://codereview.webrtc.org/1228823002 https://codereview.webrtc.org/1228823003 https://codereview.webrtc.org/1228843002 https://codereview.webrtc.org/1230693002 https://codereview.webrtc.org/1231713002 The change is being landed as TBR to all the folks who reviewed the above. BUG=chromium:81439 TEST=none R=andrew@webrtc.org, pbos@webrtc.org TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher Review URL: https://codereview.webrtc.org/1230503003 . Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
size_t& nSamplesOut,
int64_t* elapsed_time_ms,
int64_t* ntp_time_ms) override;
AudioTransportImpl(AudioDeviceModule* audioDevice);
~AudioTransportImpl();
public:
int32_t SetFilePlayout(bool enable, const char* fileName = NULL);
void SetFullDuplex(bool enable);
void SetSpeakerVolume(bool enable)
{
_speakerVolume = enable;
}
;
void SetSpeakerMute(bool enable)
{
_speakerMute = enable;
}
;
void SetMicrophoneMute(bool enable)
{
_microphoneMute = enable;
}
;
void SetMicrophoneVolume(bool enable)
{
_microphoneVolume = enable;
}
;
void SetMicrophoneBoost(bool enable)
{
_microphoneBoost = enable;
}
;
void SetLoopbackMeasurements(bool enable)
{
_loopBackMeasurements = enable;
}
;
void SetMicrophoneAGC(bool enable)
{
_microphoneAGC = enable;
}
;
private:
typedef std::list<AudioPacket*> AudioPacketList;
AudioDeviceModule* _audioDevice;
bool _playFromFile;
bool _fullDuplex;
bool _speakerVolume;
bool _speakerMute;
bool _microphoneVolume;
bool _microphoneMute;
bool _microphoneBoost;
bool _microphoneAGC;
bool _loopBackMeasurements;
FileWrapper& _playFile;
uint32_t _recCount;
uint32_t _playCount;
AudioPacketList _audioList;
Resampler _resampler;
};
// ----------------------------------------------------------------------------
// FuncTestManager
// ----------------------------------------------------------------------------
class FuncTestManager
{
public:
FuncTestManager();
~FuncTestManager();
int32_t Init();
int32_t Close();
int32_t DoTest(const TestType testType);
private:
int32_t TestAudioLayerSelection();
int32_t TestDeviceEnumeration();
int32_t TestDeviceSelection();
int32_t TestAudioTransport();
int32_t TestSpeakerVolume();
int32_t TestMicrophoneVolume();
int32_t TestSpeakerMute();
int32_t TestMicrophoneMute();
int32_t TestMicrophoneBoost();
int32_t TestLoopback();
int32_t TestDeviceRemoval();
int32_t TestExtra();
int32_t TestMicrophoneAGC();
int32_t SelectPlayoutDevice();
int32_t SelectRecordingDevice();
int32_t TestAdvancedMBAPI();
private:
// Paths to where the resource files to be used for this test are located.
std::string _playoutFile48;
std::string _playoutFile44;
std::string _playoutFile16;
std::string _playoutFile8;
std::unique_ptr<ProcessThread> _processThread;
AudioDeviceModule* _audioDevice;
AudioEventObserver* _audioEventObserver;
AudioTransportImpl* _audioTransport;
};
} // namespace webrtc
#endif // #ifndef WEBRTC_AUDIO_DEVICE_FUNC_TEST_MANAGER_H