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

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

Issue 14619016: Add WebKit prefix to MediaSource,SourceBuffer, and SourceBufferList objects. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 7 years, 7 months 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 | Annotate | Revision Log
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 11 matching lines...) Expand all
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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/SourceBuffer.h" 32 #include "modules/mediasource/WebKitSourceBuffer.h"
33 33
34 #include "core/html/TimeRanges.h" 34 #include "core/html/TimeRanges.h"
35 #include "core/platform/graphics/SourceBufferPrivate.h" 35 #include "core/platform/graphics/SourceBufferPrivate.h"
36 #include "modules/mediasource/MediaSource.h" 36 #include "modules/mediasource/WebKitMediaSource.h"
37 #include "wtf/Uint8Array.h" 37 #include "wtf/Uint8Array.h"
38 38
39 namespace WebCore { 39 namespace WebCore {
40 40
41 PassRefPtr<SourceBuffer> SourceBuffer::create(PassOwnPtr<SourceBufferPrivate> so urceBufferPrivate, PassRefPtr<MediaSource> source) 41 PassRefPtr<WebKitSourceBuffer> WebKitSourceBuffer::create(PassOwnPtr<SourceBuffe rPrivate> sourceBufferPrivate, PassRefPtr<WebKitMediaSource> source)
42 { 42 {
43 return adoptRef(new SourceBuffer(sourceBufferPrivate, source)); 43 return adoptRef(new WebKitSourceBuffer(sourceBufferPrivate, source));
44 } 44 }
45 45
46 SourceBuffer::SourceBuffer(PassOwnPtr<SourceBufferPrivate> sourceBufferPrivate, PassRefPtr<MediaSource> source) 46 WebKitSourceBuffer::WebKitSourceBuffer(PassOwnPtr<SourceBufferPrivate> sourceBuf ferPrivate, PassRefPtr<WebKitMediaSource> source)
47 : m_private(sourceBufferPrivate) 47 : m_private(sourceBufferPrivate)
48 , m_source(source) 48 , m_source(source)
49 , m_timestampOffset(0) 49 , m_timestampOffset(0)
50 { 50 {
51 ASSERT(m_private); 51 ASSERT(m_private);
52 ASSERT(m_source); 52 ASSERT(m_source);
53 } 53 }
54 54
55 SourceBuffer::~SourceBuffer() 55 WebKitSourceBuffer::~WebKitSourceBuffer()
56 { 56 {
57 } 57 }
58 58
59 PassRefPtr<TimeRanges> SourceBuffer::buffered(ExceptionCode& ec) const 59 PassRefPtr<TimeRanges> WebKitSourceBuffer::buffered(ExceptionCode& ec) const
60 { 60 {
61 // Section 3.1 buffered attribute steps. 61 // Section 3.1 buffered attribute steps.
62 // 1. If this object has been removed from the sourceBuffers attribute of th e parent media source then throw an 62 // 1. If this object has been removed from the sourceBuffers attribute of th e parent media source then throw an
63 // INVALID_STATE_ERR exception and abort these steps. 63 // INVALID_STATE_ERR exception and abort these steps.
64 if (isRemoved()) { 64 if (isRemoved()) {
65 ec = INVALID_STATE_ERR; 65 ec = INVALID_STATE_ERR;
66 return 0; 66 return 0;
67 } 67 }
68 68
69 // 2. Return a new static normalized TimeRanges object for the media segment s buffered. 69 // 2. Return a new static normalized TimeRanges object for the media segment s buffered.
70 return m_private->buffered(); 70 return m_private->buffered();
71 } 71 }
72 72
73 double SourceBuffer::timestampOffset() const 73 double WebKitSourceBuffer::timestampOffset() const
74 { 74 {
75 return m_timestampOffset; 75 return m_timestampOffset;
76 } 76 }
77 77
78 void SourceBuffer::setTimestampOffset(double offset, ExceptionCode& ec) 78 void WebKitSourceBuffer::setTimestampOffset(double offset, ExceptionCode& ec)
79 { 79 {
80 // Section 3.1 timestampOffset attribute setter steps. 80 // Section 3.1 timestampOffset attribute setter steps.
81 // 1. If this object has been removed from the sourceBuffers attribute of th e parent media source then throw an 81 // 1. If this object has been removed from the sourceBuffers attribute of th e parent media source then throw an
82 // INVALID_STATE_ERR exception and abort these steps. 82 // INVALID_STATE_ERR exception and abort these steps.
83 if (isRemoved()) { 83 if (isRemoved()) {
84 ec = INVALID_STATE_ERR; 84 ec = INVALID_STATE_ERR;
85 return; 85 return;
86 } 86 }
87 87
88 // 4. If the readyState attribute of the parent media source is in the "ende d" state then run the following steps: 88 // 4. If the readyState attribute of the parent media source is in the "ende d" state then run the following steps:
89 if (isEnded()) { 89 // 4.1 Set the readyState attribute of the parent media source to "open"
90 // 4.1 Set the readyState attribute of the parent media source to "open" 90 // 4.2 Queue a task to fire a simple event named sourceopen at the parent me dia source.
91 // 4.2 Queue a task to fire a simple event named sourceopen at the paren t media source. 91 openIfInEndedState();
92 m_source->setReadyState(MediaSource::openKeyword());
93 }
94 92
95 // 5. If this object is waiting for the end of a media segment to be appende d, then throw an INVALID_STATE_ERR 93 // 5. If this object is waiting for the end of a media segment to be appende d, then throw an INVALID_STATE_ERR
96 // and abort these steps. 94 // and abort these steps.
97 if (!m_private->setTimestampOffset(offset)) { 95 if (!m_private->setTimestampOffset(offset)) {
98 ec = INVALID_STATE_ERR; 96 ec = INVALID_STATE_ERR;
99 return; 97 return;
100 } 98 }
101 99
102 // 6. Update the attribute to the new value. 100 // 6. Update the attribute to the new value.
103 m_timestampOffset = offset; 101 m_timestampOffset = offset;
104 } 102 }
105 103
106 void SourceBuffer::append(PassRefPtr<Uint8Array> data, ExceptionCode& ec) 104 void WebKitSourceBuffer::append(PassRefPtr<Uint8Array> data, ExceptionCode& ec)
107 { 105 {
108 // SourceBuffer.append() steps from October 1st version of the Media Source Extensions spec. 106 // SourceBuffer.append() steps from October 1st version of the Media Source Extensions spec.
109 // https://dvcs.w3.org/hg/html-media/raw-file/7bab66368f2c/media-source/medi a-source.html#dom-append 107 // https://dvcs.w3.org/hg/html-media/raw-file/7bab66368f2c/media-source/medi a-source.html#dom-append
110 108
111 // 2. If data is null then throw an INVALID_ACCESS_ERR exception and abort t hese steps. 109 // 2. If data is null then throw an INVALID_ACCESS_ERR exception and abort t hese steps.
112 if (!data) { 110 if (!data) {
113 ec = INVALID_ACCESS_ERR; 111 ec = INVALID_ACCESS_ERR;
114 return; 112 return;
115 } 113 }
116 114
117 // 3. If this object has been removed from the sourceBuffers attribute of me dia source then throw 115 // 3. If this object has been removed from the sourceBuffers attribute of me dia source then throw
118 // an INVALID_STATE_ERR exception and abort these steps. 116 // an INVALID_STATE_ERR exception and abort these steps.
119 if (isRemoved()) { 117 if (isRemoved()) {
120 ec = INVALID_STATE_ERR; 118 ec = INVALID_STATE_ERR;
121 return; 119 return;
122 } 120 }
123 121
124 // 5. If the readyState attribute of media source is in the "ended" state th en run the following steps: 122 // 5. If the readyState attribute of media source is in the "ended" state th en run the following steps:
125 if (isEnded()) { 123 // 5.1. Set the readyState attribute of media source to "open"
126 // 5.1. Set the readyState attribute of media source to "open" 124 // 5.2. Queue a task to fire a simple event named sourceopen at media source .
127 // 5.2. Queue a task to fire a simple event named sourceopen at media so urce. 125 openIfInEndedState();
128 m_source->setReadyState(MediaSource::openKeyword());
129 }
130 126
131 // Steps 6 & beyond are handled by the private implementation. 127 // Steps 6 & beyond are handled by the private implementation.
132 m_private->append(data->data(), data->length()); 128 m_private->append(data->data(), data->length());
133 } 129 }
134 130
135 void SourceBuffer::abort(ExceptionCode& ec) 131 void WebKitSourceBuffer::abort(ExceptionCode& ec)
136 { 132 {
137 // Section 3.2 abort() method steps. 133 // Section 3.2 abort() method steps.
138 // 1. If this object has been removed from the sourceBuffers attribute of th e parent media source 134 // 1. If this object has been removed from the sourceBuffers attribute of th e parent media source
139 // then throw an INVALID_STATE_ERR exception and abort these steps. 135 // then throw an INVALID_STATE_ERR exception and abort these steps.
140 // 2. If the readyState attribute of the parent media source is not in the " open" state 136 // 2. If the readyState attribute of the parent media source is not in the " open" state
141 // then throw an INVALID_STATE_ERR exception and abort these steps. 137 // then throw an INVALID_STATE_ERR exception and abort these steps.
142 if (isRemoved() || !isOpen()) { 138 if (isRemoved() || !isOpen()) {
143 ec = INVALID_STATE_ERR; 139 ec = INVALID_STATE_ERR;
144 return; 140 return;
145 } 141 }
146 142
147 // 4. Run the reset parser state algorithm. 143 // 4. Run the reset parser state algorithm.
148 m_private->abort(); 144 m_private->abort();
149 } 145 }
150 146
151 void SourceBuffer::removedFromMediaSource() 147 void WebKitSourceBuffer::removedFromMediaSource()
152 { 148 {
153 if (isRemoved()) 149 if (isRemoved())
154 return; 150 return;
155 151
156 m_private->removedFromMediaSource(); 152 m_private->removedFromMediaSource();
157 m_source.clear(); 153 m_source.clear();
158 } 154 }
159 155
160 bool SourceBuffer::isRemoved() const 156 bool WebKitSourceBuffer::isRemoved() const
161 { 157 {
162 return !m_source; 158 return !m_source;
163 } 159 }
164 160
165 bool SourceBuffer::isOpen() const 161 bool WebKitSourceBuffer::isOpen() const
166 { 162 {
167 ASSERT(m_source); 163 ASSERT(m_source);
168 return m_source->readyState() == MediaSource::openKeyword(); 164 return m_source->readyState() == WebKitMediaSource::openKeyword();
169 } 165 }
170 166
171 bool SourceBuffer::isEnded() const 167 void WebKitSourceBuffer::openIfInEndedState()
172 { 168 {
173 ASSERT(m_source); 169 ASSERT(m_source);
174 return m_source->readyState() == MediaSource::endedKeyword(); 170 if (m_source->readyState() != WebKitMediaSource::endedKeyword())
171 return;
172
173 m_source->setReadyState(WebKitMediaSource::openKeyword());
175 } 174 }
176 175
177 } // namespace WebCore 176 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/mediasource/WebKitSourceBuffer.h ('k') | Source/modules/mediasource/WebKitSourceBuffer.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698