| 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 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 } | 532 } |
| 524 | 533 |
| 525 void MediaSource::setLiveSeekableRange(double start, double end, ExceptionState&
exceptionState) | 534 void MediaSource::setLiveSeekableRange(double start, double end, ExceptionState&
exceptionState) |
| 526 { | 535 { |
| 527 // http://w3c.github.io/media-source/#widl-MediaSource-setLiveSeekableRange-
void-double-start-double-end | 536 // http://w3c.github.io/media-source/#widl-MediaSource-setLiveSeekableRange-
void-double-start-double-end |
| 528 // 1. If the readyState attribute is not "open" then throw an | 537 // 1. If the readyState attribute is not "open" then throw an |
| 529 // InvalidStateError exception and abort these steps. | 538 // InvalidStateError exception and abort these steps. |
| 530 // 2. If the updating attribute equals true on any SourceBuffer in | 539 // 2. If the updating attribute equals true on any SourceBuffer in |
| 531 // SourceBuffers, then throw an InvalidStateError exception and abort | 540 // SourceBuffers, then throw an InvalidStateError exception and abort |
| 532 // these steps. | 541 // these steps. |
| 533 if (throwExceptionIfClosedOrUpdating(isOpen(), isUpdating(), exceptionState)
) | 542 // Note: https://github.com/w3c/media-source/issues/118, once fixed, will |
| 543 // remove the updating check (step 2). We skip that check here already. |
| 544 if (throwExceptionIfClosed(isOpen(), exceptionState)) |
| 534 return; | 545 return; |
| 535 | 546 |
| 536 // 3. If start is negative or greater than end, then throw a TypeError | 547 // 3. If start is negative or greater than end, then throw a TypeError |
| 537 // exception and abort these steps. | 548 // exception and abort these steps. |
| 538 if (start < 0 || start > end) { | 549 if (start < 0 || start > end) { |
| 539 exceptionState.throwTypeError(ExceptionMessages::indexOutsideRange("star
t value", start, 0.0, ExceptionMessages::InclusiveBound, end, ExceptionMessages:
:InclusiveBound)); | 550 exceptionState.throwTypeError(ExceptionMessages::indexOutsideRange("star
t value", start, 0.0, ExceptionMessages::InclusiveBound, end, ExceptionMessages:
:InclusiveBound)); |
| 540 return; | 551 return; |
| 541 } | 552 } |
| 542 | 553 |
| 543 // 4. Set live seekable range to be a new normalized TimeRanges object | 554 // 4. Set live seekable range to be a new normalized TimeRanges object |
| 544 // containing a single range whose start position is start and end | 555 // containing a single range whose start position is start and end |
| 545 // position is end. | 556 // position is end. |
| 546 m_liveSeekableRange = TimeRanges::create(start, end); | 557 m_liveSeekableRange = TimeRanges::create(start, end); |
| 547 } | 558 } |
| 548 | 559 |
| 549 void MediaSource::clearLiveSeekableRange(ExceptionState& exceptionState) | 560 void MediaSource::clearLiveSeekableRange(ExceptionState& exceptionState) |
| 550 { | 561 { |
| 551 // http://w3c.github.io/media-source/#widl-MediaSource-clearLiveSeekableRang
e-void | 562 // http://w3c.github.io/media-source/#widl-MediaSource-clearLiveSeekableRang
e-void |
| 552 // 1. If the readyState attribute is not "open" then throw an | 563 // 1. If the readyState attribute is not "open" then throw an |
| 553 // InvalidStateError exception and abort these steps. | 564 // InvalidStateError exception and abort these steps. |
| 554 // 2. If the updating attribute equals true on any SourceBuffer in | 565 // 2. If the updating attribute equals true on any SourceBuffer in |
| 555 // SourceBuffers, then throw an InvalidStateError exception and abort | 566 // SourceBuffers, then throw an InvalidStateError exception and abort |
| 556 // these steps. | 567 // these steps. |
| 557 if (throwExceptionIfClosedOrUpdating(isOpen(), isUpdating(), exceptionState)
) | 568 // Note: https://github.com/w3c/media-source/issues/118, once fixed, will |
| 569 // remove the updating check (step 2). We skip that check here already. |
| 570 if (throwExceptionIfClosed(isOpen(), exceptionState)) |
| 558 return; | 571 return; |
| 559 | 572 |
| 560 // 3. If live seekable range contains a range, then set live seekable range | 573 // 3. If live seekable range contains a range, then set live seekable range |
| 561 // to be a new empty TimeRanges object. | 574 // to be a new empty TimeRanges object. |
| 562 if (m_liveSeekableRange->length() != 0) | 575 if (m_liveSeekableRange->length() != 0) |
| 563 m_liveSeekableRange = TimeRanges::create(); | 576 m_liveSeekableRange = TimeRanges::create(); |
| 564 } | 577 } |
| 565 | 578 |
| 566 void MediaSource::endOfStreamInternal(const WebMediaSource::EndOfStreamStatus eo
sStatus, ExceptionState& exceptionState) | 579 void MediaSource::endOfStreamInternal(const WebMediaSource::EndOfStreamStatus eo
sStatus, ExceptionState& exceptionState) |
| 567 { | 580 { |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 | 710 |
| 698 m_asyncEventQueue->enqueueEvent(event); | 711 m_asyncEventQueue->enqueueEvent(event); |
| 699 } | 712 } |
| 700 | 713 |
| 701 URLRegistry& MediaSource::registry() const | 714 URLRegistry& MediaSource::registry() const |
| 702 { | 715 { |
| 703 return MediaSourceRegistry::registry(); | 716 return MediaSourceRegistry::registry(); |
| 704 } | 717 } |
| 705 | 718 |
| 706 } // namespace blink | 719 } // namespace blink |
| OLD | NEW |