#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "media/webrtc/audio_processor.h"
#include <stddef.h>
#include <stdint.h>
#include <optional>
#include <string>
#include <string_view>
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/memory/aligned_memory.h"
#include "base/path_service.h"
#include "base/strings/stringprintf.h"
#include "base/test/mock_callback.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/test/test_file_util.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "build/chromecast_buildflags.h"
#include "media/base/audio_bus.h"
#include "media/base/audio_parameters.h"
#include "media/base/audio_processing.h"
#include "media/webrtc/constants.h"
#include "media/webrtc/webrtc_features.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/webrtc/api/make_ref_counted.h"
#include "third_party/webrtc/modules/audio_processing/include/mock_audio_processing.h"
_;
AnyNumber;
AtLeast;
Return;
namespace media {
namespace {
static const int kSupportedSampleRates[] = …;
MockProcessedCaptureCallback;
AudioProcessor::LogCallback LogCallbackForTesting() { … }
const int kNumberOfPacketsForTest = …;
void ReadDataFromSpeechFile(char* data, int length) { … }
void DisableDefaultSettings(AudioProcessingSettings& settings) { … }
}
class AudioProcessorTest : public ::testing::Test { … };
struct AudioProcessorTestMultichannelAndFormat
: public AudioProcessorTest,
public ::testing::WithParamInterface<std::tuple<bool, bool>> { … };
INSTANTIATE_TEST_SUITE_P(…);
#if BUILDFLAG(IS_ANDROID) && defined(ADDRESS_SANITIZER)
#define MAYBE_WithAudioProcessing …
#else
#define MAYBE_WithAudioProcessing …
#endif
TEST_P(AudioProcessorTestMultichannelAndFormat, MAYBE_WithAudioProcessing) { … }
TEST_F(AudioProcessorTest, TurnOffDefaultConstraints) { … }
#if BUILDFLAG(IS_ANDROID) && defined(ADDRESS_SANITIZER)
#define MAYBE_TestAllSampleRates …
#else
#define MAYBE_TestAllSampleRates …
#endif
TEST_P(AudioProcessorTestMultichannelAndFormat, MAYBE_TestAllSampleRates) { … }
TEST_F(AudioProcessorTest, StartStopAecDump) { … }
TEST_F(AudioProcessorTest, StartAecDumpDuringOngoingAecDump) { … }
TEST_P(AudioProcessorTestMultichannelAndFormat, TestStereoAudio) { … }
struct AudioProcessorDefaultOutputFormatTest
: public ::testing::Test,
public ::testing::WithParamInterface<std::tuple<bool, int>> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(AudioProcessorDefaultOutputFormatTest, GetDefaultOutputFormat) { … }
TEST_F(AudioProcessorTest, DiscreteChannelLayout) { … }
class AudioProcessorPlayoutTest : public AudioProcessorTest { … };
TEST_F(AudioProcessorPlayoutTest, OnPlayoutData_ForwardsDataToWebrtcApm) { … }
TEST_F(AudioProcessorPlayoutTest, OnPlayoutData_BuffersPlayout) { … }
TEST_F(AudioProcessorPlayoutTest, OnPlayoutData_HandlesVariableInputSize) { … }
TEST_F(AudioProcessorPlayoutTest, OnPlayoutData_HandlesSampleRateChange) { … }
TEST(AudioProcessorCallbackTest,
ProcessedAudioIsDeliveredAsSoonAsPossibleWithShortBuffers) { … }
TEST(AudioProcessorCallbackTest,
ProcessedAudioIsDeliveredAsSoonAsPossibleWithLongBuffers) { … }
TEST(AudioProcessorCallbackTest,
UnprocessedAudioIsDeliveredImmediatelyWithShortBuffers) { … }
TEST(AudioProcessorCallbackTest,
UnprocessedAudioIsDeliveredImmediatelyWithLongBuffers) { … }
class ApmTellsIfPlayoutReferenceIsNeededParametrizedTest
: public ::testing::TestWithParam<bool> { … };
TEST_P(ApmTellsIfPlayoutReferenceIsNeededParametrizedTest,
DoesNotNeedPlayoutReference) { … }
#if BUILDFLAG(IS_IOS)
#define MAYBE_NeedsPlayoutReference …
#else
#define MAYBE_NeedsPlayoutReference …
#endif
TEST_P(ApmTellsIfPlayoutReferenceIsNeededParametrizedTest,
MAYBE_NeedsPlayoutReference) { … }
INSTANTIATE_TEST_SUITE_P(…);
}