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

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

Issue 2362193003: Add FLAC audio codec support (Closed)
Patch Set: Created 4 years, 3 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/base/mime_util_internal.h ('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 "media/base/mime_util_internal.h" 5 #include "media/base/mime_util_internal.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/string_split.h" 9 #include "base/strings/string_split.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 15 matching lines...) Expand all
26 const char* const codec_id; 26 const char* const codec_id;
27 MimeUtil::Codec codec; 27 MimeUtil::Codec codec;
28 }; 28 };
29 29
30 // List of codec IDs that provide enough information to determine the 30 // List of codec IDs that provide enough information to determine the
31 // codec and profile being requested. 31 // codec and profile being requested.
32 // 32 //
33 // The "mp4a" strings come from RFC 6381. 33 // The "mp4a" strings come from RFC 6381.
34 static const CodecIDMappings kUnambiguousCodecStringMap[] = { 34 static const CodecIDMappings kUnambiguousCodecStringMap[] = {
35 {"1", MimeUtil::PCM}, // We only allow this for WAV so it isn't ambiguous. 35 {"1", MimeUtil::PCM}, // We only allow this for WAV so it isn't ambiguous.
36 {"flac", MimeUtil::FLAC},
36 // avc1/avc3.XXXXXX may be unambiguous; handled by ParseAVCCodecId(). 37 // avc1/avc3.XXXXXX may be unambiguous; handled by ParseAVCCodecId().
37 // hev1/hvc1.XXXXXX may be unambiguous; handled by ParseHEVCCodecID(). 38 // hev1/hvc1.XXXXXX may be unambiguous; handled by ParseHEVCCodecID().
38 // vp9, vp9.0, vp09.xx.xx.xx.xx.xx.xx.xx may be unambiguous; handled by 39 // vp9, vp9.0, vp09.xx.xx.xx.xx.xx.xx.xx may be unambiguous; handled by
39 // ParseVp9CodecID(). 40 // ParseVp9CodecID().
40 {"mp3", MimeUtil::MP3}, 41 {"mp3", MimeUtil::MP3},
41 // Following is the list of RFC 6381 compliant audio codec strings: 42 // Following is the list of RFC 6381 compliant audio codec strings:
42 // mp4a.66 - MPEG-2 AAC MAIN 43 // mp4a.66 - MPEG-2 AAC MAIN
43 // mp4a.67 - MPEG-2 AAC LC 44 // mp4a.67 - MPEG-2 AAC LC
44 // mp4a.68 - MPEG-2 AAC SSR 45 // mp4a.68 - MPEG-2 AAC SSR
45 // mp4a.69 - MPEG-2 extension to MPEG-1 (MP3) 46 // mp4a.69 - MPEG-2 extension to MPEG-1 (MP3)
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 360
360 CodecSet webm_audio_codecs; 361 CodecSet webm_audio_codecs;
361 webm_audio_codecs.insert(OPUS); 362 webm_audio_codecs.insert(OPUS);
362 webm_audio_codecs.insert(VORBIS); 363 webm_audio_codecs.insert(VORBIS);
363 CodecSet webm_video_codecs; 364 CodecSet webm_video_codecs;
364 webm_video_codecs.insert(VP8); 365 webm_video_codecs.insert(VP8);
365 webm_video_codecs.insert(VP9); 366 webm_video_codecs.insert(VP9);
366 CodecSet webm_codecs(webm_audio_codecs); 367 CodecSet webm_codecs(webm_audio_codecs);
367 webm_codecs.insert(webm_video_codecs.begin(), webm_video_codecs.end()); 368 webm_codecs.insert(webm_video_codecs.begin(), webm_video_codecs.end());
368 369
370 CodecSet flac_audio_codecs;
371 flac_audio_codecs.insert(FLAC);
372
369 #if defined(USE_PROPRIETARY_CODECS) 373 #if defined(USE_PROPRIETARY_CODECS)
370 CodecSet mp3_codecs; 374 CodecSet mp3_codecs;
371 mp3_codecs.insert(MP3); 375 mp3_codecs.insert(MP3);
372 376
373 CodecSet aac; 377 CodecSet aac;
374 aac.insert(MPEG2_AAC); 378 aac.insert(MPEG2_AAC);
375 aac.insert(MPEG4_AAC); 379 aac.insert(MPEG4_AAC);
376 380
377 CodecSet avc_and_aac(aac); 381 CodecSet avc_and_aac(aac);
378 avc_and_aac.insert(H264); 382 avc_and_aac.insert(H264);
(...skipping 23 matching lines...) Expand all
402 DCHECK(!webm_video_codecs.empty()); 406 DCHECK(!webm_video_codecs.empty());
403 AddContainerWithCodecs("video/webm", webm_codecs, false); 407 AddContainerWithCodecs("video/webm", webm_codecs, false);
404 AddContainerWithCodecs("audio/ogg", ogg_audio_codecs, false); 408 AddContainerWithCodecs("audio/ogg", ogg_audio_codecs, false);
405 // video/ogg is only supported if an appropriate video codec is supported. 409 // video/ogg is only supported if an appropriate video codec is supported.
406 // Note: This assumes such codecs cannot be later excluded. 410 // Note: This assumes such codecs cannot be later excluded.
407 if (!ogg_video_codecs.empty()) 411 if (!ogg_video_codecs.empty())
408 AddContainerWithCodecs("video/ogg", ogg_codecs, false); 412 AddContainerWithCodecs("video/ogg", ogg_codecs, false);
409 // TODO(ddorwin): Should the application type support Opus? 413 // TODO(ddorwin): Should the application type support Opus?
410 AddContainerWithCodecs("application/ogg", ogg_codecs, false); 414 AddContainerWithCodecs("application/ogg", ogg_codecs, false);
411 415
416 AddContainerWithCodecs("audio/flac", flac_audio_codecs, false);
417 AddContainerWithCodecs("audio/x-flac", flac_audio_codecs, false);
418 AddContainerWithCodecs("application/x-flac", flac_audio_codecs, false);
servolk 2016/09/23 22:17:15 Firefox supports all 3 mime types (https://reviewb
419
412 #if defined(USE_PROPRIETARY_CODECS) 420 #if defined(USE_PROPRIETARY_CODECS)
413 AddContainerWithCodecs("audio/mpeg", mp3_codecs, true); // Allow "mp3". 421 AddContainerWithCodecs("audio/mpeg", mp3_codecs, true); // Allow "mp3".
414 AddContainerWithCodecs("audio/mp3", implicit_codec, true); 422 AddContainerWithCodecs("audio/mp3", implicit_codec, true);
415 AddContainerWithCodecs("audio/x-mp3", implicit_codec, true); 423 AddContainerWithCodecs("audio/x-mp3", implicit_codec, true);
416 AddContainerWithCodecs("audio/aac", implicit_codec, true); // AAC / ADTS. 424 AddContainerWithCodecs("audio/aac", implicit_codec, true); // AAC / ADTS.
417 AddContainerWithCodecs("audio/mp4", mp4_audio_codecs, true); 425 AddContainerWithCodecs("audio/mp4", mp4_audio_codecs, true);
418 DCHECK(!mp4_video_codecs.empty()); 426 DCHECK(!mp4_video_codecs.empty());
419 AddContainerWithCodecs("video/mp4", mp4_codecs, true); 427 AddContainerWithCodecs("video/mp4", mp4_codecs, true);
420 // These strings are supported for backwards compatibility only and thus only 428 // These strings are supported for backwards compatibility only and thus only
421 // support the codecs needed for compatibility. 429 // support the codecs needed for compatibility.
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 case INVALID_CODEC: 563 case INVALID_CODEC:
556 case AC3: 564 case AC3:
557 case EAC3: 565 case EAC3:
558 case THEORA: 566 case THEORA:
559 return false; 567 return false;
560 568
561 // ---------------------------------------------------------------------- 569 // ----------------------------------------------------------------------
562 // The remaining codecs may be supported depending on platform abilities. 570 // The remaining codecs may be supported depending on platform abilities.
563 // ---------------------------------------------------------------------- 571 // ----------------------------------------------------------------------
564 572
573 case FLAC:
565 case PCM: 574 case PCM:
566 case MP3: 575 case MP3:
567 case MPEG4_AAC: 576 case MPEG4_AAC:
568 case VORBIS: 577 case VORBIS:
569 // These codecs are always supported; via a platform decoder (when used 578 // These codecs are always supported; via a platform decoder (when used
570 // with MSE/EME), a software decoder (the unified pipeline), or with 579 // with MSE/EME), a software decoder (the unified pipeline), or with
571 // MediaPlayer. 580 // MediaPlayer.
572 DCHECK(!is_encrypted || platform_info.has_platform_decoders); 581 DCHECK(!is_encrypted || platform_info.has_platform_decoders);
573 return true; 582 return true;
574 583
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 case INVALID_CODEC: 768 case INVALID_CODEC:
760 case AC3: 769 case AC3:
761 case EAC3: 770 case EAC3:
762 case MP3: 771 case MP3:
763 case MPEG2_AAC: 772 case MPEG2_AAC:
764 case MPEG4_AAC: 773 case MPEG4_AAC:
765 case H264: 774 case H264:
766 case HEVC: 775 case HEVC:
767 return true; 776 return true;
768 777
778 case FLAC:
769 case PCM: 779 case PCM:
770 case VORBIS: 780 case VORBIS:
771 case OPUS: 781 case OPUS:
772 case VP8: 782 case VP8:
773 case VP9: 783 case VP9:
774 case THEORA: 784 case THEORA:
775 return false; 785 return false;
776 } 786 }
777 787
778 return true; 788 return true;
(...skipping 20 matching lines...) Expand all
799 const std::string& mime_type_lower_case, 809 const std::string& mime_type_lower_case,
800 bool is_encrypted) const { 810 bool is_encrypted) const {
801 Codec default_codec = Codec::INVALID_CODEC; 811 Codec default_codec = Codec::INVALID_CODEC;
802 if (!GetDefaultCodecLowerCase(mime_type_lower_case, &default_codec)) 812 if (!GetDefaultCodecLowerCase(mime_type_lower_case, &default_codec))
803 return false; 813 return false;
804 return IsCodecSupported(default_codec, mime_type_lower_case, is_encrypted); 814 return IsCodecSupported(default_codec, mime_type_lower_case, is_encrypted);
805 } 815 }
806 816
807 } // namespace internal 817 } // namespace internal
808 } // namespace media 818 } // namespace media
OLDNEW
« no previous file with comments | « media/base/mime_util_internal.h ('k') | media/base/mime_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698