Skip to content

Commit b347fee

Browse files
jyavenardcalvaris
authored andcommitted
Remove access from MediaPlayerPrivateMediaSource to MediaSourcePrivate::buffered
https://bugs.webkit.org/show_bug.cgi?id=269560 rdar://problem/123074982 Reviewed by Youenn Fablet. When a MediaSource object is in use, the HTMLMediaElement retrieves the buffered directly from it rather than from the MediaPlayer/MediaPlayerPrivate. As such, we don't need to implement the buffered method for the MediaPlayerPrivateMediaSourceX. No change in observable behaviour, Covered by existing tests. * Source/WebCore/Modules/mediasource/MediaSource.cpp: (WebCore::MediaSource::buffered const): (WebCore::MediaSource::hasBufferedTime): * Source/WebCore/Modules/mediasource/MediaSource.h: * Source/WebCore/html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::mediaPlayerBufferedTimeRangesChanged): * Source/WebCore/platform/graphics/MediaSourcePrivate.cpp: (WebCore::MediaSourcePrivate::hasFutureTime const): (WebCore::MediaSourcePrivate::duration const): (WebCore::MediaSourcePrivate::buffered const): * Source/WebCore/platform/graphics/MediaSourcePrivate.h: * Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::buffered const): * Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp: (WebCore::MediaPlayerPrivateGStreamerMSE::buffered const): * Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.cpp: (WebCore::MockMediaPlayerMediaSource::buffered const): (WebCore::MockMediaPlayerMediaSource::advanceCurrentTime): Canonical link: https://commits.webkit.org/274824@main
1 parent bca46e6 commit b347fee

8 files changed

Lines changed: 16 additions & 17 deletions

File tree

Source/WebCore/Modules/mediasource/MediaSource.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ MediaTime MediaSource::currentTime() const
201201
return m_private->currentTime();
202202
}
203203

204-
const PlatformTimeRanges& MediaSource::buffered() const
204+
PlatformTimeRanges MediaSource::buffered() const
205205
{
206206
assertIsCurrent(m_dispatcher);
207207

@@ -403,7 +403,7 @@ bool MediaSource::hasBufferedTime(const MediaTime& time)
403403
if (time > duration())
404404
return false;
405405

406-
auto& ranges = m_private->buffered();
406+
auto ranges = m_private->buffered();
407407
if (!ranges.length())
408408
return false;
409409

Source/WebCore/Modules/mediasource/MediaSource.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class MediaSource
8787
bool isEnded() const;
8888
void sourceBufferDidChangeActiveState(SourceBuffer&, bool);
8989
MediaTime duration() const;
90-
const PlatformTimeRanges& buffered() const;
90+
PlatformTimeRanges buffered() const;
9191

9292
enum class EndOfStreamError { Network, Decode };
9393
void streamEndedWithError(std::optional<EndOfStreamError>);

Source/WebCore/html/HTMLMediaElement.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8023,13 +8023,11 @@ void HTMLMediaElement::mediaPlayerBufferedTimeRangesChanged()
80238023
if (!track.shouldPurgeCuesFromUnbufferedRanges())
80248024
continue;
80258025

8026-
auto& buffered =
8026+
track.removeCuesNotInTimeRanges(
80278027
#if ENABLE(MEDIA_SOURCE)
80288028
m_mediaSource ? m_mediaSource->buffered() :
80298029
#endif
8030-
m_player->buffered();
8031-
8032-
track.removeCuesNotInTimeRanges(buffered);
8030+
m_player->buffered());
80338031
}
80348032
});
80358033
}

Source/WebCore/platform/graphics/MediaSourcePrivate.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ bool MediaSourcePrivate::hasFutureTime(const MediaTime& currentTime) const
3939
if (currentTime >= duration())
4040
return false;
4141

42-
auto& ranges = buffered();
42+
auto ranges = buffered();
4343
MediaTime nearest = ranges.nearest(currentTime);
4444
if (abs(nearest - currentTime) > timeFudgeFactor())
4545
return false;
@@ -73,7 +73,7 @@ RefPtr<MediaSourcePrivateClient> MediaSourcePrivate::client() const
7373
return m_client.get();
7474
}
7575

76-
const MediaTime& MediaSourcePrivate::duration() const
76+
MediaTime MediaSourcePrivate::duration() const
7777
{
7878
Locker locker { m_lock };
7979

@@ -163,7 +163,7 @@ void MediaSourcePrivate::bufferedChanged(const PlatformTimeRanges& buffered)
163163
m_buffered = buffered;
164164
}
165165

166-
const PlatformTimeRanges& MediaSourcePrivate::buffered() const
166+
PlatformTimeRanges MediaSourcePrivate::buffered() const
167167
{
168168
Locker locker { m_lock };
169169

Source/WebCore/platform/graphics/MediaSourcePrivate.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ class WEBCORE_EXPORT MediaSourcePrivate
9595
virtual void setTimeFudgeFactor(const MediaTime& fudgeFactor) { m_timeFudgeFactor = fudgeFactor; }
9696
MediaTime timeFudgeFactor() const { return m_timeFudgeFactor; }
9797

98-
const MediaTime& duration() const;
99-
const PlatformTimeRanges& buffered() const;
98+
MediaTime duration() const;
99+
PlatformTimeRanges buffered() const;
100100

101101
bool hasFutureTime(const MediaTime& currentTime) const;
102102
bool hasAudio() const;

Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,8 @@ void getSupportedTypes(HashSet<String>& types) const final
672672

673673
const PlatformTimeRanges& MediaPlayerPrivateMediaSourceAVFObjC::buffered() const
674674
{
675-
return m_mediaSourcePrivate ? m_mediaSourcePrivate->buffered() : PlatformTimeRanges::emptyRanges();
675+
ASSERT_NOT_REACHED();
676+
return PlatformTimeRanges::emptyRanges();
676677
}
677678

678679
bool MediaPlayerPrivateMediaSourceAVFObjC::didLoadingProgress() const

Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,7 @@ void MediaPlayerPrivateGStreamerMSE::didPreroll()
300300

301301
const PlatformTimeRanges& MediaPlayerPrivateGStreamerMSE::buffered() const
302302
{
303-
if (m_mediaSourcePrivate)
304-
return m_mediaSourcePrivate->buffered();
303+
ASSERT_NOT_REACHED();
305304
return PlatformTimeRanges::emptyRanges();
306305
}
307306

Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ MediaTime MockMediaPlayerMediaSource::maxTimeSeekable() const
177177

178178
const PlatformTimeRanges& MockMediaPlayerMediaSource::buffered() const
179179
{
180-
return m_mediaSourcePrivate ? m_mediaSourcePrivate->buffered() : PlatformTimeRanges::emptyRanges();
180+
ASSERT_NOT_REACHED();
181+
return PlatformTimeRanges::emptyRanges();
181182
}
182183

183184
bool MockMediaPlayerMediaSource::didLoadingProgress() const
@@ -247,7 +248,7 @@ void MockMediaPlayerMediaSource::advanceCurrentTime()
247248
if (!m_mediaSourcePrivate)
248249
return;
249250

250-
auto& buffered = m_mediaSourcePrivate->buffered();
251+
auto buffered = m_mediaSourcePrivate->buffered();
251252
size_t pos = buffered.find(m_currentTime);
252253
if (pos == notFound)
253254
return;

0 commit comments

Comments
 (0)