Bug 1370805: P3. Use whichever extradata is available when constructing the decoder. r?jwwang
Prior
bug 1313398, the only time we would call H264Converter::CreateDecoderAndInit was if we encountered AVC3 content where the H264 extradata didn't exist in the metadata.
AVC3 was the only situation where mDecoder would be null after construction.
However, now, it is possible for the construction of the decoder to be interrupted, which would leave mDecoder null. For AVC1 content, if this happened, we wouldn't have in-band SPS/PPS necessary for CreateDecoderAndInit to complete.
So we use whichever extradata is available.
MozReview-Commit-ID: 702xj045LAv
--- a/dom/media/platforms/wrappers/H264Converter.cpp
+++ b/dom/media/platforms/wrappers/H264Converter.cpp
@@ -273,20 +273,25 @@ H264Converter::CreateDecoder(const Video
return NS_OK;
}
nsresult
H264Converter::CreateDecoderAndInit(MediaRawData* aSample)
{
RefPtr<MediaByteBuffer> extra_data =
mp4_demuxer::AnnexB::ExtractExtraData(aSample);
- if (!mp4_demuxer::AnnexB::HasSPS(extra_data)) {
+ bool inbandExtradata = mp4_demuxer::AnnexB::HasSPS(extra_data);
+ if (!inbandExtradata &&
+ !mp4_demuxer::AnnexB::HasSPS(mCurrentConfig.mExtraData)) {
return NS_ERROR_NOT_INITIALIZED;
}
- UpdateConfigFromExtraData(extra_data);
+
+ if (inbandExtradata) {
+ UpdateConfigFromExtraData(extra_data);
+ }
nsresult rv =
CreateDecoder(mCurrentConfig, /* DecoderDoctorDiagnostics* */ nullptr);
if (NS_SUCCEEDED(rv)) {
// Queue the incoming sample.
mPendingSample = aSample;