Chromium Code Reviews| Index: Source/modules/mediasource/MediaSource.cpp |
| diff --git a/Source/modules/mediasource/MediaSource.cpp b/Source/modules/mediasource/MediaSource.cpp |
| index 424a6662caa1a66ecd53e0839cb0814c8b0eb034..5ebeac7ddb1c990d19bb4d80095d0a613bcfebb0 100644 |
| --- a/Source/modules/mediasource/MediaSource.cpp |
| +++ b/Source/modules/mediasource/MediaSource.cpp |
| @@ -358,10 +358,37 @@ void MediaSource::setDuration(double duration, ExceptionState& exceptionState) |
| // 4. Run the duration change algorithm with new duration set to the value being |
| // assigned to this attribute. |
| - // Synchronously process duration change algorithm to enforce any required |
| - // seek is started prior to returning. |
| - m_attachedElement->durationChanged(duration); |
| - m_webMediaSource->setDuration(duration); |
| + durationChangeAlgorithm(duration); |
| +} |
| + |
| +void MediaSource::durationChangeAlgorithm(double newDuration) |
| +{ |
| + // Section 2.6.4 Duration change |
| + // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-source.html#duration-change-algorithm |
| + // 1. If the current value of duration is equal to new duration, then return. |
| + if (newDuration == duration()) |
| + return; |
| + |
| + // 2. Set old duration to the current value of duration. |
| + double oldDuration = duration(); |
| + |
| + bool requestSeek = m_attachedElement->currentTime() > newDuration; |
| + |
| + // 3. Update duration to new duration. |
| + m_webMediaSource->setDuration(newDuration); |
| + |
| + // 4. If the new duration is less than old duration, then call remove(new duration, old duration) on all all objects in sourceBuffers. |
| + if (newDuration < oldDuration) { |
| + for (size_t i = 0; i < m_sourceBuffers->length(); ++i) |
| + m_sourceBuffers->item(i)->remove(newDuration, oldDuration, ASSERT_NO_EXCEPTION); |
| + } |
| + |
| + // 5. If a user agent is unable to partially render audio frames or text cues that start before and end after the duration, then run the following steps: |
| + // NOTE: Currently we assume that the media engine is able to render partial frames/cues. If a media |
| + // engine gets added that doesn't support this, then we'll need to add logic to handle the substeps. |
| + |
| + // 6. Update the media controller duration to new duration and run the HTMLMediaElement duration change algorithm. |
|
philipj_slow
2014/06/16 13:26:19
Spec nit: The "media controller duration" is a cal
acolwell GONE FROM CHROMIUM
2014/06/17 01:24:02
Good point. I'll update the spec.
|
| + m_attachedElement->durationChanged(newDuration, requestSeek); |
| } |
| void MediaSource::setReadyState(const AtomicString& state) |