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 17 matching lines...) Expand all Loading... |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "modules/mediasource/WebKitMediaSource.h" | 32 #include "modules/mediasource/WebKitMediaSource.h" |
33 | 33 |
34 #include "bindings/v8/ExceptionState.h" | 34 #include "bindings/v8/ExceptionState.h" |
35 #include "bindings/v8/ExceptionStatePlaceholder.h" | 35 #include "bindings/v8/ExceptionStatePlaceholder.h" |
36 #include "core/dom/ExceptionCode.h" | 36 #include "core/dom/ExceptionCode.h" |
37 #include "core/html/TimeRanges.h" | 37 #include "core/html/TimeRanges.h" |
38 #include "core/platform/graphics/SourceBufferPrivate.h" | |
39 #include "modules/mediasource/MediaSourceRegistry.h" | 38 #include "modules/mediasource/MediaSourceRegistry.h" |
40 #include "platform/ContentType.h" | 39 #include "platform/ContentType.h" |
41 #include "platform/MIMETypeRegistry.h" | 40 #include "platform/MIMETypeRegistry.h" |
| 41 #include "public/platform/WebSourceBuffer.h" |
42 #include "wtf/Uint8Array.h" | 42 #include "wtf/Uint8Array.h" |
43 | 43 |
| 44 using blink::WebSourceBuffer; |
| 45 |
44 namespace WebCore { | 46 namespace WebCore { |
45 | 47 |
46 PassRefPtr<WebKitMediaSource> WebKitMediaSource::create(ExecutionContext* contex
t) | 48 PassRefPtr<WebKitMediaSource> WebKitMediaSource::create(ExecutionContext* contex
t) |
47 { | 49 { |
48 RefPtr<WebKitMediaSource> mediaSource(adoptRef(new WebKitMediaSource(context
))); | 50 RefPtr<WebKitMediaSource> mediaSource(adoptRef(new WebKitMediaSource(context
))); |
49 mediaSource->suspendIfNeeded(); | 51 mediaSource->suspendIfNeeded(); |
50 return mediaSource.release(); | 52 return mediaSource.release(); |
51 } | 53 } |
52 | 54 |
53 WebKitMediaSource::WebKitMediaSource(ExecutionContext* context) | 55 WebKitMediaSource::WebKitMediaSource(ExecutionContext* context) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 // 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 |
90 // InvalidStateError exception and abort these steps. | 92 // InvalidStateError exception and abort these steps. |
91 if (!isOpen()) { | 93 if (!isOpen()) { |
92 es.throwUninformativeAndGenericDOMException(InvalidStateError); | 94 es.throwUninformativeAndGenericDOMException(InvalidStateError); |
93 return 0; | 95 return 0; |
94 } | 96 } |
95 | 97 |
96 // 5. Create a new SourceBuffer object and associated resources. | 98 // 5. Create a new SourceBuffer object and associated resources. |
97 ContentType contentType(type); | 99 ContentType contentType(type); |
98 Vector<String> codecs = contentType.codecs(); | 100 Vector<String> codecs = contentType.codecs(); |
99 OwnPtr<SourceBufferPrivate> sourceBufferPrivate = createSourceBufferPrivate(
contentType.type(), codecs, es); | 101 OwnPtr<WebSourceBuffer> webSourceBuffer = createWebSourceBuffer(contentType.
type(), codecs, es); |
100 if (!sourceBufferPrivate) | 102 if (!webSourceBuffer) |
101 return 0; | 103 return 0; |
102 | 104 |
103 RefPtr<WebKitSourceBuffer> buffer = WebKitSourceBuffer::create(sourceBufferP
rivate.release(), this); | 105 RefPtr<WebKitSourceBuffer> buffer = WebKitSourceBuffer::create(webSourceBuff
er.release(), this); |
104 // 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. |
105 m_sourceBuffers->add(buffer); | 107 m_sourceBuffers->add(buffer); |
106 m_activeSourceBuffers->add(buffer); | 108 m_activeSourceBuffers->add(buffer); |
107 // 7. Return the new object to the caller. | 109 // 7. Return the new object to the caller. |
108 return buffer.get(); | 110 return buffer.get(); |
109 } | 111 } |
110 | 112 |
111 void WebKitMediaSource::removeSourceBuffer(WebKitSourceBuffer* buffer, Exception
State& es) | 113 void WebKitMediaSource::removeSourceBuffer(WebKitSourceBuffer* buffer, Exception
State& es) |
112 { | 114 { |
113 // 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 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 // 6. Return true. | 198 // 6. Return true. |
197 return MIMETypeRegistry::isSupportedMediaSourceMIMEType(contentType.type(),
codecs); | 199 return MIMETypeRegistry::isSupportedMediaSourceMIMEType(contentType.type(),
codecs); |
198 } | 200 } |
199 | 201 |
200 const AtomicString& WebKitMediaSource::interfaceName() const | 202 const AtomicString& WebKitMediaSource::interfaceName() const |
201 { | 203 { |
202 return EventTargetNames::WebKitMediaSource; | 204 return EventTargetNames::WebKitMediaSource; |
203 } | 205 } |
204 | 206 |
205 } // namespace WebCore | 207 } // namespace WebCore |
OLD | NEW |