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

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

Powered by Google App Engine
This is Rietveld 408576698