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
--- a/dom/media/platforms/wmf/WMFDecoderModule.cpp
+++ b/dom/media/platforms/wmf/WMFDecoderModule.cpp
@@ -20,16 +20,17 @@
#include "nsWindowsHelpers.h"
#include "GfxDriverInfo.h"
#include "mozilla/gfx/gfxVars.h"
#include "MediaInfo.h"
#include "MediaPrefs.h"
#include "prsystem.h"
#include "mozilla/Maybe.h"
#include "mozilla/StaticMutex.h"
+#include "mozilla/WindowsVersion.h"
#include "MP4Decoder.h"
#include "VPXDecoder.h"
namespace mozilla {
static Atomic<bool> sDXVAEnabled(false);
WMFDecoderModule::WMFDecoderModule()
@@ -188,34 +189,60 @@ WMFDecoderModule::HasAAC()
{
return CanCreateWMFDecoder<CLSID_CMSAACDecMFT>();
}
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;
}
}
// Some unsupported codec.
return false;
}
--- a/dom/media/platforms/wmf/WMFDecoderModule.h
+++ b/dom/media/platforms/wmf/WMFDecoderModule.h
@@ -22,16 +22,18 @@ public:
already_AddRefed<MediaDataDecoder>
CreateVideoDecoder(const CreateDecoderParams& aParams) override;
already_AddRefed<MediaDataDecoder>
CreateAudioDecoder(const CreateDecoderParams& aParams) override;
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;
// Called on main thread.
static void Init();
// Called from any thread, must call init first