Bug 1370805: P3. Use whichever extradata is available when constructing the decoder. r?jwwang draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 07 Jun 2017 15:14:57 +0200
changeset 590902 2953be3b92d698326a8c50a63a48220dc8f73bc8
parent 590901 17862b4659ddc3d4f719323ae962e5391cafd64f
child 632346 80a30fbef5fb63d98c24c3cc494b41acb93ade75
push id62873
push userbmo:jyavenard@mozilla.com
push dateThu, 08 Jun 2017 09:12:40 +0000
reviewersjwwang
bugs1370805, 1313398
milestone55.0a1
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
dom/media/platforms/wrappers/H264Converter.cpp
--- 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;