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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 BLINK_MSLOG << __func__ << " this=" << this; | 129 BLINK_MSLOG << __func__ << " this=" << this; |
| 130 DCHECK(isClosed()); | 130 DCHECK(isClosed()); |
| 131 } | 131 } |
| 132 | 132 |
| 133 void MediaSource::logAndThrowDOMException(ExceptionState& exceptionState, const ExceptionCode& error, const String& message) | 133 void MediaSource::logAndThrowDOMException(ExceptionState& exceptionState, const ExceptionCode& error, const String& message) |
| 134 { | 134 { |
| 135 BLINK_MSLOG << __func__ << " (error=" << error << ", message=" << message << ")"; | 135 BLINK_MSLOG << __func__ << " (error=" << error << ", message=" << message << ")"; |
| 136 exceptionState.throwDOMException(error, message); | 136 exceptionState.throwDOMException(error, message); |
| 137 } | 137 } |
| 138 | 138 |
| 139 void MediaSource::logAndThrowTypeError(ExceptionState& exceptionState, const Str ing& message) | |
| 140 { | |
| 141 BLINK_MSLOG << __func__ << " (message=" << message << ")"; | |
| 142 exceptionState.throwTypeError(message); | |
| 143 } | |
| 144 | |
| 139 SourceBuffer* MediaSource::addSourceBuffer(const String& type, ExceptionState& e xceptionState) | 145 SourceBuffer* MediaSource::addSourceBuffer(const String& type, ExceptionState& e xceptionState) |
| 140 { | 146 { |
| 141 BLINK_MSLOG << __func__ << " this=" << this << " type=" << type; | 147 BLINK_MSLOG << __func__ << " this=" << this << " type=" << type; |
| 142 | 148 |
| 143 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media -source.html#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type | 149 // 2.2 https://www.w3.org/TR/media-source/#widl-MediaSource-addSourceBuffer- SourceBuffer-DOMString-type/ |
| 144 // 1. If type is an empty string then throw an InvalidAccessError exception | 150 // 1. If type is an empty string then throw a TypeError exception |
| 145 // and abort these steps. | 151 // and abort these steps. |
| 146 if (type.isEmpty()) { | 152 if (type.isEmpty()) { |
| 147 logAndThrowDOMException(exceptionState, InvalidAccessError, "The type pr ovided is empty."); | 153 logAndThrowTypeError(exceptionState, "The type provided is empty"); |
| 148 return 0; | 154 return 0; |
| 149 } | 155 } |
| 150 | 156 |
| 151 // 2. If type contains a MIME type that is not supported ..., then throw a | 157 // 2. If type contains a MIME type that is not supported ..., then throw a |
| 152 // NotSupportedError exception and abort these steps. | 158 // NotSupportedError exception and abort these steps. |
| 153 if (!isTypeSupported(type)) { | 159 if (!isTypeSupported(type)) { |
| 154 logAndThrowDOMException(exceptionState, NotSupportedError, "The type pro vided ('" + type + "') is unsupported."); | 160 logAndThrowDOMException(exceptionState, NotSupportedError, "The type pro vided ('" + type + "') is unsupported."); |
| 155 return 0; | 161 return 0; |
| 156 } | 162 } |
| 157 | 163 |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 434 sourceBuffer->videoTracks().trackSelected(track->id()); | 440 sourceBuffer->videoTracks().trackSelected(track->id()); |
| 435 sourceBuffer->videoTracks().scheduleChangeEvent(); | 441 sourceBuffer->videoTracks().scheduleChangeEvent(); |
| 436 } | 442 } |
| 437 | 443 |
| 438 bool isActive = (sourceBuffer->videoTracks().selectedIndex() != -1) || sourc eBuffer->audioTracks().hasEnabledTrack(); | 444 bool isActive = (sourceBuffer->videoTracks().selectedIndex() != -1) || sourc eBuffer->audioTracks().hasEnabledTrack(); |
| 439 setSourceBufferActive(sourceBuffer, isActive); | 445 setSourceBufferActive(sourceBuffer, isActive); |
| 440 } | 446 } |
| 441 | 447 |
| 442 void MediaSource::setDuration(double duration, ExceptionState& exceptionState) | 448 void MediaSource::setDuration(double duration, ExceptionState& exceptionState) |
| 443 { | 449 { |
| 444 // 2.1 http://www.w3.org/TR/media-source/#widl-MediaSource-duration | 450 // 2.1 https://www.w3.org/TR/media-source/#widl-MediaSource-duration |
| 445 // 1. If the value being set is negative or NaN then throw an InvalidAccessE rror | 451 // 1. If the value being set is negative or NaN then throw a TypeError |
| 446 // exception and abort these steps. | 452 // exception and abort these steps. |
| 447 if (std::isnan(duration)) { | 453 if (std::isnan(duration)) { |
| 448 logAndThrowDOMException(exceptionState, InvalidAccessError, ExceptionMes sages::notAFiniteNumber(duration, "duration")); | 454 logAndThrowTypeError(exceptionState, ExceptionMessages::notAFiniteNumber (duration, "duration")); |
| 449 return; | 455 return; |
| 450 } | 456 } |
| 451 if (duration < 0.0) { | 457 if (duration < 0.0) { |
| 452 logAndThrowDOMException(exceptionState, InvalidAccessError, ExceptionMes sages::indexExceedsMinimumBound("duration", duration, 0.0)); | 458 logAndThrowTypeError(exceptionState, ExceptionMessages::indexExceedsMini mumBound("duration", duration, 0.0)); |
| 453 return; | 459 return; |
| 454 } | 460 } |
| 455 | 461 |
| 456 // 2. If the readyState attribute is not "open" then throw an InvalidStateEr ror | 462 // 2. If the readyState attribute is not "open" then throw an InvalidStateEr ror |
| 457 // exception and abort these steps. | 463 // exception and abort these steps. |
| 458 // 3. If the updating attribute equals true on any SourceBuffer in sourceBuf fers, | 464 // 3. If the updating attribute equals true on any SourceBuffer in sourceBuf fers, |
| 459 // then throw an InvalidStateError exception and abort these steps. | 465 // then throw an InvalidStateError exception and abort these steps. |
| 460 if (throwExceptionIfClosedOrUpdating(isOpen(), isUpdating(), exceptionState) ) | 466 if (throwExceptionIfClosedOrUpdating(isOpen(), isUpdating(), exceptionState) ) |
| 461 return; | 467 return; |
| 462 | 468 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 563 // 2. If the updating attribute equals true on any SourceBuffer in | 569 // 2. If the updating attribute equals true on any SourceBuffer in |
| 564 // SourceBuffers, then throw an InvalidStateError exception and abort | 570 // SourceBuffers, then throw an InvalidStateError exception and abort |
| 565 // these steps. | 571 // these steps. |
| 566 // Note: https://github.com/w3c/media-source/issues/118, once fixed, will | 572 // Note: https://github.com/w3c/media-source/issues/118, once fixed, will |
| 567 // remove the updating check (step 2). We skip that check here already. | 573 // remove the updating check (step 2). We skip that check here already. |
| 568 if (throwExceptionIfClosed(isOpen(), exceptionState)) | 574 if (throwExceptionIfClosed(isOpen(), exceptionState)) |
| 569 return; | 575 return; |
| 570 | 576 |
| 571 // 3. If start is negative or greater than end, then throw a TypeError | 577 // 3. If start is negative or greater than end, then throw a TypeError |
| 572 // exception and abort these steps. | 578 // exception and abort these steps. |
| 573 if (start < 0 || start > end) { | 579 if (start < 0 || start > end) { |
|
chcunningham
2016/09/07 18:36:05
Note that we let start == end here. That allolwed
wolenetz
2016/09/07 21:09:26
This is intended. It allows an app to direct the U
| |
| 574 exceptionState.throwTypeError(ExceptionMessages::indexOutsideRange("star t value", start, 0.0, ExceptionMessages::InclusiveBound, end, ExceptionMessages: :InclusiveBound)); | 580 logAndThrowTypeError(exceptionState, ExceptionMessages::indexOutsideRang e("start value", start, 0.0, ExceptionMessages::InclusiveBound, end, ExceptionMe ssages::InclusiveBound)); |
| 575 return; | 581 return; |
| 576 } | 582 } |
| 577 | 583 |
| 578 // 4. Set live seekable range to be a new normalized TimeRanges object | 584 // 4. Set live seekable range to be a new normalized TimeRanges object |
| 579 // containing a single range whose start position is start and end | 585 // containing a single range whose start position is start and end |
| 580 // position is end. | 586 // position is end. |
| 581 m_liveSeekableRange = TimeRanges::create(start, end); | 587 m_liveSeekableRange = TimeRanges::create(start, end); |
| 582 } | 588 } |
| 583 | 589 |
| 584 void MediaSource::clearLiveSeekableRange(ExceptionState& exceptionState) | 590 void MediaSource::clearLiveSeekableRange(ExceptionState& exceptionState) |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 741 | 747 |
| 742 m_asyncEventQueue->enqueueEvent(event); | 748 m_asyncEventQueue->enqueueEvent(event); |
| 743 } | 749 } |
| 744 | 750 |
| 745 URLRegistry& MediaSource::registry() const | 751 URLRegistry& MediaSource::registry() const |
| 746 { | 752 { |
| 747 return MediaSourceRegistry::registry(); | 753 return MediaSourceRegistry::registry(); |
| 748 } | 754 } |
| 749 | 755 |
| 750 } // namespace blink | 756 } // namespace blink |
| OLD | NEW |