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

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: Buildfix 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
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 <map> 5 #include <map>
6 6
7 #include "base/containers/hash_tables.h" 7 #include "base/containers/hash_tables.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "media/base/mime_util.h" 13 #include "media/base/mime_util.h"
14 #include "media/media_features.h"
14 15
15 #if defined(OS_ANDROID) 16 #if defined(OS_ANDROID)
16 #include "base/android/build_info.h" 17 #include "base/android/build_info.h"
17 #endif 18 #endif
18 19
19 namespace media { 20 namespace media {
20 21
21 // Singleton utility class for mime types. 22 // Singleton utility class for mime types.
22 class MimeUtil { 23 class MimeUtil {
23 public: 24 public:
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 #endif 245 #endif
245 #if defined(USE_PROPRIETARY_CODECS) 246 #if defined(USE_PROPRIETARY_CODECS)
246 {"audio/mpeg", PROPRIETARY, "mp3"}, 247 {"audio/mpeg", PROPRIETARY, "mp3"},
247 {"audio/mp3", PROPRIETARY, ""}, 248 {"audio/mp3", PROPRIETARY, ""},
248 {"audio/x-mp3", PROPRIETARY, ""}, 249 {"audio/x-mp3", PROPRIETARY, ""},
249 {"audio/aac", PROPRIETARY, ""}, // AAC / ADTS 250 {"audio/aac", PROPRIETARY, ""}, // AAC / ADTS
250 {"audio/mp4", PROPRIETARY, kMP4AudioCodecsExpression}, 251 {"audio/mp4", PROPRIETARY, kMP4AudioCodecsExpression},
251 {"audio/x-m4a", PROPRIETARY, kMP4AudioCodecsExpression}, 252 {"audio/x-m4a", PROPRIETARY, kMP4AudioCodecsExpression},
252 {"video/mp4", PROPRIETARY, kMP4VideoCodecsExpression}, 253 {"video/mp4", PROPRIETARY, kMP4VideoCodecsExpression},
253 {"video/x-m4v", PROPRIETARY, kMP4VideoCodecsExpression}, 254 {"video/x-m4v", PROPRIETARY, kMP4VideoCodecsExpression},
254 #if defined(ENABLE_MPEG2TS_STREAM_PARSER) 255 #if BUILDFLAG(ENABLE_MSE_MPEG2TS_STREAM_PARSER)
255 {"video/mp2t", PROPRIETARY, kMP4VideoCodecsExpression}, 256 {"video/mp2t", PROPRIETARY, kMP4VideoCodecsExpression},
256 #endif 257 #endif
257 #if defined(OS_ANDROID) 258 #if defined(OS_ANDROID)
258 // HTTP Live Streaming (HLS) 259 // HTTP Live Streaming (HLS)
259 {"application/x-mpegurl", PROPRIETARY, kMP4VideoCodecsExpression}, 260 {"application/x-mpegurl", PROPRIETARY, kMP4VideoCodecsExpression},
260 {"application/vnd.apple.mpegurl", PROPRIETARY, kMP4VideoCodecsExpression} 261 {"application/vnd.apple.mpegurl", PROPRIETARY, kMP4VideoCodecsExpression}
261 #endif 262 #endif
262 #endif // USE_PROPRIETARY_CODECS 263 #endif // USE_PROPRIETARY_CODECS
263 }; 264 };
264 265
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 // enough information to determine the codec and profile. 298 // enough information to determine the codec and profile.
298 // The codec in these entries indicate the codec and profile 299 // The codec in these entries indicate the codec and profile
299 // we assume the user is trying to indicate. 300 // we assume the user is trying to indicate.
300 static const CodecIDMappings kAmbiguousCodecStringMap[] = { 301 static const CodecIDMappings kAmbiguousCodecStringMap[] = {
301 {"mp4a.40", MimeUtil::MPEG4_AAC_LC}, 302 {"mp4a.40", MimeUtil::MPEG4_AAC_LC},
302 {"avc1", MimeUtil::H264_BASELINE}, 303 {"avc1", MimeUtil::H264_BASELINE},
303 {"avc3", MimeUtil::H264_BASELINE}, 304 {"avc3", MimeUtil::H264_BASELINE},
304 // avc1/avc3.XXXXXX may be ambiguous; handled by ParseH264CodecID(). 305 // avc1/avc3.XXXXXX may be ambiguous; handled by ParseH264CodecID().
305 }; 306 };
306 307
307 #if defined(ENABLE_MPEG2TS_STREAM_PARSER) 308 #if BUILDFLAG(ENABLE_MSE_MPEG2TS_STREAM_PARSER)
308 static const char kHexString[] = "0123456789ABCDEF"; 309 static const char kHexString[] = "0123456789ABCDEF";
309 static char IntToHex(int i) { 310 static char IntToHex(int i) {
310 DCHECK_GE(i, 0) << i << " not a hex value"; 311 DCHECK_GE(i, 0) << i << " not a hex value";
311 DCHECK_LE(i, 15) << i << " not a hex value"; 312 DCHECK_LE(i, 15) << i << " not a hex value";
312 return kHexString[i]; 313 return kHexString[i];
313 } 314 }
314 315
315 std::string TranslateLegacyAvc1CodecIds(const std::string& codec_id) { 316 std::string TranslateLegacyAvc1CodecIds(const std::string& codec_id) {
316 // Special handling for old, pre-RFC 6381 format avc1 strings, which are still 317 // Special handling for old, pre-RFC 6381 format avc1 strings, which are still
317 // being used by some HLS apps to preserve backward compatibility with older 318 // being used by some HLS apps to preserve backward compatibility with older
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 // but didn't get one. If |mime_type_lower_case| does not have a default 469 // but didn't get one. If |mime_type_lower_case| does not have a default
469 // codec the best we can do is say "maybe" because we don't have enough 470 // codec the best we can do is say "maybe" because we don't have enough
470 // information. 471 // information.
471 Codec default_codec = INVALID_CODEC; 472 Codec default_codec = INVALID_CODEC;
472 if (!GetDefaultCodecLowerCase(mime_type_lower_case, &default_codec)) 473 if (!GetDefaultCodecLowerCase(mime_type_lower_case, &default_codec))
473 return MayBeSupported; 474 return MayBeSupported;
474 475
475 return IsCodecSupported(default_codec) ? IsSupported : IsNotSupported; 476 return IsCodecSupported(default_codec) ? IsSupported : IsNotSupported;
476 } 477 }
477 478
478 #if defined(ENABLE_MPEG2TS_STREAM_PARSER) 479 #if BUILDFLAG(ENABLE_MSE_MPEG2TS_STREAM_PARSER)
479 if (mime_type_lower_case == "video/mp2t") { 480 if (mime_type_lower_case == "video/mp2t") {
480 std::vector<std::string> codecs_to_check; 481 std::vector<std::string> codecs_to_check;
481 for (const auto& codec_id : codecs) { 482 for (const auto& codec_id : codecs) {
482 codecs_to_check.push_back(TranslateLegacyAvc1CodecIds(codec_id)); 483 codecs_to_check.push_back(TranslateLegacyAvc1CodecIds(codec_id));
483 } 484 }
484 return AreSupportedCodecs(it_media_format_map->second, codecs_to_check); 485 return AreSupportedCodecs(it_media_format_map->second, codecs_to_check);
485 } 486 }
486 #endif 487 #endif
487 488
488 return AreSupportedCodecs(it_media_format_map->second, codecs); 489 return AreSupportedCodecs(it_media_format_map->second, codecs);
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 std::vector<std::string>* codecs_out, 696 std::vector<std::string>* codecs_out,
696 const bool strip) { 697 const bool strip) {
697 g_media_mime_util.Get().ParseCodecString(codecs, codecs_out, strip); 698 g_media_mime_util.Get().ParseCodecString(codecs, codecs_out, strip);
698 } 699 }
699 700
700 void RemoveProprietaryMediaTypesAndCodecsForTests() { 701 void RemoveProprietaryMediaTypesAndCodecsForTests() {
701 g_media_mime_util.Get().RemoveProprietaryMediaTypesAndCodecsForTests(); 702 g_media_mime_util.Get().RemoveProprietaryMediaTypesAndCodecsForTests();
702 } 703 }
703 704
704 } // namespace media 705 } // namespace media
OLDNEW
« no previous file with comments | « media/BUILD.gn ('k') | media/base/mime_util_unittest.cc » ('j') | media/media.gyp » ('J')

Powered by Google App Engine
This is Rietveld 408576698