Chromium Code Reviews| 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 23 matching lines...) Expand all Loading... | |
| 34 #include "bindings/v8/ExceptionState.h" | 34 #include "bindings/v8/ExceptionState.h" |
| 35 #include "core/dom/Event.h" | 35 #include "core/dom/Event.h" |
| 36 #include "core/dom/ExceptionCode.h" | 36 #include "core/dom/ExceptionCode.h" |
| 37 #include "core/dom/GenericEventQueue.h" | 37 #include "core/dom/GenericEventQueue.h" |
| 38 #include "core/html/TimeRanges.h" | 38 #include "core/html/TimeRanges.h" |
| 39 #include "core/platform/Logging.h" | 39 #include "core/platform/Logging.h" |
| 40 #include "core/platform/graphics/SourceBufferPrivate.h" | 40 #include "core/platform/graphics/SourceBufferPrivate.h" |
| 41 #include "modules/mediasource/MediaSource.h" | 41 #include "modules/mediasource/MediaSource.h" |
| 42 #include "wtf/ArrayBuffer.h" | 42 #include "wtf/ArrayBuffer.h" |
| 43 #include "wtf/ArrayBufferView.h" | 43 #include "wtf/ArrayBufferView.h" |
| 44 #include "wtf/MathExtras.h" | |
| 45 | |
| 46 #include <limits> | |
| 44 | 47 |
| 45 namespace WebCore { | 48 namespace WebCore { |
| 46 | 49 |
| 47 PassRefPtr<SourceBuffer> SourceBuffer::create(PassOwnPtr<SourceBufferPrivate> so urceBufferPrivate, MediaSource* source, GenericEventQueue* asyncEventQueue) | 50 PassRefPtr<SourceBuffer> SourceBuffer::create(PassOwnPtr<SourceBufferPrivate> so urceBufferPrivate, MediaSource* source, GenericEventQueue* asyncEventQueue) |
| 48 { | 51 { |
| 49 RefPtr<SourceBuffer> sourceBuffer(adoptRef(new SourceBuffer(sourceBufferPriv ate, source, asyncEventQueue))); | 52 RefPtr<SourceBuffer> sourceBuffer(adoptRef(new SourceBuffer(sourceBufferPriv ate, source, asyncEventQueue))); |
| 50 sourceBuffer->suspendIfNeeded(); | 53 sourceBuffer->suspendIfNeeded(); |
| 51 return sourceBuffer.release(); | 54 return sourceBuffer.release(); |
| 52 } | 55 } |
| 53 | 56 |
| 54 SourceBuffer::SourceBuffer(PassOwnPtr<SourceBufferPrivate> sourceBufferPrivate, MediaSource* source, GenericEventQueue* asyncEventQueue) | 57 SourceBuffer::SourceBuffer(PassOwnPtr<SourceBufferPrivate> sourceBufferPrivate, MediaSource* source, GenericEventQueue* asyncEventQueue) |
| 55 : ActiveDOMObject(source->scriptExecutionContext()) | 58 : ActiveDOMObject(source->scriptExecutionContext()) |
| 56 , m_private(sourceBufferPrivate) | 59 , m_private(sourceBufferPrivate) |
| 57 , m_source(source) | 60 , m_source(source) |
| 58 , m_asyncEventQueue(asyncEventQueue) | 61 , m_asyncEventQueue(asyncEventQueue) |
| 59 , m_updating(false) | 62 , m_updating(false) |
| 60 , m_timestampOffset(0) | 63 , m_timestampOffset(0) |
| 61 , m_appendBufferTimer(this, &SourceBuffer::appendBufferTimerFired) | 64 , m_appendBufferTimer(this, &SourceBuffer::appendBufferTimerFired) |
| 65 , m_appendWindowStart(0) | |
| 66 , m_appendWindowEnd(std::numeric_limits<double>::infinity()) | |
| 62 { | 67 { |
| 63 ASSERT(m_private); | 68 ASSERT(m_private); |
| 64 ASSERT(m_source); | 69 ASSERT(m_source); |
| 65 ScriptWrappable::init(this); | 70 ScriptWrappable::init(this); |
| 66 } | 71 } |
| 67 | 72 |
| 68 SourceBuffer::~SourceBuffer() | 73 SourceBuffer::~SourceBuffer() |
| 69 { | 74 { |
| 70 ASSERT(isRemoved()); | 75 ASSERT(isRemoved()); |
| 71 } | 76 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 // and abort these steps. | 113 // and abort these steps. |
| 109 if (!m_private->setTimestampOffset(offset)) { | 114 if (!m_private->setTimestampOffset(offset)) { |
| 110 es.throwDOMException(InvalidStateError); | 115 es.throwDOMException(InvalidStateError); |
| 111 return; | 116 return; |
| 112 } | 117 } |
| 113 | 118 |
| 114 // 6. Update the attribute to the new value. | 119 // 6. Update the attribute to the new value. |
| 115 m_timestampOffset = offset; | 120 m_timestampOffset = offset; |
| 116 } | 121 } |
| 117 | 122 |
| 123 double SourceBuffer::appendWindowStart() const | |
| 124 { | |
| 125 return m_appendWindowStart; | |
| 126 } | |
| 127 | |
| 128 void SourceBuffer::setAppendWindowStart(double start, ExceptionState& es) | |
| 129 { | |
| 130 // Section 3.1 appendWindowStart attribute setter steps. | |
|
acolwell GONE FROM CHROMIUM
2013/08/06 18:10:33
You should probably add code along these lines to
| |
| 131 // 1. If this object has been removed from the sourceBuffers attribute of th e parent media source then throw an | |
| 132 // InvalidStateError exception and abort these steps. | |
| 133 if (isRemoved()) { | |
| 134 es.throwDOMException(InvalidStateError); | |
| 135 return; | |
| 136 } | |
| 137 | |
| 138 // 2. If the updating attribute equals true, then throw an INVALID_STATE_ERR exception and abort these steps. | |
|
acolwell GONE FROM CHROMIUM
2013/08/06 18:10:33
nit: s/INVALID_STATE_ERR/InvalidStateError
| |
| 139 if (m_updating) { | |
|
acolwell GONE FROM CHROMIUM
2013/08/06 18:10:33
nit: This could be added to the conditional above.
| |
| 140 es.throwDOMException(InvalidStateError); | |
| 141 return; | |
| 142 } | |
| 143 | |
| 144 // 3. If the new value is less than 0 or greater than or equal to appendWind owEnd then throw an InvalidAccessError | |
| 145 // exception and abort these steps. | |
| 146 if (start < 0 || start >= m_appendWindowEnd) { | |
| 147 es.throwDOMException(InvalidAccessError); | |
| 148 return; | |
| 149 } | |
| 150 | |
| 151 m_private->setAppendWindowStart(start); | |
| 152 | |
| 153 // 4. Update the attribute to the new value. | |
| 154 m_appendWindowStart = start; | |
| 155 } | |
| 156 | |
| 157 double SourceBuffer::appendWindowEnd() const | |
| 158 { | |
| 159 return m_appendWindowEnd; | |
| 160 } | |
| 161 | |
| 162 void SourceBuffer::setAppendWindowEnd(double end, ExceptionState& es) | |
| 163 { | |
| 164 // Section 3.1 appendWindowEnd attribute setter steps. | |
| 165 // 1. If this object has been removed from the sourceBuffers attribute of th e parent media source then throw an | |
| 166 // InvalidStateError exception and abort these steps. | |
| 167 if (isRemoved()) { | |
| 168 es.throwDOMException(InvalidStateError); | |
| 169 return; | |
| 170 } | |
| 171 | |
| 172 // 2. If the updating attribute equals true, then throw an INVALID_STATE_ERR exception and abort these steps. | |
|
acolwell GONE FROM CHROMIUM
2013/08/06 18:10:33
nit: s/INVALID_STATE_ERR/InvalidStateError
| |
| 173 if (m_updating) { | |
|
acolwell GONE FROM CHROMIUM
2013/08/06 18:10:33
nit: this could be added to the conditional above.
| |
| 174 es.throwDOMException(InvalidStateError); | |
| 175 return; | |
| 176 } | |
| 177 | |
| 178 // 3. If the new value equals NaN, then throw an INVALID_ACCESS_ERR and abor t these steps. | |
|
acolwell GONE FROM CHROMIUM
2013/08/06 18:10:33
nit: s/INVALID_ACCESS_ERR/InvalidAccessError
| |
| 179 if (std::isnan(end)) { | |
| 180 es.throwDOMException(InvalidAccessError); | |
| 181 return; | |
| 182 } | |
| 183 | |
| 184 // 4. If the new value is less than or equal to appendWindowStart then throw an InvalidAccessError | |
| 185 // exception and abort these steps. | |
| 186 if (end <= m_appendWindowStart) { | |
|
acolwell GONE FROM CHROMIUM
2013/08/06 18:10:33
nit: This can be added to the conditional above.
| |
| 187 es.throwDOMException(InvalidAccessError); | |
| 188 return; | |
| 189 } | |
| 190 | |
| 191 m_private->setAppendWindowEnd(end); | |
| 192 | |
| 193 // 5. Update the attribute to the new value. | |
| 194 m_appendWindowEnd = end; | |
| 195 } | |
| 196 | |
| 197 | |
| 198 | |
| 118 void SourceBuffer::appendBuffer(PassRefPtr<ArrayBuffer> data, ExceptionState& es ) | 199 void SourceBuffer::appendBuffer(PassRefPtr<ArrayBuffer> data, ExceptionState& es ) |
| 119 { | 200 { |
| 120 // Section 3.2 appendBuffer() | 201 // Section 3.2 appendBuffer() |
| 121 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou rce.html#widl-SourceBuffer-appendBuffer-void-ArrayBufferView-data | 202 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou rce.html#widl-SourceBuffer-appendBuffer-void-ArrayBufferView-data |
| 122 // 1. If data is null then throw an InvalidAccessError exception and abort t hese steps. | 203 // 1. If data is null then throw an InvalidAccessError exception and abort t hese steps. |
| 123 if (!data) { | 204 if (!data) { |
| 124 es.throwDOMException(InvalidAccessError); | 205 es.throwDOMException(InvalidAccessError); |
| 125 return; | 206 return; |
| 126 } | 207 } |
| 127 | 208 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 153 es.throwDOMException(InvalidStateError); | 234 es.throwDOMException(InvalidStateError); |
| 154 return; | 235 return; |
| 155 } | 236 } |
| 156 | 237 |
| 157 // 3. If the sourceBuffer.updating attribute equals true, then run the follo wing steps: ... | 238 // 3. If the sourceBuffer.updating attribute equals true, then run the follo wing steps: ... |
| 158 abortIfUpdating(); | 239 abortIfUpdating(); |
| 159 | 240 |
| 160 // 4. Run the reset parser state algorithm. | 241 // 4. Run the reset parser state algorithm. |
| 161 m_private->abort(); | 242 m_private->abort(); |
| 162 | 243 |
| 163 // FIXME(229408) Add steps 5-6 update appendWindowStart & appendWindowEnd. | 244 // 5. Set appendWindowStart to 0. |
| 245 m_appendWindowStart = 0; | |
|
acolwell GONE FROM CHROMIUM
2013/08/06 18:10:33
nit: This doesn't notify m_private about this chan
| |
| 246 | |
| 247 // 6. Set appendWindowEnd to positive Infinity. | |
| 248 m_appendWindowEnd = std::numeric_limits<double>::infinity(); | |
|
acolwell GONE FROM CHROMIUM
2013/08/06 18:10:33
nit: ditto. Call setAppendWindowEnd(std::numeric_l
| |
| 164 } | 249 } |
| 165 | 250 |
| 166 | 251 |
| 167 void SourceBuffer::abortIfUpdating() | 252 void SourceBuffer::abortIfUpdating() |
| 168 { | 253 { |
| 169 // Section 3.2 abort() method step 3 substeps. | 254 // Section 3.2 abort() method step 3 substeps. |
| 170 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou rce.html#widl-SourceBuffer-abort-void | 255 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou rce.html#widl-SourceBuffer-abort-void |
| 171 | 256 |
| 172 if (!m_updating) | 257 if (!m_updating) |
| 173 return; | 258 return; |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 295 m_pendingAppendData.clear(); | 380 m_pendingAppendData.clear(); |
| 296 | 381 |
| 297 // 4. Queue a task to fire a simple event named update at this SourceBuffer object. | 382 // 4. Queue a task to fire a simple event named update at this SourceBuffer object. |
| 298 scheduleEvent(eventNames().updateEvent); | 383 scheduleEvent(eventNames().updateEvent); |
| 299 | 384 |
| 300 // 5. Queue a task to fire a simple event named updateend at this SourceBuff er object. | 385 // 5. Queue a task to fire a simple event named updateend at this SourceBuff er object. |
| 301 scheduleEvent(eventNames().updateendEvent); | 386 scheduleEvent(eventNames().updateendEvent); |
| 302 } | 387 } |
| 303 | 388 |
| 304 } // namespace WebCore | 389 } // namespace WebCore |
| OLD | NEW |