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 30 matching lines...) Expand all Loading... |
41 #include "platform/Logging.h" | 41 #include "platform/Logging.h" |
42 #include "platform/MIMETypeRegistry.h" | 42 #include "platform/MIMETypeRegistry.h" |
43 #include "public/platform/WebSourceBuffer.h" | 43 #include "public/platform/WebSourceBuffer.h" |
44 #include "wtf/Uint8Array.h" | 44 #include "wtf/Uint8Array.h" |
45 #include "wtf/text/CString.h" | 45 #include "wtf/text/CString.h" |
46 | 46 |
47 using blink::WebSourceBuffer; | 47 using blink::WebSourceBuffer; |
48 | 48 |
49 namespace WebCore { | 49 namespace WebCore { |
50 | 50 |
51 PassRefPtrWillBeRawPtr<MediaSource> MediaSource::create(ExecutionContext* contex
t) | 51 MediaSource* MediaSource::create(ExecutionContext* context) |
52 { | 52 { |
53 RefPtrWillBeRawPtr<MediaSource> mediaSource(adoptRefWillBeRefCountedGarbageC
ollected(new MediaSource(context))); | 53 MediaSource* mediaSource(adoptRefCountedGarbageCollected(new MediaSource(con
text))); |
54 mediaSource->suspendIfNeeded(); | 54 mediaSource->suspendIfNeeded(); |
55 return mediaSource.release(); | 55 return mediaSource; |
56 } | 56 } |
57 | 57 |
58 MediaSource::MediaSource(ExecutionContext* context) | 58 MediaSource::MediaSource(ExecutionContext* context) |
59 : MediaSourceBase(context) | 59 : MediaSourceBase(context) |
60 { | 60 { |
61 WTF_LOG(Media, "MediaSource::MediaSource %p", this); | 61 WTF_LOG(Media, "MediaSource::MediaSource %p", this); |
62 ScriptWrappable::init(this); | 62 ScriptWrappable::init(this); |
63 m_sourceBuffers = SourceBufferList::create(executionContext(), asyncEventQue
ue()); | 63 m_sourceBuffers = SourceBufferList::create(executionContext(), asyncEventQue
ue()); |
64 m_activeSourceBuffers = SourceBufferList::create(executionContext(), asyncEv
entQueue()); | 64 m_activeSourceBuffers = SourceBufferList::create(executionContext(), asyncEv
entQueue()); |
65 } | 65 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 Vector<String> codecs = contentType.codecs(); | 101 Vector<String> codecs = contentType.codecs(); |
102 OwnPtr<WebSourceBuffer> webSourceBuffer = createWebSourceBuffer(contentType.
type(), codecs, exceptionState); | 102 OwnPtr<WebSourceBuffer> webSourceBuffer = createWebSourceBuffer(contentType.
type(), codecs, exceptionState); |
103 | 103 |
104 if (!webSourceBuffer) { | 104 if (!webSourceBuffer) { |
105 ASSERT(exceptionState.code() == NotSupportedError || exceptionState.code
() == QuotaExceededError); | 105 ASSERT(exceptionState.code() == NotSupportedError || exceptionState.code
() == QuotaExceededError); |
106 // 2. If type contains a MIME type that is not supported ..., then throw
a NotSupportedError exception and abort these steps. | 106 // 2. If type contains a MIME type that is not supported ..., then throw
a NotSupportedError exception and abort these steps. |
107 // 3. If the user agent can't handle any more SourceBuffer objects then
throw a QuotaExceededError exception and abort these steps | 107 // 3. If the user agent can't handle any more SourceBuffer objects then
throw a QuotaExceededError exception and abort these steps |
108 return 0; | 108 return 0; |
109 } | 109 } |
110 | 110 |
111 RefPtrWillBeRawPtr<SourceBuffer> buffer = SourceBuffer::create(webSourceBuff
er.release(), this, asyncEventQueue()); | 111 SourceBuffer* buffer = SourceBuffer::create(webSourceBuffer.release(), this,
asyncEventQueue()); |
112 // 6. Add the new object to sourceBuffers and fire a addsourcebuffer on that
object. | 112 // 6. Add the new object to sourceBuffers and fire a addsourcebuffer on that
object. |
113 m_sourceBuffers->add(buffer); | 113 m_sourceBuffers->add(buffer); |
114 m_activeSourceBuffers->add(buffer); | 114 m_activeSourceBuffers->add(buffer); |
115 // 7. Return the new object to the caller. | 115 // 7. Return the new object to the caller. |
116 return buffer.get(); | 116 return buffer; |
117 } | 117 } |
118 | 118 |
119 void MediaSource::removeSourceBuffer(SourceBuffer* buffer, ExceptionState& excep
tionState) | 119 void MediaSource::removeSourceBuffer(SourceBuffer* buffer, ExceptionState& excep
tionState) |
120 { | 120 { |
121 WTF_LOG(Media, "MediaSource::removeSourceBuffer() %p", this); | 121 WTF_LOG(Media, "MediaSource::removeSourceBuffer() %p", this); |
122 RefPtr<SourceBuffer> protect(buffer); | 122 RefPtr<SourceBuffer> protect(buffer); |
123 | 123 |
124 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media
-source.html#widl-MediaSource-removeSourceBuffer-void-SourceBuffer-sourceBuffer | 124 // 2.2 https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media
-source.html#widl-MediaSource-removeSourceBuffer-void-SourceBuffer-sourceBuffer |
125 | 125 |
126 // 1. If sourceBuffer specifies an object that is not in sourceBuffers then | 126 // 1. If sourceBuffer specifies an object that is not in sourceBuffers then |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 } | 221 } |
222 | 222 |
223 void MediaSource::trace(Visitor* visitor) | 223 void MediaSource::trace(Visitor* visitor) |
224 { | 224 { |
225 visitor->trace(m_sourceBuffers); | 225 visitor->trace(m_sourceBuffers); |
226 visitor->trace(m_activeSourceBuffers); | 226 visitor->trace(m_activeSourceBuffers); |
227 MediaSourceBase::trace(visitor); | 227 MediaSourceBase::trace(visitor); |
228 } | 228 } |
229 | 229 |
230 } // namespace WebCore | 230 } // namespace WebCore |
OLD | NEW |