chromium/media/filters/video_decoder_stream_unittest.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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) {}

}  // namespace

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) {}

// Tests that the decoder stream will switch from a software decoder to a
// hardware decoder if the config size increases
TEST_P(VideoDecoderStreamTest, ConfigChangeSwToHw) {}

// Tests that the decoder stream will switch from a hardware decoder to a
// software decoder if the config size decreases
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) {}

// No Reset() before initialization is successfully completed.
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) {}

// In the following Destroy_* tests, |video_decoder_stream_| is destroyed in
// VideoDecoderStreamTest destructor.

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) {}

// The following tests cover the fallback logic after reinitialization error or
// decode error of the first buffer after initialization.

TEST_P(VideoDecoderStreamTest, FallbackDecoder_DecodeError) {}

TEST_P(VideoDecoderStreamTest,
       FallbackDecoder_EndOfStreamReachedBeforeFallback) {}

TEST_P(VideoDecoderStreamTest,
       FallbackDecoder_DoesReinitializeStompPendingRead) {}

TEST_P(VideoDecoderStreamTest, FallbackDecoder_DecodeErrorRepeated) {}

// This tests verifies that we properly fallback to a new decoder if the first
// decode after a config change fails.
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) {}

}  // namespace media