2011-07-07 08:21:25 +00:00
|
|
|
/*
|
2012-03-05 16:07:51 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* 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
|
|
|
|
|
|
2012-09-21 20:46:40 +00:00
|
|
|
#include "modules/audio_device/audio_device_utility.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2011-10-25 08:24:20 +00:00
|
|
|
#include <string>
|
|
|
|
|
|
2011-07-07 08:21:25 +00:00
|
|
|
#include "typedefs.h"
|
|
|
|
|
#include "audio_device.h"
|
|
|
|
|
#include "audio_device_test_defines.h"
|
|
|
|
|
#include "file_wrapper.h"
|
|
|
|
|
#include "list_wrapper.h"
|
|
|
|
|
#include "resampler.h"
|
|
|
|
|
|
2012-09-11 17:25:46 +00:00
|
|
|
#if defined(WEBRTC_IOS) || defined(ANDROID)
|
2011-07-07 08:21:25 +00:00
|
|
|
#define USE_SLEEP_AS_PAUSE
|
|
|
|
|
#else
|
|
|
|
|
//#define USE_SLEEP_AS_PAUSE
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// Sets the default pause time if using sleep as pause
|
|
|
|
|
#define DEFAULT_PAUSE_TIME 5000
|
|
|
|
|
|
|
|
|
|
#if defined(USE_SLEEP_AS_PAUSE)
|
2012-08-27 08:33:33 +00:00
|
|
|
#define PAUSE(a) SleepMs(a);
|
2011-07-07 08:21:25 +00:00
|
|
|
#else
|
|
|
|
|
#define PAUSE(a) AudioDeviceUtility::WaitForKey();
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#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,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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:
|
2013-04-09 10:30:35 +00:00
|
|
|
virtual int32_t
|
2012-03-09 08:59:19 +00:00
|
|
|
RecordedDataIsAvailable(const void* audioSamples,
|
2013-04-09 10:30:35 +00:00
|
|
|
const uint32_t nSamples,
|
|
|
|
|
const uint8_t nBytesPerSample,
|
|
|
|
|
const uint8_t nChannels,
|
|
|
|
|
const uint32_t samplesPerSec,
|
|
|
|
|
const uint32_t totalDelayMS,
|
|
|
|
|
const int32_t clockDrift,
|
|
|
|
|
const uint32_t currentMicLevel,
|
2013-05-07 21:04:24 +00:00
|
|
|
const bool keyPressed,
|
2013-04-09 10:30:35 +00:00
|
|
|
uint32_t& newMicLevel);
|
|
|
|
|
|
|
|
|
|
virtual int32_t NeedMorePlayData(const uint32_t nSamples,
|
|
|
|
|
const uint8_t nBytesPerSample,
|
|
|
|
|
const uint8_t nChannels,
|
|
|
|
|
const uint32_t samplesPerSec,
|
|
|
|
|
void* audioSamples,
|
|
|
|
|
uint32_t& nSamplesOut);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
AudioTransportImpl(AudioDeviceModule* audioDevice);
|
|
|
|
|
~AudioTransportImpl();
|
|
|
|
|
|
|
|
|
|
public:
|
2013-04-09 10:30:35 +00:00
|
|
|
int32_t SetFilePlayout(bool enable, const char* fileName = NULL);
|
2011-07-07 08:21:25 +00:00
|
|
|
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:
|
|
|
|
|
AudioDeviceModule* _audioDevice;
|
|
|
|
|
|
|
|
|
|
bool _playFromFile;
|
|
|
|
|
bool _fullDuplex;
|
|
|
|
|
bool _speakerVolume;
|
|
|
|
|
bool _speakerMute;
|
|
|
|
|
bool _microphoneVolume;
|
|
|
|
|
bool _microphoneMute;
|
|
|
|
|
bool _microphoneBoost;
|
|
|
|
|
bool _microphoneAGC;
|
|
|
|
|
bool _loopBackMeasurements;
|
|
|
|
|
|
|
|
|
|
FileWrapper& _playFile;
|
|
|
|
|
|
2013-04-09 10:30:35 +00:00
|
|
|
uint32_t _recCount;
|
|
|
|
|
uint32_t _playCount;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
ListWrapper _audioList;
|
|
|
|
|
|
|
|
|
|
Resampler _resampler;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
// FuncTestManager
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
class FuncTestManager
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
FuncTestManager();
|
|
|
|
|
~FuncTestManager();
|
2013-04-09 10:30:35 +00:00
|
|
|
int32_t Init();
|
|
|
|
|
int32_t Close();
|
|
|
|
|
int32_t DoTest(const TestType testType);
|
2011-07-07 08:21:25 +00:00
|
|
|
private:
|
2013-04-09 10:30:35 +00:00
|
|
|
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();
|
2011-07-07 08:21:25 +00:00
|
|
|
private:
|
2011-10-25 08:24:20 +00:00
|
|
|
// 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;
|
|
|
|
|
|
2011-07-07 08:21:25 +00:00
|
|
|
ProcessThread* _processThread;
|
|
|
|
|
AudioDeviceModule* _audioDevice;
|
|
|
|
|
AudioEventObserver* _audioEventObserver;
|
|
|
|
|
AudioTransportImpl* _audioTransport;
|
|
|
|
|
};
|
|
|
|
|
|
2013-07-03 15:12:26 +00:00
|
|
|
} // namespace webrtc
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
#endif // #ifndef WEBRTC_AUDIO_DEVICE_FUNC_TEST_MANAGER_H
|