Bug 1743159 Disable hardware video decoding for WebRTC when decode fails, r=jya

Recently hardware video decoding is enabled by default for WebRTC and there isn't any fallback if it fails.
Let's try HW decoding first and fallback to SW decoding if we fail as we do for media video playback.

Differential Revision: https://phabricator.services.mozilla.com/D132492
This commit is contained in:
stransky 2021-12-03 14:52:09 +00:00
Родитель 4ef99ace6a
Коммит 9b8c7dbec4
2 изменённых файлов: 15 добавлений и 3 удалений

Просмотреть файл

@ -61,6 +61,9 @@ int32_t WebrtcMediaDataDecoder::Decode(const webrtc::EncodedImage& aInputImage,
}
}
auto disabledHardwareAcceleration =
MakeScopeExit([&] { mDisabledHardwareAcceleration = true; });
RefPtr<MediaRawData> compressedFrame =
new MediaRawData(aInputImage.data(), aInputImage.size());
if (!compressedFrame->Data()) {
@ -108,8 +111,12 @@ int32_t WebrtcMediaDataDecoder::Decode(const webrtc::EncodedImage& aInputImage,
return WEBRTC_VIDEO_CODEC_ERROR;
}
return NS_SUCCEEDED(mError) ? WEBRTC_VIDEO_CODEC_OK
: WEBRTC_VIDEO_CODEC_ERROR;
if (NS_FAILED(mError)) {
return WEBRTC_VIDEO_CODEC_ERROR;
}
disabledHardwareAcceleration.release();
return WEBRTC_VIDEO_CODEC_OK;
}
int32_t WebrtcMediaDataDecoder::RegisterDecodeCompleteCallback(
@ -157,7 +164,11 @@ int32_t WebrtcMediaDataDecoder::CreateDecoder() {
CreateDecoderParams::Option::LowLatency,
CreateDecoderParams::Option::FullH264Parsing,
CreateDecoderParams::Option::
ErrorIfNoInitializationData),
ErrorIfNoInitializationData,
mDisabledHardwareAcceleration
? CreateDecoderParams::Option::
HardwareDecoderNotAllowed
: CreateDecoderParams::Option::Default),
mTrackType, mImageContainer, knowsCompositor})
->Then(
tq, __func__,

Просмотреть файл

@ -62,6 +62,7 @@ class WebrtcMediaDataDecoder : public WebrtcVideoDecoder {
MediaResult mError = NS_OK;
MediaDataDecoder::DecodedData mResults;
const nsCString mCodecType;
bool mDisabledHardwareAcceleration = false;
};
} // namespace mozilla