Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
|
ddorwin
2016/02/24 22:44:33
Please rebase. Most of this code has moved.
| |
| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
| 11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 37 MPEG2_AAC_SSR, | 37 MPEG2_AAC_SSR, |
| 38 MPEG4_AAC_LC, | 38 MPEG4_AAC_LC, |
| 39 MPEG4_AAC_SBR_v1, | 39 MPEG4_AAC_SBR_v1, |
| 40 MPEG4_AAC_SBR_PS_v2, | 40 MPEG4_AAC_SBR_PS_v2, |
| 41 VORBIS, | 41 VORBIS, |
| 42 OPUS, | 42 OPUS, |
| 43 H264_BASELINE, | 43 H264_BASELINE, |
| 44 H264_MAIN, | 44 H264_MAIN, |
| 45 H264_HIGH, | 45 H264_HIGH, |
| 46 HEVC_MAIN, | 46 HEVC_MAIN, |
| 47 VP8, | 47 WEBM_VP8, |
|
ddorwin
2016/02/24 22:44:33
We may not need these anymore. We can now (after r
kqyang
2016/03/01 01:18:52
Removed and pass MIME type to StringToCodec instea
| |
| 48 VP9, | 48 WEBM_VP9, |
| 49 MPEG4_VP8, | |
|
ddorwin
2016/02/24 22:44:33
As discussed, unless there is a demand for VP8 in
kqyang
2016/03/01 01:18:52
Removed.
| |
| 50 MPEG4_VP9, | |
| 49 THEORA | 51 THEORA |
| 50 }; | 52 }; |
| 51 | 53 |
| 52 bool IsSupportedMediaMimeType(const std::string& mime_type) const; | 54 bool IsSupportedMediaMimeType(const std::string& mime_type) const; |
| 53 | 55 |
| 54 void ParseCodecString(const std::string& codecs, | 56 void ParseCodecString(const std::string& codecs, |
| 55 std::vector<std::string>* codecs_out, | 57 std::vector<std::string>* codecs_out, |
| 56 bool strip); | 58 bool strip); |
| 57 | 59 |
| 58 SupportsType IsSupportedMediaFormat( | 60 SupportsType IsSupportedMediaFormat( |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 | 146 |
| 145 case MimeUtil::PCM: | 147 case MimeUtil::PCM: |
| 146 case MimeUtil::MP3: | 148 case MimeUtil::MP3: |
| 147 case MimeUtil::MPEG4_AAC_LC: | 149 case MimeUtil::MPEG4_AAC_LC: |
| 148 case MimeUtil::MPEG4_AAC_SBR_v1: | 150 case MimeUtil::MPEG4_AAC_SBR_v1: |
| 149 case MimeUtil::MPEG4_AAC_SBR_PS_v2: | 151 case MimeUtil::MPEG4_AAC_SBR_PS_v2: |
| 150 case MimeUtil::VORBIS: | 152 case MimeUtil::VORBIS: |
| 151 case MimeUtil::H264_BASELINE: | 153 case MimeUtil::H264_BASELINE: |
| 152 case MimeUtil::H264_MAIN: | 154 case MimeUtil::H264_MAIN: |
| 153 case MimeUtil::H264_HIGH: | 155 case MimeUtil::H264_HIGH: |
| 154 case MimeUtil::VP8: | 156 case MimeUtil::WEBM_VP8: |
| 155 return true; | 157 return true; |
| 156 | 158 |
| 157 case MimeUtil::AC3: | 159 case MimeUtil::AC3: |
| 158 case MimeUtil::EAC3: | 160 case MimeUtil::EAC3: |
| 159 // TODO(servolk): Revisit this for AC3/EAC3 support on AndroidTV | 161 // TODO(servolk): Revisit this for AC3/EAC3 support on AndroidTV |
| 160 return false; | 162 return false; |
| 161 | 163 |
| 162 case MimeUtil::MPEG2_AAC_LC: | 164 case MimeUtil::MPEG2_AAC_LC: |
| 163 case MimeUtil::MPEG2_AAC_MAIN: | 165 case MimeUtil::MPEG2_AAC_MAIN: |
| 164 case MimeUtil::MPEG2_AAC_SSR: | 166 case MimeUtil::MPEG2_AAC_SSR: |
| 165 // MPEG-2 variants of AAC are not supported on Android. | 167 // MPEG-2 variants of AAC are not supported on Android. |
| 166 return false; | 168 return false; |
| 167 | 169 |
| 168 case MimeUtil::OPUS: | 170 case MimeUtil::OPUS: |
| 169 // Opus is supported only in Lollipop+ (API Level 21). | 171 // Opus is supported only in Lollipop+ (API Level 21). |
| 170 return base::android::BuildInfo::GetInstance()->sdk_int() >= 21; | 172 return base::android::BuildInfo::GetInstance()->sdk_int() >= 21; |
| 171 | 173 |
| 172 case MimeUtil::HEVC_MAIN: | 174 case MimeUtil::HEVC_MAIN: |
| 173 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) | 175 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) |
| 174 // HEVC/H.265 is supported in Lollipop+ (API Level 21), according to | 176 // HEVC/H.265 is supported in Lollipop+ (API Level 21), according to |
| 175 // http://developer.android.com/reference/android/media/MediaFormat.html | 177 // http://developer.android.com/reference/android/media/MediaFormat.html |
| 176 return base::android::BuildInfo::GetInstance()->sdk_int() >= 21; | 178 return base::android::BuildInfo::GetInstance()->sdk_int() >= 21; |
| 177 #else | 179 #else |
| 178 return false; | 180 return false; |
| 179 #endif | 181 #endif |
| 180 | 182 |
| 181 case MimeUtil::VP9: | 183 case MimeUtil::WEBM_VP9: |
| 182 // VP9 is supported only in KitKat+ (API Level 19). | 184 // VP9 is supported only in KitKat+ (API Level 19). |
| 183 return base::android::BuildInfo::GetInstance()->sdk_int() >= 19; | 185 return base::android::BuildInfo::GetInstance()->sdk_int() >= 19; |
| 184 | 186 |
| 185 case MimeUtil::THEORA: | 187 case MimeUtil::THEORA: |
| 186 return false; | 188 return false; |
| 189 | |
| 190 case MimeUtil::MPEG4_VP8: | |
| 191 case MimeUtil::MPEG4_VP9: | |
| 192 // TODO(kqyang): Verify if it is supported in Android. Return false for | |
|
ddorwin
2016/02/25 00:27:47
This will work with the unified pipeline (see new
| |
| 193 // now. | |
| 194 return false; | |
| 187 } | 195 } |
| 188 | 196 |
| 189 return false; | 197 return false; |
| 190 } | 198 } |
| 191 #endif | 199 #endif |
| 192 | 200 |
| 193 enum MediaFormatType { COMMON, PROPRIETARY }; | 201 enum MediaFormatType { COMMON, PROPRIETARY }; |
| 194 | 202 |
| 195 struct MediaFormat { | 203 struct MediaFormat { |
| 196 const char* const mime_type; | 204 const char* const mime_type; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 208 // mp4a.40.2 - MPEG-4 AAC LC | 216 // mp4a.40.2 - MPEG-4 AAC LC |
| 209 // mp4a.40.02 - MPEG-4 AAC LC (leading 0 in aud-oti for compatibility) | 217 // mp4a.40.02 - MPEG-4 AAC LC (leading 0 in aud-oti for compatibility) |
| 210 // mp4a.40.5 - MPEG-4 HE-AAC v1 (AAC LC + SBR) | 218 // mp4a.40.5 - MPEG-4 HE-AAC v1 (AAC LC + SBR) |
| 211 // mp4a.40.05 - MPEG-4 HE-AAC v1 (AAC LC + SBR) (leading 0 in aud-oti for | 219 // mp4a.40.05 - MPEG-4 HE-AAC v1 (AAC LC + SBR) (leading 0 in aud-oti for |
| 212 // compatibility) | 220 // compatibility) |
| 213 // mp4a.40.29 - MPEG-4 HE-AAC v2 (AAC LC + SBR + PS) | 221 // mp4a.40.29 - MPEG-4 HE-AAC v2 (AAC LC + SBR + PS) |
| 214 // | 222 // |
| 215 // avc1.42E0xx - H.264 Baseline | 223 // avc1.42E0xx - H.264 Baseline |
| 216 // avc1.4D40xx - H.264 Main | 224 // avc1.4D40xx - H.264 Main |
| 217 // avc1.6400xx - H.264 High | 225 // avc1.6400xx - H.264 High |
| 226 // vp08.... - MPEG4 VP8 | |
| 227 // vp09.... - MPEG4 VP9 | |
| 218 static const char kMP4AudioCodecsExpression[] = | 228 static const char kMP4AudioCodecsExpression[] = |
| 219 "mp4a.66,mp4a.67,mp4a.68,mp4a.69,mp4a.6B,mp4a.40.2,mp4a.40.02,mp4a.40.5," | 229 "mp4a.66,mp4a.67,mp4a.68,mp4a.69,mp4a.6B,mp4a.40.2,mp4a.40.02,mp4a.40.5," |
| 220 #if BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING) | 230 #if BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING) |
| 221 // Only one variant each of ac3 and eac3 codec string is sufficient here, | 231 // Only one variant each of ac3 and eac3 codec string is sufficient here, |
| 222 // since these strings are parsed and mapped to MimeUtil::Codec enum values. | 232 // since these strings are parsed and mapped to MimeUtil::Codec enum values. |
| 223 "ac-3,ec-3," | 233 "ac-3,ec-3," |
| 224 #endif | 234 #endif |
| 225 "mp4a.40.05,mp4a.40.29"; | 235 "mp4a.40.05,mp4a.40.29"; |
| 226 static const char kMP4VideoCodecsExpression[] = | 236 static const char kMP4VideoCodecsExpression[] = |
| 227 // This is not a complete list of supported avc1 codecs. It is simply used | 237 // This is not a complete list of supported avc1 codecs. It is simply used |
| 228 // to register support for the corresponding Codec enum. Instead of using | 238 // to register support for the corresponding Codec enum. Instead of using |
| 229 // strings in these three arrays, we should use the Codec enum values. | 239 // strings in these three arrays, we should use the Codec enum values. |
| 230 // This will avoid confusion and unnecessary parsing at runtime. | 240 // This will avoid confusion and unnecessary parsing at runtime. |
| 231 // kUnambiguousCodecStringMap/kAmbiguousCodecStringMap should be the only | 241 // kUnambiguousCodecStringMap/kAmbiguousCodecStringMap should be the only |
| 232 // mapping from strings to codecs. See crbug.com/461009. | 242 // mapping from strings to codecs. See crbug.com/461009. |
| 233 "avc1.42E00A,avc1.4D400A,avc1.64000A," | 243 "avc1.42E00A,avc1.4D400A,avc1.64000A," |
| 234 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) | 244 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) |
| 235 // Any valid unambiguous HEVC codec id will work here, since these strings | 245 // Any valid unambiguous HEVC codec id will work here, since these strings |
| 236 // are parsed and mapped to MimeUtil::Codec enum values. | 246 // are parsed and mapped to MimeUtil::Codec enum values. |
| 237 "hev1.1.6.L93.B0," | 247 "hev1.1.6.L93.B0," |
| 238 #endif | 248 #endif |
| 239 "mp4a.66,mp4a.67,mp4a.68,mp4a.69,mp4a.6B,mp4a.40.2,mp4a.40.02,mp4a.40.5," | |
| 240 #if BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING) | 249 #if BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING) |
| 241 // Only one variant each of ac3 and eac3 codec string is sufficient here, | 250 // Only one variant each of ac3 and eac3 codec string is sufficient here, |
| 242 // since these strings are parsed and mapped to MimeUtil::Codec enum values. | 251 // since these strings are parsed and mapped to MimeUtil::Codec enum values. |
| 243 "ac-3,ec-3," | 252 "ac-3,ec-3," |
| 244 #endif | 253 #endif |
| 254 #if BUILDFLAG(ENABLE_MP4_VP8_VP9_DEMUXING) | |
| 255 // This is not a complete list of supported vpx codecs. Similar to avc1 | |
| 256 // comments above. | |
| 257 "vp08.00.00.08.01.01.00.00,vp09.00.00.08.00.01.00.00," | |
| 258 #endif | |
| 259 "mp4a.66,mp4a.67,mp4a.68,mp4a.69,mp4a.6B,mp4a.40.2,mp4a.40.02,mp4a.40.5," | |
| 245 "mp4a.40.05,mp4a.40.29"; | 260 "mp4a.40.05,mp4a.40.29"; |
| 246 #endif // USE_PROPRIETARY_CODECS | 261 #endif // USE_PROPRIETARY_CODECS |
| 247 | 262 |
| 248 // A list of media types (https://en.wikipedia.org/wiki/Media_type) and | 263 // A list of media types (https://en.wikipedia.org/wiki/Media_type) and |
| 249 // corresponding media codecs supported by these types/containers. | 264 // corresponding media codecs supported by these types/containers. |
| 250 // Media formats marked as PROPRIETARY are not supported by Chromium, only | 265 // Media formats marked as PROPRIETARY are not supported by Chromium, only |
| 251 // Google Chrome browser supports them. | 266 // Google Chrome browser supports them. |
| 252 static const MediaFormat kFormatCodecMappings[] = { | 267 static const MediaFormat kFormatCodecMappings[] = { |
| 253 {"video/webm", COMMON, "opus,vorbis,vp8,vp8.0,vp9,vp9.0"}, | 268 {"video/webm", COMMON, "opus,vorbis,vp8,vp8.0,vp9,vp9.0"}, |
| 254 {"audio/webm", COMMON, "opus,vorbis"}, | 269 {"audio/webm", COMMON, "opus,vorbis"}, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 290 }; | 305 }; |
| 291 | 306 |
| 292 // List of codec IDs that provide enough information to determine the | 307 // List of codec IDs that provide enough information to determine the |
| 293 // codec and profile being requested. | 308 // codec and profile being requested. |
| 294 // | 309 // |
| 295 // The "mp4a" strings come from RFC 6381. | 310 // The "mp4a" strings come from RFC 6381. |
| 296 static const CodecIDMappings kUnambiguousCodecStringMap[] = { | 311 static const CodecIDMappings kUnambiguousCodecStringMap[] = { |
| 297 {"1", MimeUtil::PCM}, // We only allow this for WAV so it isn't ambiguous. | 312 {"1", MimeUtil::PCM}, // We only allow this for WAV so it isn't ambiguous. |
| 298 // avc1/avc3.XXXXXX may be unambiguous; handled by ParseH264CodecID(). | 313 // avc1/avc3.XXXXXX may be unambiguous; handled by ParseH264CodecID(). |
| 299 // hev1/hvc1.XXXXXX may be unambiguous; handled by ParseHEVCCodecID(). | 314 // hev1/hvc1.XXXXXX may be unambiguous; handled by ParseHEVCCodecID(). |
| 315 // vp08/vp09.xx.xx.xx.xx.xx.xx.xx may be unambiguous; handled by | |
| 316 // ParseVpxCodecID(). | |
| 300 {"mp3", MimeUtil::MP3}, | 317 {"mp3", MimeUtil::MP3}, |
| 301 {"mp4a.66", MimeUtil::MPEG2_AAC_MAIN}, | 318 {"mp4a.66", MimeUtil::MPEG2_AAC_MAIN}, |
| 302 {"mp4a.67", MimeUtil::MPEG2_AAC_LC}, | 319 {"mp4a.67", MimeUtil::MPEG2_AAC_LC}, |
| 303 {"mp4a.68", MimeUtil::MPEG2_AAC_SSR}, | 320 {"mp4a.68", MimeUtil::MPEG2_AAC_SSR}, |
| 304 {"mp4a.69", MimeUtil::MP3}, | 321 {"mp4a.69", MimeUtil::MP3}, |
| 305 {"mp4a.6B", MimeUtil::MP3}, | 322 {"mp4a.6B", MimeUtil::MP3}, |
| 306 {"mp4a.40.2", MimeUtil::MPEG4_AAC_LC}, | 323 {"mp4a.40.2", MimeUtil::MPEG4_AAC_LC}, |
| 307 {"mp4a.40.02", MimeUtil::MPEG4_AAC_LC}, | 324 {"mp4a.40.02", MimeUtil::MPEG4_AAC_LC}, |
| 308 {"mp4a.40.5", MimeUtil::MPEG4_AAC_SBR_v1}, | 325 {"mp4a.40.5", MimeUtil::MPEG4_AAC_SBR_v1}, |
| 309 {"mp4a.40.05", MimeUtil::MPEG4_AAC_SBR_v1}, | 326 {"mp4a.40.05", MimeUtil::MPEG4_AAC_SBR_v1}, |
| 310 {"mp4a.40.29", MimeUtil::MPEG4_AAC_SBR_PS_v2}, | 327 {"mp4a.40.29", MimeUtil::MPEG4_AAC_SBR_PS_v2}, |
| 311 #if BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING) | 328 #if BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING) |
| 312 // TODO(servolk): Strictly speaking only mp4a.A5 and mp4a.A6 codec ids are | 329 // TODO(servolk): Strictly speaking only mp4a.A5 and mp4a.A6 codec ids are |
| 313 // valid according to RFC 6381 section 3.3, 3.4. Lower-case oti (mp4a.a5 and | 330 // valid according to RFC 6381 section 3.3, 3.4. Lower-case oti (mp4a.a5 and |
| 314 // mp4a.a6) should be rejected. But we used to allow those in older versions | 331 // mp4a.a6) should be rejected. But we used to allow those in older versions |
| 315 // of Chromecast firmware and some apps (notably MPL) depend on those codec | 332 // of Chromecast firmware and some apps (notably MPL) depend on those codec |
| 316 // types being supported, so they should be allowed for now | 333 // types being supported, so they should be allowed for now |
| 317 // (crbug.com/564960). | 334 // (crbug.com/564960). |
| 318 {"ac-3", MimeUtil::AC3}, | 335 {"ac-3", MimeUtil::AC3}, |
| 319 {"mp4a.a5", MimeUtil::AC3}, | 336 {"mp4a.a5", MimeUtil::AC3}, |
| 320 {"mp4a.A5", MimeUtil::AC3}, | 337 {"mp4a.A5", MimeUtil::AC3}, |
| 321 {"ec-3", MimeUtil::EAC3}, | 338 {"ec-3", MimeUtil::EAC3}, |
| 322 {"mp4a.a6", MimeUtil::EAC3}, | 339 {"mp4a.a6", MimeUtil::EAC3}, |
| 323 {"mp4a.A6", MimeUtil::EAC3}, | 340 {"mp4a.A6", MimeUtil::EAC3}, |
| 324 #endif | 341 #endif |
| 325 {"vorbis", MimeUtil::VORBIS}, | 342 {"vorbis", MimeUtil::VORBIS}, |
| 326 {"opus", MimeUtil::OPUS}, | 343 {"opus", MimeUtil::OPUS}, |
| 327 {"vp8", MimeUtil::VP8}, | 344 {"vp8", MimeUtil::WEBM_VP8}, |
| 328 {"vp8.0", MimeUtil::VP8}, | 345 {"vp8.0", MimeUtil::WEBM_VP8}, |
| 329 {"vp9", MimeUtil::VP9}, | 346 {"vp9", MimeUtil::WEBM_VP9}, |
| 330 {"vp9.0", MimeUtil::VP9}, | 347 {"vp9.0", MimeUtil::WEBM_VP9}, |
| 331 {"theora", MimeUtil::THEORA}}; | 348 {"theora", MimeUtil::THEORA}}; |
| 332 | 349 |
| 333 // List of codec IDs that are ambiguous and don't provide | 350 // List of codec IDs that are ambiguous and don't provide |
| 334 // enough information to determine the codec and profile. | 351 // enough information to determine the codec and profile. |
| 335 // The codec in these entries indicate the codec and profile | 352 // The codec in these entries indicate the codec and profile |
| 336 // we assume the user is trying to indicate. | 353 // we assume the user is trying to indicate. |
| 337 static const CodecIDMappings kAmbiguousCodecStringMap[] = { | 354 static const CodecIDMappings kAmbiguousCodecStringMap[] = { |
| 338 {"mp4a.40", MimeUtil::MPEG4_AAC_LC}, | 355 {"mp4a.40", MimeUtil::MPEG4_AAC_LC}, |
| 339 {"avc1", MimeUtil::H264_BASELINE}, | 356 {"avc1", MimeUtil::H264_BASELINE}, |
| 340 {"avc3", MimeUtil::H264_BASELINE}, | 357 {"avc3", MimeUtil::H264_BASELINE}, |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 626 *is_ambiguous = false; | 643 *is_ambiguous = false; |
| 627 } | 644 } |
| 628 | 645 |
| 629 return true; | 646 return true; |
| 630 } | 647 } |
| 631 | 648 |
| 632 return false; | 649 return false; |
| 633 } | 650 } |
| 634 #endif | 651 #endif |
| 635 | 652 |
| 653 #if BUILDFLAG(ENABLE_MP4_VP8_VP9_DEMUXING) | |
| 654 // Handle parsing of vpx codec IDs. | |
| 655 static bool ParseVpxCodecID(const std::string& codec_id, | |
| 656 MimeUtil::Codec* codec, | |
| 657 bool* is_ambiguous) { | |
| 658 std::vector<std::string> fields = base::SplitString( | |
| 659 codec_id, ".", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL); | |
| 660 if (fields.size() < 1) | |
| 661 return false; | |
| 662 | |
| 663 if (fields[0] == "vp08") { | |
| 664 *codec = MimeUtil::MPEG4_VP8; | |
| 665 } else if (fields[0] == "vp09") { | |
| 666 *codec = MimeUtil::MPEG4_VP9; | |
| 667 } else { | |
| 668 return false; | |
| 669 } | |
| 670 | |
| 671 if (fields.size() > 8) | |
| 672 return false; | |
| 673 | |
| 674 std::vector<int> values; | |
| 675 for (size_t i = 1; i < fields.size(); ++i) { | |
| 676 // Missing value is not allowed. | |
| 677 if (fields[i] == "") | |
| 678 return false; | |
| 679 int value; | |
| 680 if (!base::StringToInt(fields[i], &value)) | |
| 681 return false; | |
| 682 if (value < 0) | |
| 683 return false; | |
| 684 values.push_back(value); | |
| 685 } | |
| 686 | |
| 687 // The spec specifies 8 fields (7 values excluding the first codec field). | |
| 688 // We do not allow missing fields. | |
| 689 if (values.size() < 7) | |
| 690 return false; | |
| 691 | |
| 692 const int profile = values[0]; | |
| 693 if (profile > 3) | |
| 694 return false; | |
| 695 | |
| 696 const int bit_depth = values[2]; | |
| 697 if (bit_depth != 8 && bit_depth != 10 && bit_depth != 12) | |
| 698 return false; | |
| 699 | |
| 700 const int color_space = values[3]; | |
| 701 if (color_space > 7) | |
| 702 return false; | |
| 703 | |
| 704 const int chroma_subsampling = values[4]; | |
| 705 if (chroma_subsampling > 3) | |
| 706 return false; | |
| 707 | |
| 708 const int transfer_function = values[5]; | |
| 709 if (transfer_function > 1) | |
| 710 return false; | |
| 711 | |
| 712 const int video_full_range_flag = values[6]; | |
| 713 if (video_full_range_flag > 1) | |
| 714 return false; | |
| 715 | |
| 716 *is_ambiguous = false; | |
| 717 return true; | |
| 718 } | |
| 719 #endif | |
| 720 | |
| 636 bool MimeUtil::StringToCodec(const std::string& codec_id, | 721 bool MimeUtil::StringToCodec(const std::string& codec_id, |
| 637 Codec* codec, | 722 Codec* codec, |
| 638 bool* is_ambiguous) const { | 723 bool* is_ambiguous) const { |
| 639 StringToCodecMappings::const_iterator itr = | 724 StringToCodecMappings::const_iterator itr = |
| 640 string_to_codec_map_.find(codec_id); | 725 string_to_codec_map_.find(codec_id); |
| 641 if (itr != string_to_codec_map_.end()) { | 726 if (itr != string_to_codec_map_.end()) { |
| 642 *codec = itr->second.codec; | 727 *codec = itr->second.codec; |
| 643 *is_ambiguous = itr->second.is_ambiguous; | 728 *is_ambiguous = itr->second.is_ambiguous; |
| 644 return true; | 729 return true; |
| 645 } | 730 } |
| 646 | 731 |
| 647 // If |codec_id| is not in |string_to_codec_map_|, then we assume that it is | 732 // If |codec_id| is not in |string_to_codec_map_|, then we assume that it is |
| 648 // either H.264 or HEVC/H.265 codec ID because currently those are the only | 733 // either H.264, HEVC/H.265, VP8 or VP9 codec ID because currently those are |
| 649 // ones that are not added to the |string_to_codec_map_| and require parsing. | 734 // the only ones that are not added to the |string_to_codec_map_| and require |
| 735 // parsing. | |
| 650 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) | 736 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) |
| 651 if (ParseHEVCCodecID(codec_id, codec, is_ambiguous)) { | 737 if (ParseHEVCCodecID(codec_id, codec, is_ambiguous)) { |
| 652 return true; | 738 return true; |
| 653 } | 739 } |
| 654 #endif | 740 #endif |
| 655 return ParseH264CodecID(codec_id, codec, is_ambiguous); | 741 if (ParseH264CodecID(codec_id, codec, is_ambiguous)) { |
| 742 return true; | |
| 743 } | |
| 744 #if BUILDFLAG(ENABLE_MP4_VP8_VP9_DEMUXING) | |
| 745 if (ParseVpxCodecID(codec_id, codec, is_ambiguous)) { | |
| 746 return true; | |
| 747 } | |
| 748 #endif | |
| 749 return false; | |
| 656 } | 750 } |
| 657 | 751 |
| 658 bool MimeUtil::IsCodecSupported(Codec codec) const { | 752 bool MimeUtil::IsCodecSupported(Codec codec) const { |
| 659 DCHECK_NE(codec, INVALID_CODEC); | 753 DCHECK_NE(codec, INVALID_CODEC); |
| 660 | 754 |
| 661 #if defined(OS_ANDROID) | 755 #if defined(OS_ANDROID) |
| 662 if (!IsCodecSupportedOnAndroid(codec)) | 756 if (!IsCodecSupportedOnAndroid(codec)) |
| 663 return false; | 757 return false; |
| 664 #endif | 758 #endif |
| 665 | 759 |
| 666 return allow_proprietary_codecs_ || !IsCodecProprietary(codec); | 760 return allow_proprietary_codecs_ || !IsCodecProprietary(codec); |
| 667 } | 761 } |
| 668 | 762 |
| 669 bool MimeUtil::IsCodecProprietary(Codec codec) const { | 763 bool MimeUtil::IsCodecProprietary(Codec codec) const { |
| 670 switch (codec) { | 764 switch (codec) { |
| 671 case INVALID_CODEC: | 765 case INVALID_CODEC: |
| 672 case AC3: | 766 case AC3: |
| 673 case EAC3: | 767 case EAC3: |
| 674 case MP3: | 768 case MP3: |
| 675 case MPEG2_AAC_LC: | 769 case MPEG2_AAC_LC: |
| 676 case MPEG2_AAC_MAIN: | 770 case MPEG2_AAC_MAIN: |
| 677 case MPEG2_AAC_SSR: | 771 case MPEG2_AAC_SSR: |
| 678 case MPEG4_AAC_LC: | 772 case MPEG4_AAC_LC: |
| 679 case MPEG4_AAC_SBR_v1: | 773 case MPEG4_AAC_SBR_v1: |
| 680 case MPEG4_AAC_SBR_PS_v2: | 774 case MPEG4_AAC_SBR_PS_v2: |
| 681 case H264_BASELINE: | 775 case H264_BASELINE: |
| 682 case H264_MAIN: | 776 case H264_MAIN: |
| 683 case H264_HIGH: | 777 case H264_HIGH: |
| 684 case HEVC_MAIN: | 778 case HEVC_MAIN: |
| 779 case MPEG4_VP8: | |
|
ddorwin
2016/02/24 22:44:33
These codecs aren't actually proprietary. Really,
kqyang
2016/03/01 01:18:52
Removed.
| |
| 780 case MPEG4_VP9: | |
| 685 return true; | 781 return true; |
| 686 | 782 |
| 687 case PCM: | 783 case PCM: |
| 688 case VORBIS: | 784 case VORBIS: |
| 689 case OPUS: | 785 case OPUS: |
| 690 case VP8: | 786 case WEBM_VP8: |
| 691 case VP9: | 787 case WEBM_VP9: |
| 692 case THEORA: | 788 case THEORA: |
| 693 return false; | 789 return false; |
| 694 } | 790 } |
| 695 | 791 |
| 696 return true; | 792 return true; |
| 697 } | 793 } |
| 698 | 794 |
| 699 bool MimeUtil::GetDefaultCodecLowerCase(const std::string& mime_type_lower_case, | 795 bool MimeUtil::GetDefaultCodecLowerCase(const std::string& mime_type_lower_case, |
| 700 Codec* default_codec) const { | 796 Codec* default_codec) const { |
| 701 if (mime_type_lower_case == "audio/mpeg" || | 797 if (mime_type_lower_case == "audio/mpeg" || |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 734 std::vector<std::string>* codecs_out, | 830 std::vector<std::string>* codecs_out, |
| 735 const bool strip) { | 831 const bool strip) { |
| 736 g_media_mime_util.Get().ParseCodecString(codecs, codecs_out, strip); | 832 g_media_mime_util.Get().ParseCodecString(codecs, codecs_out, strip); |
| 737 } | 833 } |
| 738 | 834 |
| 739 void RemoveProprietaryMediaTypesAndCodecsForTests() { | 835 void RemoveProprietaryMediaTypesAndCodecsForTests() { |
| 740 g_media_mime_util.Get().RemoveProprietaryMediaTypesAndCodecsForTests(); | 836 g_media_mime_util.Get().RemoveProprietaryMediaTypesAndCodecsForTests(); |
| 741 } | 837 } |
| 742 | 838 |
| 743 } // namespace media | 839 } // namespace media |
| OLD | NEW |