#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/modules/mediastream/media_stream_audio_processor.h"
#include <stddef.h>
#include <stdint.h>
#include <optional>
#include <string>
#include <vector>
#include "base/containers/heap_array.h"
#include "base/containers/span.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/memory/aligned_memory.h"
#include "base/numerics/safe_conversions.h"
#include "base/path_service.h"
#include "base/test/mock_callback.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/webrtc/constants.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/platform/modules/webrtc/webrtc_logging.h"
#include "third_party/blink/renderer/modules/webrtc/webrtc_audio_device_impl.h"
#include "third_party/blink/renderer/platform/mediastream/media_stream_audio_processor_options.h"
#include "third_party/blink/renderer/platform/testing/task_environment.h"
#include "third_party/webrtc/api/media_stream_interface.h"
#include "third_party/webrtc/rtc_base/ref_counted_object.h"
_;
AnyNumber;
AtLeast;
Return;
AudioParameters;
AnalogGainController;
namespace blink {
namespace {
MockProcessedCaptureCallback;
const int kNumberOfPacketsForTest = …;
void ReadDataFromSpeechFile(base::HeapArray<int16_t>& data) { … }
}
class MediaStreamAudioProcessorTest : public ::testing::Test { … };
class MediaStreamAudioProcessorTestMultichannel
: public MediaStreamAudioProcessorTest,
public ::testing::WithParamInterface<bool> { … };
#if BUILDFLAG(IS_ANDROID) && defined(ADDRESS_SANITIZER)
#define MAYBE_WithAudioProcessing …
#else
#define MAYBE_WithAudioProcessing …
#endif
TEST_P(MediaStreamAudioProcessorTestMultichannel, MAYBE_WithAudioProcessing) { … }
TEST_F(MediaStreamAudioProcessorTest, TurnOffDefaultConstraints) { … }
#if BUILDFLAG(IS_ANDROID) && defined(ADDRESS_SANITIZER)
#define MAYBE_TestAllSampleRates …
#else
#define MAYBE_TestAllSampleRates …
#endif
TEST_P(MediaStreamAudioProcessorTestMultichannel, MAYBE_TestAllSampleRates) { … }
TEST_F(MediaStreamAudioProcessorTest, StartStopAecDump) { … }
TEST_P(MediaStreamAudioProcessorTestMultichannel, TestStereoAudio) { … }
TEST_F(MediaStreamAudioProcessorTest, DiscreteChannelLayout) { … }
INSTANTIATE_TEST_SUITE_P(…);
TEST(MediaStreamAudioProcessorCallbackTest,
ProcessedAudioIsDeliveredAsSoonAsPossibleWithShortBuffers) { … }
TEST(MediaStreamAudioProcessorCallbackTest,
ProcessedAudioIsDeliveredAsSoonAsPossibleWithLongBuffers) { … }
TEST(MediaStreamAudioProcessorCallbackTest,
UnprocessedAudioIsDeliveredImmediatelyWithShortBuffers) { … }
TEST(MediaStreamAudioProcessorCallbackTest,
UnprocessedAudioIsDeliveredImmediatelyWithLongBuffers) { … }
namespace {
scoped_refptr<MediaStreamAudioProcessor> CreateAudioProcessorWithProperties(
AudioProcessingProperties properties) { … }
}
TEST(MediaStreamAudioProcessorWouldModifyAudioTest, TrueByDefault) { … }
TEST(MediaStreamAudioProcessorWouldModifyAudioTest,
FalseWhenEverythingIsDisabled) { … }
TEST(MediaStreamAudioProcessorWouldModifyAudioTest,
FalseWhenOnlyHardwareEffectsAreUsed) { … }
#if BUILDFLAG(IS_IOS)
#define MAYBE_TrueWhenSoftwareEchoCancellationIsEnabled …
#else
#define MAYBE_TrueWhenSoftwareEchoCancellationIsEnabled …
#endif
TEST(MediaStreamAudioProcessorWouldModifyAudioTest,
MAYBE_TrueWhenSoftwareEchoCancellationIsEnabled) { … }
#if BUILDFLAG(IS_IOS)
#define MAYBE_TrueWhenStereoMirroringIsEnabled …
#else
#define MAYBE_TrueWhenStereoMirroringIsEnabled …
#endif
TEST(MediaStreamAudioProcessorWouldModifyAudioTest,
MAYBE_TrueWhenStereoMirroringIsEnabled) { … }
#if BUILDFLAG(IS_IOS)
#define MAYBE_TrueWhenGainControlIsEnabled …
#else
#define MAYBE_TrueWhenGainControlIsEnabled …
#endif
TEST(MediaStreamAudioProcessorWouldModifyAudioTest,
MAYBE_TrueWhenGainControlIsEnabled) { … }
#if BUILDFLAG(IS_IOS)
#define MAYBE_TrueWhenExperimentalEchoCancellationIsEnabled …
#else
#define MAYBE_TrueWhenExperimentalEchoCancellationIsEnabled …
#endif
TEST(MediaStreamAudioProcessorWouldModifyAudioTest,
MAYBE_TrueWhenExperimentalEchoCancellationIsEnabled) { … }
TEST(MediaStreamAudioProcessorWouldModifyAudioTest,
TrueWhenNoiseSuppressionIsEnabled) { … }
TEST(MediaStreamAudioProcessorWouldModifyAudioTest,
TrueWhenExperimentalNoiseSuppression) { … }
TEST(MediaStreamAudioProcessorWouldModifyAudioTest,
TrueWhenHighpassFilterIsEnabled) { … }
}