Commit f395553f authored by servolk's avatar servolk Committed by Commit bot

Moved media mime type and codec checks to media/base/mime_util.*

BUG=318217

Review URL: https://codereview.chromium.org/1129643002

Cr-Commit-Position: refs/heads/master@{#330239}
parent 9e02055b
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "components/mime_util/mime_util.h" #include "components/mime_util/mime_util.h"
#include "media/base/key_systems.h" #include "media/base/key_systems.h"
#include "media/base/mime_util.h"
#include "media/filters/stream_parser_factory.h" #include "media/filters/stream_parser_factory.h"
#include "net/base/mime_util.h" #include "net/base/mime_util.h"
#include "third_party/WebKit/public/platform/WebString.h" #include "third_party/WebKit/public/platform/WebString.h"
...@@ -63,7 +64,7 @@ blink::WebMimeRegistry::SupportsType WebMimeRegistryImpl::supportsMediaMIMEType( ...@@ -63,7 +64,7 @@ blink::WebMimeRegistry::SupportsType WebMimeRegistryImpl::supportsMediaMIMEType(
const blink::WebString& key_system) { const blink::WebString& key_system) {
const std::string mime_type_ascii = ToASCIIOrEmpty(mime_type); const std::string mime_type_ascii = ToASCIIOrEmpty(mime_type);
// Not supporting the container is a flat-out no. // Not supporting the container is a flat-out no.
if (!net::IsSupportedMediaMimeType(mime_type_ascii)) if (!media::IsSupportedMediaMimeType(mime_type_ascii))
return IsNotSupported; return IsNotSupported;
// Mojo does not currently support any key systems. // Mojo does not currently support any key systems.
...@@ -71,18 +72,18 @@ blink::WebMimeRegistry::SupportsType WebMimeRegistryImpl::supportsMediaMIMEType( ...@@ -71,18 +72,18 @@ blink::WebMimeRegistry::SupportsType WebMimeRegistryImpl::supportsMediaMIMEType(
return IsNotSupported; return IsNotSupported;
// Check list of strict codecs to see if it is supported. // Check list of strict codecs to see if it is supported.
if (net::IsStrictMediaMimeType(mime_type_ascii)) { if (media::IsStrictMediaMimeType(mime_type_ascii)) {
// Check if the codecs are a perfect match. // Check if the codecs are a perfect match.
std::vector<std::string> strict_codecs; std::vector<std::string> strict_codecs;
net::ParseCodecString(ToASCIIOrEmpty(codecs), &strict_codecs, false); media::ParseCodecString(ToASCIIOrEmpty(codecs), &strict_codecs, false);
return static_cast<WebMimeRegistry::SupportsType>( return static_cast<WebMimeRegistry::SupportsType>(
net::IsSupportedStrictMediaMimeType(mime_type_ascii, strict_codecs)); media::IsSupportedStrictMediaMimeType(mime_type_ascii, strict_codecs));
} }
// If we don't recognize the codec, it's possible we support it. // If we don't recognize the codec, it's possible we support it.
std::vector<std::string> parsed_codecs; std::vector<std::string> parsed_codecs;
net::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codecs, true); media::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codecs, true);
if (!net::AreSupportedMediaCodecs(parsed_codecs)) if (!media::AreSupportedMediaCodecs(parsed_codecs))
return MayBeSupported; return MayBeSupported;
// Otherwise we have a perfect match. // Otherwise we have a perfect match.
...@@ -97,7 +98,7 @@ bool WebMimeRegistryImpl::supportsMediaSourceMIMEType( ...@@ -97,7 +98,7 @@ bool WebMimeRegistryImpl::supportsMediaSourceMIMEType(
return false; return false;
std::vector<std::string> parsed_codec_ids; std::vector<std::string> parsed_codec_ids;
net::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codec_ids, false); media::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codec_ids, false);
return media::StreamParserFactory::IsTypeSupported(mime_type_ascii, return media::StreamParserFactory::IsTypeSupported(mime_type_ascii,
parsed_codec_ids); parsed_codec_ids);
} }
......
...@@ -12,6 +12,11 @@ static_library("mime_util") { ...@@ -12,6 +12,11 @@ static_library("mime_util") {
"//base", "//base",
"//net", "//net",
] ]
# iOS doesn't use and must not depend on //media
if (!is_ios) {
deps += [ "//media" ]
}
} }
source_set("unit_tests") { source_set("unit_tests") {
......
...@@ -3,5 +3,6 @@ include_rules = [ ...@@ -3,5 +3,6 @@ include_rules = [
# any dependencies on //content # any dependencies on //content
"-content", "-content",
"+media/base/mime_util.h", # Only for platforms other than iOS
"+net/base", "+net/base",
] ]
...@@ -9,6 +9,11 @@ ...@@ -9,6 +9,11 @@
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "build/build_config.h" #include "build/build_config.h"
#if !defined(OS_IOS)
// iOS doesn't use and must not depend on //media
#include "media/base/mime_util.h"
#endif
namespace mime_util { namespace mime_util {
namespace { namespace {
...@@ -153,11 +158,13 @@ bool MimeUtil::IsSupportedImageMimeType(const std::string& mime_type) const { ...@@ -153,11 +158,13 @@ bool MimeUtil::IsSupportedImageMimeType(const std::string& mime_type) const {
bool MimeUtil::IsSupportedNonImageMimeType(const std::string& mime_type) const { bool MimeUtil::IsSupportedNonImageMimeType(const std::string& mime_type) const {
return non_image_types_.find(base::StringToLowerASCII(mime_type)) != return non_image_types_.find(base::StringToLowerASCII(mime_type)) !=
non_image_types_.end() || non_image_types_.end() ||
#if !defined(OS_IOS)
media::IsSupportedMediaMimeType(mime_type) ||
#endif
(StartsWithASCII(mime_type, "text/", false /* case insensitive */) && (StartsWithASCII(mime_type, "text/", false /* case insensitive */) &&
!IsUnsupportedTextMimeType(mime_type)) || !IsUnsupportedTextMimeType(mime_type)) ||
(StartsWithASCII(mime_type, "application/", false) && (StartsWithASCII(mime_type, "application/", false) &&
net::MatchesMimeType("application/*+json", mime_type)) || net::MatchesMimeType("application/*+json", mime_type));
net::IsSupportedMediaMimeType(mime_type);
} }
bool MimeUtil::IsUnsupportedTextMimeType(const std::string& mime_type) const { bool MimeUtil::IsUnsupportedTextMimeType(const std::string& mime_type) const {
......
...@@ -16,6 +16,14 @@ ...@@ -16,6 +16,14 @@
'mime_util.cc', 'mime_util.cc',
'mime_util.h', 'mime_util.h',
], ],
'conditions': [
['OS!="ios"', {
# iOS doesn't use and must not depend on //media
'dependencies': [
'../../media/media.gyp:media',
],
}],
],
} }
], ],
} }
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "base/trace_event/trace_event.h" #include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "cc/base/switches.h" #include "cc/base/switches.h"
#include "components/mime_util/mime_util.h" #include "components/mime_util/mime_util.h"
#include "content/browser/bad_message.h" #include "content/browser/bad_message.h"
...@@ -40,8 +41,8 @@ ...@@ -40,8 +41,8 @@
#include "content/public/common/content_client.h" #include "content/public/common/content_client.h"
#include "content/public/common/content_constants.h" #include "content/public/common/content_constants.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "media/base/mime_util.h"
#include "net/base/escape.h" #include "net/base/escape.h"
#include "net/base/mime_util.h"
#include "net/base/net_util.h" #include "net/base/net_util.h"
#include "skia/ext/platform_canvas.h" #include "skia/ext/platform_canvas.h"
#include "url/url_constants.h" #include "url/url_constants.h"
...@@ -496,7 +497,7 @@ bool NavigationControllerImpl::CanViewSource() const { ...@@ -496,7 +497,7 @@ bool NavigationControllerImpl::CanViewSource() const {
const std::string& mime_type = delegate_->GetContentsMimeType(); const std::string& mime_type = delegate_->GetContentsMimeType();
bool is_viewable_mime_type = bool is_viewable_mime_type =
mime_util::IsSupportedNonImageMimeType(mime_type) && mime_util::IsSupportedNonImageMimeType(mime_type) &&
!net::IsSupportedMediaMimeType(mime_type); !media::IsSupportedMediaMimeType(mime_type);
NavigationEntry* visible_entry = GetVisibleEntry(); NavigationEntry* visible_entry = GetVisibleEntry();
return visible_entry && !visible_entry->IsViewSourceMode() && return visible_entry && !visible_entry->IsViewSourceMode() &&
is_viewable_mime_type && !delegate_->GetInterstitialPage(); is_viewable_mime_type && !delegate_->GetInterstitialPage();
......
...@@ -9,6 +9,6 @@ include_rules = [ ...@@ -9,6 +9,6 @@ include_rules = [
"+content/app/strings/grit", # For generated headers "+content/app/strings/grit", # For generated headers
"+content/public/child", "+content/public/child",
"+media/base/android", "+media/base",
"+v8/include/v8.h" "+v8/include/v8.h"
] ]
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "cc/animation/animation.h" #include "cc/animation/animation.h"
#include "content/public/common/screen_orientation_values.h" #include "content/public/common/screen_orientation_values.h"
#include "net/base/mime_util.h" #include "media/base/mime_util.h"
#include "third_party/WebKit/public/platform/WebCompositorAnimation.h" #include "third_party/WebKit/public/platform/WebCompositorAnimation.h"
#include "third_party/WebKit/public/platform/WebMimeRegistry.h" #include "third_party/WebKit/public/platform/WebMimeRegistry.h"
#include "third_party/WebKit/public/platform/WebScreenOrientationLockType.h" #include "third_party/WebKit/public/platform/WebScreenOrientationLockType.h"
...@@ -40,11 +40,11 @@ STATIC_ASSERT_MATCHING_ENUM(blink::WebScreenOrientationLockNatural, ...@@ -40,11 +40,11 @@ STATIC_ASSERT_MATCHING_ENUM(blink::WebScreenOrientationLockNatural,
// SupportsType // SupportsType
STATIC_ASSERT_MATCHING_ENUM(blink::WebMimeRegistry::IsNotSupported, STATIC_ASSERT_MATCHING_ENUM(blink::WebMimeRegistry::IsNotSupported,
net::IsNotSupported); media::IsNotSupported);
STATIC_ASSERT_MATCHING_ENUM(blink::WebMimeRegistry::IsSupported, STATIC_ASSERT_MATCHING_ENUM(blink::WebMimeRegistry::IsSupported,
net::IsSupported); media::IsSupported);
STATIC_ASSERT_MATCHING_ENUM(blink::WebMimeRegistry::MayBeSupported, STATIC_ASSERT_MATCHING_ENUM(blink::WebMimeRegistry::MayBeSupported,
net::MayBeSupported); media::MayBeSupported);
// TargetProperty // TargetProperty
STATIC_ASSERT_MATCHING_ENUM( STATIC_ASSERT_MATCHING_ENUM(
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "base/numerics/safe_conversions.h" #include "base/numerics/safe_conversions.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "cc/blink/context_provider_web_context.h" #include "cc/blink/context_provider_web_context.h"
#include "components/scheduler/child/web_scheduler_impl.h" #include "components/scheduler/child/web_scheduler_impl.h"
#include "components/scheduler/renderer/renderer_scheduler.h" #include "components/scheduler/renderer/renderer_scheduler.h"
...@@ -63,9 +64,9 @@ ...@@ -63,9 +64,9 @@
#include "media/audio/audio_output_device.h" #include "media/audio/audio_output_device.h"
#include "media/base/audio_hardware_config.h" #include "media/base/audio_hardware_config.h"
#include "media/base/key_systems.h" #include "media/base/key_systems.h"
#include "media/base/mime_util.h"
#include "media/blink/webcontentdecryptionmodule_impl.h" #include "media/blink/webcontentdecryptionmodule_impl.h"
#include "media/filters/stream_parser_factory.h" #include "media/filters/stream_parser_factory.h"
#include "net/base/mime_util.h"
#include "net/base/net_util.h" #include "net/base/net_util.h"
#include "storage/common/database/database_identifier.h" #include "storage/common/database/database_identifier.h"
#include "storage/common/quota/quota_types.h" #include "storage/common/quota/quota_types.h"
...@@ -412,7 +413,7 @@ RendererBlinkPlatformImpl::MimeRegistry::supportsMediaMIMEType( ...@@ -412,7 +413,7 @@ RendererBlinkPlatformImpl::MimeRegistry::supportsMediaMIMEType(
const WebString& key_system) { const WebString& key_system) {
const std::string mime_type_ascii = ToASCIIOrEmpty(mime_type); const std::string mime_type_ascii = ToASCIIOrEmpty(mime_type);
// Not supporting the container is a flat-out no. // Not supporting the container is a flat-out no.
if (!net::IsSupportedMediaMimeType(mime_type_ascii)) if (!media::IsSupportedMediaMimeType(mime_type_ascii))
return IsNotSupported; return IsNotSupported;
if (!key_system.isEmpty()) { if (!key_system.isEmpty()) {
...@@ -425,7 +426,7 @@ RendererBlinkPlatformImpl::MimeRegistry::supportsMediaMIMEType( ...@@ -425,7 +426,7 @@ RendererBlinkPlatformImpl::MimeRegistry::supportsMediaMIMEType(
std::string key_system_ascii = std::string key_system_ascii =
media::GetUnprefixedKeySystemName(base::UTF16ToASCII(key_system)); media::GetUnprefixedKeySystemName(base::UTF16ToASCII(key_system));
std::vector<std::string> strict_codecs; std::vector<std::string> strict_codecs;
net::ParseCodecString(ToASCIIOrEmpty(codecs), &strict_codecs, true); media::ParseCodecString(ToASCIIOrEmpty(codecs), &strict_codecs, true);
if (!media::PrefixedIsSupportedKeySystemWithMediaMimeType( if (!media::PrefixedIsSupportedKeySystemWithMediaMimeType(
mime_type_ascii, strict_codecs, key_system_ascii)) { mime_type_ascii, strict_codecs, key_system_ascii)) {
...@@ -436,18 +437,18 @@ RendererBlinkPlatformImpl::MimeRegistry::supportsMediaMIMEType( ...@@ -436,18 +437,18 @@ RendererBlinkPlatformImpl::MimeRegistry::supportsMediaMIMEType(
} }
// Check list of strict codecs to see if it is supported. // Check list of strict codecs to see if it is supported.
if (net::IsStrictMediaMimeType(mime_type_ascii)) { if (media::IsStrictMediaMimeType(mime_type_ascii)) {
// Check if the codecs are a perfect match. // Check if the codecs are a perfect match.
std::vector<std::string> strict_codecs; std::vector<std::string> strict_codecs;
net::ParseCodecString(ToASCIIOrEmpty(codecs), &strict_codecs, false); media::ParseCodecString(ToASCIIOrEmpty(codecs), &strict_codecs, false);
return static_cast<WebMimeRegistry::SupportsType> ( return static_cast<WebMimeRegistry::SupportsType> (
net::IsSupportedStrictMediaMimeType(mime_type_ascii, strict_codecs)); media::IsSupportedStrictMediaMimeType(mime_type_ascii, strict_codecs));
} }
// If we don't recognize the codec, it's possible we support it. // If we don't recognize the codec, it's possible we support it.
std::vector<std::string> parsed_codecs; std::vector<std::string> parsed_codecs;
net::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codecs, true); media::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codecs, true);
if (!net::AreSupportedMediaCodecs(parsed_codecs)) if (!media::AreSupportedMediaCodecs(parsed_codecs))
return MayBeSupported; return MayBeSupported;
// Otherwise we have a perfect match. // Otherwise we have a perfect match.
...@@ -459,7 +460,7 @@ bool RendererBlinkPlatformImpl::MimeRegistry::supportsMediaSourceMIMEType( ...@@ -459,7 +460,7 @@ bool RendererBlinkPlatformImpl::MimeRegistry::supportsMediaSourceMIMEType(
const WebString& codecs) { const WebString& codecs) {
const std::string mime_type_ascii = ToASCIIOrEmpty(mime_type); const std::string mime_type_ascii = ToASCIIOrEmpty(mime_type);
std::vector<std::string> parsed_codec_ids; std::vector<std::string> parsed_codec_ids;
net::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codec_ids, false); media::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codec_ids, false);
if (mime_type_ascii.empty()) if (mime_type_ascii.empty())
return false; return false;
return media::StreamParserFactory::IsTypeSupported( return media::StreamParserFactory::IsTypeSupported(
......
...@@ -29,6 +29,9 @@ include_rules = [ ...@@ -29,6 +29,9 @@ include_rules = [
# For enabling media related features. # For enabling media related features.
"+media/base/media_switches.h", "+media/base/media_switches.h",
# For media::RemoveProprietaryMediaTypesAndCodecsForTests.
"+media/base/mime_util.h",
] ]
specific_include_rules = { specific_include_rules = {
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/lazy_instance.h" #include "base/lazy_instance.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "build/build_config.h"
#include "cc/base/switches.h" #include "cc/base/switches.h"
#include "content/public/browser/browser_main_runner.h" #include "content/public/browser/browser_main_runner.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
...@@ -27,6 +28,7 @@ ...@@ -27,6 +28,7 @@
#include "content/shell/renderer/layout_test/layout_test_content_renderer_client.h" #include "content/shell/renderer/layout_test/layout_test_content_renderer_client.h"
#include "content/shell/renderer/shell_content_renderer_client.h" #include "content/shell/renderer/shell_content_renderer_client.h"
#include "media/base/media_switches.h" #include "media/base/media_switches.h"
#include "media/base/mime_util.h"
#include "net/cookies/cookie_monster.h" #include "net/cookies/cookie_monster.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_paths.h" #include "ui/base/ui_base_paths.h"
...@@ -206,7 +208,7 @@ bool ShellMainDelegate::BasicStartupComplete(int* exit_code) { ...@@ -206,7 +208,7 @@ bool ShellMainDelegate::BasicStartupComplete(int* exit_code) {
// Unless/until WebM files are added to the media layout tests, we need to // Unless/until WebM files are added to the media layout tests, we need to
// avoid removing MP4/H264/AAC so that layout tests can run on Android. // avoid removing MP4/H264/AAC so that layout tests can run on Android.
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
net::RemoveProprietaryMediaTypesAndCodecsForTests(); media::RemoveProprietaryMediaTypesAndCodecsForTests();
#endif #endif
if (!BlinkTestPlatformInitialize()) { if (!BlinkTestPlatformInitialize()) {
......
...@@ -119,6 +119,8 @@ source_set("base") { ...@@ -119,6 +119,8 @@ source_set("base") {
"media_permission.h", "media_permission.h",
"media_switches.cc", "media_switches.cc",
"media_switches.h", "media_switches.h",
"mime_util.cc",
"mime_util.h",
"moving_average.cc", "moving_average.cc",
"moving_average.h", "moving_average.h",
"multi_channel_resampler.cc", "multi_channel_resampler.cc",
...@@ -380,6 +382,7 @@ source_set("unittests") { ...@@ -380,6 +382,7 @@ source_set("unittests") {
"fake_demuxer_stream_unittest.cc", "fake_demuxer_stream_unittest.cc",
"gmock_callback_support_unittest.cc", "gmock_callback_support_unittest.cc",
"key_systems_unittest.cc", "key_systems_unittest.cc",
"mime_util_unittest.cc",
"moving_average_unittest.cc", "moving_average_unittest.cc",
"multi_channel_resampler_unittest.cc", "multi_channel_resampler_unittest.cc",
"null_video_sink_unittest.cc", "null_video_sink_unittest.cc",
......
This diff is collapsed.
// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MEDIA_BASE_MIME_UTIL_H__
#define MEDIA_BASE_MIME_UTIL_H__
#include <string>
#include <vector>
#include "media/base/media_export.h"
namespace media {
// Check to see if a particular MIME type is in the list of
// supported/recognized MIME types.
MEDIA_EXPORT bool IsSupportedMediaMimeType(const std::string& mime_type);
// Returns true if and only if all codecs are supported, false otherwise.
MEDIA_EXPORT bool AreSupportedMediaCodecs(
const std::vector<std::string>& codecs);
// Parses a codec string, populating |codecs_out| with the prefix of each codec
// in the string |codecs_in|. For example, passed "aaa.b.c,dd.eee", if
// |strip| == true |codecs_out| will contain {"aaa", "dd"}, if |strip| == false
// |codecs_out| will contain {"aaa.b.c", "dd.eee"}.
// See http://www.ietf.org/rfc/rfc4281.txt.
MEDIA_EXPORT void ParseCodecString(const std::string& codecs,
std::vector<std::string>* codecs_out,
bool strip);
// Check to see if a particular MIME type is in our list which only supports a
// certain subset of codecs.
MEDIA_EXPORT bool IsStrictMediaMimeType(const std::string& mime_type);
// Indicates that the MIME type and (possible codec string) are supported by the
// underlying platform.
enum SupportsType {
// The underlying platform is known not to support the given MIME type and
// codec combination.
IsNotSupported,
// The underlying platform is known to support the given MIME type and codec
// combination.
IsSupported,
// The underlying platform is unsure whether the given MIME type and codec
// combination can be rendered or not before actually trying to play it.
MayBeSupported
};
// Checks the |mime_type| and |codecs| against the MIME types known to support
// only a particular subset of codecs.
// * Returns IsSupported if the |mime_type| is supported and all the codecs
// within the |codecs| are supported for the |mime_type|.
// * Returns MayBeSupported if the |mime_type| is supported and is known to
// support only a subset of codecs, but |codecs| was empty. Also returned if
// all the codecs in |codecs| are supported, but additional codec parameters
// were supplied (such as profile) for which the support cannot be decided.
// * Returns IsNotSupported if either the |mime_type| is not supported or the
// |mime_type| is supported but at least one of the codecs within |codecs| is
// not supported for the |mime_type|.
MEDIA_EXPORT SupportsType IsSupportedStrictMediaMimeType(
const std::string& mime_type,
const std::vector<std::string>& codecs);
// Test only method that removes proprietary media types and codecs from the
// list of supported MIME types and codecs. These types and codecs must be
// removed to ensure consistent layout test results across all Chromium
// variations.
MEDIA_EXPORT void RemoveProprietaryMediaTypesAndCodecsForTests();
} // namespace media
#endif // MEDIA_BASE_MIME_UTIL_H__
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/basictypes.h"
#include "base/strings/string_split.h"
#include "build/build_config.h"
#include "media/base/mime_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#if defined(OS_ANDROID)
#include "base/android/build_info.h"
#endif
namespace media {
TEST(MimeUtilTest, LookupTypes) {
#if defined(OS_ANDROID)
EXPECT_TRUE(IsSupportedMediaMimeType("application/vnd.apple.mpegurl"));
EXPECT_TRUE(IsSupportedMediaMimeType("application/x-mpegurl"));
EXPECT_TRUE(IsSupportedMediaMimeType("Application/X-MPEGURL"));
#endif
}
TEST(MimeUtilTest, StrictMediaMimeType) {
EXPECT_TRUE(IsStrictMediaMimeType("video/webm"));
EXPECT_TRUE(IsStrictMediaMimeType("Video/WEBM"));
EXPECT_TRUE(IsStrictMediaMimeType("audio/webm"));
EXPECT_TRUE(IsStrictMediaMimeType("audio/wav"));
EXPECT_TRUE(IsStrictMediaMimeType("audio/x-wav"));
EXPECT_TRUE(IsStrictMediaMimeType("video/ogg"));
EXPECT_TRUE(IsStrictMediaMimeType("audio/ogg"));
EXPECT_TRUE(IsStrictMediaMimeType("application/ogg"));
EXPECT_TRUE(IsStrictMediaMimeType("audio/mpeg"));
EXPECT_TRUE(IsStrictMediaMimeType("audio/mp3"));
EXPECT_TRUE(IsStrictMediaMimeType("audio/x-mp3"));
EXPECT_TRUE(IsStrictMediaMimeType("video/mp4"));
EXPECT_TRUE(IsStrictMediaMimeType("video/x-m4v"));
EXPECT_TRUE(IsStrictMediaMimeType("audio/mp4"));
EXPECT_TRUE(IsStrictMediaMimeType("audio/x-m4a"));
EXPECT_TRUE(IsStrictMediaMimeType("application/x-mpegurl"));
EXPECT_TRUE(IsStrictMediaMimeType("application/vnd.apple.mpegurl"));
EXPECT_FALSE(IsStrictMediaMimeType("video/unknown"));
EXPECT_FALSE(IsStrictMediaMimeType("Video/UNKNOWN"));
EXPECT_FALSE(IsStrictMediaMimeType("audio/unknown"));
EXPECT_FALSE(IsStrictMediaMimeType("application/unknown"));
EXPECT_FALSE(IsStrictMediaMimeType("unknown/unknown"));
}
TEST(MimeUtilTest, CommonMediaMimeType) {
#if defined(OS_ANDROID)
bool HLSSupported;
if (base::android::BuildInfo::GetInstance()->sdk_int() < 14)
HLSSupported = false;
else
HLSSupported = true;
#endif
EXPECT_TRUE(IsSupportedMediaMimeType("audio/webm"));
EXPECT_TRUE(IsSupportedMediaMimeType("video/webm"));
EXPECT_TRUE(IsSupportedMediaMimeType("audio/wav"));
EXPECT_TRUE(IsSupportedMediaMimeType("audio/x-wav"));
EXPECT_TRUE(IsSupportedMediaMimeType("audio/ogg"));
EXPECT_TRUE(IsSupportedMediaMimeType("application/ogg"));
#if defined(OS_ANDROID)
EXPECT_FALSE(IsSupportedMediaMimeType("video/ogg"));
EXPECT_EQ(HLSSupported, IsSupportedMediaMimeType("application/x-mpegurl"));
EXPECT_EQ(HLSSupported,
IsSupportedMediaMimeType("application/vnd.apple.mpegurl"));
#else
EXPECT_TRUE(IsSupportedMediaMimeType("video/ogg"));
EXPECT_FALSE(IsSupportedMediaMimeType("application/x-mpegurl"));
EXPECT_FALSE(IsSupportedMediaMimeType("application/vnd.apple.mpegurl"));
#endif // OS_ANDROID
#if defined(USE_PROPRIETARY_CODECS)
EXPECT_TRUE(IsSupportedMediaMimeType("audio/mp4"));
EXPECT_TRUE(IsSupportedMediaMimeType("audio/x-m4a"));
EXPECT_TRUE(IsSupportedMediaMimeType("video/mp4"));
EXPECT_TRUE(IsSupportedMediaMimeType("video/x-m4v"));
EXPECT_TRUE(IsSupportedMediaMimeType("audio/mp3"));
EXPECT_TRUE(IsSupportedMediaMimeType("audio/x-mp3"));
EXPECT_TRUE(IsSupportedMediaMimeType("audio/mpeg"));
EXPECT_TRUE(IsSupportedMediaMimeType("audio/aac"));
#if defined(ENABLE_MPEG2TS_STREAM_PARSER)
EXPECT_TRUE(IsSupportedMediaMimeType("video/mp2t"));
#else
EXPECT_FALSE(IsSupportedMediaMimeType("video/mp2t"));
#endif
#else
EXPECT_FALSE(IsSupportedMediaMimeType("audio/mp4"));
EXPECT_FALSE(IsSupportedMediaMimeType("audio/x-m4a"));
EXPECT_FALSE(IsSupportedMediaMimeType("video/mp4"));
EXPECT_FALSE(IsSupportedMediaMimeType("video/x-m4v"));
EXPECT_FALSE(IsSupportedMediaMimeType("audio/mp3"));
EXPECT_FALSE(IsSupportedMediaMimeType("audio/x-mp3"));
EXPECT_FALSE(IsSupportedMediaMimeType("audio/mpeg"));
EXPECT_FALSE(IsSupportedMediaMimeType("audio/aac"));
#endif // USE_PROPRIETARY_CODECS
EXPECT_FALSE(IsSupportedMediaMimeType("video/mp3"));
EXPECT_FALSE(IsSupportedMediaMimeType("video/unknown"));
EXPECT_FALSE(IsSupportedMediaMimeType("audio/unknown"));
EXPECT_FALSE(IsSupportedMediaMimeType("unknown/unknown"));
}
// Note: codecs should only be a list of 2 or fewer; hence the restriction of
// results' length to 2.
TEST(MimeUtilTest, ParseCodecString) {
const struct {
const char* const original;
size_t expected_size;
const char* const results[2];
} tests[] = {
{ "\"bogus\"", 1, { "bogus" } },
{ "0", 1, { "0" } },
{ "avc1.42E01E, mp4a.40.2", 2, { "avc1", "mp4a" } },
{ "\"mp4v.20.240, mp4a.40.2\"", 2, { "mp4v", "mp4a" } },
{ "mp4v.20.8, samr", 2, { "mp4v", "samr" } },
{ "\"theora, vorbis\"", 2, { "theora", "vorbis" } },
{ "", 0, { } },
{ "\"\"", 0, { } },
{ "\" \"", 0, { } },
{ ",", 2, { "", "" } },
};
for (size_t i = 0; i < arraysize(tests); ++i) {
std::vector<std::string> codecs_out;
ParseCodecString(tests[i].original, &codecs_out, true);
ASSERT_EQ(tests[i].expected_size, codecs_out.size());
for (size_t j = 0; j < tests[i].expected_size; ++j)
EXPECT_EQ(tests[i].results[j], codecs_out[j]);
}
// Test without stripping the codec type.
std::vector<std::string> codecs_out;
ParseCodecString("avc1.42E01E, mp4a.40.2", &codecs_out, false);
ASSERT_EQ(2u, codecs_out.size());
EXPECT_EQ("avc1.42E01E", codecs_out[0]);
EXPECT_EQ("mp4a.40.2", codecs_out[1]);
}
} // namespace media
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
#include "media/base/cdm_config.h" #include "media/base/cdm_config.h"
#include "media/base/key_systems.h" #include "media/base/key_systems.h"
#include "media/base/media_permission.h" #include "media/base/media_permission.h"
#include "media/base/mime_util.h"
#include "media/blink/webmediaplayer_util.h" #include "media/blink/webmediaplayer_util.h"
#include "net/base/mime_util.h"
#include "third_party/WebKit/public/platform/WebMediaKeySystemConfiguration.h" #include "third_party/WebKit/public/platform/WebMediaKeySystemConfiguration.h"
#include "third_party/WebKit/public/platform/WebSecurityOrigin.h" #include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
#include "third_party/WebKit/public/platform/WebString.h" #include "third_party/WebKit/public/platform/WebString.h"
...@@ -284,7 +284,7 @@ bool KeySystemConfigSelector::IsSupportedContentType( ...@@ -284,7 +284,7 @@ bool KeySystemConfigSelector::IsSupportedContentType(
std::string container_lower = base::StringToLowerASCII(container_mime_type); std::string container_lower = base::StringToLowerASCII(container_mime_type);
// Check that |container_mime_type| is supported by Chrome. // Check that |container_mime_type| is supported by Chrome.
if (!net::IsSupportedMediaMimeType(container_lower)) if (!media::IsSupportedMediaMimeType(container_lower))
return false; return false;
// Check that |codecs| are supported by Chrome. This is done primarily to // Check that |codecs| are supported by Chrome. This is done primarily to
...@@ -292,10 +292,10 @@ bool KeySystemConfigSelector::IsSupportedContentType( ...@@ -292,10 +292,10 @@ bool KeySystemConfigSelector::IsSupportedContentType(
// codecs that Chrome does not (which could complicate the robustness // codecs that Chrome does not (which could complicate the robustness
// algorithm). // algorithm).
std::vector<std::string> codec_vector; std::vector<std::string> codec_vector;
net::ParseCodecString(codecs, &codec_vector, false); media::ParseCodecString(codecs, &codec_vector, false);
if (!codec_vector.empty() && if (!codec_vector.empty() &&
(net::IsSupportedStrictMediaMimeType(container_lower, codec_vector) != (media::IsSupportedStrictMediaMimeType(container_lower, codec_vector) !=
net::IsSupported)) { media::IsSupported)) {
return false; return false;
} }
...@@ -303,7 +303,7 @@ bool KeySystemConfigSelector::IsSupportedContentType( ...@@ -303,7 +303,7 @@ bool KeySystemConfigSelector::IsSupportedContentType(
// This check does not handle extended codecs, so extended codec information // This check does not handle extended codecs, so extended codec information
// is stripped (extended codec information was checked above). // is stripped (extended codec information was checked above).
std::vector<std::string> stripped_codec_vector; std::vector<std::string> stripped_codec_vector;
net::ParseCodecString(codecs, &stripped_codec_vector, true); media::ParseCodecString(codecs, &stripped_codec_vector, true);
EmeConfigRule codecs_rule = key_systems_->GetContentTypeConfigRule( EmeConfigRule codecs_rule = key_systems_->GetContentTypeConfigRule(
key_system, media_type, container_lower, stripped_codec_vector); key_system, media_type, container_lower, stripped_codec_vector);
if (!config_state->IsRuleSupported(codecs_rule)) if (!config_state->IsRuleSupported(codecs_rule))
......
...@@ -330,6 +330,8 @@ ...@@ -330,6 +330,8 @@
'base/media_switches.cc', 'base/media_switches.cc',
'base/media_switches.h', 'base/media_switches.h',
'base/media_win.cc', 'base/media_win.cc',
'base/mime_util.cc',
'base/mime_util.h',
'base/moving_average.cc', 'base/moving_average.cc',
'base/moving_average.h', 'base/moving_average.h',
'base/multi_channel_resampler.cc', 'base/multi_channel_resampler.cc',
...@@ -1141,6 +1143,7 @@ ...@@ -1141,6 +1143,7 @@
'base/key_systems_unittest.cc', 'base/key_systems_unittest.cc',
'base/mac/video_frame_mac_unittests.cc', 'base/mac/video_frame_mac_unittests.cc',
'base/media_file_checker_unittest.cc', 'base/media_file_checker_unittest.cc',
'base/mime_util_unittest.cc',
'base/moving_average_unittest.cc', 'base/moving_average_unittest.cc',
'base/multi_channel_resampler_unittest.cc', 'base/multi_channel_resampler_unittest.cc',
'base/null_video_sink_unittest.cc', 'base/null_video_sink_unittest.cc',
......
This diff is collapsed.
...@@ -50,9 +50,6 @@ NET_EXPORT bool GetPreferredExtensionForMimeType( ...@@ -50,9 +50,6 @@ NET_EXPORT bool GetPreferredExtensionForMimeType(
const std::string& mime_type, const std::string& mime_type,
base::FilePath::StringType* extension); base::FilePath::StringType* extension);
// Check to see if a particular MIME type is in our list.
NET_EXPORT bool IsSupportedMediaMimeType(const std::string& mime_type);
// Returns true if this the mime_type_pattern matches a given mime-type. // Returns true if this the mime_type_pattern matches a given mime-type.
// Checks for absolute matching and wildcards. MIME types are case insensitive. // Checks for absolute matching and wildcards. MIME types are case insensitive.
NET_EXPORT bool MatchesMimeType(const std::string& mime_type_pattern, NET_EXPORT bool MatchesMimeType(const std::string& mime_type_pattern,
...@@ -81,53 +78,6 @@ NET_EXPORT bool ParseMimeTypeWithoutParameter(const std::string& type_string, ...@@ -81,53 +78,6 @@ NET_EXPORT bool ParseMimeTypeWithoutParameter(const std::string& type_string,
// this method. // this method.
NET_EXPORT bool IsValidTopLevelMimeType(const std::string& type_string); NET_EXPORT bool IsValidTopLevelMimeType(const std::string& type_string);
// Returns true if and only if all codecs are supported, false otherwise.
NET_EXPORT bool AreSupportedMediaCodecs(const std::vector<std::string>& codecs);
// Parses a codec string, populating |codecs_out| with the prefix of each codec
// in the string |codecs_in|. For example, passed "aaa.b.c,dd.eee", if
// |strip| == true |codecs_out| will contain {"aaa", "dd"}, if |strip| == false
// |codecs_out| will contain {"aaa.b.c", "dd.eee"}.
// See http://www.ietf.org/rfc/rfc4281.txt.
NET_EXPORT void ParseCodecString(const std::string& codecs,
std::vector<std::string>* codecs_out,
bool strip);
// Check to see if a particular MIME type is in our list which only supports a
// certain subset of codecs.
NET_EXPORT bool IsStrictMediaMimeType(const std::string& mime_type);
// Indicates that the MIME type and (possible codec string) are supported by the
// underlying platform.
enum SupportsType {
// The underlying platform is known not to support the given MIME type and
// codec combination.
IsNotSupported,
// The underlying platform is known to support the given MIME type and codec
// combination.
IsSupported,
// The underlying platform is unsure whether the given MIME type and codec
// combination can be rendered or not before actually trying to play it.
MayBeSupported
};
// Checks the |mime_type| and |codecs| against the MIME types known to support
// only a particular subset of codecs.
// * Returns IsSupported if the |mime_type| is supported and all the codecs
// within the |codecs| are supported for the |mime_type|.
// * Returns MayBeSupported if the |mime_type| is supported and is known to
// support only a subset of codecs, but |codecs| was empty. Also returned if
// all the codecs in |codecs| are supported, but additional codec parameters
// were supplied (such as profile) for which the support cannot be decided.
// * Returns IsNotSupported if either the |mime_type| is not supported or the
// |mime_type| is supported but at least one of the codecs within |codecs| is
// not supported for the |mime_type|.
NET_EXPORT SupportsType IsSupportedStrictMediaMimeType(
const std::string& mime_type,
const std::vector<std::string>& codecs);
// Get the extensions associated with the given mime type. There could be // Get the extensions associated with the given mime type. There could be
// multiple extensions for a given mime type, like "html,htm" for "text/html", // multiple extensions for a given mime type, like "html,htm" for "text/html",
// or "txt,text,html,..." for "text/*". // or "txt,text,html,..." for "text/*".
...@@ -137,12 +87,6 @@ NET_EXPORT void GetExtensionsForMimeType( ...@@ -137,12 +87,6 @@ NET_EXPORT void GetExtensionsForMimeType(
const std::string& mime_type, const std::string& mime_type,
std::vector<base::FilePath::StringType>* extensions); std::vector<base::FilePath::StringType>* extensions);
// Test only method that removes proprietary media types and codecs from the
// list of supported MIME types and codecs. These types and codecs must be
// removed to ensure consistent layout test results across all Chromium
// variations.
NET_EXPORT void RemoveProprietaryMediaTypesAndCodecsForTests();
// A list of supported certificate-related mime types. // A list of supported certificate-related mime types.
// //
// A Java counterpart will be generated for this enum. // A Java counterpart will be generated for this enum.
......
...@@ -5,13 +5,10 @@ ...@@ -5,13 +5,10 @@
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/strings/string_split.h" #include "base/strings/string_split.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "net/base/mime_util.h" #include "net/base/mime_util.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#if defined(OS_ANDROID)
#include "base/android/build_info.h"
#endif
namespace net { namespace net {
TEST(MimeUtilTest, ExtensionTest) { TEST(MimeUtilTest, ExtensionTest) {
...@@ -69,45 +66,6 @@ TEST(MimeUtilTest, FileTest) { ...@@ -69,45 +66,6 @@ TEST(MimeUtilTest, FileTest) {
} }
} }
TEST(MimeUtilTest, LookupTypes) {
#if defined(OS_ANDROID)
EXPECT_TRUE(IsSupportedMediaMimeType("application/vnd.apple.mpegurl"));
EXPECT_TRUE(IsSupportedMediaMimeType("application/x-mpegurl"));
EXPECT_TRUE(IsSupportedMediaMimeType("Application/X-MPEGURL"));
#endif
}
TEST(MimeUtilTest, StrictMediaMimeType) {
EXPECT_TRUE(IsStrictMediaMimeType("video/webm"));
EXPECT_TRUE(IsStrictMediaMimeType("Video/WEBM"));
EXPECT_TRUE(IsStrictMediaMimeType("audio/webm"));
EXPECT_TRUE(IsStrictMediaMimeType("audio/wav"));
EXPECT_TRUE(IsStrictMediaMimeType("audio/x-wav"));
EXPECT_TRUE(IsStrictMediaMimeType("video/ogg"));
EXPECT_TRUE(IsStrictMediaMimeType("audio/ogg"));
EXPECT_TRUE(IsStrictMediaMimeType("application/ogg"));
EXPECT_TRUE(IsStrictMediaMimeType("audio/mpeg"));
EXPECT_TRUE(IsStrictMediaMimeType("audio/mp3"));
EXPECT_TRUE(IsStrictMediaMimeType("audio/x-mp3"));
EXPECT_TRUE(IsStrictMediaMimeType("video/mp4"));
EXPECT_TRUE(IsStrictMediaMimeType("video/x-m4v"));
EXPECT_TRUE(IsStrictMediaMimeType("audio/mp4"));
EXPECT_TRUE(IsStrictMediaMimeType("audio/x-m4a"));
EXPECT_TRUE(IsStrictMediaMimeType("application/x-mpegurl"));
EXPECT_TRUE(IsStrictMediaMimeType("application/vnd.apple.mpegurl"));
EXPECT_FALSE(IsStrictMediaMimeType("video/unknown"));
EXPECT_FALSE(IsStrictMediaMimeType("Video/UNKNOWN"));
EXPECT_FALSE(IsStrictMediaMimeType("audio/unknown"));
EXPECT_FALSE(IsStrictMediaMimeType("application/unknown"));
EXPECT_FALSE(IsStrictMediaMimeType("unknown/unknown"));
}
TEST(MimeUtilTest, MatchesMimeType) { TEST(MimeUtilTest, MatchesMimeType) {
// MIME types are case insensitive. // MIME types are case insensitive.
EXPECT_TRUE(MatchesMimeType("VIDEO/*", "video/x-mpeg")); EXPECT_TRUE(MatchesMimeType("VIDEO/*", "video/x-mpeg"));
...@@ -187,104 +145,6 @@ TEST(MimeUtilTest, MatchesMimeType) { ...@@ -187,104 +145,6 @@ TEST(MimeUtilTest, MatchesMimeType) {
EXPECT_TRUE(MatchesMimeType("ab/*cd", "ab/xxxcd")); EXPECT_TRUE(MatchesMimeType("ab/*cd", "ab/xxxcd"));
} }
TEST(MimeUtilTest, CommonMediaMimeType) {
#if defined(OS_ANDROID)
bool HLSSupported;
if (base::android::BuildInfo::GetInstance()->sdk_int() < 14)
HLSSupported = false;
else
HLSSupported = true;
#endif
EXPECT_TRUE(IsSupportedMediaMimeType("audio/webm"));
EXPECT_TRUE(IsSupportedMediaMimeType("video/webm"));
EXPECT_TRUE(IsSupportedMediaMimeType("audio/wav"));
EXPECT_TRUE(IsSupportedMediaMimeType("audio/x-wav"));
EXPECT_TRUE(IsSupportedMediaMimeType("audio/ogg"));
EXPECT_TRUE(IsSupportedMediaMimeType("application/ogg"));
#if defined(OS_ANDROID)
EXPECT_FALSE(IsSupportedMediaMimeType("video/ogg"));
EXPECT_EQ(HLSSupported, IsSupportedMediaMimeType("application/x-mpegurl"));
EXPECT_EQ(HLSSupported,
IsSupportedMediaMimeType("application/vnd.apple.mpegurl"));
#else
EXPECT_TRUE(IsSupportedMediaMimeType("video/ogg"));
EXPECT_FALSE(IsSupportedMediaMimeType("application/x-mpegurl"));
EXPECT_FALSE(IsSupportedMediaMimeType("application/vnd.apple.mpegurl"));
#endif // OS_ANDROID
#if defined(USE_PROPRIETARY_CODECS)
EXPECT_TRUE(IsSupportedMediaMimeType("audio/mp4"));
EXPECT_TRUE(IsSupportedMediaMimeType("audio/x-m4a"));
EXPECT_TRUE(IsSupportedMediaMimeType("video/mp4"));
EXPECT_TRUE(IsSupportedMediaMimeType("video/x-m4v"));
EXPECT_TRUE(IsSupportedMediaMimeType("audio/mp3"));
EXPECT_TRUE(IsSupportedMediaMimeType("audio/x-mp3"));
EXPECT_TRUE(IsSupportedMediaMimeType("audio/mpeg"));
EXPECT_TRUE(IsSupportedMediaMimeType("audio/aac"));
#if defined(ENABLE_MPEG2TS_STREAM_PARSER)
EXPECT_TRUE(IsSupportedMediaMimeType("video/mp2t"));
#else
EXPECT_FALSE(IsSupportedMediaMimeType("video/mp2t"));
#endif
#else
EXPECT_FALSE(IsSupportedMediaMimeType("audio/mp4"));
EXPECT_FALSE(IsSupportedMediaMimeType("audio/x-m4a"));
EXPECT_FALSE(IsSupportedMediaMimeType("video/mp4"));
EXPECT_FALSE(IsSupportedMediaMimeType("video/x-m4v"));
EXPECT_FALSE(IsSupportedMediaMimeType("audio/mp3"));
EXPECT_FALSE(IsSupportedMediaMimeType("audio/x-mp3"));
EXPECT_FALSE(IsSupportedMediaMimeType("audio/mpeg"));
EXPECT_FALSE(IsSupportedMediaMimeType("audio/aac"));
#endif // USE_PROPRIETARY_CODECS
EXPECT_FALSE(IsSupportedMediaMimeType("video/mp3"));
EXPECT_FALSE(IsSupportedMediaMimeType("video/unknown"));
EXPECT_FALSE(IsSupportedMediaMimeType("audio/unknown"));
EXPECT_FALSE(IsSupportedMediaMimeType("unknown/unknown"));
}
// Note: codecs should only be a list of 2 or fewer; hence the restriction of
// results' length to 2.
TEST(MimeUtilTest, ParseCodecString) {
const struct {
const char* const original;
size_t expected_size;
const char* const results[2];
} tests[] = {
{ "\"bogus\"", 1, { "bogus" } },
{ "0", 1, { "0" } },
{ "avc1.42E01E, mp4a.40.2", 2, { "avc1", "mp4a" } },
{ "\"mp4v.20.240, mp4a.40.2\"", 2, { "mp4v", "mp4a" } },
{ "mp4v.20.8, samr", 2, { "mp4v", "samr" } },
{ "\"theora, vorbis\"", 2, { "theora", "vorbis" } },
{ "", 0, { } },
{ "\"\"", 0, { } },
{ "\" \"", 0, { } },
{ ",", 2, { "", "" } },
};
for (size_t i = 0; i < arraysize(tests); ++i) {
std::vector<std::string> codecs_out;
ParseCodecString(tests[i].original, &codecs_out, true);
ASSERT_EQ(tests[i].expected_size, codecs_out.size());
for (size_t j = 0; j < tests[i].expected_size; ++j)
EXPECT_EQ(tests[i].results[j], codecs_out[j]);
}
// Test without stripping the codec type.
std::vector<std::string> codecs_out;
ParseCodecString("avc1.42E01E, mp4a.40.2", &codecs_out, false);
ASSERT_EQ(2u, codecs_out.size());
EXPECT_EQ("avc1.42E01E", codecs_out[0]);
EXPECT_EQ("mp4a.40.2", codecs_out[1]);
}
TEST(MimeUtilTest, TestParseMimeTypeWithoutParameter) { TEST(MimeUtilTest, TestParseMimeTypeWithoutParameter) {
std::string nonAscii("application/nonutf8"); std::string nonAscii("application/nonutf8");
EXPECT_TRUE(ParseMimeTypeWithoutParameter(nonAscii, NULL, NULL)); EXPECT_TRUE(ParseMimeTypeWithoutParameter(nonAscii, NULL, NULL));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment