Bug 1397141 - part1 : update error description when resolution is not supported.
MozReview-Commit-ID: 43xkkHfqw0p
--- a/dom/media/platforms/wmf/WMFDecoderModule.cpp
+++ b/dom/media/platforms/wmf/WMFDecoderModule.cpp
@@ -105,17 +105,17 @@ WMFDecoderModule::CreateVideoDecoder(con
}
nsAutoPtr<WMFVideoMFTManager> manager(
new WMFVideoMFTManager(aParams.VideoConfig(),
aParams.mKnowsCompositor,
aParams.mImageContainer,
sDXVAEnabled));
- if (!manager->Init()) {
+ if (!manager->Init(aParams.mError)) {
return nullptr;
}
RefPtr<MediaDataDecoder> decoder =
new WMFMediaDataDecoder(manager.forget(), aParams.mTaskQueue);
return decoder.forget();
}
--- a/dom/media/platforms/wmf/WMFVideoMFTManager.cpp
+++ b/dom/media/platforms/wmf/WMFVideoMFTManager.cpp
@@ -519,29 +519,31 @@ WMFVideoMFTManager::InitializeDXVA()
SystemGroup::EventTargetFor(mozilla::TaskCategory::Other), event);
}
mDXVA2Manager = event->mDXVA2Manager;
return mDXVA2Manager != nullptr;
}
bool
-WMFVideoMFTManager::ValidateVideoInfo()
+WMFVideoMFTManager::ValidateVideoInfo(MediaResult* aError)
{
// The WMF H.264 decoder is documented to have a minimum resolution
// 48x48 pixels. We've observed the decoder working for output smaller than
// that, but on some output it hangs in IMFTransform::ProcessOutput(), so
// we just reject streams which are less than the documented minimum.
// https://msdn.microsoft.com/en-us/library/windows/desktop/dd797815(v=vs.85).aspx
static const int32_t MIN_H264_FRAME_DIMENSION = 48;
if (mStreamType == H264 &&
(mVideoInfo.mImage.width < MIN_H264_FRAME_DIMENSION ||
mVideoInfo.mImage.height < MIN_H264_FRAME_DIMENSION)) {
- LogToBrowserConsole(NS_LITERAL_STRING(
- "Can't decode H.264 stream with width or height less than 48 pixels."));
+ MOZ_ASSERT(aError);
+ *aError = MediaResult(
+ NS_ERROR_DOM_MEDIA_FATAL_ERR,
+ RESULT_DETAIL("Can't decode H.264 stream with width or height less than 48 pixels."));
mIsValid = false;
}
return mIsValid;
}
already_AddRefed<MFTDecoder>
WMFVideoMFTManager::LoadAMDVP9Decoder()
@@ -565,19 +567,19 @@ WMFVideoMFTManager::LoadAMDVP9Decoder()
return nullptr;
}
hr = decoder->Create(decoderDLL, CLSID_AMDWebmMfVp9Dec);
NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr);
return decoder.forget();
}
bool
-WMFVideoMFTManager::Init()
+WMFVideoMFTManager::Init(MediaResult* aError)
{
- if (!ValidateVideoInfo()) {
+ if (!ValidateVideoInfo(aError)) {
return false;
}
bool success = InitInternal();
if (!success && mAMDVP9InUse) {
// Something failed with the AMD VP9 decoder; attempt again defaulting back
// to Microsoft MFT.
mCheckForAMDDecoder = false;
--- a/dom/media/platforms/wmf/WMFVideoMFTManager.h
+++ b/dom/media/platforms/wmf/WMFVideoMFTManager.h
@@ -2,16 +2,17 @@
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#if !defined(WMFVideoMFTManager_h_)
#define WMFVideoMFTManager_h_
+#include "MediaResult.h"
#include "MFTDecoder.h"
#include "WMF.h"
#include "WMFMediaDataDecoder.h"
#include "mozilla/Atomics.h"
#include "mozilla/RefPtr.h"
#include "nsAutoPtr.h"
#include "mozilla/gfx/Rect.h"
@@ -23,17 +24,17 @@ class WMFVideoMFTManager : public MFTMan
{
public:
WMFVideoMFTManager(const VideoInfo& aConfig,
layers::KnowsCompositor* aKnowsCompositor,
layers::ImageContainer* aImageContainer,
bool aDXVAEnabled);
~WMFVideoMFTManager();
- bool Init();
+ bool Init(MediaResult* aError);
HRESULT Input(MediaRawData* aSample) override;
HRESULT Output(int64_t aStreamOffset, RefPtr<MediaData>& aOutput) override;
void Shutdown() override;
bool IsHardwareAccelerated(nsACString& aFailureReason) const override;
@@ -58,17 +59,17 @@ public:
MediaDataDecoder::ConversionRequired NeedsConversion() const override
{
return mStreamType == H264
? MediaDataDecoder::ConversionRequired::kNeedAnnexB
: MediaDataDecoder::ConversionRequired::kNeedNone;
}
private:
- bool ValidateVideoInfo();
+ bool ValidateVideoInfo(MediaResult* aError);
bool InitializeDXVA();
bool InitInternal();
HRESULT CreateBasicVideoFrame(IMFSample* aSample,
int64_t aStreamOffset,
VideoData** aOutVideoData);