Cannot clear a MediaSource SourceBuffer in Safari 9 and WebKit nightly
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Jun 2016 19:22:59 +0000 (19:22 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Jun 2016 19:22:59 +0000 (19:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=159230

Reviewed by Eric Carlson.

Source/WebCore:

Test: media/media-source/media-source-remove.html (modified)

Move to using a MediaTime directly (rather than as a double) to add
and removed buffered ranges. Also, drop the use of the "microsecond"
fudge factor when adding buffered ranges.

* Modules/mediasource/SourceBuffer.cpp:
(WebCore::removeSamplesFromTrackBuffer):
(WebCore::SourceBuffer::sourceBufferPrivateDidReceiveSample):

LayoutTests:

* media/media-source/media-source-remove.html:
* media/media-source/media-source-remove-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202641 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/media/media-source/media-source-remove-expected.txt
LayoutTests/media/media-source/media-source-remove.html
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediasource/SourceBuffer.cpp

index 31385f9..f250c24 100644 (file)
@@ -1,3 +1,13 @@
+2016-06-29  Jer Noble  <jer.noble@apple.com>
+
+        Cannot clear a MediaSource SourceBuffer in Safari 9 and WebKit nightly
+        https://bugs.webkit.org/show_bug.cgi?id=159230
+
+        Reviewed by Eric Carlson.
+
+        * media/media-source/media-source-remove.html:
+        * media/media-source/media-source-remove-expected.txt:
+
 2016-06-29  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: Show Shadow Root type in DOM Tree
index 79263fa..78b8c25 100644 (file)
@@ -9,6 +9,6 @@ RUN(sourceBuffer.appendBuffer(samples))
 EVENT(updateend)
 RUN(sourceBuffer.remove(0, 2))
 EVENT(updateend)
-EXPECTED (sourceBuffer.buffered.start(0).toFixed(1) == '4') OK
+EXPECTED (sourceBuffer.buffered.start(0) == '4') OK
 END OF TEST
 
index 4948591..26fb818 100644 (file)
@@ -48,7 +48,7 @@
     }
 
     function checkRemoved() {
-        testExpected('sourceBuffer.buffered.start(0).toFixed(1)', 4);
+        testExpected('sourceBuffer.buffered.start(0)', 4);
         endTest();
     }
 
index 96d213d..97fa788 100644 (file)
@@ -1,3 +1,20 @@
+2016-06-29  Jer Noble  <jer.noble@apple.com>
+
+        Cannot clear a MediaSource SourceBuffer in Safari 9 and WebKit nightly
+        https://bugs.webkit.org/show_bug.cgi?id=159230
+
+        Reviewed by Eric Carlson.
+
+        Test: media/media-source/media-source-remove.html (modified)
+
+        Move to using a MediaTime directly (rather than as a double) to add
+        and removed buffered ranges. Also, drop the use of the "microsecond"
+        fudge factor when adding buffered ranges.
+
+        * Modules/mediasource/SourceBuffer.cpp:
+        (WebCore::removeSamplesFromTrackBuffer):
+        (WebCore::SourceBuffer::sourceBufferPrivateDidReceiveSample):
+
 2016-06-29  Jiewen Tan  <jiewen_tan@apple.com>
 
         Unreviewed, second attempt to fix ASAN build for r202599
index db3b954..6378e79 100644 (file)
@@ -655,8 +655,8 @@ static bool decodeTimeComparator(const PresentationOrderSampleMap::MapType::valu
 static PassRefPtr<TimeRanges> removeSamplesFromTrackBuffer(const DecodeOrderSampleMap::MapType& samples, SourceBuffer::TrackBuffer& trackBuffer, const SourceBuffer* buffer, const char* logPrefix)
 {
 #if !LOG_DISABLED
-    double earliestSample = std::numeric_limits<double>::infinity();
-    double latestSample = 0;
+    MediaTime earliestSample = MediaTime::positiveInfiniteTime();
+    MediaTime latestSample = MediaTime::zeroTime();
     size_t bytesRemoved = 0;
 #else
     UNUSED_PARAM(logPrefix);
@@ -664,7 +664,6 @@ static PassRefPtr<TimeRanges> removeSamplesFromTrackBuffer(const DecodeOrderSamp
 #endif
 
     auto erasedRanges = TimeRanges::create();
-    MediaTime microsecond(1, 1000000);
     for (auto sampleIt : samples) {
         const DecodeOrderSampleMap::KeyType& decodeKey = sampleIt.first;
 #if !LOG_DISABLED
@@ -680,9 +679,9 @@ static PassRefPtr<TimeRanges> removeSamplesFromTrackBuffer(const DecodeOrderSamp
         // Also remove the erased samples from the TrackBuffer decodeQueue.
         trackBuffer.decodeQueue.erase(decodeKey);
 
-        double startTime = sample->presentationTime().toDouble();
-        double endTime = startTime + (sample->duration() + microsecond).toDouble();
-        erasedRanges->add(startTime, endTime);
+        auto startTime = sample->presentationTime();
+        auto endTime = startTime + sample->duration();
+        erasedRanges->ranges().add(startTime, endTime);
 
 #if !LOG_DISABLED
         bytesRemoved += startBufferSize - trackBuffer.samples.sizeInBytes();
@@ -695,7 +694,7 @@ static PassRefPtr<TimeRanges> removeSamplesFromTrackBuffer(const DecodeOrderSamp
 
 #if !LOG_DISABLED
     if (bytesRemoved)
-        LOG(MediaSource, "SourceBuffer::%s(%p) removed %zu bytes, start(%lf), end(%lf)", logPrefix, buffer, bytesRemoved, earliestSample, latestSample);
+        LOG(MediaSource, "SourceBuffer::%s(%p) removed %zu bytes, start(%lf), end(%lf)", logPrefix, buffer, bytesRemoved, earliestSample.toDouble(), latestSample.toDouble());
 #endif
 
     return WTFMove(erasedRanges);
@@ -1586,7 +1585,7 @@ void SourceBuffer::sourceBufferPrivateDidReceiveSample(SourceBufferPrivate*, Pas
         if (m_shouldGenerateTimestamps)
             m_timestampOffset = frameEndTimestamp;
 
-        m_buffered->add(presentationTimestamp.toDouble(), (presentationTimestamp + frameDuration + microsecond).toDouble());
+        m_buffered->ranges().add(presentationTimestamp, presentationTimestamp + frameDuration);
         m_bufferedSinceLastMonitor += frameDuration.toDouble();
         setBufferedDirty(true);