chromium/media/filters/ffmpeg_glue_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.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "media/filters/ffmpeg_glue.h"

#include <stdint.h>

#include <memory>

#include "base/check.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "build/chromeos_buildflags.h"
#include "media/base/container_names.h"
#include "media/base/media_switches.h"
#include "media/base/mock_filters.h"
#include "media/base/test_data_util.h"
#include "media/ffmpeg/ffmpeg_common.h"
#include "media/ffmpeg/ffmpeg_deleters.h"
#include "media/filters/in_memory_url_protocol.h"
#include "testing/gtest/include/gtest/gtest.h"

_;
DoAll;
InSequence;
Return;
SetArgPointee;
StrictMock;

namespace media {

class MockProtocol : public FFmpegURLProtocol {};

class FFmpegGlueTest : public ::testing::Test {};

class FFmpegGlueDestructionTest : public ::testing::Test {};

// Tests that ensure we are using the correct AVInputFormat name given by ffmpeg
// for supported containers.
class FFmpegGlueContainerTest : public FFmpegGlueDestructionTest {};

// Ensure writing has been disabled.
TEST_F(FFmpegGlueTest, Write) {}

// Test both successful and unsuccessful reads pass through correctly.
TEST_F(FFmpegGlueTest, Read) {}

// Test a variety of seek operations.
TEST_F(FFmpegGlueTest, Seek) {}

// Ensure destruction release the appropriate resources when OpenContext() is
// never called.
TEST_F(FFmpegGlueDestructionTest, WithoutOpen) {}

// Ensure destruction releases the appropriate resources when
// avformat_open_input() fails.
TEST_F(FFmpegGlueDestructionTest, WithOpenFailure) {}

// Ensure destruction release the appropriate resources when OpenContext() is
// called, but no streams have been opened.
TEST_F(FFmpegGlueDestructionTest, WithOpenNoStreams) {}

// Ensure destruction release the appropriate resources when OpenContext() is
// called and streams exist.
TEST_F(FFmpegGlueDestructionTest, WithOpenWithStreams) {}

// Ensure destruction release the appropriate resources when OpenContext() is
// called and streams have been opened. This now requires user of FFmpegGlue to
// ensure any allocated AVCodecContext is closed prior to ~FFmpegGlue().
TEST_F(FFmpegGlueDestructionTest, WithOpenWithOpenStreams) {}

TEST_F(FFmpegGlueContainerTest, OGG) {}

TEST_F(FFmpegGlueContainerTest, WEBM) {}

TEST_F(FFmpegGlueContainerTest, FLAC) {}

TEST_F(FFmpegGlueContainerTest, WAV) {}

TEST_F(FFmpegGlueContainerTest, MP3) {}

#if BUILDFLAG(USE_PROPRIETARY_CODECS)
TEST_F(FFmpegGlueContainerTest, MOV) {
  InitializeAndOpen("sfx.m4a");
  ExpectContainer(container_names::MediaContainerName::kContainerMOV);
}

TEST_F(FFmpegGlueContainerTest, AAC) {
  InitializeAndOpen("sfx.adts");
  ExpectContainer(container_names::MediaContainerName::kContainerAAC);
}
#endif  // BUILDFLAG(USE_PROPRIETARY_CODECS)

// Probe something unsupported to ensure we fall back to the our internal guess.
TEST_F(FFmpegGlueContainerTest, FLV) {}

}  // namespace media