From eed8c3c754baa1fb681b0c71d095cdd47daa15a7 Mon Sep 17 00:00:00 2001 From: modeveci Date: Mon, 19 Feb 2018 18:24:36 +0100 Subject: [PATCH] [acn][webkit]: add finding next sync sample to seek the next buffered sync sample in the appended buffers --- ...se-next-sync-sample-for-seek-to-time.patch | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 package/wpe/wpewebkit/0002-use-next-sync-sample-for-seek-to-time.patch diff --git a/package/wpe/wpewebkit/0002-use-next-sync-sample-for-seek-to-time.patch b/package/wpe/wpewebkit/0002-use-next-sync-sample-for-seek-to-time.patch new file mode 100644 index 000000000000..06cc35bdb2b7 --- /dev/null +++ b/package/wpe/wpewebkit/0002-use-next-sync-sample-for-seek-to-time.patch @@ -0,0 +1,88 @@ +diff --git a/Source/WebCore/Modules/mediasource/MediaSource.cpp b/Source/WebCore/Modules/mediasource/MediaSource.cpp +index 46ce126..23674fa 100644 +--- a/Source/WebCore/Modules/mediasource/MediaSource.cpp ++++ b/Source/WebCore/Modules/mediasource/MediaSource.cpp +@@ -232,6 +232,14 @@ void MediaSource::seekToTime(const MediaTime& time) + // ↳ Otherwise + // Continue + ++#if PLATFORM(BCM_NEXUS) ++ MediaTime negativeThreshold = MediaTime::zeroTime(); ++ MediaTime positiveThreshold = MediaTime(10, 1); // Find sync sample in the next 5 seconds ++ for (auto& sourceBuffer : *m_activeSourceBuffers) { ++ m_pendingSeekTime = sourceBuffer->findVideoSyncSampleMediaTime(time, negativeThreshold, positiveThreshold); ++ } ++#endif ++ + // https://bugs.webkit.org/show_bug.cgi?id=125157 broke seek on MediaPlayerPrivateGStreamerMSE + #if !USE(GSTREAMER) + m_private->waitForSeekCompleted(); +diff --git a/Source/WebCore/Modules/mediasource/SourceBuffer.cpp b/Source/WebCore/Modules/mediasource/SourceBuffer.cpp +index 75fbbab..c56f983 100644 +--- a/Source/WebCore/Modules/mediasource/SourceBuffer.cpp ++++ b/Source/WebCore/Modules/mediasource/SourceBuffer.cpp +@@ -435,6 +435,49 @@ void SourceBuffer::seekToTime(const MediaTime& time) + } + } + ++#if PLATFORM(BCM_NEXUS) ++MediaTime SourceBuffer::findVideoSyncSampleMediaTime(const MediaTime& targetTime, const MediaTime& negativeThreshold, const MediaTime& positiveThreshold) ++{ ++ MediaTime seekTime = targetTime; ++ MediaTime lowerBoundTime = targetTime - negativeThreshold; ++ MediaTime upperBoundTime = targetTime + positiveThreshold; ++ ++ for (auto& trackBufferPair : m_trackBufferMap) { ++ const auto& trackID = trackBufferPair.key; ++ if (trackID.startsWith("V")) { ++ TrackBuffer& trackBuffer = trackBufferPair.value; ++ ++ // Find the sample which contains the target time. ++ auto futureSyncSampleIterator = trackBuffer.samples.decodeOrder().findSyncSampleAfterPresentationTime(targetTime, positiveThreshold); ++ auto pastSyncSampleIterator = trackBuffer.samples.decodeOrder().findSyncSamplePriorToPresentationTime(targetTime, negativeThreshold); ++ auto upperBound = trackBuffer.samples.decodeOrder().end(); ++ auto lowerBound = trackBuffer.samples.decodeOrder().rend(); ++ ++ if (futureSyncSampleIterator == upperBound && pastSyncSampleIterator == lowerBound) ++ continue; ++ ++ MediaTime futureSeekTime = MediaTime::positiveInfiniteTime(); ++ if (futureSyncSampleIterator != upperBound) { ++ RefPtr& sample = futureSyncSampleIterator->second; ++ futureSeekTime = sample->presentationTime(); ++ } ++ ++ MediaTime pastSeekTime = MediaTime::negativeInfiniteTime(); ++ if (pastSyncSampleIterator != lowerBound) { ++ RefPtr& sample = pastSyncSampleIterator->second; ++ pastSeekTime = sample->presentationTime(); ++ } ++ ++ MediaTime trackSeekTime = abs(targetTime - futureSeekTime) < abs(targetTime - pastSeekTime) ? futureSeekTime : pastSeekTime; ++ if (abs(targetTime - trackSeekTime) > abs(targetTime - seekTime)) ++ seekTime = trackSeekTime; ++ } ++ } ++ ++ return seekTime; ++} ++#endif ++ + MediaTime SourceBuffer::sourceBufferPrivateFastSeekTimeForMediaTime(const MediaTime& targetTime, const MediaTime& negativeThreshold, const MediaTime& positiveThreshold) + { + MediaTime seekTime = targetTime; +diff --git a/Source/WebCore/Modules/mediasource/SourceBuffer.h b/Source/WebCore/Modules/mediasource/SourceBuffer.h +index 9109186..832c0a3 100644 +--- a/Source/WebCore/Modules/mediasource/SourceBuffer.h ++++ b/Source/WebCore/Modules/mediasource/SourceBuffer.h +@@ -86,7 +86,9 @@ public: + void abortIfUpdating(); + void removedFromMediaSource(); + void seekToTime(const MediaTime&); +- ++#if PLATFORM(BCM_NEXUS) ++ MediaTime findVideoSyncSampleMediaTime(const MediaTime&, const MediaTime& negativeThreshold, const MediaTime& positiveThreshold); ++#endif + bool canPlayThroughRange(PlatformTimeRanges&); + + bool hasVideo() const;