Chromium Code Reviews| 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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 354 sourceRanges->add(sourceRanges->start(sourceRanges->length() - 1, AS SERT_NO_EXCEPTION), highestEndTime); | 354 sourceRanges->add(sourceRanges->start(sourceRanges->length() - 1, AS SERT_NO_EXCEPTION), highestEndTime); |
| 355 | 355 |
| 356 // 5.3 Let new intersection ranges equal the the intersection between th e intersection ranges and the source ranges. | 356 // 5.3 Let new intersection ranges equal the the intersection between th e intersection ranges and the source ranges. |
| 357 // 5.4 Replace the ranges in intersection ranges with the new intersecti on ranges. | 357 // 5.4 Replace the ranges in intersection ranges with the new intersecti on ranges. |
| 358 intersectionRanges->intersectWith(sourceRanges); | 358 intersectionRanges->intersectWith(sourceRanges); |
| 359 } | 359 } |
| 360 | 360 |
| 361 return intersectionRanges.release(); | 361 return intersectionRanges.release(); |
| 362 } | 362 } |
| 363 | 363 |
| 364 PassRefPtrWillBeRawPtr<TimeRanges> MediaSource::seekable() const | |
| 365 { | |
| 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 | |
| 368 | |
| 369 double sourceDuration = duration(); | |
| 370 // 1. If duration equals NaN then return an empty TimeRanges object. | |
| 371 if (std::isnan(sourceDuration)) | |
| 372 return TimeRanges::create(); | |
| 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 | |
| 375 // highest end time reported by the HTMLMediaElement.buffered attribute. | |
| 376 if (sourceDuration == std::numeric_limits<double>::infinity()) { | |
| 377 RefPtrWillBeRawPtr<TimeRanges> buffered = m_attachedElement->buffered(); | |
| 378 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?
| |
| 379 return TimeRanges::create(); | |
| 380 return TimeRanges::create(0, buffered->end(buffered->length() - 1, ASSER T_NO_EXCEPTION)); | |
| 381 } | |
| 382 | |
| 383 // 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); | |
| 385 } | |
| 386 | |
| 364 void MediaSource::setDuration(double duration, ExceptionState& exceptionState) | 387 void MediaSource::setDuration(double duration, ExceptionState& exceptionState) |
| 365 { | 388 { |
| 366 // 2.1 http://www.w3.org/TR/media-source/#widl-MediaSource-duration | 389 // 2.1 http://www.w3.org/TR/media-source/#widl-MediaSource-duration |
| 367 // 1. If the value being set is negative or NaN then throw an InvalidAccessE rror | 390 // 1. If the value being set is negative or NaN then throw an InvalidAccessE rror |
| 368 // exception and abort these steps. | 391 // exception and abort these steps. |
| 369 if (std::isnan(duration)) { | 392 if (std::isnan(duration)) { |
| 370 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages:: notAFiniteNumber(duration, "duration")); | 393 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages:: notAFiniteNumber(duration, "duration")); |
| 371 return; | 394 return; |
| 372 } | 395 } |
| 373 if (duration < 0.0) { | 396 if (duration < 0.0) { |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 585 | 608 |
| 586 m_asyncEventQueue->enqueueEvent(event.release()); | 609 m_asyncEventQueue->enqueueEvent(event.release()); |
| 587 } | 610 } |
| 588 | 611 |
| 589 URLRegistry& MediaSource::registry() const | 612 URLRegistry& MediaSource::registry() const |
| 590 { | 613 { |
| 591 return MediaSourceRegistry::registry(); | 614 return MediaSourceRegistry::registry(); |
| 592 } | 615 } |
| 593 | 616 |
| 594 } // namespace blink | 617 } // namespace blink |
| OLD | NEW |