Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1399)

Unified Diff: Source/modules/mediasource/MediaSource.cpp

Issue 710173004: Implement seekable() according to the MediaSource specification (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/modules/mediasource/MediaSource.cpp
diff --git a/Source/modules/mediasource/MediaSource.cpp b/Source/modules/mediasource/MediaSource.cpp
index 2580e8ab2ea7e39b193ce5ff17bcc736e6ba350a..73242b7d1d28e2492361a9e48b6f60513af51f6d 100644
--- a/Source/modules/mediasource/MediaSource.cpp
+++ b/Source/modules/mediasource/MediaSource.cpp
@@ -361,6 +361,29 @@ PassRefPtrWillBeRawPtr<TimeRanges> MediaSource::buffered() const
return intersectionRanges.release();
}
+PassRefPtrWillBeRawPtr<TimeRanges> MediaSource::seekable() const
+{
+ // Implements MediaSource algorithm for HTMLMediaElement.seekable.
+ // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-source.html#htmlmediaelement-extensions
+
+ double sourceDuration = duration();
+ // 1. If duration equals NaN then return an empty TimeRanges object.
+ if (std::isnan(sourceDuration))
+ return TimeRanges::create();
+
+ // 2. If duration equals positive Infinity, then return a single range with a start time of 0 and an end time equal to the
+ // highest end time reported by the HTMLMediaElement.buffered attribute.
+ if (sourceDuration == std::numeric_limits<double>::infinity()) {
+ RefPtrWillBeRawPtr<TimeRanges> buffered = m_attachedElement->buffered();
+ if (buffered->length() == 0)
philipj_slow 2014/11/11 10:09:02 The spec doesn't mention this case. If it's imposs
Henrik Steen 2014/11/11 10:42:37 Filed https://www.w3.org/Bugs/Public/show_bug.cgi?
+ return TimeRanges::create();
+ return TimeRanges::create(0, buffered->end(buffered->length() - 1, ASSERT_NO_EXCEPTION));
+ }
+
+ // 3. Otherwise, return a single range with a start time of 0 and an end time equal to duration.
+ return TimeRanges::create(0, sourceDuration);
+}
+
void MediaSource::setDuration(double duration, ExceptionState& exceptionState)
{
// 2.1 http://www.w3.org/TR/media-source/#widl-MediaSource-duration

Powered by Google App Engine
This is Rietveld 408576698