| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 { | 64 { |
| 65 return m_sourceBuffers.get(); | 65 return m_sourceBuffers.get(); |
| 66 } | 66 } |
| 67 | 67 |
| 68 WebKitSourceBufferList* WebKitMediaSource::activeSourceBuffers() | 68 WebKitSourceBufferList* WebKitMediaSource::activeSourceBuffers() |
| 69 { | 69 { |
| 70 // FIXME(91649): support track selection | 70 // FIXME(91649): support track selection |
| 71 return m_activeSourceBuffers.get(); | 71 return m_activeSourceBuffers.get(); |
| 72 } | 72 } |
| 73 | 73 |
| 74 WebKitSourceBuffer* WebKitMediaSource::addSourceBuffer(const String& type, Excep
tionState& es) | 74 WebKitSourceBuffer* WebKitMediaSource::addSourceBuffer(const String& type, Excep
tionState& exceptionState) |
| 75 { | 75 { |
| 76 // 3.1 http://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-sour
ce.html#dom-addsourcebuffer | 76 // 3.1 http://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-sour
ce.html#dom-addsourcebuffer |
| 77 // 1. If type is null or an empty then throw an InvalidAccessError exception
and | 77 // 1. If type is null or an empty then throw an InvalidAccessError exception
and |
| 78 // abort these steps. | 78 // abort these steps. |
| 79 if (type.isNull() || type.isEmpty()) { | 79 if (type.isNull() || type.isEmpty()) { |
| 80 es.throwUninformativeAndGenericDOMException(InvalidAccessError); | 80 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr
or); |
| 81 return 0; | 81 return 0; |
| 82 } | 82 } |
| 83 | 83 |
| 84 // 2. If type contains a MIME type that is not supported ..., then throw a | 84 // 2. If type contains a MIME type that is not supported ..., then throw a |
| 85 // NotSupportedError exception and abort these steps. | 85 // NotSupportedError exception and abort these steps. |
| 86 if (!isTypeSupported(type)) { | 86 if (!isTypeSupported(type)) { |
| 87 es.throwUninformativeAndGenericDOMException(NotSupportedError); | 87 exceptionState.throwUninformativeAndGenericDOMException(NotSupportedErro
r); |
| 88 return 0; | 88 return 0; |
| 89 } | 89 } |
| 90 | 90 |
| 91 // 4. If the readyState attribute is not in the "open" state then throw an | 91 // 4. If the readyState attribute is not in the "open" state then throw an |
| 92 // InvalidStateError exception and abort these steps. | 92 // InvalidStateError exception and abort these steps. |
| 93 if (!isOpen()) { | 93 if (!isOpen()) { |
| 94 es.throwUninformativeAndGenericDOMException(InvalidStateError); | 94 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro
r); |
| 95 return 0; | 95 return 0; |
| 96 } | 96 } |
| 97 | 97 |
| 98 // 5. Create a new SourceBuffer object and associated resources. | 98 // 5. Create a new SourceBuffer object and associated resources. |
| 99 ContentType contentType(type); | 99 ContentType contentType(type); |
| 100 Vector<String> codecs = contentType.codecs(); | 100 Vector<String> codecs = contentType.codecs(); |
| 101 OwnPtr<WebSourceBuffer> webSourceBuffer = createWebSourceBuffer(contentType.
type(), codecs, es); | 101 OwnPtr<WebSourceBuffer> webSourceBuffer = createWebSourceBuffer(contentType.
type(), codecs, exceptionState); |
| 102 if (!webSourceBuffer) | 102 if (!webSourceBuffer) |
| 103 return 0; | 103 return 0; |
| 104 | 104 |
| 105 RefPtr<WebKitSourceBuffer> buffer = WebKitSourceBuffer::create(webSourceBuff
er.release(), this); | 105 RefPtr<WebKitSourceBuffer> buffer = WebKitSourceBuffer::create(webSourceBuff
er.release(), this); |
| 106 // 6. Add the new object to sourceBuffers and fire a addsourcebuffer on that
object. | 106 // 6. Add the new object to sourceBuffers and fire a addsourcebuffer on that
object. |
| 107 m_sourceBuffers->add(buffer); | 107 m_sourceBuffers->add(buffer); |
| 108 m_activeSourceBuffers->add(buffer); | 108 m_activeSourceBuffers->add(buffer); |
| 109 // 7. Return the new object to the caller. | 109 // 7. Return the new object to the caller. |
| 110 return buffer.get(); | 110 return buffer.get(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 void WebKitMediaSource::removeSourceBuffer(WebKitSourceBuffer* buffer, Exception
State& es) | 113 void WebKitMediaSource::removeSourceBuffer(WebKitSourceBuffer* buffer, Exception
State& exceptionState) |
| 114 { | 114 { |
| 115 // 3.1 http://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-sour
ce.html#dom-removesourcebuffer | 115 // 3.1 http://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-sour
ce.html#dom-removesourcebuffer |
| 116 // 1. If sourceBuffer is null then throw an InvalidAccessError exception and | 116 // 1. If sourceBuffer is null then throw an InvalidAccessError exception and |
| 117 // abort these steps. | 117 // abort these steps. |
| 118 if (!buffer) { | 118 if (!buffer) { |
| 119 es.throwUninformativeAndGenericDOMException(InvalidAccessError); | 119 exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessErr
or); |
| 120 return; | 120 return; |
| 121 } | 121 } |
| 122 | 122 |
| 123 // 2. If sourceBuffers is empty then throw an InvalidStateError exception an
d | 123 // 2. If sourceBuffers is empty then throw an InvalidStateError exception an
d |
| 124 // abort these steps. | 124 // abort these steps. |
| 125 if (isClosed() || !m_sourceBuffers->length()) { | 125 if (isClosed() || !m_sourceBuffers->length()) { |
| 126 es.throwUninformativeAndGenericDOMException(InvalidStateError); | 126 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro
r); |
| 127 return; | 127 return; |
| 128 } | 128 } |
| 129 | 129 |
| 130 // 3. If sourceBuffer specifies an object that is not in sourceBuffers then | 130 // 3. If sourceBuffer specifies an object that is not in sourceBuffers then |
| 131 // throw a NotFoundError exception and abort these steps. | 131 // throw a NotFoundError exception and abort these steps. |
| 132 // 6. Remove sourceBuffer from sourceBuffers and fire a removesourcebuffer e
vent | 132 // 6. Remove sourceBuffer from sourceBuffers and fire a removesourcebuffer e
vent |
| 133 // on that object. | 133 // on that object. |
| 134 if (!m_sourceBuffers->remove(buffer)) { | 134 if (!m_sourceBuffers->remove(buffer)) { |
| 135 es.throwUninformativeAndGenericDOMException(NotFoundError); | 135 exceptionState.throwUninformativeAndGenericDOMException(NotFoundError); |
| 136 return; | 136 return; |
| 137 } | 137 } |
| 138 | 138 |
| 139 // 7. Destroy all resources for sourceBuffer. | 139 // 7. Destroy all resources for sourceBuffer. |
| 140 m_activeSourceBuffers->remove(buffer); | 140 m_activeSourceBuffers->remove(buffer); |
| 141 | 141 |
| 142 // 4. Remove track information from audioTracks, videoTracks, and textTracks
for all tracks | 142 // 4. Remove track information from audioTracks, videoTracks, and textTracks
for all tracks |
| 143 // associated with sourceBuffer and fire a simple event named change on the
modified lists. | 143 // associated with sourceBuffer and fire a simple event named change on the
modified lists. |
| 144 // FIXME(91649): support track selection | 144 // FIXME(91649): support track selection |
| 145 | 145 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 // 6. Return true. | 198 // 6. Return true. |
| 199 return MIMETypeRegistry::isSupportedMediaSourceMIMEType(contentType.type(),
codecs); | 199 return MIMETypeRegistry::isSupportedMediaSourceMIMEType(contentType.type(),
codecs); |
| 200 } | 200 } |
| 201 | 201 |
| 202 const AtomicString& WebKitMediaSource::interfaceName() const | 202 const AtomicString& WebKitMediaSource::interfaceName() const |
| 203 { | 203 { |
| 204 return EventTargetNames::WebKitMediaSource; | 204 return EventTargetNames::WebKitMediaSource; |
| 205 } | 205 } |
| 206 | 206 |
| 207 } // namespace WebCore | 207 } // namespace WebCore |
| OLD | NEW |