Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(697)

Unified Diff: media/filters/ffmpeg_glue_unittest.cc

Issue 2819863003: Only run container name detection upon ffmpeg parse failure. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/filters/ffmpeg_glue_unittest.cc
diff --git a/media/filters/ffmpeg_glue_unittest.cc b/media/filters/ffmpeg_glue_unittest.cc
index 5781bf3e2afb0d20c8c0530c09ba2dde24eb1d2a..cda290e9695501eb81902a1d74b7523d0f22eab3 100644
--- a/media/filters/ffmpeg_glue_unittest.cc
+++ b/media/filters/ffmpeg_glue_unittest.cc
@@ -10,6 +10,8 @@
#include "base/logging.h"
#include "base/macros.h"
+#include "base/test/histogram_tester.h"
+#include "media/base/container_names.h"
#include "media/base/mock_filters.h"
#include "media/base/test_data_util.h"
#include "media/ffmpeg/ffmpeg_common.h"
@@ -61,8 +63,8 @@ class FFmpegGlueTest : public ::testing::Test {
}
int ReadPacket(int size, uint8_t* data) {
- return glue_->format_context()->pb->read_packet(
- protocol_.get(), data, size);
+ return glue_->format_context()->pb->read_packet(protocol_.get(), data,
+ size);
}
int64_t Seek(int64_t offset, int whence) {
@@ -113,6 +115,29 @@ class FFmpegGlueDestructionTest : public ::testing::Test {
DISALLOW_COPY_AND_ASSIGN(FFmpegGlueDestructionTest);
};
+// Tests that ensure we are using the correct AVInputFormat name given by ffmpeg
+// for supported containers.
+class FFmpegGlueContainerTest : public FFmpegGlueDestructionTest {
+ public:
+ FFmpegGlueContainerTest() {}
+ ~FFmpegGlueContainerTest() override {}
+
+ protected:
+ void InitializeAndOpen(const char* filename) {
+ Initialize(filename);
+ ASSERT_TRUE(glue_->OpenContext());
+ }
+
+ void ExpectContainer(container_names::MediaContainerName container) {
+ histogram_tester_.ExpectUniqueSample("Media.DetectedContainer", container,
+ 1);
+ }
+
+ private:
+ base::HistogramTester histogram_tester_;
+ DISALLOW_COPY_AND_ASSIGN(FFmpegGlueContainerTest);
+};
+
// Ensure writing has been disabled.
TEST_F(FFmpegGlueTest, Write) {
ASSERT_FALSE(glue_->format_context()->pb->write_packet);
@@ -253,4 +278,60 @@ TEST_F(FFmpegGlueDestructionTest, WithOpenWithOpenStreams) {
avcodec_find_decoder(context->codec_id), nullptr));
}
+TEST_F(FFmpegGlueContainerTest, OGG) {
+ InitializeAndOpen("sfx.ogg");
+ ExpectContainer(container_names::CONTAINER_OGG);
+}
+
+TEST_F(FFmpegGlueContainerTest, WEBM) {
+ InitializeAndOpen("sfx-opus-441.webm");
+ ExpectContainer(container_names::CONTAINER_WEBM);
+}
+
+TEST_F(FFmpegGlueContainerTest, FLAC) {
+ InitializeAndOpen("sfx.flac");
+ ExpectContainer(container_names::CONTAINER_FLAC);
+}
+
+TEST_F(FFmpegGlueContainerTest, WAV) {
+ InitializeAndOpen("sfx_s16le.wav");
+ ExpectContainer(container_names::CONTAINER_WAV);
+}
+
+#if BUILDFLAG(USE_PROPRIETARY_CODECS)
+TEST_F(FFmpegGlueContainerTest, MOV) {
+ InitializeAndOpen("sfx.m4a");
+ ExpectContainer(container_names::CONTAINER_MOV);
+}
+
+TEST_F(FFmpegGlueContainerTest, MP3) {
+ InitializeAndOpen("sfx.mp3");
+ ExpectContainer(container_names::CONTAINER_MP3);
+}
+
+TEST_F(FFmpegGlueContainerTest, AAC) {
+ InitializeAndOpen("sfx.adts");
+ ExpectContainer(container_names::CONTAINER_AAC);
+}
+
+#if defined(OS_CHROMEOS)
+TEST_F(FFmpegGlueContainerTest, AVI) {
+ InitializeAndOpen("bear.avi");
+ ExpectContainer(container_names::CONTAINER_AVI);
+}
+
+TEST_F(FFmpegGlueContainerTest, AMR) {
+ InitializeAndOpen("bear.amr");
+ ExpectContainer(container_names::CONTAINER_AMR);
+}
+#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
+
+// Probe something unsupported to ensure we fall back to the our internal guess.
+TEST_F(FFmpegGlueContainerTest, FLV) {
+ Initialize("bear.flv");
+ ASSERT_FALSE(glue_->OpenContext());
+ ExpectContainer(container_names::CONTAINER_FLV);
+}
+
} // namespace media

Powered by Google App Engine
This is Rietveld 408576698