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
--- 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;