Chromium Code Reviews| Index: Source/modules/mediasource/SourceBuffer.cpp |
| diff --git a/Source/modules/mediasource/SourceBuffer.cpp b/Source/modules/mediasource/SourceBuffer.cpp |
| index 4c08f27d9534a53f88bd14b99e547062ce90292f..eebd677e2b4c944bd8080e27b8e1d412e29006f4 100644 |
| --- a/Source/modules/mediasource/SourceBuffer.cpp |
| +++ b/Source/modules/mediasource/SourceBuffer.cpp |
| @@ -65,6 +65,7 @@ SourceBuffer::SourceBuffer(PassOwnPtr<WebSourceBuffer> webSourceBuffer, MediaSou |
| , m_webSourceBuffer(webSourceBuffer) |
| , m_source(source) |
| , m_asyncEventQueue(asyncEventQueue) |
| + , m_mode(segmentsKeyword()) |
| , m_updating(false) |
| , m_timestampOffset(0) |
| , m_appendWindowStart(0) |
| @@ -89,6 +90,53 @@ SourceBuffer::~SourceBuffer() |
| ASSERT(!m_stream); |
| } |
| +const AtomicString& SourceBuffer::segmentsKeyword() |
| +{ |
| + DEFINE_STATIC_LOCAL(const AtomicString, segments, ("segments", AtomicString::ConstructFromLiteral)); |
| + return segments; |
| +} |
| + |
| +const AtomicString& SourceBuffer::sequenceKeyword() |
| +{ |
| + DEFINE_STATIC_LOCAL(const AtomicString, sequence, ("sequence", AtomicString::ConstructFromLiteral)); |
| + return sequence; |
| +} |
| + |
| +void SourceBuffer::setMode(const AtomicString& newMode, ExceptionState& exceptionState) |
| +{ |
| + // Section 3.1 On setting mode attribute steps. |
| + // 1. Let new mode equal the new value being assigned to this attribute. |
| + // 2. If new mode does not equal "segments" or "sequence", then throw an INVALID_ACCESS_ERR exception and abort |
| + // these steps. |
| + if (newMode != segmentsKeyword() && newMode != sequenceKeyword()) { |
| + exceptionState.throwUninformativeAndGenericDOMException(InvalidAccessError); |
| + return; |
| + } |
| + |
| + // 3. If this object has been removed from the sourceBuffers attribute of the parent media source, then throw |
| + // an INVALID_STATE_ERR exception and abort these steps. |
| + // 4. If the updating attribute equals true, then throw an INVALID_STATE_ERR exception and abort these steps. |
| + if (isRemoved() || m_updating) { |
| + exceptionState.throwUninformativeAndGenericDOMException(InvalidStateError); |
| + return; |
| + } |
| + |
| + // 5. If the readyState attribute of the parent media source is in the "ended" state then run the following steps: |
| + // 5.1 Set the readyState attribute of the parent media source to "open" |
| + // 5.2 Queue a task to fire a simple event named sourceopen at the parent media source. |
| + m_source->openIfInEndedState(); |
| + |
| + // 6. If the append state equals PARSING_MEDIA_SEGMENT, then throw an INVALID_STATE_ERR and abort these steps. |
| + // TODO(wolenetz): Figure out how to enforce this step. See http://crbug.com/249422. |
|
acolwell GONE FROM CHROMIUM
2014/01/09 02:53:58
I'd recommmend you just have your m_source->setMod
wolenetz
2014/01/09 21:43:11
Done.
|
| + |
| + // 7. If the new mode equals "sequence", then set the group start timestamp to the highest presentation end |
| + // timestamp. |
| + // TODO(wolenetz): Figure out how to enforce this step. See http://crbug.com/249422. |
| + |
| + // 8. Update the attribute to new mode. |
| + m_mode = newMode; |
| +} |
| + |
| PassRefPtr<TimeRanges> SourceBuffer::buffered(ExceptionState& exceptionState) const |
| { |
| // Section 3.1 buffered attribute steps. |