#include <memory>
#include <utility>
#include <vector>
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/test/gmock_callback_support.h"
#include "base/test/mock_callback.h"
#include "base/test/task_environment.h"
#include "build/build_config.h"
#include "media/base/fake_demuxer_stream.h"
#include "media/base/mock_filters.h"
#include "media/base/mock_media_log.h"
#include "media/base/test_helpers.h"
#include "media/base/timestamp_constants.h"
#include "media/filters/decoder_stream.h"
#include "media/filters/fake_video_decoder.h"
#include "testing/gtest/include/gtest/gtest.h"
#if !BUILDFLAG(IS_ANDROID)
#include "media/filters/decrypting_video_decoder.h"
#endif
#include <iostream>
RunCallback;
RunOnceCallback;
_;
AnyNumber;
Assign;
HasSubstr;
InSequence;
Invoke;
InvokeWithoutArgs;
NiceMock;
Return;
SaveArg;
StrictMock;
namespace media {
namespace {
const int kNumConfigs = …;
const int kNumBuffersInOneConfig = …;
constexpr base::TimeDelta kPrepareDelay = …;
static int GetDecoderId(int i) { … }
DecoderPriority MockDecoderPriority(const VideoDecoderConfig& config,
const VideoDecoder& decoder) { … }
}
struct VideoDecoderStreamTestParams { … };
class VideoDecoderStreamTest
: public testing::Test,
public testing::WithParamInterface<VideoDecoderStreamTestParams> { … };
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(VideoDecoderStreamTest, CanReadWithoutStallingAtAnyTime) { … }
TEST_P(VideoDecoderStreamTest, Initialization) { … }
TEST_P(VideoDecoderStreamTest, AllDecoderInitializationFails) { … }
TEST_P(VideoDecoderStreamTest, PartialDecoderInitializationFails) { … }
TEST_P(VideoDecoderStreamTest, ReadOneFrame) { … }
TEST_P(VideoDecoderStreamTest, ReadAllFrames) { … }
TEST_P(VideoDecoderStreamTest, Read_AfterReset) { … }
TEST_P(VideoDecoderStreamTest, ConfigChangeSwToHw) { … }
TEST_P(VideoDecoderStreamTest, ConfigChangeHwToSw) { … }
TEST_P(VideoDecoderStreamTest, Read_ProperMetadata) { … }
TEST_P(VideoDecoderStreamTest, Read_BlockedDemuxer) { … }
TEST_P(VideoDecoderStreamTest, Read_BlockedDemuxerAndDecoder) { … }
TEST_P(VideoDecoderStreamTest, Read_DuringEndOfStreamDecode) { … }
TEST_P(VideoDecoderStreamTest, Read_DemuxerStreamReadError) { … }
TEST_P(VideoDecoderStreamTest, Reset_AfterInitialization) { … }
TEST_P(VideoDecoderStreamTest, Reset_DuringReinitialization) { … }
TEST_P(VideoDecoderStreamTest, Reset_AfterReinitialization) { … }
TEST_P(VideoDecoderStreamTest, Reset_DuringDemuxerRead_Normal) { … }
TEST_P(VideoDecoderStreamTest, Reset_DuringDemuxerRead_ConfigChange) { … }
TEST_P(VideoDecoderStreamTest, Reset_DuringNormalDecoderDecode) { … }
TEST_P(VideoDecoderStreamTest, Reset_AfterNormalRead) { … }
TEST_P(VideoDecoderStreamTest, Reset_AfterDemuxerRead_ConfigChange) { … }
TEST_P(VideoDecoderStreamTest, Reset_AfterEndOfStream) { … }
TEST_P(VideoDecoderStreamTest, Reset_DuringNoKeyRead) { … }
TEST_P(VideoDecoderStreamTest, Destroy_BeforeInitialization) { … }
TEST_P(VideoDecoderStreamTest, Destroy_DuringInitialization) { … }
TEST_P(VideoDecoderStreamTest, Destroy_AfterInitialization) { … }
TEST_P(VideoDecoderStreamTest, Destroy_DuringReinitialization) { … }
TEST_P(VideoDecoderStreamTest, Destroy_AfterReinitialization) { … }
TEST_P(VideoDecoderStreamTest, Destroy_DuringDemuxerRead_Normal) { … }
TEST_P(VideoDecoderStreamTest, Destroy_DuringDemuxerRead_ConfigChange) { … }
TEST_P(VideoDecoderStreamTest, Destroy_DuringNormalDecoderDecode) { … }
TEST_P(VideoDecoderStreamTest, Destroy_AfterNormalRead) { … }
TEST_P(VideoDecoderStreamTest, Destroy_AfterConfigChangeRead) { … }
TEST_P(VideoDecoderStreamTest, Destroy_DuringDecoderReinitialization) { … }
TEST_P(VideoDecoderStreamTest, Destroy_DuringNoKeyRead) { … }
TEST_P(VideoDecoderStreamTest, Destroy_DuringReset) { … }
TEST_P(VideoDecoderStreamTest, Destroy_AfterReset) { … }
TEST_P(VideoDecoderStreamTest, Destroy_DuringRead_DuringReset) { … }
TEST_P(VideoDecoderStreamTest, Destroy_AfterRead_DuringReset) { … }
TEST_P(VideoDecoderStreamTest, Destroy_AfterRead_AfterReset) { … }
TEST_P(VideoDecoderStreamTest, FallbackDecoder_DecodeError) { … }
TEST_P(VideoDecoderStreamTest,
FallbackDecoder_EndOfStreamReachedBeforeFallback) { … }
TEST_P(VideoDecoderStreamTest,
FallbackDecoder_DoesReinitializeStompPendingRead) { … }
TEST_P(VideoDecoderStreamTest, FallbackDecoder_DecodeErrorRepeated) { … }
TEST_P(VideoDecoderStreamTest,
FallbackDecoder_SelectedOnMidstreamDecodeErrorAfterReinitialization) { … }
TEST_P(VideoDecoderStreamTest,
FallbackDecoder_DecodeErrorRepeated_AfterReinitialization) { … }
TEST_P(VideoDecoderStreamTest,
FallbackDecoder_ConfigChangeClearsPendingBuffers) { … }
TEST_P(VideoDecoderStreamTest,
FallbackDecoder_ErrorDuringConfigChangeFlushing) { … }
TEST_P(VideoDecoderStreamTest,
FallbackDecoder_PendingBuffersIsFilledAndCleared) { … }
TEST_P(VideoDecoderStreamTest, FallbackDecoder_SelectedOnDecodeThenInitErrors) { … }
TEST_P(VideoDecoderStreamTest, FallbackDecoder_SelectedOnInitThenDecodeErrors) { … }
TEST_P(VideoDecoderStreamTest,
FallbackDecoder_NotSelectedOnMidstreamDecodeError) { … }
TEST_P(VideoDecoderStreamTest, DecoderErrorWhenNotReading) { … }
TEST_P(VideoDecoderStreamTest, ReinitializeFailure_Once) { … }
TEST_P(VideoDecoderStreamTest, ReinitializeFailure_Twice) { … }
TEST_P(VideoDecoderStreamTest, ReinitializeFailure_OneUnsupportedDecoder) { … }
TEST_P(VideoDecoderStreamTest, ReinitializeFailure_NoSupportedDecoder) { … }
TEST_P(VideoDecoderStreamTest, Destroy_DuringFallbackDecoderSelection) { … }
}