зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1397141 - part6 : use MediaResult to replace nsresult r=jya
Return MediaResult instead of using nsresult, because it can contain more detailed error information. We could also return this error with our rejected decode promise. MozReview-Commit-ID: HrI3QKlSJC --HG-- extra : rebase_source : 6aba73c887e3068bf2a3f031a9a3b0698decc2e3
This commit is contained in:
Родитель
45f6a63ccf
Коммит
3da04770d6
|
@ -33,7 +33,7 @@ H264Converter::H264Converter(PlatformDecoderModule* aPDM,
|
|||
, mOnWaitingForKeyEvent(aParams.mOnWaitingForKeyEvent)
|
||||
, mDecoderOptions(aParams.mOptions)
|
||||
{
|
||||
CreateDecoder(mOriginalConfig, aParams.mDiagnostics);
|
||||
mLastError = CreateDecoder(mOriginalConfig, aParams.mDiagnostics);
|
||||
if (mDecoder) {
|
||||
MOZ_ASSERT(mp4_demuxer::H264::HasSPS(mOriginalConfig.mExtraData));
|
||||
// The video metadata contains out of band SPS/PPS (AVC1) store it.
|
||||
|
@ -81,7 +81,7 @@ H264Converter::Decode(MediaRawData* aSample)
|
|||
__func__);
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
MediaResult rv(NS_OK);
|
||||
if (!mDecoder) {
|
||||
// It is not possible to create an AVCC H264 decoder without SPS.
|
||||
// As such, creation will fail if the extra_data just extracted doesn't
|
||||
|
@ -112,10 +112,7 @@ H264Converter::Decode(MediaRawData* aSample)
|
|||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return DecodePromise::CreateAndReject(
|
||||
MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR,
|
||||
RESULT_DETAIL("Unable to create H264 decoder")),
|
||||
__func__);
|
||||
return DecodePromise::CreateAndReject(rv, __func__);
|
||||
}
|
||||
|
||||
if (mNeedKeyframe && !aSample->mKeyframe) {
|
||||
|
@ -243,7 +240,7 @@ H264Converter::SetSeekThreshold(const media::TimeUnit& aTime)
|
|||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
MediaResult
|
||||
H264Converter::CreateDecoder(const VideoInfo& aConfig,
|
||||
DecoderDoctorDiagnostics* aDiagnostics)
|
||||
{
|
||||
|
@ -259,17 +256,15 @@ H264Converter::CreateDecoder(const VideoInfo& aConfig,
|
|||
// WMF H.264 Video Decoder and Apple ATDecoder do not support YUV444 format.
|
||||
if (spsdata.profile_idc == 244 /* Hi444PP */ ||
|
||||
spsdata.chroma_format_idc == PDMFactory::kYUV444) {
|
||||
mLastError = MediaResult(NS_ERROR_FAILURE,
|
||||
RESULT_DETAIL("Not support for YUV444 format."));
|
||||
if (aDiagnostics) {
|
||||
aDiagnostics->SetVideoNotSupported();
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
return MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR,
|
||||
RESULT_DETAIL("No support for YUV444 format."));
|
||||
}
|
||||
} else {
|
||||
mLastError = MediaResult(NS_ERROR_FAILURE,
|
||||
RESULT_DETAIL("Invalid SPS NAL."));
|
||||
return NS_ERROR_FAILURE;
|
||||
return MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR,
|
||||
RESULT_DETAIL("Invalid SPS NAL."));
|
||||
}
|
||||
|
||||
mDecoder = mPDM->CreateVideoDecoder({
|
||||
|
@ -287,10 +282,9 @@ H264Converter::CreateDecoder(const VideoInfo& aConfig,
|
|||
|
||||
if (!mDecoder) {
|
||||
MOZ_ASSERT(NS_FAILED(mLastError));
|
||||
mLastError = MediaResult(mLastError.Code(),
|
||||
RESULT_DETAIL("Unable to create H264 decoder, reason = %s.",
|
||||
mLastError.Description().get()));
|
||||
return NS_ERROR_FAILURE;
|
||||
return MediaResult(mLastError.Code(),
|
||||
RESULT_DETAIL("Unable to create H264 decoder, reason = %s.",
|
||||
mLastError.Description().get()));
|
||||
}
|
||||
|
||||
mNeedKeyframe = true;
|
||||
|
@ -298,7 +292,7 @@ H264Converter::CreateDecoder(const VideoInfo& aConfig,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
MediaResult
|
||||
H264Converter::CreateDecoderAndInit(MediaRawData* aSample)
|
||||
{
|
||||
RefPtr<MediaByteBuffer> extra_data =
|
||||
|
@ -313,7 +307,7 @@ H264Converter::CreateDecoderAndInit(MediaRawData* aSample)
|
|||
UpdateConfigFromExtraData(extra_data);
|
||||
}
|
||||
|
||||
nsresult rv =
|
||||
MediaResult rv =
|
||||
CreateDecoder(mCurrentConfig, /* DecoderDoctorDiagnostics* */ nullptr);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
|
@ -400,7 +394,7 @@ H264Converter::DecodeFirstSample(MediaRawData* aSample)
|
|||
->Track(mDecodePromiseRequest);
|
||||
}
|
||||
|
||||
nsresult
|
||||
MediaResult
|
||||
H264Converter::CheckForSPSChange(MediaRawData* aSample)
|
||||
{
|
||||
RefPtr<MediaByteBuffer> extra_data =
|
||||
|
@ -512,7 +506,7 @@ void H264Converter::FlushThenShutdownDecoder(MediaRawData* aPendingSample)
|
|||
return;
|
||||
}
|
||||
|
||||
nsresult rv = CreateDecoderAndInit(sample);
|
||||
MediaResult rv = CreateDecoderAndInit(sample);
|
||||
if (rv == NS_ERROR_DOM_MEDIA_INITIALIZING_DECODER) {
|
||||
// All good so far, will continue later.
|
||||
return;
|
||||
|
|
|
@ -65,10 +65,10 @@ private:
|
|||
// Will create the required MediaDataDecoder if need AVCC and we have a SPS NAL.
|
||||
// Returns NS_ERROR_FAILURE if error is permanent and can't be recovered and
|
||||
// will set mError accordingly.
|
||||
nsresult CreateDecoder(const VideoInfo& aConfig,
|
||||
MediaResult CreateDecoder(const VideoInfo& aConfig,
|
||||
DecoderDoctorDiagnostics* aDiagnostics);
|
||||
nsresult CreateDecoderAndInit(MediaRawData* aSample);
|
||||
nsresult CheckForSPSChange(MediaRawData* aSample);
|
||||
MediaResult CreateDecoderAndInit(MediaRawData* aSample);
|
||||
MediaResult CheckForSPSChange(MediaRawData* aSample);
|
||||
void UpdateConfigFromExtraData(MediaByteBuffer* aExtraData);
|
||||
|
||||
bool CanRecycleDecoder() const;
|
||||
|
|
Загрузка…
Ссылка в новой задаче