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

Side by Side Diff: media/base/mime_util.cc

Issue 1539983004: Convert enable_mpeg2ts into a new-style buildflag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 11 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 unified diff | Download patch
« no previous file with comments | « media/BUILD.gn ('k') | media/base/mime_util_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 <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"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/string_split.h" 14 #include "base/strings/string_split.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "build/build_config.h" 16 #include "build/build_config.h"
17 #include "media/base/mime_util.h" 17 #include "media/base/mime_util.h"
18 #include "media/media_features.h"
18 19
19 #if defined(OS_ANDROID) 20 #if defined(OS_ANDROID)
20 #include "base/android/build_info.h" 21 #include "base/android/build_info.h"
21 #endif 22 #endif
22 23
23 namespace media { 24 namespace media {
24 25
25 // Singleton utility class for mime types. 26 // Singleton utility class for mime types.
26 class MimeUtil { 27 class MimeUtil {
27 public: 28 public:
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 #endif 249 #endif
249 #if defined(USE_PROPRIETARY_CODECS) 250 #if defined(USE_PROPRIETARY_CODECS)
250 {"audio/mpeg", PROPRIETARY, "mp3"}, 251 {"audio/mpeg", PROPRIETARY, "mp3"},
251 {"audio/mp3", PROPRIETARY, ""}, 252 {"audio/mp3", PROPRIETARY, ""},
252 {"audio/x-mp3", PROPRIETARY, ""}, 253 {"audio/x-mp3", PROPRIETARY, ""},
253 {"audio/aac", PROPRIETARY, ""}, // AAC / ADTS 254 {"audio/aac", PROPRIETARY, ""}, // AAC / ADTS
254 {"audio/mp4", PROPRIETARY, kMP4AudioCodecsExpression}, 255 {"audio/mp4", PROPRIETARY, kMP4AudioCodecsExpression},
255 {"audio/x-m4a", PROPRIETARY, kMP4AudioCodecsExpression}, 256 {"audio/x-m4a", PROPRIETARY, kMP4AudioCodecsExpression},
256 {"video/mp4", PROPRIETARY, kMP4VideoCodecsExpression}, 257 {"video/mp4", PROPRIETARY, kMP4VideoCodecsExpression},
257 {"video/x-m4v", PROPRIETARY, kMP4VideoCodecsExpression}, 258 {"video/x-m4v", PROPRIETARY, kMP4VideoCodecsExpression},
258 #if defined(ENABLE_MPEG2TS_STREAM_PARSER) 259 #if BUILDFLAG(ENABLE_MSE_MPEG2TS_STREAM_PARSER)
259 {"video/mp2t", PROPRIETARY, kMP4VideoCodecsExpression}, 260 {"video/mp2t", PROPRIETARY, kMP4VideoCodecsExpression},
260 #endif 261 #endif
261 #if defined(OS_ANDROID) 262 #if defined(OS_ANDROID)
262 // HTTP Live Streaming (HLS) 263 // HTTP Live Streaming (HLS)
263 {"application/x-mpegurl", PROPRIETARY, kMP4VideoCodecsExpression}, 264 {"application/x-mpegurl", PROPRIETARY, kMP4VideoCodecsExpression},
264 {"application/vnd.apple.mpegurl", PROPRIETARY, kMP4VideoCodecsExpression} 265 {"application/vnd.apple.mpegurl", PROPRIETARY, kMP4VideoCodecsExpression}
265 #endif 266 #endif
266 #endif // USE_PROPRIETARY_CODECS 267 #endif // USE_PROPRIETARY_CODECS
267 }; 268 };
268 269
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 // enough information to determine the codec and profile. 302 // enough information to determine the codec and profile.
302 // The codec in these entries indicate the codec and profile 303 // The codec in these entries indicate the codec and profile
303 // we assume the user is trying to indicate. 304 // we assume the user is trying to indicate.
304 static const CodecIDMappings kAmbiguousCodecStringMap[] = { 305 static const CodecIDMappings kAmbiguousCodecStringMap[] = {
305 {"mp4a.40", MimeUtil::MPEG4_AAC_LC}, 306 {"mp4a.40", MimeUtil::MPEG4_AAC_LC},
306 {"avc1", MimeUtil::H264_BASELINE}, 307 {"avc1", MimeUtil::H264_BASELINE},
307 {"avc3", MimeUtil::H264_BASELINE}, 308 {"avc3", MimeUtil::H264_BASELINE},
308 // avc1/avc3.XXXXXX may be ambiguous; handled by ParseH264CodecID(). 309 // avc1/avc3.XXXXXX may be ambiguous; handled by ParseH264CodecID().
309 }; 310 };
310 311
311 #if defined(ENABLE_MPEG2TS_STREAM_PARSER) 312 #if BUILDFLAG(ENABLE_MSE_MPEG2TS_STREAM_PARSER)
312 static const char kHexString[] = "0123456789ABCDEF"; 313 static const char kHexString[] = "0123456789ABCDEF";
313 static char IntToHex(int i) { 314 static char IntToHex(int i) {
314 DCHECK_GE(i, 0) << i << " not a hex value"; 315 DCHECK_GE(i, 0) << i << " not a hex value";
315 DCHECK_LE(i, 15) << i << " not a hex value"; 316 DCHECK_LE(i, 15) << i << " not a hex value";
316 return kHexString[i]; 317 return kHexString[i];
317 } 318 }
318 319
319 std::string TranslateLegacyAvc1CodecIds(const std::string& codec_id) { 320 std::string TranslateLegacyAvc1CodecIds(const std::string& codec_id) {
320 // Special handling for old, pre-RFC 6381 format avc1 strings, which are still 321 // Special handling for old, pre-RFC 6381 format avc1 strings, which are still
321 // being used by some HLS apps to preserve backward compatibility with older 322 // being used by some HLS apps to preserve backward compatibility with older
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 // but didn't get one. If |mime_type_lower_case| does not have a default 473 // but didn't get one. If |mime_type_lower_case| does not have a default
473 // codec the best we can do is say "maybe" because we don't have enough 474 // codec the best we can do is say "maybe" because we don't have enough
474 // information. 475 // information.
475 Codec default_codec = INVALID_CODEC; 476 Codec default_codec = INVALID_CODEC;
476 if (!GetDefaultCodecLowerCase(mime_type_lower_case, &default_codec)) 477 if (!GetDefaultCodecLowerCase(mime_type_lower_case, &default_codec))
477 return MayBeSupported; 478 return MayBeSupported;
478 479
479 return IsCodecSupported(default_codec) ? IsSupported : IsNotSupported; 480 return IsCodecSupported(default_codec) ? IsSupported : IsNotSupported;
480 } 481 }
481 482
482 #if defined(ENABLE_MPEG2TS_STREAM_PARSER) 483 #if BUILDFLAG(ENABLE_MSE_MPEG2TS_STREAM_PARSER)
483 if (mime_type_lower_case == "video/mp2t") { 484 if (mime_type_lower_case == "video/mp2t") {
484 std::vector<std::string> codecs_to_check; 485 std::vector<std::string> codecs_to_check;
485 for (const auto& codec_id : codecs) { 486 for (const auto& codec_id : codecs) {
486 codecs_to_check.push_back(TranslateLegacyAvc1CodecIds(codec_id)); 487 codecs_to_check.push_back(TranslateLegacyAvc1CodecIds(codec_id));
487 } 488 }
488 return AreSupportedCodecs(it_media_format_map->second, codecs_to_check); 489 return AreSupportedCodecs(it_media_format_map->second, codecs_to_check);
489 } 490 }
490 #endif 491 #endif
491 492
492 return AreSupportedCodecs(it_media_format_map->second, codecs); 493 return AreSupportedCodecs(it_media_format_map->second, codecs);
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 std::vector<std::string>* codecs_out, 700 std::vector<std::string>* codecs_out,
700 const bool strip) { 701 const bool strip) {
701 g_media_mime_util.Get().ParseCodecString(codecs, codecs_out, strip); 702 g_media_mime_util.Get().ParseCodecString(codecs, codecs_out, strip);
702 } 703 }
703 704
704 void RemoveProprietaryMediaTypesAndCodecsForTests() { 705 void RemoveProprietaryMediaTypesAndCodecsForTests() {
705 g_media_mime_util.Get().RemoveProprietaryMediaTypesAndCodecsForTests(); 706 g_media_mime_util.Get().RemoveProprietaryMediaTypesAndCodecsForTests();
706 } 707 }
707 708
708 } // namespace media 709 } // namespace media
OLDNEW
« no previous file with comments | « media/BUILD.gn ('k') | media/base/mime_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698