Bug 1332619 - Fix missed duration when skipping a frame in VP8TrackEncoder. r?jesup draft
authorAndreas Pehrson <pehrsons@gmail.com>
Fri, 20 Jan 2017 15:47:04 +0100
changeset 464999 522dd73ee4d0d1fc71448d5f97d236ee976aa612
parent 464998 1261a15e16779d34e3c97b0f0de42bdaf4ad2252
child 465600 8604e8de61e61c69ec02295ccd8a92fe770e2783
child 465625 d392f0bc2887e609c33e30979ef8044c0d387e53
push id42518
push userbmo:pehrson@telenordigital.com
push dateMon, 23 Jan 2017 16:37:02 +0000
reviewersjesup
bugs1332619
milestone53.0a1
Bug 1332619 - Fix missed duration when skipping a frame in VP8TrackEncoder. r?jesup MozReview-Commit-ID: GpXUHfUj5v2
dom/media/encoder/VP8TrackEncoder.cpp
--- a/dom/media/encoder/VP8TrackEncoder.cpp
+++ b/dom/media/encoder/VP8TrackEncoder.cpp
@@ -548,21 +548,25 @@ VP8TrackEncoder::GetEncodedTrack(Encoded
                            VPX_DL_REALTIME)) {
         return NS_ERROR_FAILURE;
       }
       // Get the encoded data from VP8 encoder.
       GetEncodedPartitions(aData);
     } else {
       // SKIP_FRAME
       // Extend the duration of the last encoded data in aData
-      // because this frame will be skip.
+      // because this frame will be skipped.
       VP8LOG(LogLevel::Warning, "MediaRecorder lagging behind. Skipping a frame.");
       RefPtr<EncodedFrame> last = aData.GetEncodedFrames().LastElement();
       if (last) {
-        last->SetDuration(last->GetDuration() + chunk.GetDuration());
+        CheckedInt64 skippedDuration = FramesToUsecs(chunk.mDuration, mTrackRate);
+        if (skippedDuration.isValid() && skippedDuration.value() > 0) {
+          last->SetDuration(last->GetDuration() +
+                            (static_cast<uint64_t>(skippedDuration.value())));
+        }
       }
     }
 
     // Move forward the mEncodedTimestamp.
     mEncodedTimestamp += chunk.GetDuration();
     totalProcessedDuration += chunk.GetDuration();
 
     // Check what to do next.