Bug 1206948 - delay the notification of metadata to guarantee video size is correct when 'loadedmetadata' is fired in non-MSE case. draft
authorJW Wang <jwwang@mozilla.com>
Thu, 21 Jul 2016 11:40:33 +0800
changeset 390390 0c55433958280c9845f4bbfdbd645f0b8a8e237b
parent 389550 5a91e5b49be3c1ba401b057e90c92d7488e3647d
child 525995 bba57638089ddfbfc78b7adf4578427268131186
push id23664
push userjwwang@mozilla.com
push dateThu, 21 Jul 2016 03:41:06 +0000
bugs1206948
milestone50.0a1
Bug 1206948 - delay the notification of metadata to guarantee video size is correct when 'loadedmetadata' is fired in non-MSE case. MozReview-Commit-ID: H5yQlrk7A36
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -2008,18 +2008,22 @@ MediaDecoderStateMachine::OnMetadataRead
   // thus get the metadata). We could fix this if we could compute the start
   // time by demuxing without necessaring decoding.
   bool waitingForCDM =
 #ifdef MOZ_EME
     mInfo.IsEncrypted() && !mCDMProxy;
 #else
     false;
 #endif
-  mNotifyMetadataBeforeFirstFrame = mDuration.Ref().isSome() || waitingForCDM;
-  if (mNotifyMetadataBeforeFirstFrame) {
+
+  // Notify metadata if it is MSE. Otherwise we will delay the event until 1st
+  // frames are decoded to workaround the case where video size in the metadata
+  // is different from that of the 1st frame.
+  if (waitingForCDM || mReader->ForceZeroStartTime()) {
+    mNotifyMetadataBeforeFirstFrame = true;
     EnqueueLoadedMetadataEvent();
   }
 
   if (waitingForCDM) {
     // Metadata parsing was successful but we're still waiting for CDM caps
     // to become available so that we can build the correct decryptor/decoder.
     SetState(DECODER_STATE_WAIT_FOR_CDM);
     return;