OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 | 360 |
361 return intersectionRanges.release(); | 361 return intersectionRanges.release(); |
362 } | 362 } |
363 | 363 |
364 PassRefPtrWillBeRawPtr<TimeRanges> MediaSource::seekable() const | 364 PassRefPtrWillBeRawPtr<TimeRanges> MediaSource::seekable() const |
365 { | 365 { |
366 // Implements MediaSource algorithm for HTMLMediaElement.seekable. | 366 // Implements MediaSource algorithm for HTMLMediaElement.seekable. |
367 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou
rce.html#htmlmediaelement-extensions | 367 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou
rce.html#htmlmediaelement-extensions |
368 | 368 |
369 double sourceDuration = duration(); | 369 double sourceDuration = duration(); |
370 // 1. If duration equals NaN then return an empty TimeRanges object. | 370 // If duration equals NaN: Return an empty TimeRanges object. |
371 if (std::isnan(sourceDuration)) | 371 if (std::isnan(sourceDuration)) |
372 return TimeRanges::create(); | 372 return TimeRanges::create(); |
373 | 373 |
374 // 2. If duration equals positive Infinity, then return a single range with
a start time of 0 and an end time equal to the | 374 // If duration equals positive Infinity: |
375 // highest end time reported by the HTMLMediaElement.buffered attribute. | |
376 if (sourceDuration == std::numeric_limits<double>::infinity()) { | 375 if (sourceDuration == std::numeric_limits<double>::infinity()) { |
377 RefPtrWillBeRawPtr<TimeRanges> buffered = m_attachedElement->buffered(); | 376 RefPtrWillBeRawPtr<TimeRanges> buffered = m_attachedElement->buffered(); |
| 377 |
| 378 // 1. If the HTMLMediaElement.buffered attribute returns an empty TimeRa
nges object, then |
| 379 // return an empty TimeRanges object and abort these steps. |
378 if (buffered->length() == 0) | 380 if (buffered->length() == 0) |
379 return TimeRanges::create(); | 381 return TimeRanges::create(); |
| 382 |
| 383 // 2. Return a single range with a start time of 0 and an end time equal
to the highest end |
| 384 // time reported by the HTMLMediaElement.buffered attribute. |
380 return TimeRanges::create(0, buffered->end(buffered->length() - 1, ASSER
T_NO_EXCEPTION)); | 385 return TimeRanges::create(0, buffered->end(buffered->length() - 1, ASSER
T_NO_EXCEPTION)); |
381 } | 386 } |
382 | 387 |
383 // 3. Otherwise, return a single range with a start time of 0 and an end tim
e equal to duration. | 388 // 3. Otherwise: Return a single range with a start time of 0 and an end tim
e equal to duration. |
384 return TimeRanges::create(0, sourceDuration); | 389 return TimeRanges::create(0, sourceDuration); |
385 } | 390 } |
386 | 391 |
387 void MediaSource::setDuration(double duration, ExceptionState& exceptionState) | 392 void MediaSource::setDuration(double duration, ExceptionState& exceptionState) |
388 { | 393 { |
389 // 2.1 http://www.w3.org/TR/media-source/#widl-MediaSource-duration | 394 // 2.1 http://www.w3.org/TR/media-source/#widl-MediaSource-duration |
390 // 1. If the value being set is negative or NaN then throw an InvalidAccessE
rror | 395 // 1. If the value being set is negative or NaN then throw an InvalidAccessE
rror |
391 // exception and abort these steps. | 396 // exception and abort these steps. |
392 if (std::isnan(duration)) { | 397 if (std::isnan(duration)) { |
393 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
notAFiniteNumber(duration, "duration")); | 398 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
notAFiniteNumber(duration, "duration")); |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 | 613 |
609 m_asyncEventQueue->enqueueEvent(event.release()); | 614 m_asyncEventQueue->enqueueEvent(event.release()); |
610 } | 615 } |
611 | 616 |
612 URLRegistry& MediaSource::registry() const | 617 URLRegistry& MediaSource::registry() const |
613 { | 618 { |
614 return MediaSourceRegistry::registry(); | 619 return MediaSourceRegistry::registry(); |
615 } | 620 } |
616 | 621 |
617 } // namespace blink | 622 } // namespace blink |
OLD | NEW |