#include "third_party/blink/renderer/modules/webcodecs/audio_decoder_broker.h"
#include <memory>
#include <vector>
#include "base/files/file_util.h"
#include "base/run_loop.h"
#include "build/build_config.h"
#include "media/base/audio_codecs.h"
#include "media/base/channel_layout.h"
#include "media/base/decoder_buffer.h"
#include "media/base/decoder_status.h"
#include "media/base/media_util.h"
#include "media/base/mock_filters.h"
#include "media/base/sample_format.h"
#include "media/base/test_data_util.h"
#include "media/base/test_helpers.h"
#include "media/mojo/buildflags.h"
#include "media/mojo/mojom/audio_decoder.mojom.h"
#include "media/mojo/mojom/interface_factory.mojom.h"
#include "media/mojo/services/interface_factory_impl.h"
#include "media/mojo/services/mojo_audio_decoder_service.h"
#include "media/mojo/services/mojo_cdm_service_context.h"
#include "media/mojo/services/mojo_media_client.h"
#include "mojo/public/cpp/bindings/unique_receiver_set.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/thread_safe_browser_interface_broker_proxy.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_testing.h"
#include "third_party/blink/renderer/platform/testing/task_environment.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
_;
Return;
namespace blink {
namespace {
constexpr media::AudioCodec kCodec = …;
constexpr media::SampleFormat kSampleFormat = …;
constexpr media::ChannelLayout kChannelLayout = …;
constexpr int kChannels = …;
constexpr int kSamplesPerSecond = …;
constexpr int kInputFramesChunk = …;
class FakeAudioDecoder : public media::MockAudioDecoder { … };
class FakeMojoMediaClient : public media::MojoMediaClient { … };
class FakeInterfaceFactory : public media::mojom::InterfaceFactory { … };
}
class AudioDecoderBrokerTest : public testing::Test { … };
TEST_F(AudioDecoderBrokerTest, Decode_Uninitialized) { … }
media::AudioDecoderConfig MakeVorbisConfig() { … }
TEST_F(AudioDecoderBrokerTest, Decode_NoMojoDecoder) { … }
#if BUILDFLAG(ENABLE_MOJO_AUDIO_DECODER)
TEST_F(AudioDecoderBrokerTest, Decode_WithMojoDecoder) {
V8TestingScope v8_scope;
ExecutionContext* execution_context = v8_scope.GetExecutionContext();
SetupMojo(*execution_context);
ConstructDecoder(*execution_context);
EXPECT_EQ(GetDecoderType(), media::AudioDecoderType::kBroker);
EXPECT_FALSE(IsPlatformDecoder());
EXPECT_FALSE(SupportsDecryption());
InitializeDecoder(media::AudioDecoderConfig(
media::AudioCodec::kMpegHAudio, kSampleFormat, kChannelLayout,
kSamplesPerSecond, media::EmptyExtraData(),
media::EncryptionScheme::kUnencrypted));
EXPECT_EQ(GetDecoderType(), media::AudioDecoderType::kTesting);
DecodeBuffer(media::ReadTestDataFile("vorbis-packet-0"));
DecodeBuffer(media::DecoderBuffer::CreateEOSBuffer());
ASSERT_EQ(1U, output_buffers_.size());
EXPECT_TRUE(IsPlatformDecoder());
EXPECT_FALSE(SupportsDecryption());
ResetDecoder();
}
#endif
}