Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Side by Side Diff: Source/modules/mediasource/WebKitSourceBuffer.cpp

Issue 61603006: Remove MediaSourcePrivate/SourceBufferPrivate (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 16 matching lines...) Expand all
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
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/WebKitSourceBuffer.h" 32 #include "modules/mediasource/WebKitSourceBuffer.h"
33 33
34 #include "bindings/v8/ExceptionState.h" 34 #include "bindings/v8/ExceptionState.h"
35 #include "core/dom/ExceptionCode.h" 35 #include "core/dom/ExceptionCode.h"
36 #include "core/html/TimeRanges.h" 36 #include "core/html/TimeRanges.h"
37 #include "core/platform/graphics/SourceBufferPrivate.h"
38 #include "modules/mediasource/WebKitMediaSource.h" 37 #include "modules/mediasource/WebKitMediaSource.h"
39 #include "platform/TraceEvent.h" 38 #include "platform/TraceEvent.h"
39 #include "public/platform/WebSourceBuffer.h"
40 #include "public/platform/WebTimeRange.h"
40 #include "wtf/Uint8Array.h" 41 #include "wtf/Uint8Array.h"
41 42
43 using blink::WebSourceBuffer;
44 using blink::WebTimeRanges;
45
42 namespace WebCore { 46 namespace WebCore {
43 47
44 PassRefPtr<WebKitSourceBuffer> WebKitSourceBuffer::create(PassOwnPtr<SourceBuffe rPrivate> sourceBufferPrivate, PassRefPtr<WebKitMediaSource> source) 48 PassRefPtr<WebKitSourceBuffer> WebKitSourceBuffer::create(PassOwnPtr<WebSourceBu ffer> webSourceBuffer, PassRefPtr<WebKitMediaSource> source)
45 { 49 {
46 return adoptRef(new WebKitSourceBuffer(sourceBufferPrivate, source)); 50 return adoptRef(new WebKitSourceBuffer(webSourceBuffer, source));
47 } 51 }
48 52
49 WebKitSourceBuffer::WebKitSourceBuffer(PassOwnPtr<SourceBufferPrivate> sourceBuf ferPrivate, PassRefPtr<WebKitMediaSource> source) 53 WebKitSourceBuffer::WebKitSourceBuffer(PassOwnPtr<WebSourceBuffer> webSourceBuff er, PassRefPtr<WebKitMediaSource> source)
50 : m_private(sourceBufferPrivate) 54 : m_webSourceBuffer(webSourceBuffer)
51 , m_source(source) 55 , m_source(source)
52 , m_timestampOffset(0) 56 , m_timestampOffset(0)
53 { 57 {
54 ASSERT(m_private); 58 ASSERT(m_webSourceBuffer);
55 ASSERT(m_source); 59 ASSERT(m_source);
56 ScriptWrappable::init(this); 60 ScriptWrappable::init(this);
57 } 61 }
58 62
59 WebKitSourceBuffer::~WebKitSourceBuffer() 63 WebKitSourceBuffer::~WebKitSourceBuffer()
60 { 64 {
61 } 65 }
62 66
63 PassRefPtr<TimeRanges> WebKitSourceBuffer::buffered(ExceptionState& es) const 67 PassRefPtr<TimeRanges> WebKitSourceBuffer::buffered(ExceptionState& es) const
64 { 68 {
65 // Section 3.1 buffered attribute steps. 69 // Section 3.1 buffered attribute steps.
66 // 1. If this object has been removed from the sourceBuffers attribute of th e parent media source then throw an 70 // 1. If this object has been removed from the sourceBuffers attribute of th e parent media source then throw an
67 // InvalidStateError exception and abort these steps. 71 // InvalidStateError exception and abort these steps.
68 if (isRemoved()) { 72 if (isRemoved()) {
69 es.throwUninformativeAndGenericDOMException(InvalidStateError); 73 es.throwUninformativeAndGenericDOMException(InvalidStateError);
70 return 0; 74 return 0;
71 } 75 }
72 76
73 // 2. Return a new static normalized TimeRanges object for the media segment s buffered. 77 // 2. Return a new static normalized TimeRanges object for the media segment s buffered.
74 return m_private->buffered(); 78 WebTimeRanges webRanges = m_webSourceBuffer->buffered();
acolwell GONE FROM CHROMIUM 2013/11/11 18:06:55 WDYT about creating a constructor on TimeRanges th
philipj_slow 2013/11/12 09:43:51 Yes, I thought about that as well. Done.
79 RefPtr<TimeRanges> ranges = TimeRanges::create();
80 for (size_t i = 0; i < webRanges.size(); ++i)
81 ranges->add(webRanges[i].start, webRanges[i].end);
82 return ranges.release();
75 } 83 }
76 84
77 double WebKitSourceBuffer::timestampOffset() const 85 double WebKitSourceBuffer::timestampOffset() const
78 { 86 {
79 return m_timestampOffset; 87 return m_timestampOffset;
80 } 88 }
81 89
82 void WebKitSourceBuffer::setTimestampOffset(double offset, ExceptionState& es) 90 void WebKitSourceBuffer::setTimestampOffset(double offset, ExceptionState& es)
83 { 91 {
84 // Section 3.1 timestampOffset attribute setter steps. 92 // Section 3.1 timestampOffset attribute setter steps.
85 // 1. If this object has been removed from the sourceBuffers attribute of th e parent media source then throw an 93 // 1. If this object has been removed from the sourceBuffers attribute of th e parent media source then throw an
86 // InvalidStateError exception and abort these steps. 94 // InvalidStateError exception and abort these steps.
87 if (isRemoved()) { 95 if (isRemoved()) {
88 es.throwUninformativeAndGenericDOMException(InvalidStateError); 96 es.throwUninformativeAndGenericDOMException(InvalidStateError);
89 return; 97 return;
90 } 98 }
91 99
92 // 4. If the readyState attribute of the parent media source is in the "ende d" state then run the following steps: 100 // 4. If the readyState attribute of the parent media source is in the "ende d" state then run the following steps:
93 // 4.1 Set the readyState attribute of the parent media source to "open" 101 // 4.1 Set the readyState attribute of the parent media source to "open"
94 // 4.2 Queue a task to fire a simple event named sourceopen at the parent me dia source. 102 // 4.2 Queue a task to fire a simple event named sourceopen at the parent me dia source.
95 m_source->openIfInEndedState(); 103 m_source->openIfInEndedState();
96 104
97 // 5. If this object is waiting for the end of a media segment to be appende d, then throw an InvalidStateError 105 // 5. If this object is waiting for the end of a media segment to be appende d, then throw an InvalidStateError
98 // and abort these steps. 106 // and abort these steps.
99 if (!m_private->setTimestampOffset(offset)) { 107 if (!m_webSourceBuffer->setTimestampOffset(offset)) {
100 es.throwUninformativeAndGenericDOMException(InvalidStateError); 108 es.throwUninformativeAndGenericDOMException(InvalidStateError);
101 return; 109 return;
102 } 110 }
103 111
104 // 6. Update the attribute to the new value. 112 // 6. Update the attribute to the new value.
105 m_timestampOffset = offset; 113 m_timestampOffset = offset;
106 } 114 }
107 115
108 void WebKitSourceBuffer::append(PassRefPtr<Uint8Array> data, ExceptionState& es) 116 void WebKitSourceBuffer::append(PassRefPtr<Uint8Array> data, ExceptionState& es)
109 { 117 {
(...skipping 13 matching lines...) Expand all
123 if (isRemoved()) { 131 if (isRemoved()) {
124 es.throwUninformativeAndGenericDOMException(InvalidStateError); 132 es.throwUninformativeAndGenericDOMException(InvalidStateError);
125 return; 133 return;
126 } 134 }
127 135
128 // 5. If the readyState attribute of media source is in the "ended" state th en run the following steps: 136 // 5. If the readyState attribute of media source is in the "ended" state th en run the following steps:
129 // 5.1. Set the readyState attribute of media source to "open" 137 // 5.1. Set the readyState attribute of media source to "open"
130 // 5.2. Queue a task to fire a simple event named sourceopen at media source . 138 // 5.2. Queue a task to fire a simple event named sourceopen at media source .
131 m_source->openIfInEndedState(); 139 m_source->openIfInEndedState();
132 140
133 // Steps 6 & beyond are handled by the private implementation. 141 // Steps 6 & beyond are handled by m_webSourceBuffer.
134 m_private->append(data->data(), data->length()); 142 m_webSourceBuffer->append(data->data(), data->length());
135 } 143 }
136 144
137 void WebKitSourceBuffer::abort(ExceptionState& es) 145 void WebKitSourceBuffer::abort(ExceptionState& es)
138 { 146 {
139 // Section 3.2 abort() method steps. 147 // Section 3.2 abort() method steps.
140 // 1. If this object has been removed from the sourceBuffers attribute of th e parent media source 148 // 1. If this object has been removed from the sourceBuffers attribute of th e parent media source
141 // then throw an InvalidStateError exception and abort these steps. 149 // then throw an InvalidStateError exception and abort these steps.
142 // 2. If the readyState attribute of the parent media source is not in the " open" state 150 // 2. If the readyState attribute of the parent media source is not in the " open" state
143 // then throw an InvalidStateError exception and abort these steps. 151 // then throw an InvalidStateError exception and abort these steps.
144 if (isRemoved() || !m_source->isOpen()) { 152 if (isRemoved() || !m_source->isOpen()) {
145 es.throwUninformativeAndGenericDOMException(InvalidStateError); 153 es.throwUninformativeAndGenericDOMException(InvalidStateError);
146 return; 154 return;
147 } 155 }
148 156
149 // 4. Run the reset parser state algorithm. 157 // 4. Run the reset parser state algorithm.
150 m_private->abort(); 158 m_webSourceBuffer->abort();
151 } 159 }
152 160
153 void WebKitSourceBuffer::removedFromMediaSource() 161 void WebKitSourceBuffer::removedFromMediaSource()
154 { 162 {
155 if (isRemoved()) 163 if (isRemoved())
156 return; 164 return;
157 165
158 m_private->removedFromMediaSource(); 166 m_webSourceBuffer->removedFromMediaSource();
159 m_source.clear(); 167 m_source.clear();
160 } 168 }
161 169
162 bool WebKitSourceBuffer::isRemoved() const 170 bool WebKitSourceBuffer::isRemoved() const
163 { 171 {
164 return !m_source; 172 return !m_source;
165 } 173 }
166 174
167 } // namespace WebCore 175 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698