Bug 1548629 - Separate logic for media data with gaps and overlaps. r=jya a=jcristau
authorAndreas Pehrson <apehrson@mozilla.com>
Wed, 22 May 2019 12:44:44 +0000
changeset 533432 67d20a416452bedd1df182229de370b3e32e4212
parent 533431 d32cf703d5665f0c9818289c1fab5e3bc0cfa1d6
child 533433 97158e94fd0a16e451db9720d64bdfc7df4c685e
push id11319
push userrgurzau@mozilla.com
push dateMon, 27 May 2019 23:54:00 +0000
treeherdermozilla-beta@6ec3cb391f03 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya, jcristau
bugs1548629
milestone68.0
Bug 1548629 - Separate logic for media data with gaps and overlaps. r=jya a=jcristau If we end up taking the gap branch of the if in the patch, and the media file in the future from the point we branched at contains no gaps or overlaps, we'll still end up taking the gap branch until the end. This is because it only appends up to the start of the current frame, but not the frame itself. I.e., when the next frame gets processed, there's still a gap in appended data. Depends on D32107 Differential Revision: https://phabricator.services.mozilla.com/D32108
dom/media/mediasink/DecodedStream.cpp
--- a/dom/media/mediasink/DecodedStream.cpp
+++ b/dom/media/mediasink/DecodedStream.cpp
@@ -753,17 +753,18 @@ void DecodedStream::SendVideo(bool aIsSa
   TimeUnit currentPosition = GetPosition(&currentTime);
 
   if (mData->mLastVideoTimeStamp.IsNull()) {
     mData->mLastVideoTimeStamp = currentTime;
   }
 
   for (uint32_t i = 0; i < video.Length(); ++i) {
     VideoData* v = video[i];
-    TimeUnit lastStart = mData->mLastVideoStartTime.valueOr(mStartTime.ref());
+    TimeUnit lastStart = mData->mLastVideoStartTime.valueOr(
+        mStartTime.ref() - TimeUnit::FromMicroseconds(1));
     TimeUnit lastEnd = mData->mLastVideoEndTime.valueOr(mStartTime.ref());
 
     if (lastEnd < v->mTime) {
       // Write last video frame to catch up. mLastVideoImage can be null here
       // which is fine, it just means there's no video.
 
       // TODO: |mLastVideoImage| should come from the last image rendered
       // by the state machine. This will avoid the black frame when capture
@@ -772,17 +773,20 @@ void DecodedStream::SendVideo(bool aIsSa
       // and capture happens at 15 sec, we'll have to append a black frame
       // that is 15 sec long.
       TimeStamp t =
           std::max(mData->mLastVideoTimeStamp,
                    currentTime + (lastEnd - currentPosition).ToTimeDuration());
       mData->WriteVideoToSegment(mData->mLastVideoImage, lastEnd, v->mTime,
                                  mData->mLastVideoImageDisplaySize, t, &output,
                                  aPrincipalHandle);
-    } else if (lastStart < v->mTime) {
+      lastEnd = v->mTime;
+    }
+
+    if (lastStart < v->mTime) {
       // This frame starts after the last frame's start. Note that this could be
       // before the last frame's end time for some videos. This only matters for
       // the track's lifetime in the MSG, as rendering is based on timestamps,
       // aka frame start times.
       TimeStamp t =
           std::max(mData->mLastVideoTimeStamp,
                    currentTime + (lastEnd - currentPosition).ToTimeDuration());
       TimeUnit end = std::max(