Bug 1400758 - part1 : report the error description with InitPromise for Apple's decoders.
MozReview-Commit-ID: 8rifWLm8BPt
--- a/dom/media/platforms/apple/AppleATDecoder.cpp
+++ b/dom/media/platforms/apple/AppleATDecoder.cpp
@@ -1,19 +1,19 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
+#include "AppleATDecoder.h"
#include "AppleUtils.h"
#include "MP4Decoder.h"
#include "mp4_demuxer/Adts.h"
#include "MediaInfo.h"
-#include "AppleATDecoder.h"
#include "mozilla/Logging.h"
#include "mozilla/SyncRunnable.h"
#include "mozilla/UniquePtr.h"
#define LOG(...) MOZ_LOG(sPDMLog, mozilla::LogLevel::Debug, (__VA_ARGS__))
#define FourCC2Str(n) ((char[5]){(char)(n >> 24), (char)(n >> 16), (char)(n >> 8), (char)(n), 0})
namespace mozilla {
@@ -50,18 +50,20 @@ AppleATDecoder::~AppleATDecoder()
MOZ_COUNT_DTOR(AppleATDecoder);
MOZ_ASSERT(!mConverter);
}
RefPtr<MediaDataDecoder::InitPromise>
AppleATDecoder::Init()
{
if (!mFormatID) {
- NS_ERROR("Non recognised format");
- return InitPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_FATAL_ERR, __func__);
+ return InitPromise::CreateAndReject(
+ MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR,
+ RESULT_DETAIL("Non recognised format")),
+ __func__);
}
return InitPromise::CreateAndResolve(TrackType::kAudioTrack, __func__);
}
RefPtr<MediaDataDecoder::DecodePromise>
AppleATDecoder::Decode(MediaRawData* aSample)
{
--- a/dom/media/platforms/apple/AppleVTDecoder.cpp
+++ b/dom/media/platforms/apple/AppleVTDecoder.cpp
@@ -1,20 +1,20 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#include <CoreFoundation/CFString.h>
+#include "AppleVTDecoder.h"
#include "AppleCMLinker.h"
#include "AppleDecoderModule.h"
#include "AppleUtils.h"
-#include "AppleVTDecoder.h"
#include "AppleVTLinker.h"
#include "MediaData.h"
#include "mozilla/ArrayUtils.h"
#include "mp4_demuxer/H264.h"
#include "nsAutoPtr.h"
#include "nsThreadUtils.h"
#include "mozilla/Logging.h"
#include "VideoUtils.h"
@@ -58,23 +58,23 @@ AppleVTDecoder::AppleVTDecoder(const Vid
AppleVTDecoder::~AppleVTDecoder()
{
MOZ_COUNT_DTOR(AppleVTDecoder);
}
RefPtr<MediaDataDecoder::InitPromise>
AppleVTDecoder::Init()
{
- nsresult rv = InitializeSession();
+ MediaResult rv = InitializeSession();
if (NS_SUCCEEDED(rv)) {
return InitPromise::CreateAndResolve(TrackType::kVideoTrack, __func__);
}
- return InitPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_FATAL_ERR, __func__);
+ return InitPromise::CreateAndReject(rv, __func__);
}
RefPtr<MediaDataDecoder::DecodePromise>
AppleVTDecoder::Decode(MediaRawData* aSample)
{
LOG("mp4 input sample %p pts %lld duration %lld us%s %zu bytes",
aSample,
aSample->mTime.ToMicroseconds(),
@@ -468,32 +468,32 @@ AppleVTDecoder::WaitForAsynchronousFrame
OSStatus rv = VTDecompressionSessionWaitForAsynchronousFrames(mSession);
if (rv != noErr) {
NS_ERROR("AppleVTDecoder: Error waiting for asynchronous frames");
return NS_ERROR_FAILURE;
}
return NS_OK;
}
-nsresult
+MediaResult
AppleVTDecoder::InitializeSession()
{
OSStatus rv;
AutoCFRelease<CFDictionaryRef> extensions = CreateDecoderExtensions();
rv = CMVideoFormatDescriptionCreate(kCFAllocatorDefault,
kCMVideoCodecType_H264,
mPictureWidth,
mPictureHeight,
extensions,
&mFormat);
if (rv != noErr) {
- NS_ERROR("Couldn't create format description!");
- return NS_ERROR_FAILURE;
+ return MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR,
+ RESULT_DETAIL("Couldn't create format description!"));
}
// Contruct video decoder selection spec.
AutoCFRelease<CFDictionaryRef> spec = CreateDecoderSpecification();
// Contruct output configuration.
AutoCFRelease<CFDictionaryRef> outputConfiguration =
CreateOutputConfiguration();
@@ -502,18 +502,18 @@ AppleVTDecoder::InitializeSession()
rv = VTDecompressionSessionCreate(kCFAllocatorDefault,
mFormat,
spec, // Video decoder selection.
outputConfiguration, // Output video format.
&cb,
&mSession);
if (rv != noErr) {
- NS_ERROR("Couldn't create decompression session!");
- return NS_ERROR_FAILURE;
+ return MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR,
+ RESULT_DETAIL("Couldn't create decompression session!"));
}
if (AppleVTLinker::skPropUsingHWAccel) {
CFBooleanRef isUsingHW = nullptr;
rv = VTSessionCopyProperty(mSession,
AppleVTLinker::skPropUsingHWAccel,
kCFAllocatorDefault,
&isUsingHW);
--- a/dom/media/platforms/apple/AppleVTDecoder.h
+++ b/dom/media/platforms/apple/AppleVTDecoder.h
@@ -87,17 +87,17 @@ private:
const RefPtr<MediaByteBuffer> mExtraData;
const uint32_t mPictureWidth;
const uint32_t mPictureHeight;
const uint32_t mDisplayWidth;
const uint32_t mDisplayHeight;
// Method to set up the decompression session.
- nsresult InitializeSession();
+ MediaResult InitializeSession();
nsresult WaitForAsynchronousFrames();
CFDictionaryRef CreateDecoderSpecification();
CFDictionaryRef CreateDecoderExtensions();
const RefPtr<TaskQueue> mTaskQueue;
const uint32_t mMaxRefFrames;
const RefPtr<layers::ImageContainer> mImageContainer;
const bool mUseSoftwareImages;