Bug 1176218 - p13. Reject Resolutions that are too big for Windows' decoder - r=jya

The WMFDecoderModule can override Supports(TrackInfo) to reject resolutions
that we know are too big for the platform decoder.

MozReview-Commit-ID: dU905wjZcJ

--HG--
extra : rebase_source : 40e5987deeffff652a88264f157391c0dbc0a2da
This commit is contained in:
Gerald Squelart 2016-10-07 15:51:34 +11:00
Родитель 413e411d7c
Коммит 0e173b53b1
2 изменённых файлов: 35 добавлений и 6 удалений

Просмотреть файл

@ -25,6 +25,7 @@
#include "prsystem.h"
#include "mozilla/Maybe.h"
#include "mozilla/StaticMutex.h"
#include "mozilla/WindowsVersion.h"
#include "MP4Decoder.h"
#include "VPXDecoder.h"
@ -193,24 +194,50 @@ bool
WMFDecoderModule::SupportsMimeType(const nsACString& aMimeType,
DecoderDoctorDiagnostics* aDiagnostics) const
{
if ((aMimeType.EqualsLiteral("audio/mp4a-latm") ||
aMimeType.EqualsLiteral("audio/mp4")) &&
UniquePtr<TrackInfo> trackInfo = CreateTrackInfoWithMIMEType(aMimeType);
if (!trackInfo) {
return false;
}
return Supports(*trackInfo, aDiagnostics);
}
bool
WMFDecoderModule::Supports(const TrackInfo& aTrackInfo,
DecoderDoctorDiagnostics* aDiagnostics) const
{
if ((aTrackInfo.mMimeType.EqualsLiteral("audio/mp4a-latm") ||
aTrackInfo.mMimeType.EqualsLiteral("audio/mp4")) &&
WMFDecoderModule::HasAAC()) {
return true;
}
if (MP4Decoder::IsH264(aMimeType) && WMFDecoderModule::HasH264()) {
if (MP4Decoder::IsH264(aTrackInfo.mMimeType) && WMFDecoderModule::HasH264()) {
const VideoInfo* videoInfo = aTrackInfo.GetAsVideoInfo();
MOZ_ASSERT(videoInfo);
// Check Windows format constraints, based on:
// https://msdn.microsoft.com/en-us/library/windows/desktop/dd797815(v=vs.85).aspx
if (IsWin8OrLater()) {
// Windows >7 supports at most 4096x2304.
if (videoInfo->mImage.width > 4096 || videoInfo->mImage.height > 2304) {
return false;
}
} else {
// Windows <=7 supports at most 1920x1088.
if (videoInfo->mImage.width > 1920 || videoInfo->mImage.height > 1088) {
return false;
}
}
return true;
}
if (aMimeType.EqualsLiteral("audio/mpeg") &&
if (aTrackInfo.mMimeType.EqualsLiteral("audio/mpeg") &&
CanCreateWMFDecoder<CLSID_CMP3DecMediaObject>()) {
return true;
}
if (MediaPrefs::PDMWMFIntelDecoderEnabled() && sDXVAEnabled) {
if (VPXDecoder::IsVP8(aMimeType) &&
if (VPXDecoder::IsVP8(aTrackInfo.mMimeType) &&
CanCreateWMFDecoder<CLSID_WebmMfVp8Dec>()) {
return true;
}
if (VPXDecoder::IsVP9(aMimeType) &&
if (VPXDecoder::IsVP9(aTrackInfo.mMimeType) &&
CanCreateWMFDecoder<CLSID_WebmMfVp9Dec>()) {
return true;
}

Просмотреть файл

@ -27,6 +27,8 @@ public:
bool SupportsMimeType(const nsACString& aMimeType,
DecoderDoctorDiagnostics* aDiagnostics) const override;
bool Supports(const TrackInfo& aTrackInfo,
DecoderDoctorDiagnostics* aDiagnostics) const override;
ConversionRequired
DecoderNeedsConversion(const TrackInfo& aConfig) const override;