Bug 1285987: Narrow the workaround added in bug 1276184 to only be effective with webm. r?gerald draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 13 Jul 2016 21:20:50 +1000
changeset 387034 2c7e241f072651c7032733eefaa24c39ef55b4a9
parent 387033 e9bcdff90bb8694ad729678f7ed8bc653c3fafe6
child 525287 27fa372e97a15121e5196ec8431fe4cc38b1db71
push id22892
push userbmo:jyavenard@mozilla.com
push dateWed, 13 Jul 2016 11:33:55 +0000
reviewersgerald
bugs1285987, 1276184
milestone50.0a1
Bug 1285987: Narrow the workaround added in bug 1276184 to only be effective with webm. r?gerald Some invalid streams incorrectly tag all frames as keyframes, which cause the frames to be inserted in the wrong order in the trackbuffer. MozReview-Commit-ID: EZurdiMxmle
dom/media/mediasource/TrackBuffersManager.cpp
--- a/dom/media/mediasource/TrackBuffersManager.cpp
+++ b/dom/media/mediasource/TrackBuffersManager.cpp
@@ -1620,20 +1620,27 @@ TrackBuffersManager::InsertFrames(TrackB
 
   // 15. Remove decoding dependencies of the coded frames removed in the previous step:
   // Remove all coded frames between the coded frames removed in the previous step and the next random access point after those removed frames.
 
   TimeIntervals intersection = trackBuffer.mBufferedRanges;
   intersection.Intersection(aIntervals);
 
   if (intersection.Length()) {
-    if (aSamples[0]->mKeyframe) {
+    if (aSamples[0]->mKeyframe &&
+        (mType.LowerCaseEqualsLiteral("video/webm") ||
+         mType.LowerCaseEqualsLiteral("audio/webm"))) {
       // We are starting a new GOP, we do not have to worry about breaking an
       // existing current coded frame group. Reset the next insertion index
       // so the search for when to start our frames removal can be exhaustive.
+      // This is a workaround for bug 1276184 and only until either bug 1277733
+      // or bug 1209386 is fixed.
+      // With the webm container, we can't always properly determine the
+      // duration of the last frame, which may cause the last frame of a cluster
+      // to overlap the following frame.
       trackBuffer.mNextInsertionIndex.reset();
     }
     size_t index =
       RemoveFrames(aIntervals, trackBuffer, trackBuffer.mNextInsertionIndex.refOr(0));
     if (index) {
       trackBuffer.mNextInsertionIndex = Some(index);
     }
   }