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

Unified Diff: net/base/mime_util.cc

Issue 812643005: Re-add AC3/EAC3 audio demuxing support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added browser tests for AC3/EAC3 Created 5 years, 10 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: net/base/mime_util.cc
diff --git a/net/base/mime_util.cc b/net/base/mime_util.cc
index e4901277c3f8c12e9207a83deddfeee0fa09ad71..d8a714c00cec2522ad7b6c89a93c1237a1a5ecfe 100644
--- a/net/base/mime_util.cc
+++ b/net/base/mime_util.cc
@@ -48,6 +48,11 @@ class MimeUtil : public PlatformMimeUtil {
VP8,
VP9,
THEORA
+#if defined(ENABLE_AC3_EAC3_AUDIO_DEMUXING)
+ ,
+ AC3,
+ EAC3
+#endif
};
bool GetMimeTypeFromExtension(const base::FilePath::StringType& ext,
@@ -472,6 +477,13 @@ static bool IsCodecSupportedOnAndroid(MimeUtil::Codec codec) {
// MPEG-2 variants of AAC are not supported on Android.
return false;
+#if defined(ENABLE_AC3_EAC3_AUDIO_DEMUXING)
+ case MimeUtil::AC3:
+ case MimeUtil::EAC3:
+ // TODO(servolk): Revisit this for AC3/EAC3 support on AndroidTV
+ return false;
+#endif
+
case MimeUtil::VP9:
// VP9 is supported only in KitKat+ (API Level 19).
return base::android::BuildInfo::GetInstance()->sdk_int() >= 19;
@@ -521,6 +533,11 @@ struct MediaFormatStrict {
// avc1.6400xx - H.264 High
static const char kMP4AudioCodecsExpression[] =
"mp4a.66,mp4a.67,mp4a.68,mp4a.69,mp4a.6B,mp4a.40.2,mp4a.40.02,mp4a.40.5,"
+#if defined(ENABLE_AC3_EAC3_AUDIO_DEMUXING)
+ "ac-3,ec-3," // Note: only one variant of eac codec string is sufficient
+ // here since these are converted into enums in
+ // InitializeMimeTypeMaps
+#endif
"mp4a.40.05,mp4a.40.29";
static const char kMP4VideoCodecsExpression[] =
// This is not a complete list of supported avc1 codecs. It is simply used
@@ -530,6 +547,11 @@ static const char kMP4VideoCodecsExpression[] =
// kUnambiguousCodecStringMap/kAmbiguousCodecStringMap should be the only
// mapping from strings to codecs. See crbug.com/461009.
"avc1.42E00A,avc1.4D400A,avc1.64000A,"
+#if defined(ENABLE_AC3_EAC3_AUDIO_DEMUXING)
+ "ac-3,ec-3," // Note: only one variant of eac codec string is sufficient
+ // here since these are converted into enums in
+ // InitializeMimeTypeMaps
+#endif
"mp4a.66,mp4a.67,mp4a.68,mp4a.69,mp4a.6B,mp4a.40.2,mp4a.40.02,mp4a.40.5,"
"mp4a.40.05,mp4a.40.29";
@@ -583,6 +605,12 @@ static const CodecIDMappings kUnambiguousCodecStringMap[] = {
{"mp4a.40.5", MimeUtil::MPEG4_AAC_SBR_v1},
{"mp4a.40.05", MimeUtil::MPEG4_AAC_SBR_v1},
{"mp4a.40.29", MimeUtil::MPEG4_AAC_SBR_PS_v2},
+#if defined(ENABLE_AC3_EAC3_AUDIO_DEMUXING)
+ {"ac-3", MimeUtil::AC3},
+ {"ec-3", MimeUtil::EAC3},
+ {"mp4a.a5", MimeUtil::AC3},
+ {"mp4a.a6", MimeUtil::EAC3},
+#endif
{"vorbis", MimeUtil::VORBIS},
{"opus", MimeUtil::OPUS},
{"vp8", MimeUtil::VP8},
@@ -908,6 +936,13 @@ void MimeUtil::ParseCodecString(const std::string& codecs,
for (std::vector<std::string>::iterator it = codecs_out->begin();
it != codecs_out->end();
++it) {
+#if defined(ENABLE_AC3_EAC3_AUDIO_DEMUXING)
+ // We need to know the codec subtype to properly support AC3/EAC3.
+ // Do not strip the first '.' for mp4a.a5 and mp4a.a6.
+ if (it->compare("mp4a.a5") == 0 || it->compare("mp4a.a6") == 0) {
+ continue;
+ }
+#endif
size_t found = it->find_first_of('.');
if (found != std::string::npos)
it->resize(found);
@@ -1084,6 +1119,10 @@ bool MimeUtil::IsCodecProprietary(Codec codec) const {
case H264_BASELINE:
case H264_MAIN:
case H264_HIGH:
+#if defined(ENABLE_AC3_EAC3_AUDIO_DEMUXING)
+ case AC3:
+ case EAC3:
+#endif
return true;
case PCM:
« content/browser/media/media_canplaytype_browsertest.cc ('K') | « media/test/data/bear-eac3-frag.mp4 ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698