Bug 1259212 - WMFDecoderModule::Supports tries to create decoder - r?mattwoodrow
If we are given any size or rate information, outright reject insanely-high
values. This is actually used by YouTube to sense whether the browser reads
these parameters, in which case YouTube will then probe for exact size&rate
combinations.
If we are given a size&rate, try to create a decoder with the relevant track
informations, to see if the decoder really supports them.
Note that the actual decoder check will be implemented in later patches.
MozReview-Commit-ID: vlXlOj5Aw8
--- a/dom/media/platforms/wmf/WMFDecoderModule.cpp
+++ b/dom/media/platforms/wmf/WMFDecoderModule.cpp
@@ -7,19 +7,21 @@
#include "WMF.h"
#include "WMFDecoderModule.h"
#include "WMFVideoMFTManager.h"
#include "WMFAudioMFTManager.h"
#include "MFTDecoder.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/Services.h"
#include "WMFMediaDataDecoder.h"
+#include "Layers.h"
#include "nsAutoPtr.h"
#include "nsIWindowsRegKey.h"
#include "nsComponentManagerUtils.h"
+#include "nsContentUtils.h"
#include "nsServiceManagerUtils.h"
#include "nsIGfxInfo.h"
#include "nsWindowsHelpers.h"
#include "GfxDriverInfo.h"
#include "mozilla/gfx/gfxVars.h"
#include "MediaInfo.h"
#include "MediaPrefs.h"
#include "prsystem.h"
@@ -211,29 +213,52 @@ WMFDecoderModule::Supports(const TrackIn
WMFDecoderModule::HasAAC()) {
return true;
}
if (MP4Decoder::IsH264(aTrackInfo.mMimeType) && WMFDecoderModule::HasH264()) {
const VideoInfo* videoInfo = aTrackInfo.GetAsVideoInfo();
MOZ_ASSERT(videoInfo);
int32_t w = videoInfo->mImage.width;
int32_t h = videoInfo->mImage.height;
+ uint32_t fr = videoInfo->mFramerate;
+ if (w >= 99999 || h >= 99999 || fr >= 9999) {
+ // Size/rate way too big.
+ // Also signals to YouTube that we can deal with these values, so that
+ // more precise size+rate combinations will be queried.
+ return false;
+ }
// 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 (w > 4096 || h > 2304) {
return false;
}
} else {
// Windows <=7 supports at most 1920x1088.
if (w > 1920 || h > 1088) {
return false;
}
}
+ if (w > 0 && h > 0 && fr > 0) {
+ // Got size&rate -> Try to create decoder with this track information.
+ // Some drivers can check if this configuration is not supported, in
+ // which case the decoder creation will fail.
+ RefPtr<LayerManager> layerManager =
+ nsContentUtils::LayerManagerForDocument(aDoc);
+ ShadowLayerForwarder* knowsCompositor = layerManager
+ ? layerManager->AsShadowForwarder()
+ : nullptr;
+ RefPtr<MediaDataDecoder> decoder =
+ const_cast<WMFDecoderModule*>(this)->
+ CreateVideoDecoder(CreateDecoderParams(aTrackInfo, knowsCompositor));
+ if (!decoder) {
+ return false;
+ }
+ }
return true;
}
if (aTrackInfo.mMimeType.EqualsLiteral("audio/mpeg") &&
CanCreateWMFDecoder<CLSID_CMP3DecMediaObject>()) {
return true;
}
if (MediaPrefs::PDMWMFIntelDecoderEnabled() && sDXVAEnabled) {
if (VPXDecoder::IsVP8(aTrackInfo.mMimeType) &&