OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/strings/string_split.h" | 6 #include "base/strings/string_split.h" |
7 #include "media/base/mime_util.h" | 7 #include "media/base/mime_util.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 #if defined(OS_ANDROID) | |
11 #include "base/android/build_info.h" | |
12 #endif | |
13 | |
14 namespace media { | 10 namespace media { |
15 | 11 |
16 TEST(MimeUtilTest, LookupTypes) { | |
17 #if defined(OS_ANDROID) | |
18 EXPECT_TRUE(IsSupportedMediaMimeType("application/vnd.apple.mpegurl")); | |
19 EXPECT_TRUE(IsSupportedMediaMimeType("application/x-mpegurl")); | |
20 EXPECT_TRUE(IsSupportedMediaMimeType("Application/X-MPEGURL")); | |
21 #endif | |
22 } | |
23 | |
24 TEST(MimeUtilTest, StrictMediaMimeType) { | 12 TEST(MimeUtilTest, StrictMediaMimeType) { |
25 EXPECT_TRUE(IsStrictMediaMimeType("video/webm")); | 13 EXPECT_TRUE(IsStrictMediaMimeType("video/webm")); |
26 EXPECT_TRUE(IsStrictMediaMimeType("Video/WEBM")); | 14 EXPECT_TRUE(IsStrictMediaMimeType("Video/WEBM")); |
27 EXPECT_TRUE(IsStrictMediaMimeType("audio/webm")); | 15 EXPECT_TRUE(IsStrictMediaMimeType("audio/webm")); |
28 | 16 |
29 EXPECT_TRUE(IsStrictMediaMimeType("audio/wav")); | 17 EXPECT_TRUE(IsStrictMediaMimeType("audio/wav")); |
30 EXPECT_TRUE(IsStrictMediaMimeType("audio/x-wav")); | 18 EXPECT_TRUE(IsStrictMediaMimeType("audio/x-wav")); |
31 | 19 |
32 EXPECT_TRUE(IsStrictMediaMimeType("video/ogg")); | 20 EXPECT_TRUE(IsStrictMediaMimeType("video/ogg")); |
33 EXPECT_TRUE(IsStrictMediaMimeType("audio/ogg")); | 21 EXPECT_TRUE(IsStrictMediaMimeType("audio/ogg")); |
(...skipping 12 matching lines...) Expand all Loading... |
46 EXPECT_TRUE(IsStrictMediaMimeType("application/vnd.apple.mpegurl")); | 34 EXPECT_TRUE(IsStrictMediaMimeType("application/vnd.apple.mpegurl")); |
47 | 35 |
48 EXPECT_FALSE(IsStrictMediaMimeType("video/unknown")); | 36 EXPECT_FALSE(IsStrictMediaMimeType("video/unknown")); |
49 EXPECT_FALSE(IsStrictMediaMimeType("Video/UNKNOWN")); | 37 EXPECT_FALSE(IsStrictMediaMimeType("Video/UNKNOWN")); |
50 EXPECT_FALSE(IsStrictMediaMimeType("audio/unknown")); | 38 EXPECT_FALSE(IsStrictMediaMimeType("audio/unknown")); |
51 EXPECT_FALSE(IsStrictMediaMimeType("application/unknown")); | 39 EXPECT_FALSE(IsStrictMediaMimeType("application/unknown")); |
52 EXPECT_FALSE(IsStrictMediaMimeType("unknown/unknown")); | 40 EXPECT_FALSE(IsStrictMediaMimeType("unknown/unknown")); |
53 } | 41 } |
54 | 42 |
55 TEST(MimeUtilTest, CommonMediaMimeType) { | 43 TEST(MimeUtilTest, CommonMediaMimeType) { |
56 #if defined(OS_ANDROID) | |
57 bool HLSSupported; | |
58 if (base::android::BuildInfo::GetInstance()->sdk_int() < 14) | |
59 HLSSupported = false; | |
60 else | |
61 HLSSupported = true; | |
62 #endif | |
63 | |
64 EXPECT_TRUE(IsSupportedMediaMimeType("audio/webm")); | 44 EXPECT_TRUE(IsSupportedMediaMimeType("audio/webm")); |
65 EXPECT_TRUE(IsSupportedMediaMimeType("video/webm")); | 45 EXPECT_TRUE(IsSupportedMediaMimeType("video/webm")); |
66 | 46 |
67 EXPECT_TRUE(IsSupportedMediaMimeType("audio/wav")); | 47 EXPECT_TRUE(IsSupportedMediaMimeType("audio/wav")); |
68 EXPECT_TRUE(IsSupportedMediaMimeType("audio/x-wav")); | 48 EXPECT_TRUE(IsSupportedMediaMimeType("audio/x-wav")); |
69 | 49 |
70 EXPECT_TRUE(IsSupportedMediaMimeType("audio/ogg")); | 50 EXPECT_TRUE(IsSupportedMediaMimeType("audio/ogg")); |
71 EXPECT_TRUE(IsSupportedMediaMimeType("application/ogg")); | 51 EXPECT_TRUE(IsSupportedMediaMimeType("application/ogg")); |
72 #if defined(OS_ANDROID) | 52 #if defined(OS_ANDROID) |
73 EXPECT_FALSE(IsSupportedMediaMimeType("video/ogg")); | 53 EXPECT_FALSE(IsSupportedMediaMimeType("video/ogg")); |
74 EXPECT_EQ(HLSSupported, IsSupportedMediaMimeType("application/x-mpegurl")); | |
75 EXPECT_EQ(HLSSupported, | |
76 IsSupportedMediaMimeType("application/vnd.apple.mpegurl")); | |
77 #else | 54 #else |
78 EXPECT_TRUE(IsSupportedMediaMimeType("video/ogg")); | 55 EXPECT_TRUE(IsSupportedMediaMimeType("video/ogg")); |
79 EXPECT_FALSE(IsSupportedMediaMimeType("application/x-mpegurl")); | |
80 EXPECT_FALSE(IsSupportedMediaMimeType("application/vnd.apple.mpegurl")); | |
81 #endif // OS_ANDROID | 56 #endif // OS_ANDROID |
82 | 57 |
| 58 #if defined(OS_ANDROID) |
| 59 // HLS is supported on Android API level 14 and higher and Chrome supports |
| 60 // API levels 15 and higher, so these are expected to be supported. |
| 61 bool kHlsSupported = true; |
| 62 #else |
| 63 bool kHlsSupported = false; |
| 64 #endif |
| 65 |
| 66 EXPECT_EQ(kHlsSupported, IsSupportedMediaMimeType("application/x-mpegurl")); |
| 67 EXPECT_EQ(kHlsSupported, IsSupportedMediaMimeType("Application/X-MPEGURL")); |
| 68 EXPECT_EQ(kHlsSupported, IsSupportedMediaMimeType( |
| 69 "application/vnd.apple.mpegurl")); |
| 70 |
83 #if defined(USE_PROPRIETARY_CODECS) | 71 #if defined(USE_PROPRIETARY_CODECS) |
84 EXPECT_TRUE(IsSupportedMediaMimeType("audio/mp4")); | 72 EXPECT_TRUE(IsSupportedMediaMimeType("audio/mp4")); |
85 EXPECT_TRUE(IsSupportedMediaMimeType("audio/x-m4a")); | 73 EXPECT_TRUE(IsSupportedMediaMimeType("audio/x-m4a")); |
86 EXPECT_TRUE(IsSupportedMediaMimeType("video/mp4")); | 74 EXPECT_TRUE(IsSupportedMediaMimeType("video/mp4")); |
87 EXPECT_TRUE(IsSupportedMediaMimeType("video/x-m4v")); | 75 EXPECT_TRUE(IsSupportedMediaMimeType("video/x-m4v")); |
88 | 76 |
89 EXPECT_TRUE(IsSupportedMediaMimeType("audio/mp3")); | 77 EXPECT_TRUE(IsSupportedMediaMimeType("audio/mp3")); |
90 EXPECT_TRUE(IsSupportedMediaMimeType("audio/x-mp3")); | 78 EXPECT_TRUE(IsSupportedMediaMimeType("audio/x-mp3")); |
91 EXPECT_TRUE(IsSupportedMediaMimeType("audio/mpeg")); | 79 EXPECT_TRUE(IsSupportedMediaMimeType("audio/mpeg")); |
92 EXPECT_TRUE(IsSupportedMediaMimeType("audio/aac")); | 80 EXPECT_TRUE(IsSupportedMediaMimeType("audio/aac")); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 | 132 |
145 // Test without stripping the codec type. | 133 // Test without stripping the codec type. |
146 std::vector<std::string> codecs_out; | 134 std::vector<std::string> codecs_out; |
147 ParseCodecString("avc1.42E01E, mp4a.40.2", &codecs_out, false); | 135 ParseCodecString("avc1.42E01E, mp4a.40.2", &codecs_out, false); |
148 ASSERT_EQ(2u, codecs_out.size()); | 136 ASSERT_EQ(2u, codecs_out.size()); |
149 EXPECT_EQ("avc1.42E01E", codecs_out[0]); | 137 EXPECT_EQ("avc1.42E01E", codecs_out[0]); |
150 EXPECT_EQ("mp4a.40.2", codecs_out[1]); | 138 EXPECT_EQ("mp4a.40.2", codecs_out[1]); |
151 } | 139 } |
152 | 140 |
153 } // namespace media | 141 } // namespace media |
OLD | NEW |