Bug 1303888 - Accept flac from the rust mp4parse demuxer. r=kinetik draft
authorRalph Giles <giles@mozilla.com>
Tue, 25 Oct 2016 16:42:12 -0700
changeset 429484 3259110b024236ce43ddffc7fb8ab19281bddc85
parent 429483 7bcf03b9894f99cd0b8cdf3f6fb75fd3d4ee6cab
child 429485 ae249bcd648729b0212fd976960ddd3cc58ab419
push id33593
push userbmo:giles@thaumas.net
push dateWed, 26 Oct 2016 02:31:05 +0000
reviewerskinetik
bugs1303888
milestone52.0a1
Bug 1303888 - Accept flac from the rust mp4parse demuxer. r=kinetik 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
@@ -240,17 +240,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) {
@@ -736,16 +737,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.
@@ -769,16 +771,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;