зеркало из https://github.com/mozilla/gecko-dev.git
Bug 943721 - Make MP4Reader restrict its codecs output to H.264 and AAC. r=kinetk
We should restrict the output of MP4Reader to H.264 and AAC so that we don't end up invoking rogue platform decoders (if that's even possible). This means that we won't play MP3 audio inside MP4, that's deliberate.
This commit is contained in:
Родитель
14c9efc438
Коммит
fb40afad21
|
@ -141,16 +141,30 @@ MP4Reader::ReadMetadata(MediaInfo* aInfo,
|
|||
bool ok = mDemuxer->Init();
|
||||
NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);
|
||||
|
||||
mInfo.mAudio.mHasAudio = mHasAudio = mDemuxer->HasAudio();
|
||||
const AudioDecoderConfig& audio = mDemuxer->AudioConfig();
|
||||
mInfo.mAudio.mHasAudio = mHasAudio = mDemuxer->HasAudio() &&
|
||||
audio.IsValidConfig();
|
||||
// If we have audio, we *only* allow AAC to be decoded.
|
||||
if (mHasAudio && audio.codec() != kCodecAAC) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
const VideoDecoderConfig& video = mDemuxer->VideoConfig();
|
||||
mInfo.mVideo.mHasVideo = mHasVideo = mDemuxer->HasVideo() &&
|
||||
video.IsValidConfig();
|
||||
// If we have video, we *only* allow H.264 to be decoded.
|
||||
if (mHasVideo && video.codec() != kCodecH264) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (mHasAudio) {
|
||||
const AudioDecoderConfig& config = mDemuxer->AudioConfig();
|
||||
mInfo.mAudio.mRate = config.samples_per_second();
|
||||
mInfo.mAudio.mChannels = ChannelLayoutToChannelCount(config.channel_layout());
|
||||
mInfo.mAudio.mRate = audio.samples_per_second();
|
||||
mInfo.mAudio.mChannels = ChannelLayoutToChannelCount(audio.channel_layout());
|
||||
mAudioDecoder = mPlatform->CreateAudioDecoder(mInfo.mAudio.mChannels,
|
||||
mInfo.mAudio.mRate,
|
||||
config.bits_per_channel(),
|
||||
config.extra_data(),
|
||||
config.extra_data_size());
|
||||
audio.bits_per_channel(),
|
||||
audio.extra_data(),
|
||||
audio.extra_data_size());
|
||||
NS_ENSURE_TRUE(mAudioDecoder != nullptr, NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
|
@ -159,7 +173,6 @@ MP4Reader::ReadMetadata(MediaInfo* aInfo,
|
|||
const VideoDecoderConfig& config = mDemuxer->VideoConfig();
|
||||
IntSize sz = config.natural_size();
|
||||
mInfo.mVideo.mDisplay = nsIntSize(sz.width(), sz.height());
|
||||
|
||||
mVideoDecoder = mPlatform->CreateVideoDecoder(mLayersBackendType,
|
||||
mDecoder->GetImageContainer());
|
||||
NS_ENSURE_TRUE(mVideoDecoder != nullptr, NS_ERROR_FAILURE);
|
||||
|
|
Загрузка…
Ссылка в новой задаче