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

Side by Side Diff: Source/modules/mediasource/SourceBuffer.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
« no previous file with comments | « Source/modules/mediasource/SourceBuffer.h ('k') | Source/modules/mediasource/SourceBuffer.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
29 */
30
31 #include "config.h"
32 #include "modules/mediasource/SourceBuffer.h"
33
34 #include "core/html/TimeRanges.h"
35 #include "core/platform/graphics/SourceBufferPrivate.h"
36 #include "modules/mediasource/MediaSource.h"
37 #include "wtf/Uint8Array.h"
38
39 namespace WebCore {
40
41 PassRefPtr<SourceBuffer> SourceBuffer::create(PassOwnPtr<SourceBufferPrivate> so urceBufferPrivate, PassRefPtr<MediaSource> source)
42 {
43 return adoptRef(new SourceBuffer(sourceBufferPrivate, source));
44 }
45
46 SourceBuffer::SourceBuffer(PassOwnPtr<SourceBufferPrivate> sourceBufferPrivate, PassRefPtr<MediaSource> source)
47 : m_private(sourceBufferPrivate)
48 , m_source(source)
49 , m_timestampOffset(0)
50 {
51 ASSERT(m_private);
52 ASSERT(m_source);
53 }
54
55 SourceBuffer::~SourceBuffer()
56 {
57 }
58
59 PassRefPtr<TimeRanges> SourceBuffer::buffered(ExceptionCode& ec) const
60 {
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
63 // INVALID_STATE_ERR exception and abort these steps.
64 if (isRemoved()) {
65 ec = INVALID_STATE_ERR;
66 return 0;
67 }
68
69 // 2. Return a new static normalized TimeRanges object for the media segment s buffered.
70 return m_private->buffered();
71 }
72
73 double SourceBuffer::timestampOffset() const
74 {
75 return m_timestampOffset;
76 }
77
78 void SourceBuffer::setTimestampOffset(double offset, ExceptionCode& ec)
79 {
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
82 // INVALID_STATE_ERR exception and abort these steps.
83 if (isRemoved()) {
84 ec = INVALID_STATE_ERR;
85 return;
86 }
87
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()) {
90 // 4.1 Set the readyState attribute of the parent media source to "open"
91 // 4.2 Queue a task to fire a simple event named sourceopen at the paren t media source.
92 m_source->setReadyState(MediaSource::openKeyword());
93 }
94
95 // 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.
97 if (!m_private->setTimestampOffset(offset)) {
98 ec = INVALID_STATE_ERR;
99 return;
100 }
101
102 // 6. Update the attribute to the new value.
103 m_timestampOffset = offset;
104 }
105
106 void SourceBuffer::append(PassRefPtr<Uint8Array> data, ExceptionCode& ec)
107 {
108 // 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
110
111 // 2. If data is null then throw an INVALID_ACCESS_ERR exception and abort t hese steps.
112 if (!data) {
113 ec = INVALID_ACCESS_ERR;
114 return;
115 }
116
117 // 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.
119 if (isRemoved()) {
120 ec = INVALID_STATE_ERR;
121 return;
122 }
123
124 // 5. If the readyState attribute of media source is in the "ended" state th en run the following steps:
125 if (isEnded()) {
126 // 5.1. Set the readyState attribute of media source to "open"
127 // 5.2. Queue a task to fire a simple event named sourceopen at media so urce.
128 m_source->setReadyState(MediaSource::openKeyword());
129 }
130
131 // Steps 6 & beyond are handled by the private implementation.
132 m_private->append(data->data(), data->length());
133 }
134
135 void SourceBuffer::abort(ExceptionCode& ec)
136 {
137 // Section 3.2 abort() method steps.
138 // 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.
140 // 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.
142 if (isRemoved() || !isOpen()) {
143 ec = INVALID_STATE_ERR;
144 return;
145 }
146
147 // 4. Run the reset parser state algorithm.
148 m_private->abort();
149 }
150
151 void SourceBuffer::removedFromMediaSource()
152 {
153 if (isRemoved())
154 return;
155
156 m_private->removedFromMediaSource();
157 m_source.clear();
158 }
159
160 bool SourceBuffer::isRemoved() const
161 {
162 return !m_source;
163 }
164
165 bool SourceBuffer::isOpen() const
166 {
167 ASSERT(m_source);
168 return m_source->readyState() == MediaSource::openKeyword();
169 }
170
171 bool SourceBuffer::isEnded() const
172 {
173 ASSERT(m_source);
174 return m_source->readyState() == MediaSource::endedKeyword();
175 }
176
177 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/mediasource/SourceBuffer.h ('k') | Source/modules/mediasource/SourceBuffer.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698