| 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 sourceRanges->add(sourceRanges->start(sourceRanges->length() - 1, AS
SERT_NO_EXCEPTION), highestEndTime); | 141 sourceRanges->add(sourceRanges->start(sourceRanges->length() - 1, AS
SERT_NO_EXCEPTION), highestEndTime); |
| 142 | 142 |
| 143 // 5.3 Let new intersection ranges equal the the intersection between th
e intersection ranges and the source ranges. | 143 // 5.3 Let new intersection ranges equal the the intersection between th
e intersection ranges and the source ranges. |
| 144 // 5.4 Replace the ranges in intersection ranges with the new intersecti
on ranges. | 144 // 5.4 Replace the ranges in intersection ranges with the new intersecti
on ranges. |
| 145 intersectionRanges->intersectWith(sourceRanges); | 145 intersectionRanges->intersectWith(sourceRanges); |
| 146 } | 146 } |
| 147 | 147 |
| 148 return intersectionRanges.release(); | 148 return intersectionRanges.release(); |
| 149 } | 149 } |
| 150 | 150 |
| 151 void MediaSourceBase::setDuration(double duration, ExceptionState& es) | 151 void MediaSourceBase::setDuration(double duration, ExceptionState& exceptionStat
e) |
| 152 { | 152 { |
| 153 if (duration < 0.0 || std::isnan(duration)) { | 153 if (duration < 0.0 || std::isnan(duration)) { |
| 154 es.throwUninformativeAndGenericDOMException(InvalidAccessError); | 154 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr
or); |
| 155 return; | 155 return; |
| 156 } | 156 } |
| 157 if (!isOpen()) { | 157 if (!isOpen()) { |
| 158 es.throwUninformativeAndGenericDOMException(InvalidStateError); | 158 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro
r); |
| 159 return; | 159 return; |
| 160 } | 160 } |
| 161 | 161 |
| 162 // Synchronously process duration change algorithm to enforce any required | 162 // Synchronously process duration change algorithm to enforce any required |
| 163 // seek is started prior to returning. | 163 // seek is started prior to returning. |
| 164 m_attachedElement->durationChanged(duration); | 164 m_attachedElement->durationChanged(duration); |
| 165 m_webMediaSource->setDuration(duration); | 165 m_webMediaSource->setDuration(duration); |
| 166 } | 166 } |
| 167 | 167 |
| 168 | 168 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 179 } | 179 } |
| 180 | 180 |
| 181 if (oldState == state) | 181 if (oldState == state) |
| 182 return; | 182 return; |
| 183 | 183 |
| 184 m_readyState = state; | 184 m_readyState = state; |
| 185 | 185 |
| 186 onReadyStateChange(oldState, state); | 186 onReadyStateChange(oldState, state); |
| 187 } | 187 } |
| 188 | 188 |
| 189 void MediaSourceBase::endOfStream(const AtomicString& error, ExceptionState& es) | 189 void MediaSourceBase::endOfStream(const AtomicString& error, ExceptionState& exc
eptionState) |
| 190 { | 190 { |
| 191 DEFINE_STATIC_LOCAL(const AtomicString, network, ("network", AtomicString::C
onstructFromLiteral)); | 191 DEFINE_STATIC_LOCAL(const AtomicString, network, ("network", AtomicString::C
onstructFromLiteral)); |
| 192 DEFINE_STATIC_LOCAL(const AtomicString, decode, ("decode", AtomicString::Con
structFromLiteral)); | 192 DEFINE_STATIC_LOCAL(const AtomicString, decode, ("decode", AtomicString::Con
structFromLiteral)); |
| 193 | 193 |
| 194 // 3.1 http://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-sour
ce.html#dom-endofstream | 194 // 3.1 http://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-sour
ce.html#dom-endofstream |
| 195 // 1. If the readyState attribute is not in the "open" state then throw an | 195 // 1. If the readyState attribute is not in the "open" state then throw an |
| 196 // InvalidStateError exception and abort these steps. | 196 // InvalidStateError exception and abort these steps. |
| 197 if (!isOpen()) { | 197 if (!isOpen()) { |
| 198 es.throwUninformativeAndGenericDOMException(InvalidStateError); | 198 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro
r); |
| 199 return; | 199 return; |
| 200 } | 200 } |
| 201 | 201 |
| 202 WebMediaSource::EndOfStreamStatus eosStatus = WebMediaSource::EndOfStreamSta
tusNoError; | 202 WebMediaSource::EndOfStreamStatus eosStatus = WebMediaSource::EndOfStreamSta
tusNoError; |
| 203 | 203 |
| 204 if (error.isNull() || error.isEmpty()) { | 204 if (error.isNull() || error.isEmpty()) { |
| 205 eosStatus = WebMediaSource::EndOfStreamStatusNoError; | 205 eosStatus = WebMediaSource::EndOfStreamStatusNoError; |
| 206 } else if (error == network) { | 206 } else if (error == network) { |
| 207 eosStatus = WebMediaSource::EndOfStreamStatusNetworkError; | 207 eosStatus = WebMediaSource::EndOfStreamStatusNetworkError; |
| 208 } else if (error == decode) { | 208 } else if (error == decode) { |
| 209 eosStatus = WebMediaSource::EndOfStreamStatusDecodeError; | 209 eosStatus = WebMediaSource::EndOfStreamStatusDecodeError; |
| 210 } else { | 210 } else { |
| 211 es.throwUninformativeAndGenericDOMException(InvalidAccessError); | 211 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr
or); |
| 212 return; | 212 return; |
| 213 } | 213 } |
| 214 | 214 |
| 215 // 2. Change the readyState attribute value to "ended". | 215 // 2. Change the readyState attribute value to "ended". |
| 216 setReadyState(endedKeyword()); | 216 setReadyState(endedKeyword()); |
| 217 m_webMediaSource->markEndOfStream(eosStatus); | 217 m_webMediaSource->markEndOfStream(eosStatus); |
| 218 } | 218 } |
| 219 | 219 |
| 220 bool MediaSourceBase::isOpen() const | 220 bool MediaSourceBase::isOpen() const |
| 221 { | 221 { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 } | 260 } |
| 261 | 261 |
| 262 void MediaSourceBase::stop() | 262 void MediaSourceBase::stop() |
| 263 { | 263 { |
| 264 m_asyncEventQueue->close(); | 264 m_asyncEventQueue->close(); |
| 265 if (!isClosed()) | 265 if (!isClosed()) |
| 266 setReadyState(closedKeyword()); | 266 setReadyState(closedKeyword()); |
| 267 m_webMediaSource.clear(); | 267 m_webMediaSource.clear(); |
| 268 } | 268 } |
| 269 | 269 |
| 270 PassOwnPtr<WebSourceBuffer> MediaSourceBase::createWebSourceBuffer(const String&
type, const Vector<String>& codecs, ExceptionState& es) | 270 PassOwnPtr<WebSourceBuffer> MediaSourceBase::createWebSourceBuffer(const String&
type, const Vector<String>& codecs, ExceptionState& exceptionState) |
| 271 { | 271 { |
| 272 WebSourceBuffer* webSourceBuffer = 0; | 272 WebSourceBuffer* webSourceBuffer = 0; |
| 273 switch (m_webMediaSource->addSourceBuffer(type, codecs, &webSourceBuffer)) { | 273 switch (m_webMediaSource->addSourceBuffer(type, codecs, &webSourceBuffer)) { |
| 274 case WebMediaSource::AddStatusOk: | 274 case WebMediaSource::AddStatusOk: |
| 275 return adoptPtr(webSourceBuffer); | 275 return adoptPtr(webSourceBuffer); |
| 276 case WebMediaSource::AddStatusNotSupported: | 276 case WebMediaSource::AddStatusNotSupported: |
| 277 ASSERT(!webSourceBuffer); | 277 ASSERT(!webSourceBuffer); |
| 278 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/m
edia-source.html#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type | 278 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/m
edia-source.html#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type |
| 279 // Step 2: If type contains a MIME type ... that is not supported with t
he types | 279 // Step 2: If type contains a MIME type ... that is not supported with t
he types |
| 280 // specified for the other SourceBuffer objects in sourceBuffers, then t
hrow | 280 // specified for the other SourceBuffer objects in sourceBuffers, then t
hrow |
| 281 // a NotSupportedError exception and abort these steps. | 281 // a NotSupportedError exception and abort these steps. |
| 282 es.throwUninformativeAndGenericDOMException(NotSupportedError); | 282 exceptionState.throwUninformativeAndGenericDOMException(NotSupportedErro
r); |
| 283 return nullptr; | 283 return nullptr; |
| 284 case WebMediaSource::AddStatusReachedIdLimit: | 284 case WebMediaSource::AddStatusReachedIdLimit: |
| 285 ASSERT(!webSourceBuffer); | 285 ASSERT(!webSourceBuffer); |
| 286 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/m
edia-source.html#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type | 286 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/m
edia-source.html#widl-MediaSource-addSourceBuffer-SourceBuffer-DOMString-type |
| 287 // Step 3: If the user agent can't handle any more SourceBuffer objects
then throw | 287 // Step 3: If the user agent can't handle any more SourceBuffer objects
then throw |
| 288 // a QuotaExceededError exception and abort these steps. | 288 // a QuotaExceededError exception and abort these steps. |
| 289 es.throwUninformativeAndGenericDOMException(QuotaExceededError); | 289 exceptionState.throwUninformativeAndGenericDOMException(QuotaExceededErr
or); |
| 290 return nullptr; | 290 return nullptr; |
| 291 } | 291 } |
| 292 | 292 |
| 293 ASSERT_NOT_REACHED(); | 293 ASSERT_NOT_REACHED(); |
| 294 return nullptr; | 294 return nullptr; |
| 295 } | 295 } |
| 296 | 296 |
| 297 void MediaSourceBase::scheduleEvent(const AtomicString& eventName) | 297 void MediaSourceBase::scheduleEvent(const AtomicString& eventName) |
| 298 { | 298 { |
| 299 ASSERT(m_asyncEventQueue); | 299 ASSERT(m_asyncEventQueue); |
| 300 | 300 |
| 301 RefPtr<Event> event = Event::create(eventName); | 301 RefPtr<Event> event = Event::create(eventName); |
| 302 event->setTarget(this); | 302 event->setTarget(this); |
| 303 | 303 |
| 304 m_asyncEventQueue->enqueueEvent(event.release()); | 304 m_asyncEventQueue->enqueueEvent(event.release()); |
| 305 } | 305 } |
| 306 | 306 |
| 307 ExecutionContext* MediaSourceBase::executionContext() const | 307 ExecutionContext* MediaSourceBase::executionContext() const |
| 308 { | 308 { |
| 309 return ActiveDOMObject::executionContext(); | 309 return ActiveDOMObject::executionContext(); |
| 310 } | 310 } |
| 311 | 311 |
| 312 URLRegistry& MediaSourceBase::registry() const | 312 URLRegistry& MediaSourceBase::registry() const |
| 313 { | 313 { |
| 314 return MediaSourceRegistry::registry(); | 314 return MediaSourceRegistry::registry(); |
| 315 } | 315 } |
| 316 | 316 |
| 317 } | 317 } |
| OLD | NEW |