Title: [248616] branches/safari-608-branch
Revision
248616
Author
[email protected]
Date
2019-08-13 13:01:01 -0700 (Tue, 13 Aug 2019)

Log Message

Cherry-pick r248301. rdar://problem/54237793

    Adopt -expectMinimumUpcomingSampleBufferPresentationTime:
    https://bugs.webkit.org/show_bug.cgi?id=200457
    <rdar://problem/53961130>

    Reviewed by Eric Carlson.

    Source/WebCore:

    Test: media/media-source/media-source-minimumupcomingpresentationtime.html

    Adopt a new API vended by AVSampleBufferDisplayLayer, piped from SourceBuffer down
    through SourceBufferPrivate to SourceBufferPrivateAVFObjC. This value should be
    reset and updated when new samples are appended.

    * Modules/mediasource/SourceBuffer.cpp:
    (WebCore::SourceBuffer::sourceBufferPrivateDidReceiveSample):
    (WebCore::SourceBuffer::provideMediaData):
    (WebCore::SourceBuffer::updateMinimumUpcomingPresentationTime):
    (WebCore::SourceBuffer::resetMinimumUpcomingPresentationTime):
    (WebCore::SourceBuffer::minimumUpcomingPresentationTimeForTrackID):
    (WebCore::SourceBuffer::setMaximumQueueDepthForTrackID):
    * Modules/mediasource/SourceBuffer.h:
    * platform/graphics/SourceBufferPrivate.h:
    (WebCore::SourceBufferPrivate::canSetMinimumUpcomingPresentationTime const):
    (WebCore::SourceBufferPrivate::setMinimumUpcomingPresentationTime):
    (WebCore::SourceBufferPrivate::clearMinimumUpcomingPresentationTime):
    (WebCore::SourceBufferPrivate::enqueuedSamplesForTrackID):
    (WebCore::SourceBufferPrivate::minimumUpcomingPresentationTimeForTrackID):
    (WebCore::SourceBufferPrivate::setMaximumQueueDepthForTrackID):
    * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
    * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
    (WebCore::SourceBufferPrivateAVFObjC::canSetMinimumUpcomingPresentationTime const):
    (WebCore::SourceBufferPrivateAVFObjC::setMinimumUpcomingPresentationTime):
    (WebCore::SourceBufferPrivateAVFObjC::clearMinimumUpcomingPresentationTime):
    * platform/mock/mediasource/MockSourceBufferPrivate.cpp:
    (WebCore::MockSourceBufferPrivate::minimumUpcomingPresentationTimeForTrackID):
    (WebCore::MockSourceBufferPrivate::setMaximumQueueDepthForTrackID):
    (WebCore::MockSourceBufferPrivate::canSetMinimumUpcomingPresentationTime const):
    (WebCore::MockSourceBufferPrivate::setMinimumUpcomingPresentationTime):
    (WebCore::MockSourceBufferPrivate::clearMinimumUpcomingPresentationTime):
    * platform/mock/mediasource/MockSourceBufferPrivate.h:
    * testing/Internals.cpp:
    (WebCore::Internals::minimumUpcomingPresentationTimeForTrackID):
    (WebCore::Internals::setMaximumQueueDepthForTrackID):
    * testing/Internals.h:
    * testing/Internals.idl:

    LayoutTests:

    * media/media-source/media-source-minimumupcomingpresentationtime-expected.txt: Added.
    * media/media-source/media-source-minimumupcomingpresentationtime.html: Added.

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

Modified Paths

Added Paths

Diff

Modified: branches/safari-608-branch/LayoutTests/ChangeLog (248615 => 248616)


--- branches/safari-608-branch/LayoutTests/ChangeLog	2019-08-13 20:00:56 UTC (rev 248615)
+++ branches/safari-608-branch/LayoutTests/ChangeLog	2019-08-13 20:01:01 UTC (rev 248616)
@@ -1,5 +1,75 @@
 2019-08-13  Alan Coon  <[email protected]>
 
+        Cherry-pick r248301. rdar://problem/54237793
+
+    Adopt -expectMinimumUpcomingSampleBufferPresentationTime:
+    https://bugs.webkit.org/show_bug.cgi?id=200457
+    <rdar://problem/53961130>
+    
+    Reviewed by Eric Carlson.
+    
+    Source/WebCore:
+    
+    Test: media/media-source/media-source-minimumupcomingpresentationtime.html
+    
+    Adopt a new API vended by AVSampleBufferDisplayLayer, piped from SourceBuffer down
+    through SourceBufferPrivate to SourceBufferPrivateAVFObjC. This value should be
+    reset and updated when new samples are appended.
+    
+    * Modules/mediasource/SourceBuffer.cpp:
+    (WebCore::SourceBuffer::sourceBufferPrivateDidReceiveSample):
+    (WebCore::SourceBuffer::provideMediaData):
+    (WebCore::SourceBuffer::updateMinimumUpcomingPresentationTime):
+    (WebCore::SourceBuffer::resetMinimumUpcomingPresentationTime):
+    (WebCore::SourceBuffer::minimumUpcomingPresentationTimeForTrackID):
+    (WebCore::SourceBuffer::setMaximumQueueDepthForTrackID):
+    * Modules/mediasource/SourceBuffer.h:
+    * platform/graphics/SourceBufferPrivate.h:
+    (WebCore::SourceBufferPrivate::canSetMinimumUpcomingPresentationTime const):
+    (WebCore::SourceBufferPrivate::setMinimumUpcomingPresentationTime):
+    (WebCore::SourceBufferPrivate::clearMinimumUpcomingPresentationTime):
+    (WebCore::SourceBufferPrivate::enqueuedSamplesForTrackID):
+    (WebCore::SourceBufferPrivate::minimumUpcomingPresentationTimeForTrackID):
+    (WebCore::SourceBufferPrivate::setMaximumQueueDepthForTrackID):
+    * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
+    * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
+    (WebCore::SourceBufferPrivateAVFObjC::canSetMinimumUpcomingPresentationTime const):
+    (WebCore::SourceBufferPrivateAVFObjC::setMinimumUpcomingPresentationTime):
+    (WebCore::SourceBufferPrivateAVFObjC::clearMinimumUpcomingPresentationTime):
+    * platform/mock/mediasource/MockSourceBufferPrivate.cpp:
+    (WebCore::MockSourceBufferPrivate::minimumUpcomingPresentationTimeForTrackID):
+    (WebCore::MockSourceBufferPrivate::setMaximumQueueDepthForTrackID):
+    (WebCore::MockSourceBufferPrivate::canSetMinimumUpcomingPresentationTime const):
+    (WebCore::MockSourceBufferPrivate::setMinimumUpcomingPresentationTime):
+    (WebCore::MockSourceBufferPrivate::clearMinimumUpcomingPresentationTime):
+    * platform/mock/mediasource/MockSourceBufferPrivate.h:
+    * testing/Internals.cpp:
+    (WebCore::Internals::minimumUpcomingPresentationTimeForTrackID):
+    (WebCore::Internals::setMaximumQueueDepthForTrackID):
+    * testing/Internals.h:
+    * testing/Internals.idl:
+    
+    LayoutTests:
+    
+    * media/media-source/media-source-minimumupcomingpresentationtime-expected.txt: Added.
+    * media/media-source/media-source-minimumupcomingpresentationtime.html: Added.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248301 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-08-06  Jer Noble  <[email protected]>
+
+            Adopt -expectMinimumUpcomingSampleBufferPresentationTime:
+            https://bugs.webkit.org/show_bug.cgi?id=200457
+            <rdar://problem/53961130>
+
+            Reviewed by Eric Carlson.
+
+            * media/media-source/media-source-minimumupcomingpresentationtime-expected.txt: Added.
+            * media/media-source/media-source-minimumupcomingpresentationtime.html: Added.
+
+2019-08-13  Alan Coon  <[email protected]>
+
         Cherry-pick r248292. rdar://problem/54236220
 
     [iPadOS] Unable to increase zoom level on Google using the Aa menu

Added: branches/safari-608-branch/LayoutTests/media/media-source/media-source-minimumupcomingpresentationtime-expected.txt (0 => 248616)


--- branches/safari-608-branch/LayoutTests/media/media-source/media-source-minimumupcomingpresentationtime-expected.txt	                        (rev 0)
+++ branches/safari-608-branch/LayoutTests/media/media-source/media-source-minimumupcomingpresentationtime-expected.txt	2019-08-13 20:01:01 UTC (rev 248616)
@@ -0,0 +1,18 @@
+
+RUN(video.src = ""
+EVENT(sourceopen)
+RUN(sourceBuffer = source.addSourceBuffer("video/mock; codecs=mock"))
+RUN(sourceBuffer.appendBuffer(initSegment))
+EVENT(updateend)
+RUN(internals.setMaximumQueueDepthForTrackID(sourceBuffer, 1, 3))
+RUN(sourceBuffer.appendBuffer(samples))
+EVENT(updateend)
+EXPECTED (internals.minimumUpcomingPresentationTimeForTrackID(sourceBuffer, 1) == '1') OK
+RUN(video.currentTime = 4)
+EVENT(seeked)
+EXPECTED (internals.minimumUpcomingPresentationTimeForTrackID(sourceBuffer, 1) == '8') OK
+RUN(sourceBuffer.appendBuffer(samples))
+EVENT(updateend)
+EXPECTED (internals.minimumUpcomingPresentationTimeForTrackID(sourceBuffer, 1) == '7') OK
+END OF TEST
+

Added: branches/safari-608-branch/LayoutTests/media/media-source/media-source-minimumupcomingpresentationtime.html (0 => 248616)


--- branches/safari-608-branch/LayoutTests/media/media-source/media-source-minimumupcomingpresentationtime.html	                        (rev 0)
+++ branches/safari-608-branch/LayoutTests/media/media-source/media-source-minimumupcomingpresentationtime.html	2019-08-13 20:01:01 UTC (rev 248616)
@@ -0,0 +1,65 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <title>mock-media-source</title>
+    <script src=""
+    <script src=""
+    <script>
+    var source;
+    var sourceBuffer;
+    var samples;
+
+    if (window.internals)
+        internals.initializeMockMediaSource();
+
+    window.addEventListener('load', async event => {
+        findMediaElement();
+
+        source = new MediaSource();
+        run('video.src = ""
+        await waitFor(source, 'sourceopen');
+
+        run('sourceBuffer = source.addSourceBuffer("video/mock; codecs=mock")');
+        initSegment = makeAInit(8, [makeATrack(1, 'mock', TRACK_KIND.VIDEO)]);
+        run('sourceBuffer.appendBuffer(initSegment)');
+        await waitFor(sourceBuffer, 'updateend');
+
+        run('internals.setMaximumQueueDepthForTrackID(sourceBuffer, 1, 3)');
+
+        samples = concatenateSamples([
+            makeASample(0, 0, 1, 1, 1, SAMPLE_FLAG.SYNC),
+            makeASample(2, 1, 1, 1, 1, SAMPLE_FLAG.NONE),
+            makeASample(3, 2, 1, 1, 1, SAMPLE_FLAG.NONE),
+            makeASample(1, 3, 1, 1, 1, SAMPLE_FLAG.NONE),
+            makeASample(4, 4, 1, 1, 1, SAMPLE_FLAG.SYNC),
+            makeASample(5, 5, 1, 1, 1, SAMPLE_FLAG.NONE),
+            makeASample(6, 6, 1, 1, 1, SAMPLE_FLAG.NONE),
+            makeASample(8, 7, 1, 1, 1, SAMPLE_FLAG.NONE),
+        ]);
+        
+        run('sourceBuffer.appendBuffer(samples)');
+        await waitFor(sourceBuffer, 'updateend');
+
+        testExpected('internals.minimumUpcomingPresentationTimeForTrackID(sourceBuffer, 1)', 1);
+
+        run('video.currentTime = 4');
+        await waitFor(video, 'seeked');
+
+        testExpected('internals.minimumUpcomingPresentationTimeForTrackID(sourceBuffer, 1)', 8);
+
+        samples = makeASample(7, 8, 1, 1, 1, SAMPLE_FLAG.NONE),
+
+        run('sourceBuffer.appendBuffer(samples)');
+        await waitFor(sourceBuffer, 'updateend');
+
+        testExpected('internals.minimumUpcomingPresentationTimeForTrackID(sourceBuffer, 1)', 7);
+
+        endTest();
+    });
+    
+    </script>
+</head>
+<body>
+    <video></video>
+</body>
+</html>

Modified: branches/safari-608-branch/Source/WebCore/ChangeLog (248615 => 248616)


--- branches/safari-608-branch/Source/WebCore/ChangeLog	2019-08-13 20:00:56 UTC (rev 248615)
+++ branches/safari-608-branch/Source/WebCore/ChangeLog	2019-08-13 20:01:01 UTC (rev 248616)
@@ -1,5 +1,111 @@
 2019-08-13  Alan Coon  <[email protected]>
 
+        Cherry-pick r248301. rdar://problem/54237793
+
+    Adopt -expectMinimumUpcomingSampleBufferPresentationTime:
+    https://bugs.webkit.org/show_bug.cgi?id=200457
+    <rdar://problem/53961130>
+    
+    Reviewed by Eric Carlson.
+    
+    Source/WebCore:
+    
+    Test: media/media-source/media-source-minimumupcomingpresentationtime.html
+    
+    Adopt a new API vended by AVSampleBufferDisplayLayer, piped from SourceBuffer down
+    through SourceBufferPrivate to SourceBufferPrivateAVFObjC. This value should be
+    reset and updated when new samples are appended.
+    
+    * Modules/mediasource/SourceBuffer.cpp:
+    (WebCore::SourceBuffer::sourceBufferPrivateDidReceiveSample):
+    (WebCore::SourceBuffer::provideMediaData):
+    (WebCore::SourceBuffer::updateMinimumUpcomingPresentationTime):
+    (WebCore::SourceBuffer::resetMinimumUpcomingPresentationTime):
+    (WebCore::SourceBuffer::minimumUpcomingPresentationTimeForTrackID):
+    (WebCore::SourceBuffer::setMaximumQueueDepthForTrackID):
+    * Modules/mediasource/SourceBuffer.h:
+    * platform/graphics/SourceBufferPrivate.h:
+    (WebCore::SourceBufferPrivate::canSetMinimumUpcomingPresentationTime const):
+    (WebCore::SourceBufferPrivate::setMinimumUpcomingPresentationTime):
+    (WebCore::SourceBufferPrivate::clearMinimumUpcomingPresentationTime):
+    (WebCore::SourceBufferPrivate::enqueuedSamplesForTrackID):
+    (WebCore::SourceBufferPrivate::minimumUpcomingPresentationTimeForTrackID):
+    (WebCore::SourceBufferPrivate::setMaximumQueueDepthForTrackID):
+    * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
+    * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
+    (WebCore::SourceBufferPrivateAVFObjC::canSetMinimumUpcomingPresentationTime const):
+    (WebCore::SourceBufferPrivateAVFObjC::setMinimumUpcomingPresentationTime):
+    (WebCore::SourceBufferPrivateAVFObjC::clearMinimumUpcomingPresentationTime):
+    * platform/mock/mediasource/MockSourceBufferPrivate.cpp:
+    (WebCore::MockSourceBufferPrivate::minimumUpcomingPresentationTimeForTrackID):
+    (WebCore::MockSourceBufferPrivate::setMaximumQueueDepthForTrackID):
+    (WebCore::MockSourceBufferPrivate::canSetMinimumUpcomingPresentationTime const):
+    (WebCore::MockSourceBufferPrivate::setMinimumUpcomingPresentationTime):
+    (WebCore::MockSourceBufferPrivate::clearMinimumUpcomingPresentationTime):
+    * platform/mock/mediasource/MockSourceBufferPrivate.h:
+    * testing/Internals.cpp:
+    (WebCore::Internals::minimumUpcomingPresentationTimeForTrackID):
+    (WebCore::Internals::setMaximumQueueDepthForTrackID):
+    * testing/Internals.h:
+    * testing/Internals.idl:
+    
+    LayoutTests:
+    
+    * media/media-source/media-source-minimumupcomingpresentationtime-expected.txt: Added.
+    * media/media-source/media-source-minimumupcomingpresentationtime.html: Added.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248301 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-08-06  Jer Noble  <[email protected]>
+
+            Adopt -expectMinimumUpcomingSampleBufferPresentationTime:
+            https://bugs.webkit.org/show_bug.cgi?id=200457
+            <rdar://problem/53961130>
+
+            Reviewed by Eric Carlson.
+
+            Test: media/media-source/media-source-minimumupcomingpresentationtime.html
+
+            Adopt a new API vended by AVSampleBufferDisplayLayer, piped from SourceBuffer down
+            through SourceBufferPrivate to SourceBufferPrivateAVFObjC. This value should be
+            reset and updated when new samples are appended.
+
+            * Modules/mediasource/SourceBuffer.cpp:
+            (WebCore::SourceBuffer::sourceBufferPrivateDidReceiveSample):
+            (WebCore::SourceBuffer::provideMediaData):
+            (WebCore::SourceBuffer::updateMinimumUpcomingPresentationTime):
+            (WebCore::SourceBuffer::resetMinimumUpcomingPresentationTime):
+            (WebCore::SourceBuffer::minimumUpcomingPresentationTimeForTrackID):
+            (WebCore::SourceBuffer::setMaximumQueueDepthForTrackID):
+            * Modules/mediasource/SourceBuffer.h:
+            * platform/graphics/SourceBufferPrivate.h:
+            (WebCore::SourceBufferPrivate::canSetMinimumUpcomingPresentationTime const):
+            (WebCore::SourceBufferPrivate::setMinimumUpcomingPresentationTime):
+            (WebCore::SourceBufferPrivate::clearMinimumUpcomingPresentationTime):
+            (WebCore::SourceBufferPrivate::enqueuedSamplesForTrackID):
+            (WebCore::SourceBufferPrivate::minimumUpcomingPresentationTimeForTrackID):
+            (WebCore::SourceBufferPrivate::setMaximumQueueDepthForTrackID):
+            * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
+            * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
+            (WebCore::SourceBufferPrivateAVFObjC::canSetMinimumUpcomingPresentationTime const):
+            (WebCore::SourceBufferPrivateAVFObjC::setMinimumUpcomingPresentationTime):
+            (WebCore::SourceBufferPrivateAVFObjC::clearMinimumUpcomingPresentationTime):
+            * platform/mock/mediasource/MockSourceBufferPrivate.cpp:
+            (WebCore::MockSourceBufferPrivate::minimumUpcomingPresentationTimeForTrackID):
+            (WebCore::MockSourceBufferPrivate::setMaximumQueueDepthForTrackID):
+            (WebCore::MockSourceBufferPrivate::canSetMinimumUpcomingPresentationTime const):
+            (WebCore::MockSourceBufferPrivate::setMinimumUpcomingPresentationTime):
+            (WebCore::MockSourceBufferPrivate::clearMinimumUpcomingPresentationTime):
+            * platform/mock/mediasource/MockSourceBufferPrivate.h:
+            * testing/Internals.cpp:
+            (WebCore::Internals::minimumUpcomingPresentationTimeForTrackID):
+            (WebCore::Internals::setMaximumQueueDepthForTrackID):
+            * testing/Internals.h:
+            * testing/Internals.idl:
+
+2019-08-13  Alan Coon  <[email protected]>
+
         Cherry-pick r248295. rdar://problem/54237762
 
     REGRESSION: Cannot tap on any buttons on m.naver.com home screen on iPad

Modified: branches/safari-608-branch/Source/WebCore/Modules/mediasource/SourceBuffer.cpp (248615 => 248616)


--- branches/safari-608-branch/Source/WebCore/Modules/mediasource/SourceBuffer.cpp	2019-08-13 20:00:56 UTC (rev 248615)
+++ branches/safari-608-branch/Source/WebCore/Modules/mediasource/SourceBuffer.cpp	2019-08-13 20:01:01 UTC (rev 248616)
@@ -70,6 +70,7 @@
     MediaTime lastFrameDuration;
     MediaTime highestPresentationTimestamp;
     MediaTime lastEnqueuedPresentationTime;
+    MediaTime minimumEnqueuedPresentationTime;
     DecodeOrderSampleMap::KeyType lastEnqueuedDecodeKey;
     MediaTime lastEnqueuedDecodeDuration;
     MediaTime roundedTimestampOffset;
@@ -77,6 +78,7 @@
     bool needRandomAccessFlag { true };
     bool enabled { false };
     bool needsReenqueueing { false };
+    bool needsMinimumUpcomingPresentationTimeUpdating { false };
     SampleMap samples;
     DecodeOrderSampleMap::MapType decodeQueue;
     RefPtr<MediaDescription> description;
@@ -1782,6 +1784,9 @@
         DecodeOrderSampleMap::KeyType decodeKey(sample.decodeTime(), sample.presentationTime());
         if (trackBuffer.lastEnqueuedDecodeKey.first.isInvalid() || decodeKey > trackBuffer.lastEnqueuedDecodeKey) {
             trackBuffer.decodeQueue.insert(DecodeOrderSampleMap::MapType::value_type(decodeKey, &sample));
+
+            if (trackBuffer.minimumEnqueuedPresentationTime.isValid() && sample.presentationTime() < trackBuffer.minimumEnqueuedPresentationTime)
+                trackBuffer.needsMinimumUpcomingPresentationTimeUpdating = true;
         }
 
         // NOTE: the spec considers "Coded Frame Duration" to be the presentation duration, but this is not necessarily equal
@@ -2015,6 +2020,9 @@
     unsigned enqueuedSamples = 0;
 #endif
 
+    if (trackBuffer.needsMinimumUpcomingPresentationTimeUpdating)
+        resetMinimumUpcomingPresentationTime(trackBuffer, trackID);
+
     while (!trackBuffer.decodeQueue.empty()) {
         if (!m_private->isReadyForMoreSamples(trackID)) {
             DEBUG_LOG(LOGIDENTIFIER, "bailing early, track id ", trackID, " is not ready for more data");
@@ -2055,6 +2063,8 @@
 #endif
     }
 
+    updateMinimumUpcomingPresentationTime(trackBuffer, trackID);
+
 #if !RELEASE_LOG_DISABLED
     DEBUG_LOG(LOGIDENTIFIER, "enqueued ", enqueuedSamples, " samples, ", static_cast<size_t>(trackBuffer.decodeQueue.size()), " remaining");
 #endif
@@ -2062,6 +2072,41 @@
     trySignalAllSamplesInTrackEnqueued(trackID);
 }
 
+void SourceBuffer::updateMinimumUpcomingPresentationTime(TrackBuffer& trackBuffer, const AtomString& trackID)
+{
+    if (!m_private->canSetMinimumUpcomingPresentationTime(trackID))
+        return;
+
+    if (trackBuffer.decodeQueue.empty()) {
+        trackBuffer.minimumEnqueuedPresentationTime = MediaTime::invalidTime();
+        m_private->clearMinimumUpcomingPresentationTime(trackID);
+        return;
+    }
+
+    auto minPts = std::min_element(trackBuffer.decodeQueue.begin(), trackBuffer.decodeQueue.end(), [](auto& left, auto& right) -> bool {
+        return left.second->outputPresentationTime() < right.second->outputPresentationTime();
+    });
+
+    if (minPts == trackBuffer.decodeQueue.end()) {
+        trackBuffer.minimumEnqueuedPresentationTime = MediaTime::invalidTime();
+        m_private->clearMinimumUpcomingPresentationTime(trackID);
+        return;
+    }
+
+    trackBuffer.minimumEnqueuedPresentationTime = minPts->second->outputPresentationTime();
+    m_private->setMinimumUpcomingPresentationTime(trackID, trackBuffer.minimumEnqueuedPresentationTime);
+}
+
+
+void SourceBuffer::resetMinimumUpcomingPresentationTime(TrackBuffer& trackBuffer, const AtomString& trackID)
+{
+    if (!m_private->canSetMinimumUpcomingPresentationTime(trackID))
+        return;
+
+    trackBuffer.minimumEnqueuedPresentationTime = MediaTime::invalidTime();
+    m_private->clearMinimumUpcomingPresentationTime(trackID);
+}
+
 void SourceBuffer::trySignalAllSamplesInTrackEnqueued(const AtomString& trackID)
 {
     if (m_source->isEnded() && m_trackBufferMap.get(trackID).decodeQueue.empty()) {
@@ -2265,6 +2310,16 @@
     return m_private->enqueuedSamplesForTrackID(trackID);
 }
 
+MediaTime SourceBuffer::minimumUpcomingPresentationTimeForTrackID(const AtomString& trackID)
+{
+    return m_private->minimumUpcomingPresentationTimeForTrackID(trackID);
+}
+
+void SourceBuffer::setMaximumQueueDepthForTrackID(const AtomString& trackID, size_t maxQueueDepth)
+{
+    m_private->setMaximumQueueDepthForTrackID(trackID, maxQueueDepth);
+}
+
 Document& SourceBuffer::document() const
 {
     ASSERT(scriptExecutionContext());

Modified: branches/safari-608-branch/Source/WebCore/Modules/mediasource/SourceBuffer.h (248615 => 248616)


--- branches/safari-608-branch/Source/WebCore/Modules/mediasource/SourceBuffer.h	2019-08-13 20:00:56 UTC (rev 248615)
+++ branches/safari-608-branch/Source/WebCore/Modules/mediasource/SourceBuffer.h	2019-08-13 20:01:01 UTC (rev 248616)
@@ -198,6 +198,8 @@
     void reportExtraMemoryAllocated();
 
     void updateBufferedFromTrackBuffers();
+    void updateMinimumUpcomingPresentationTime(TrackBuffer&, const AtomString& trackID);
+    void resetMinimumUpcomingPresentationTime(TrackBuffer&, const AtomString& trackID);
 
     void appendError(bool);
 
@@ -210,6 +212,8 @@
     friend class Internals;
     WEBCORE_EXPORT Vector<String> bufferedSamplesForTrackID(const AtomString&);
     WEBCORE_EXPORT Vector<String> enqueuedSamplesForTrackID(const AtomString&);
+    WEBCORE_EXPORT MediaTime minimumUpcomingPresentationTimeForTrackID(const AtomString&);
+    WEBCORE_EXPORT void setMaximumQueueDepthForTrackID(const AtomString&, size_t);
 
     Ref<SourceBufferPrivate> m_private;
     MediaSource* m_source;

Modified: branches/safari-608-branch/Source/WebCore/platform/graphics/SourceBufferPrivate.h (248615 => 248616)


--- branches/safari-608-branch/Source/WebCore/platform/graphics/SourceBufferPrivate.h	2019-08-13 20:00:56 UTC (rev 248615)
+++ branches/safari-608-branch/Source/WebCore/platform/graphics/SourceBufferPrivate.h	2019-08-13 20:01:01 UTC (rev 248616)
@@ -62,10 +62,16 @@
     virtual void setActive(bool) { }
     virtual void notifyClientWhenReadyForMoreSamples(const AtomString&) { }
 
+    virtual bool canSetMinimumUpcomingPresentationTime(const AtomString&) const { return false; }
+    virtual void setMinimumUpcomingPresentationTime(const AtomString&, const MediaTime&) { }
+    virtual void clearMinimumUpcomingPresentationTime(const AtomString&) { }
+    virtual bool canSwitchToType(const ContentType&) { return false; }
+
+    // Internals Utility methods:
     virtual Vector<String> enqueuedSamplesForTrackID(const AtomString&) { return { }; }
+    virtual MediaTime minimumUpcomingPresentationTimeForTrackID(const AtomString&) { return MediaTime::invalidTime(); }
+    virtual void setMaximumQueueDepthForTrackID(const AtomString&, size_t) { }
 
-    virtual bool canSwitchToType(const ContentType&) { return false; }
-
 #if !RELEASE_LOG_DISABLED
     virtual const Logger& sourceBufferLogger() const = 0;
     virtual const void* sourceBufferLogIdentifier() = 0;

Modified: branches/safari-608-branch/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h (248615 => 248616)


--- branches/safari-608-branch/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h	2019-08-13 20:00:56 UTC (rev 248615)
+++ branches/safari-608-branch/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h	2019-08-13 20:01:01 UTC (rev 248616)
@@ -163,6 +163,9 @@
     bool isReadyForMoreSamples(const AtomString& trackID) final;
     void setActive(bool) final;
     void notifyClientWhenReadyForMoreSamples(const AtomString& trackID) final;
+    bool canSetMinimumUpcomingPresentationTime(const AtomString&) const override;
+    void setMinimumUpcomingPresentationTime(const AtomString&, const MediaTime&) override;
+    void clearMinimumUpcomingPresentationTime(const AtomString&) override;
     bool canSwitchToType(const ContentType&) final;
 
     void didBecomeReadyForMoreSamples(int trackID);

Modified: branches/safari-608-branch/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm (248615 => 248616)


--- branches/safari-608-branch/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm	2019-08-13 20:00:56 UTC (rev 248615)
+++ branches/safari-608-branch/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm	2019-08-13 20:01:01 UTC (rev 248616)
@@ -69,6 +69,8 @@
 
 @interface AVSampleBufferDisplayLayer (WebCoreAVSampleBufferDisplayLayerQueueManagementPrivate)
 - (void)prerollDecodeWithCompletionHandler:(void (^)(BOOL success))block;
+- (void)expectMinimumUpcomingSampleBufferPresentationTime: (CMTime)minimumUpcomingPresentationTime;
+- (void)resetUpcomingSampleBufferPresentationTimeExpectations;
 @end
 
 #pragma mark -
@@ -1258,6 +1260,28 @@
     }
 }
 
+bool SourceBufferPrivateAVFObjC::canSetMinimumUpcomingPresentationTime(const AtomString& trackIDString) const
+{
+    int trackID = trackIDString.toInt();
+    if (trackID == m_enabledVideoTrackID)
+        return [getAVSampleBufferDisplayLayerClass() instancesRespondToSelector:@selector(expectMinimumUpcomingSampleBufferPresentationTime:)];
+    return false;
+}
+
+void SourceBufferPrivateAVFObjC::setMinimumUpcomingPresentationTime(const AtomString& trackIDString, const MediaTime& presentationTime)
+{
+    ASSERT(canSetMinimumUpcomingPresentationTime(trackIDString));
+    if (canSetMinimumUpcomingPresentationTime(trackIDString))
+        [m_displayLayer expectMinimumUpcomingSampleBufferPresentationTime:toCMTime(presentationTime)];
+}
+
+void SourceBufferPrivateAVFObjC::clearMinimumUpcomingPresentationTime(const AtomString& trackIDString)
+{
+    ASSERT(canSetMinimumUpcomingPresentationTime(trackIDString));
+    if (canSetMinimumUpcomingPresentationTime(trackIDString))
+        [m_displayLayer resetUpcomingSampleBufferPresentationTimeExpectations];
+}
+
 bool SourceBufferPrivateAVFObjC::canSwitchToType(const ContentType& contentType)
 {
     ALWAYS_LOG(LOGIDENTIFIER, contentType);

Modified: branches/safari-608-branch/Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp (248615 => 248616)


--- branches/safari-608-branch/Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp	2019-08-13 20:00:56 UTC (rev 248615)
+++ branches/safari-608-branch/Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp	2019-08-13 20:01:01 UTC (rev 248616)
@@ -240,6 +240,31 @@
     return m_enqueuedSamples;
 }
 
+MediaTime MockSourceBufferPrivate::minimumUpcomingPresentationTimeForTrackID(const AtomString&)
+{
+    return m_minimumUpcomingPresentationTime;
+}
+
+void MockSourceBufferPrivate::setMaximumQueueDepthForTrackID(const AtomString&, size_t maxQueueDepth)
+{
+    m_maxQueueDepth = maxQueueDepth;
+}
+
+bool MockSourceBufferPrivate::canSetMinimumUpcomingPresentationTime(const AtomString&) const
+{
+    return true;
+}
+
+void MockSourceBufferPrivate::setMinimumUpcomingPresentationTime(const AtomString&, const MediaTime& presentationTime)
+{
+    m_minimumUpcomingPresentationTime = presentationTime;
+}
+
+void MockSourceBufferPrivate::clearMinimumUpcomingPresentationTime(const AtomString&)
+{
+    m_minimumUpcomingPresentationTime = MediaTime::invalidTime();
+}
+
 bool MockSourceBufferPrivate::canSwitchToType(const ContentType& contentType)
 {
     MediaEngineSupportParameters parameters;

Modified: branches/safari-608-branch/Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.h (248615 => 248616)


--- branches/safari-608-branch/Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.h	2019-08-13 20:00:56 UTC (rev 248615)
+++ branches/safari-608-branch/Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.h	2019-08-13 20:01:01 UTC (rev 248616)
@@ -62,14 +62,19 @@
     void removedFromMediaSource() final;
     MediaPlayer::ReadyState readyState() const final;
     void setReadyState(MediaPlayer::ReadyState) final;
+    bool canSetMinimumUpcomingPresentationTime(const AtomString&) const final;
+    void setMinimumUpcomingPresentationTime(const AtomString&, const MediaTime&) final;
+    void clearMinimumUpcomingPresentationTime(const AtomString&) final;
     bool canSwitchToType(const ContentType&) final;
 
-    void flush(const AtomString&) final { m_enqueuedSamples.clear(); }
+    void flush(const AtomString&) final { m_enqueuedSamples.clear(); m_minimumUpcomingPresentationTime = MediaTime::invalidTime(); }
     void enqueueSample(Ref<MediaSample>&&, const AtomString&) final;
-    bool isReadyForMoreSamples(const AtomString&) final { return true; }
+    bool isReadyForMoreSamples(const AtomString&) final { return !m_maxQueueDepth || m_enqueuedSamples.size() < m_maxQueueDepth.value(); }
     void setActive(bool) final;
 
     Vector<String> enqueuedSamplesForTrackID(const AtomString&) final;
+    MediaTime minimumUpcomingPresentationTimeForTrackID(const AtomString&) final;
+    void setMaximumQueueDepthForTrackID(const AtomString&, size_t) final;
 
     void didReceiveInitializationSegment(const MockInitializationBox&);
     void didReceiveSample(const MockSampleBox&);
@@ -81,8 +86,9 @@
 
     MockMediaSourcePrivate* m_mediaSource;
     SourceBufferPrivateClient* m_client;
+    MediaTime m_minimumUpcomingPresentationTime;
     Vector<String> m_enqueuedSamples;
-
+    Optional<size_t> m_maxQueueDepth;
     Vector<char> m_inputBuffer;
 };
 

Modified: branches/safari-608-branch/Source/WebCore/testing/Internals.cpp (248615 => 248616)


--- branches/safari-608-branch/Source/WebCore/testing/Internals.cpp	2019-08-13 20:00:56 UTC (rev 248615)
+++ branches/safari-608-branch/Source/WebCore/testing/Internals.cpp	2019-08-13 20:01:01 UTC (rev 248616)
@@ -3739,11 +3739,21 @@
     return buffer.enqueuedSamplesForTrackID(trackID);
 }
 
+double Internals::minimumUpcomingPresentationTimeForTrackID(SourceBuffer& buffer, const AtomString& trackID)
+{
+    return buffer.minimumUpcomingPresentationTimeForTrackID(trackID).toDouble();
+}
+
 void Internals::setShouldGenerateTimestamps(SourceBuffer& buffer, bool flag)
 {
     buffer.setShouldGenerateTimestamps(flag);
 }
 
+void Internals::setMaximumQueueDepthForTrackID(SourceBuffer& buffer, const AtomString& trackID, size_t maxQueueDepth)
+{
+    buffer.setMaximumQueueDepthForTrackID(trackID, maxQueueDepth);
+}
+
 #endif
 
 void Internals::enableMockMediaCapabilities()

Modified: branches/safari-608-branch/Source/WebCore/testing/Internals.h (248615 => 248616)


--- branches/safari-608-branch/Source/WebCore/testing/Internals.h	2019-08-13 20:00:56 UTC (rev 248615)
+++ branches/safari-608-branch/Source/WebCore/testing/Internals.h	2019-08-13 20:01:01 UTC (rev 248616)
@@ -581,7 +581,9 @@
     WEBCORE_TESTSUPPORT_EXPORT void initializeMockMediaSource();
     Vector<String> bufferedSamplesForTrackID(SourceBuffer&, const AtomString&);
     Vector<String> enqueuedSamplesForTrackID(SourceBuffer&, const AtomString&);
+    double minimumUpcomingPresentationTimeForTrackID(SourceBuffer&, const AtomString&);
     void setShouldGenerateTimestamps(SourceBuffer&, bool);
+    void setMaximumQueueDepthForTrackID(SourceBuffer&, const AtomString&, size_t);
 #endif
 
 #if ENABLE(VIDEO)

Modified: branches/safari-608-branch/Source/WebCore/testing/Internals.idl (248615 => 248616)


--- branches/safari-608-branch/Source/WebCore/testing/Internals.idl	2019-08-13 20:00:56 UTC (rev 248615)
+++ branches/safari-608-branch/Source/WebCore/testing/Internals.idl	2019-08-13 20:01:01 UTC (rev 248616)
@@ -585,6 +585,8 @@
     [Conditional=MEDIA_SOURCE] sequence<DOMString> bufferedSamplesForTrackID(SourceBuffer buffer, DOMString trackID);
     [Conditional=MEDIA_SOURCE] sequence<DOMString> enqueuedSamplesForTrackID(SourceBuffer buffer, DOMString trackID);
     [Conditional=MEDIA_SOURCE] void setShouldGenerateTimestamps(SourceBuffer buffer, boolean flag);
+    [Conditional=MEDIA_SOURCE] double minimumUpcomingPresentationTimeForTrackID(SourceBuffer buffer, DOMString trackID);
+    [Conditional=MEDIA_SOURCE] void setMaximumQueueDepthForTrackID(SourceBuffer buffer, DOMString trackID, unsigned long maxQueueDepth);
 
     [Conditional=VIDEO, MayThrowException] void beginMediaSessionInterruption(DOMString interruptionType);
     [Conditional=VIDEO] void endMediaSessionInterruption(DOMString flags);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to