diff --git a/Source/WebCore/Modules/mediasource/MediaSource.cpp b/Source/WebCore/Modules/mediasource/MediaSource.cpp index 3a64fa09667ff..8d6990ba843c0 100644 --- a/Source/WebCore/Modules/mediasource/MediaSource.cpp +++ b/Source/WebCore/Modules/mediasource/MediaSource.cpp @@ -248,7 +248,7 @@ void MediaSource::monitorSourceBuffers() // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-source.html#buffer-monitoring // Note, the behavior if activeSourceBuffers is empty is undefined. - if (!m_activeSourceBuffers) { + if (!m_activeSourceBuffers || m_activeSourceBuffers->length() == 0) { m_private->setReadyState(MediaPlayer::HaveNothing); return; } diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerMSE.cpp b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerMSE.cpp index 3104f3771b792..0b86dba8e315b 100644 --- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerMSE.cpp +++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerMSE.cpp @@ -819,7 +819,7 @@ void MediaPlayerPrivateGStreamerMSE::durationChanged() if (m_mediaTimeDuration != previousDuration && m_mediaTimeDuration.isValid() && previousDuration.isValid()) { m_player->durationChanged(); m_playbackPipeline->notifyDurationChanged(); - m_mediaSource->durationChanged(m_mediaTimeDuration); + m_mediaSource->durationChanged(durationMediaTime()); } } @@ -2266,7 +2266,7 @@ void MediaSourceClientGStreamerMSE::durationChanged(const MediaTime& duration) ASSERT(WTF::isMainThread()); TRACE_MEDIA_MESSAGE("duration: %f", duration.toFloat()); - if (!duration.isValid() || duration.isPositiveInfinite() || duration.isNegativeInfinite()) + if (!duration.isValid() || duration.isNegativeInfinite()) return; m_duration = duration; @@ -2391,15 +2391,19 @@ float MediaPlayerPrivateGStreamerMSE::maxTimeSeekable() const return 0.0f; LOG_MEDIA_MESSAGE("maxTimeSeekable"); - float result = duration(); - // infinite duration means live stream - if (isinf(result)) { - MediaTime maxBufferedTime = buffered()->maximumBufferedTime(); - // Return the highest end time reported by the buffered attribute. - result = maxBufferedTime.isValid() ? maxBufferedTime.toFloat() : 0; - } + return durationMediaTime().toFloat(); +} - return result; +MediaTime MediaPlayerPrivateGStreamerMSE::durationMediaTime() const +{ + // Infinite duration means live stream + if (!m_mediaTimeDuration.isPositiveInfinite()) + return m_mediaTimeDuration; + + MediaTime maxBufferedTime = buffered()->maximumBufferedTime(); + + // Return the highest end time reported by the buffered attribute + return maxBufferedTime.isValid() ? maxBufferedTime : MediaTime::zeroTime(); } } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerMSE.h b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerMSE.h index 9a2ac0ddebc7f..d8a61feb0b2db 100644 --- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerMSE.h +++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerMSE.h @@ -62,7 +62,7 @@ class MediaPlayerPrivateGStreamerMSE : public MediaPlayerPrivateGStreamer { bool changePipelineState(GstState) override; void durationChanged() override; - MediaTime durationMediaTime() const override { return m_mediaTimeDuration; } + MediaTime durationMediaTime() const override; float duration() const override; float mediaTimeForTimeValue(float timeValue) const; void setRate(float) override;