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

Side by Side Diff: Source/modules/mediasource/MediaSource.cpp

Issue 319213002: Fix MediaSource.duration setter behavior to match the current spec. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix release build buster Created 6 years, 6 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
« no previous file with comments | « Source/modules/mediasource/MediaSource.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 352
353 // 2. If the readyState attribute is not "open" then throw an InvalidStateEr ror 353 // 2. If the readyState attribute is not "open" then throw an InvalidStateEr ror
354 // exception and abort these steps. 354 // exception and abort these steps.
355 // 3. If the updating attribute equals true on any SourceBuffer in sourceBuf fers, 355 // 3. If the updating attribute equals true on any SourceBuffer in sourceBuf fers,
356 // then throw an InvalidStateError exception and abort these steps. 356 // then throw an InvalidStateError exception and abort these steps.
357 if (throwExceptionIfClosedOrUpdating(isOpen(), isUpdating(), exceptionState) ) 357 if (throwExceptionIfClosedOrUpdating(isOpen(), isUpdating(), exceptionState) )
358 return; 358 return;
359 359
360 // 4. Run the duration change algorithm with new duration set to the value b eing 360 // 4. Run the duration change algorithm with new duration set to the value b eing
361 // assigned to this attribute. 361 // assigned to this attribute.
362 // Synchronously process duration change algorithm to enforce any required 362 durationChangeAlgorithm(duration);
363 // seek is started prior to returning. 363 }
364 m_attachedElement->durationChanged(duration); 364
365 m_webMediaSource->setDuration(duration); 365 void MediaSource::durationChangeAlgorithm(double newDuration)
366 {
367 // Section 2.6.4 Duration change
368 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-sou rce.html#duration-change-algorithm
369 // 1. If the current value of duration is equal to new duration, then return .
370 if (newDuration == duration())
371 return;
372
373 // 2. Set old duration to the current value of duration.
374 double oldDuration = duration();
375
376 bool requestSeek = m_attachedElement->currentTime() > newDuration;
377
378 // 3. Update duration to new duration.
379 m_webMediaSource->setDuration(newDuration);
380
381 // 4. If the new duration is less than old duration, then call remove(new du ration, old duration) on all all objects in sourceBuffers.
382 if (newDuration < oldDuration) {
383 for (size_t i = 0; i < m_sourceBuffers->length(); ++i)
384 m_sourceBuffers->item(i)->remove(newDuration, oldDuration, ASSERT_NO _EXCEPTION);
385 }
386
387 // 5. If a user agent is unable to partially render audio frames or text cue s that start before and end after the duration, then run the following steps:
388 // NOTE: Currently we assume that the media engine is able to render partial frames/cues. If a media
389 // engine gets added that doesn't support this, then we'll need to add logic to handle the substeps.
390
391 // 6. Update the media controller duration to new duration and run the HTMLM ediaElement duration change algorithm.
392 m_attachedElement->durationChanged(newDuration, requestSeek);
366 } 393 }
367 394
368 void MediaSource::setReadyState(const AtomicString& state) 395 void MediaSource::setReadyState(const AtomicString& state)
369 { 396 {
370 ASSERT(state == openKeyword() || state == closedKeyword() || state == endedK eyword()); 397 ASSERT(state == openKeyword() || state == closedKeyword() || state == endedK eyword());
371 398
372 AtomicString oldState = readyState(); 399 AtomicString oldState = readyState();
373 WTF_LOG(Media, "MediaSource::setReadyState() %p : %s -> %s", this, oldState. ascii().data(), state.ascii().data()); 400 WTF_LOG(Media, "MediaSource::setReadyState() %p : %s -> %s", this, oldState. ascii().data(), state.ascii().data());
374 401
375 if (state == closedKeyword()) { 402 if (state == closedKeyword()) {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 544
518 m_asyncEventQueue->enqueueEvent(event.release()); 545 m_asyncEventQueue->enqueueEvent(event.release());
519 } 546 }
520 547
521 URLRegistry& MediaSource::registry() const 548 URLRegistry& MediaSource::registry() const
522 { 549 {
523 return MediaSourceRegistry::registry(); 550 return MediaSourceRegistry::registry();
524 } 551 }
525 552
526 } // namespace WebCore 553 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/mediasource/MediaSource.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698