Bug 1303888 - Accept flac from the rust mp4parse demuxer. r=kinetik,a=gchang
authorRalph Giles <giles@mozilla.com>
Tue, 25 Oct 2016 16:42:12 -0700
changeset 437352 9a64cd121744362855402a14c699769dcbad8771
parent 437351 3d39e45e752d48c6f649e98cae0ea75ffbf2daf2
child 437353 de0b86f887a0e67b13db75fe3032d2f4096d711d
push id35389
push userfelipc@gmail.com
push dateThu, 10 Nov 2016 19:57:46 +0000
reviewerskinetik, gchang
bugs1303888
milestone51.0a2
Bug 1303888 - Accept flac from the rust mp4parse demuxer. r=kinetik,a=gchang Recognize FLAC as an audio mimetype in MP4Metadata and prefer the rust demuxer for it. Stagefright does not support this. MozReview-Commit-ID: 7T4tCSCCNBk
media/libstagefright/binding/MP4Metadata.cpp
--- a/media/libstagefright/binding/MP4Metadata.cpp
+++ b/media/libstagefright/binding/MP4Metadata.cpp
@@ -234,17 +234,18 @@ bool MP4Metadata::ShouldPreferRust() con
   }
   // See if there's an Opus track.
   uint32_t numTracks = mRust->GetNumberTracks(TrackInfo::kAudioTrack);
   for (auto i = 0; i < numTracks; i++) {
     auto info = mRust->GetTrackInfo(TrackInfo::kAudioTrack, i);
     if (!info) {
       return false;
     }
-    if (info->mMimeType.EqualsASCII("audio/opus")) {
+    if (info->mMimeType.EqualsASCII("audio/opus") ||
+        info->mMimeType.EqualsASCII("audio/flac")) {
       return true;
     }
   }
 
   numTracks = mRust->GetNumberTracks(TrackInfo::kVideoTrack);
   for (auto i = 0; i < numTracks; i++) {
     auto info = mRust->GetTrackInfo(TrackInfo::kVideoTrack, i);
     if (!info) {
@@ -653,16 +654,17 @@ MP4MetadataRust::GetTrackInfo(mozilla::T
     return nullptr;
   }
 #ifdef DEBUG
   const char* codec_string = "unrecognized";
   switch (info.codec) {
     case MP4PARSE_CODEC_UNKNOWN: codec_string = "unknown"; break;
     case MP4PARSE_CODEC_AAC: codec_string = "aac"; break;
     case MP4PARSE_CODEC_OPUS: codec_string = "opus"; break;
+    case MP4PARSE_CODEC_FLAC: codec_string = "flac"; break;
     case MP4PARSE_CODEC_AVC: codec_string = "h.264"; break;
     case MP4PARSE_CODEC_VP9: codec_string = "vp9"; break;
   }
   MOZ_LOG(sLog, LogLevel::Debug, ("track codec %s (%u)\n",
         codec_string, info.codec));
 #endif
 
   // This specialization interface is crazy.
@@ -686,16 +688,18 @@ MP4MetadataRust::GetTrackInfo(mozilla::T
         uint16_t preskip =
           LittleEndian::readUint16(audio.codec_specific_config.data + 10);
         MOZ_LOG(sLog, LogLevel::Debug,
             ("Copying opus pre-skip value of %d as CodecDelay.",(int)preskip));
         OpusDataDecoder::AppendCodecDelay(track->mCodecSpecificConfig,
             mozilla::FramesToUsecs(preskip, 48000).value());
       } else if (info.codec == MP4PARSE_CODEC_AAC) {
         track->mMimeType = MEDIA_MIMETYPE_AUDIO_AAC;
+      } else if (info.codec == MP4PARSE_CODEC_FLAC) {
+        track->mMimeType = MEDIA_MIMETYPE_AUDIO_FLAC;
       }
       track->mCodecSpecificConfig->AppendElements(
           audio.codec_specific_config.data,
           audio.codec_specific_config.length);
       track->mRate = audio.sample_rate;
       track->mChannels = audio.channels;
       track->mBitDepth = audio.bit_depth;
       track->mDuration = info.duration;