| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 #include "wtf/text/CString.h" | 51 #include "wtf/text/CString.h" |
| 52 #include <memory> | 52 #include <memory> |
| 53 | 53 |
| 54 using blink::WebMediaSource; | 54 using blink::WebMediaSource; |
| 55 using blink::WebSourceBuffer; | 55 using blink::WebSourceBuffer; |
| 56 | 56 |
| 57 #define MSLOG DVLOG(3) | 57 #define MSLOG DVLOG(3) |
| 58 | 58 |
| 59 namespace blink { | 59 namespace blink { |
| 60 | 60 |
| 61 static bool throwExceptionIfClosedOrUpdating(bool isOpen, bool isUpdating, Excep
tionState& exceptionState) | 61 static bool throwExceptionIfClosed(bool isOpen, ExceptionState& exceptionState) |
| 62 { | 62 { |
| 63 if (!isOpen) { | 63 if (!isOpen) { |
| 64 MediaSource::logAndThrowDOMException(exceptionState, InvalidStateError,
"The MediaSource's readyState is not 'open'."); | 64 MediaSource::logAndThrowDOMException(exceptionState, InvalidStateError,
"The MediaSource's readyState is not 'open'."); |
| 65 return true; | 65 return true; |
| 66 } | 66 } |
| 67 |
| 68 return false; |
| 69 } |
| 70 |
| 71 static bool throwExceptionIfClosedOrUpdating(bool isOpen, bool isUpdating, Excep
tionState& exceptionState) |
| 72 { |
| 73 if (throwExceptionIfClosed(isOpen, exceptionState)) |
| 74 return true; |
| 75 |
| 67 if (isUpdating) { | 76 if (isUpdating) { |
| 68 MediaSource::logAndThrowDOMException(exceptionState, InvalidStateError,
"The 'updating' attribute is true on one or more of this MediaSource's SourceBuf
fers."); | 77 MediaSource::logAndThrowDOMException(exceptionState, InvalidStateError,
"The 'updating' attribute is true on one or more of this MediaSource's SourceBuf
fers."); |
| 69 return true; | 78 return true; |
| 70 } | 79 } |
| 71 | 80 |
| 72 return false; | 81 return false; |
| 73 } | 82 } |
| 74 | 83 |
| 75 const AtomicString& MediaSource::openKeyword() | 84 const AtomicString& MediaSource::openKeyword() |
| 76 { | 85 { |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 } | 531 } |
| 523 | 532 |
| 524 void MediaSource::setLiveSeekableRange(double start, double end, ExceptionState&
exceptionState) | 533 void MediaSource::setLiveSeekableRange(double start, double end, ExceptionState&
exceptionState) |
| 525 { | 534 { |
| 526 // http://w3c.github.io/media-source/#widl-MediaSource-setLiveSeekableRange-
void-double-start-double-end | 535 // http://w3c.github.io/media-source/#widl-MediaSource-setLiveSeekableRange-
void-double-start-double-end |
| 527 // 1. If the readyState attribute is not "open" then throw an | 536 // 1. If the readyState attribute is not "open" then throw an |
| 528 // InvalidStateError exception and abort these steps. | 537 // InvalidStateError exception and abort these steps. |
| 529 // 2. If the updating attribute equals true on any SourceBuffer in | 538 // 2. If the updating attribute equals true on any SourceBuffer in |
| 530 // SourceBuffers, then throw an InvalidStateError exception and abort | 539 // SourceBuffers, then throw an InvalidStateError exception and abort |
| 531 // these steps. | 540 // these steps. |
| 532 if (throwExceptionIfClosedOrUpdating(isOpen(), isUpdating(), exceptionState)
) | 541 // Note: https://github.com/w3c/media-source/issues/118, once fixed, will |
| 542 // remove the updating check (step 2). We skip that check here already. |
| 543 if (throwExceptionIfClosed(isOpen(), exceptionState)) |
| 533 return; | 544 return; |
| 534 | 545 |
| 535 // 3. If start is negative or greater than end, then throw a TypeError | 546 // 3. If start is negative or greater than end, then throw a TypeError |
| 536 // exception and abort these steps. | 547 // exception and abort these steps. |
| 537 if (start < 0 || start > end) { | 548 if (start < 0 || start > end) { |
| 538 exceptionState.throwTypeError(ExceptionMessages::indexOutsideRange("star
t value", start, 0.0, ExceptionMessages::InclusiveBound, end, ExceptionMessages:
:InclusiveBound)); | 549 exceptionState.throwTypeError(ExceptionMessages::indexOutsideRange("star
t value", start, 0.0, ExceptionMessages::InclusiveBound, end, ExceptionMessages:
:InclusiveBound)); |
| 539 return; | 550 return; |
| 540 } | 551 } |
| 541 | 552 |
| 542 // 4. Set live seekable range to be a new normalized TimeRanges object | 553 // 4. Set live seekable range to be a new normalized TimeRanges object |
| 543 // containing a single range whose start position is start and end | 554 // containing a single range whose start position is start and end |
| 544 // position is end. | 555 // position is end. |
| 545 m_liveSeekableRange = TimeRanges::create(start, end); | 556 m_liveSeekableRange = TimeRanges::create(start, end); |
| 546 } | 557 } |
| 547 | 558 |
| 548 void MediaSource::clearLiveSeekableRange(ExceptionState& exceptionState) | 559 void MediaSource::clearLiveSeekableRange(ExceptionState& exceptionState) |
| 549 { | 560 { |
| 550 // http://w3c.github.io/media-source/#widl-MediaSource-clearLiveSeekableRang
e-void | 561 // http://w3c.github.io/media-source/#widl-MediaSource-clearLiveSeekableRang
e-void |
| 551 // 1. If the readyState attribute is not "open" then throw an | 562 // 1. If the readyState attribute is not "open" then throw an |
| 552 // InvalidStateError exception and abort these steps. | 563 // InvalidStateError exception and abort these steps. |
| 553 // 2. If the updating attribute equals true on any SourceBuffer in | 564 // 2. If the updating attribute equals true on any SourceBuffer in |
| 554 // SourceBuffers, then throw an InvalidStateError exception and abort | 565 // SourceBuffers, then throw an InvalidStateError exception and abort |
| 555 // these steps. | 566 // these steps. |
| 556 if (throwExceptionIfClosedOrUpdating(isOpen(), isUpdating(), exceptionState)
) | 567 // Note: https://github.com/w3c/media-source/issues/118, once fixed, will |
| 568 // remove the updating check (step 2). We skip that check here already. |
| 569 if (throwExceptionIfClosed(isOpen(), exceptionState)) |
| 557 return; | 570 return; |
| 558 | 571 |
| 559 // 3. If live seekable range contains a range, then set live seekable range | 572 // 3. If live seekable range contains a range, then set live seekable range |
| 560 // to be a new empty TimeRanges object. | 573 // to be a new empty TimeRanges object. |
| 561 if (m_liveSeekableRange->length() != 0) | 574 if (m_liveSeekableRange->length() != 0) |
| 562 m_liveSeekableRange = TimeRanges::create(); | 575 m_liveSeekableRange = TimeRanges::create(); |
| 563 } | 576 } |
| 564 | 577 |
| 565 void MediaSource::endOfStreamInternal(const WebMediaSource::EndOfStreamStatus eo
sStatus, ExceptionState& exceptionState) | 578 void MediaSource::endOfStreamInternal(const WebMediaSource::EndOfStreamStatus eo
sStatus, ExceptionState& exceptionState) |
| 566 { | 579 { |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 | 709 |
| 697 m_asyncEventQueue->enqueueEvent(event); | 710 m_asyncEventQueue->enqueueEvent(event); |
| 698 } | 711 } |
| 699 | 712 |
| 700 URLRegistry& MediaSource::registry() const | 713 URLRegistry& MediaSource::registry() const |
| 701 { | 714 { |
| 702 return MediaSourceRegistry::registry(); | 715 return MediaSourceRegistry::registry(); |
| 703 } | 716 } |
| 704 | 717 |
| 705 } // namespace blink | 718 } // namespace blink |
| OLD | NEW |