| Index: Source/modules/mediasource/SourceBuffer.cpp
|
| diff --git a/Source/modules/mediasource/SourceBuffer.cpp b/Source/modules/mediasource/SourceBuffer.cpp
|
| index 4c08f27d9534a53f88bd14b99e547062ce90292f..9a2725a63e1d0efe6174724ff452c015e0e4569a 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,57 @@ 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.
|
| + // 7. If the new mode equals "sequence", then set the group start timestamp to the highest presentation end timestamp.
|
| + // FIXME: Remove default no-op implementation once these steps are landed in Chromium. See http://crbug.com/249422.
|
| + WebSourceBuffer::AppendMode appendMode = WebSourceBuffer::Segments;
|
| + if (newMode == sequenceKeyword())
|
| + appendMode = WebSourceBuffer::Sequence;
|
| + if (!m_webSourceBuffer->setMode(appendMode)) {
|
| + exceptionState.throwUninformativeAndGenericDOMException(InvalidStateError);
|
| + return;
|
| + }
|
| +
|
| + // 8. Update the attribute to new mode.
|
| + m_mode = newMode;
|
| +}
|
| +
|
| PassRefPtr<TimeRanges> SourceBuffer::buffered(ExceptionState& exceptionState) const
|
| {
|
| // Section 3.1 buffered attribute steps.
|
| @@ -128,7 +180,7 @@ void SourceBuffer::setTimestampOffset(double offset, ExceptionState& exceptionSt
|
| // 5. If this object is waiting for the end of a media segment to be appended, then throw an InvalidStateError
|
| // and abort these steps.
|
| //
|
| - // FIXME: Add step 6 text when mode attribute is implemented.
|
| + // FIXME: Add step 6 text when mode attribute is implemented. See http://crbug.com/249422.
|
| if (!m_webSourceBuffer->setTimestampOffset(offset)) {
|
| exceptionState.throwUninformativeAndGenericDOMException(InvalidStateError);
|
| return;
|
|
|