Skip to content

Commit eed8c3c

Browse files
committed
[acn][webkit]: add finding next sync sample to seek the next buffered sync sample in the appended buffers
1 parent c98e1e2 commit eed8c3c

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
diff --git a/Source/WebCore/Modules/mediasource/MediaSource.cpp b/Source/WebCore/Modules/mediasource/MediaSource.cpp
2+
index 46ce126..23674fa 100644
3+
--- a/Source/WebCore/Modules/mediasource/MediaSource.cpp
4+
+++ b/Source/WebCore/Modules/mediasource/MediaSource.cpp
5+
@@ -232,6 +232,14 @@ void MediaSource::seekToTime(const MediaTime& time)
6+
// ↳ Otherwise
7+
// Continue
8+
9+
+#if PLATFORM(BCM_NEXUS)
10+
+ MediaTime negativeThreshold = MediaTime::zeroTime();
11+
+ MediaTime positiveThreshold = MediaTime(10, 1); // Find sync sample in the next 5 seconds
12+
+ for (auto& sourceBuffer : *m_activeSourceBuffers) {
13+
+ m_pendingSeekTime = sourceBuffer->findVideoSyncSampleMediaTime(time, negativeThreshold, positiveThreshold);
14+
+ }
15+
+#endif
16+
+
17+
// https://bugs.webkit.org/show_bug.cgi?id=125157 broke seek on MediaPlayerPrivateGStreamerMSE
18+
#if !USE(GSTREAMER)
19+
m_private->waitForSeekCompleted();
20+
diff --git a/Source/WebCore/Modules/mediasource/SourceBuffer.cpp b/Source/WebCore/Modules/mediasource/SourceBuffer.cpp
21+
index 75fbbab..c56f983 100644
22+
--- a/Source/WebCore/Modules/mediasource/SourceBuffer.cpp
23+
+++ b/Source/WebCore/Modules/mediasource/SourceBuffer.cpp
24+
@@ -435,6 +435,49 @@ void SourceBuffer::seekToTime(const MediaTime& time)
25+
}
26+
}
27+
28+
+#if PLATFORM(BCM_NEXUS)
29+
+MediaTime SourceBuffer::findVideoSyncSampleMediaTime(const MediaTime& targetTime, const MediaTime& negativeThreshold, const MediaTime& positiveThreshold)
30+
+{
31+
+ MediaTime seekTime = targetTime;
32+
+ MediaTime lowerBoundTime = targetTime - negativeThreshold;
33+
+ MediaTime upperBoundTime = targetTime + positiveThreshold;
34+
+
35+
+ for (auto& trackBufferPair : m_trackBufferMap) {
36+
+ const auto& trackID = trackBufferPair.key;
37+
+ if (trackID.startsWith("V")) {
38+
+ TrackBuffer& trackBuffer = trackBufferPair.value;
39+
+
40+
+ // Find the sample which contains the target time.
41+
+ auto futureSyncSampleIterator = trackBuffer.samples.decodeOrder().findSyncSampleAfterPresentationTime(targetTime, positiveThreshold);
42+
+ auto pastSyncSampleIterator = trackBuffer.samples.decodeOrder().findSyncSamplePriorToPresentationTime(targetTime, negativeThreshold);
43+
+ auto upperBound = trackBuffer.samples.decodeOrder().end();
44+
+ auto lowerBound = trackBuffer.samples.decodeOrder().rend();
45+
+
46+
+ if (futureSyncSampleIterator == upperBound && pastSyncSampleIterator == lowerBound)
47+
+ continue;
48+
+
49+
+ MediaTime futureSeekTime = MediaTime::positiveInfiniteTime();
50+
+ if (futureSyncSampleIterator != upperBound) {
51+
+ RefPtr<MediaSample>& sample = futureSyncSampleIterator->second;
52+
+ futureSeekTime = sample->presentationTime();
53+
+ }
54+
+
55+
+ MediaTime pastSeekTime = MediaTime::negativeInfiniteTime();
56+
+ if (pastSyncSampleIterator != lowerBound) {
57+
+ RefPtr<MediaSample>& sample = pastSyncSampleIterator->second;
58+
+ pastSeekTime = sample->presentationTime();
59+
+ }
60+
+
61+
+ MediaTime trackSeekTime = abs(targetTime - futureSeekTime) < abs(targetTime - pastSeekTime) ? futureSeekTime : pastSeekTime;
62+
+ if (abs(targetTime - trackSeekTime) > abs(targetTime - seekTime))
63+
+ seekTime = trackSeekTime;
64+
+ }
65+
+ }
66+
+
67+
+ return seekTime;
68+
+}
69+
+#endif
70+
+
71+
MediaTime SourceBuffer::sourceBufferPrivateFastSeekTimeForMediaTime(const MediaTime& targetTime, const MediaTime& negativeThreshold, const MediaTime& positiveThreshold)
72+
{
73+
MediaTime seekTime = targetTime;
74+
diff --git a/Source/WebCore/Modules/mediasource/SourceBuffer.h b/Source/WebCore/Modules/mediasource/SourceBuffer.h
75+
index 9109186..832c0a3 100644
76+
--- a/Source/WebCore/Modules/mediasource/SourceBuffer.h
77+
+++ b/Source/WebCore/Modules/mediasource/SourceBuffer.h
78+
@@ -86,7 +86,9 @@ public:
79+
void abortIfUpdating();
80+
void removedFromMediaSource();
81+
void seekToTime(const MediaTime&);
82+
-
83+
+#if PLATFORM(BCM_NEXUS)
84+
+ MediaTime findVideoSyncSampleMediaTime(const MediaTime&, const MediaTime& negativeThreshold, const MediaTime& positiveThreshold);
85+
+#endif
86+
bool canPlayThroughRange(PlatformTimeRanges&);
87+
88+
bool hasVideo() const;

0 commit comments

Comments
 (0)