OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
12 * | 12 * |
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "core/html/HTMLMediaElement.h" | 26 #include "core/html/HTMLMediaElement.h" |
27 | 27 |
28 #include "bindings/core/v8/ExceptionState.h" | 28 #include "bindings/core/v8/ExceptionState.h" |
29 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 29 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
30 #include "bindings/core/v8/Microtask.h" | |
30 #include "bindings/core/v8/ScriptController.h" | 31 #include "bindings/core/v8/ScriptController.h" |
31 #include "bindings/core/v8/ScriptEventListener.h" | 32 #include "bindings/core/v8/ScriptEventListener.h" |
32 #include "bindings/core/v8/ScriptPromiseResolver.h" | 33 #include "bindings/core/v8/ScriptPromiseResolver.h" |
33 #include "core/HTMLNames.h" | 34 #include "core/HTMLNames.h" |
34 #include "core/css/MediaList.h" | 35 #include "core/css/MediaList.h" |
35 #include "core/dom/Attribute.h" | 36 #include "core/dom/Attribute.h" |
36 #include "core/dom/ElementTraversal.h" | 37 #include "core/dom/ElementTraversal.h" |
37 #include "core/dom/Fullscreen.h" | 38 #include "core/dom/Fullscreen.h" |
38 #include "core/dom/shadow/ShadowRoot.h" | 39 #include "core/dom/shadow/ShadowRoot.h" |
39 #include "core/events/Event.h" | 40 #include "core/events/Event.h" |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
322 visitor->trace(m_element); | 323 visitor->trace(m_element); |
323 Client::trace(visitor); | 324 Client::trace(visitor); |
324 } | 325 } |
325 | 326 |
326 private: | 327 private: |
327 AutoplayHelperClientImpl(HTMLMediaElement* element) : m_element(element) {} | 328 AutoplayHelperClientImpl(HTMLMediaElement* element) : m_element(element) {} |
328 | 329 |
329 Member<HTMLMediaElement> m_element; | 330 Member<HTMLMediaElement> m_element; |
330 }; | 331 }; |
331 | 332 |
332 | |
333 void HTMLMediaElement::recordAutoplayMetric(AutoplayMetrics metric) | 333 void HTMLMediaElement::recordAutoplayMetric(AutoplayMetrics metric) |
334 { | 334 { |
335 DEFINE_STATIC_LOCAL(EnumerationHistogram, autoplayHistogram, ("Blink.MediaEl ement.Autoplay", NumberOfAutoplayMetrics)); | 335 DEFINE_STATIC_LOCAL(EnumerationHistogram, autoplayHistogram, ("Blink.MediaEl ement.Autoplay", NumberOfAutoplayMetrics)); |
336 autoplayHistogram.count(metric); | 336 autoplayHistogram.count(metric); |
337 } | 337 } |
338 | 338 |
339 WebMimeRegistry::SupportsType HTMLMediaElement::supportsType(const ContentType& contentType) | 339 WebMimeRegistry::SupportsType HTMLMediaElement::supportsType(const ContentType& contentType) |
340 { | 340 { |
341 DEFINE_STATIC_LOCAL(const String, codecs, ("codecs")); | 341 DEFINE_STATIC_LOCAL(const String, codecs, ("codecs")); |
342 | 342 |
(...skipping 23 matching lines...) Expand all Loading... | |
366 | 366 |
367 bool HTMLMediaElement::isMediaStreamURL(const String& url) | 367 bool HTMLMediaElement::isMediaStreamURL(const String& url) |
368 { | 368 { |
369 return s_mediaStreamRegistry ? s_mediaStreamRegistry->contains(url) : false; | 369 return s_mediaStreamRegistry ? s_mediaStreamRegistry->contains(url) : false; |
370 } | 370 } |
371 | 371 |
372 HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document& docum ent) | 372 HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document& docum ent) |
373 : HTMLElement(tagName, document) | 373 : HTMLElement(tagName, document) |
374 , ActiveScriptWrappable(this) | 374 , ActiveScriptWrappable(this) |
375 , ActiveDOMObject(&document) | 375 , ActiveDOMObject(&document) |
376 , m_loadTimer(this, &HTMLMediaElement::loadTimerFired) | 376 , m_textTrackLoadTimer(this, &HTMLMediaElement::textTrackLoadTimerFired) |
377 , m_progressEventTimer(this, &HTMLMediaElement::progressEventTimerFired) | 377 , m_progressEventTimer(this, &HTMLMediaElement::progressEventTimerFired) |
378 , m_playbackProgressTimer(this, &HTMLMediaElement::playbackProgressTimerFire d) | 378 , m_playbackProgressTimer(this, &HTMLMediaElement::playbackProgressTimerFire d) |
379 , m_audioTracksTimer(this, &HTMLMediaElement::audioTracksTimerFired) | 379 , m_audioTracksTimer(this, &HTMLMediaElement::audioTracksTimerFired) |
380 , m_playedTimeRanges() | 380 , m_playedTimeRanges() |
381 , m_asyncEventQueue(GenericEventQueue::create(this)) | 381 , m_asyncEventQueue(GenericEventQueue::create(this)) |
382 , m_playbackRate(1.0f) | 382 , m_playbackRate(1.0f) |
383 , m_defaultPlaybackRate(1.0f) | 383 , m_defaultPlaybackRate(1.0f) |
384 , m_networkState(NETWORK_EMPTY) | 384 , m_networkState(NETWORK_EMPTY) |
385 , m_readyState(HAVE_NOTHING) | 385 , m_readyState(HAVE_NOTHING) |
386 , m_readyStateMaximum(HAVE_NOTHING) | 386 , m_readyStateMaximum(HAVE_NOTHING) |
387 , m_volume(1.0f) | 387 , m_volume(1.0f) |
388 , m_lastSeekTime(0) | 388 , m_lastSeekTime(0) |
389 , m_previousProgressTime(std::numeric_limits<double>::max()) | 389 , m_previousProgressTime(std::numeric_limits<double>::max()) |
390 , m_duration(std::numeric_limits<double>::quiet_NaN()) | 390 , m_duration(std::numeric_limits<double>::quiet_NaN()) |
391 , m_lastTimeUpdateEventWallTime(0) | 391 , m_lastTimeUpdateEventWallTime(0) |
392 , m_lastTimeUpdateEventMovieTime(0) | 392 , m_lastTimeUpdateEventMovieTime(0) |
393 , m_defaultPlaybackStartPosition(0) | 393 , m_defaultPlaybackStartPosition(0) |
394 , m_loadState(WaitingForSource) | 394 , m_loadState(WaitingForSource) |
395 , m_deferredLoadState(NotDeferred) | 395 , m_deferredLoadState(NotDeferred) |
396 , m_deferredLoadTimer(this, &HTMLMediaElement::deferredLoadTimerFired) | 396 , m_deferredLoadTimer(this, &HTMLMediaElement::deferredLoadTimerFired) |
397 , m_webLayer(nullptr) | 397 , m_webLayer(nullptr) |
398 , m_displayMode(Unknown) | 398 , m_displayMode(Unknown) |
399 , m_cachedTime(std::numeric_limits<double>::quiet_NaN()) | 399 , m_cachedTime(std::numeric_limits<double>::quiet_NaN()) |
400 , m_fragmentEndTime(std::numeric_limits<double>::quiet_NaN()) | 400 , m_fragmentEndTime(std::numeric_limits<double>::quiet_NaN()) |
401 , m_pendingActionFlags(0) | |
402 , m_userGestureRequiredForPlay(false) | 401 , m_userGestureRequiredForPlay(false) |
403 , m_playing(false) | 402 , m_playing(false) |
404 , m_shouldDelayLoadEvent(false) | 403 , m_shouldDelayLoadEvent(false) |
405 , m_haveFiredLoadedData(false) | 404 , m_haveFiredLoadedData(false) |
406 , m_autoplaying(true) | 405 , m_autoplaying(true) |
407 , m_muted(false) | 406 , m_muted(false) |
408 , m_paused(true) | 407 , m_paused(true) |
409 , m_seeking(false) | 408 , m_seeking(false) |
410 , m_sentStalledEvent(false) | 409 , m_sentStalledEvent(false) |
411 , m_sentEndEvent(false) | 410 , m_sentEndEvent(false) |
412 , m_closedCaptionsVisible(false) | 411 , m_closedCaptionsVisible(false) |
413 , m_ignorePreloadNone(false) | 412 , m_ignorePreloadNone(false) |
414 , m_tracksAreReady(true) | 413 , m_tracksAreReady(true) |
415 , m_processingPreferenceChange(false) | 414 , m_processingPreferenceChange(false) |
416 , m_remoteRoutesAvailable(false) | 415 , m_remoteRoutesAvailable(false) |
417 , m_playingRemotely(false) | 416 , m_playingRemotely(false) |
418 , m_isFinalizing(false) | 417 , m_isFinalizing(false) |
419 , m_inOverlayFullscreenVideo(false) | 418 , m_inOverlayFullscreenVideo(false) |
420 , m_audioTracks(AudioTrackList::create(*this)) | 419 , m_audioTracks(AudioTrackList::create(*this)) |
421 , m_videoTracks(VideoTrackList::create(*this)) | 420 , m_videoTracks(VideoTrackList::create(*this)) |
422 , m_textTracks(nullptr) | 421 , m_textTracks(nullptr) |
423 , m_playPromiseResolveTask(CancellableTaskFactory::create(this, &HTMLMediaEl ement::resolvePlayPromises)) | 422 , m_playPromiseResolveTask(CancellableTaskFactory::create(this, &HTMLMediaEl ement::resolvePlayPromises)) |
424 , m_playPromiseRejectTask(CancellableTaskFactory::create(this, &HTMLMediaEle ment::rejectPlayPromises)) | 423 , m_playPromiseRejectTask(CancellableTaskFactory::create(this, &HTMLMediaEle ment::rejectPlayPromises)) |
424 , m_resourceSelectionAlgorithmContinuationTask(CancellableTaskFactory::creat e(this, &HTMLMediaElement::continueResourceSelectionAlgorithm)) | |
425 , m_loadNextSourceChildOnErrorTask(CancellableTaskFactory::create(this, &HTM LMediaElement::loadNextSourceChildOnError)) | |
425 , m_audioSourceNode(nullptr) | 426 , m_audioSourceNode(nullptr) |
426 , m_autoplayHelperClient(AutoplayHelperClientImpl::create(this)) | 427 , m_autoplayHelperClient(AutoplayHelperClientImpl::create(this)) |
427 , m_autoplayHelper(AutoplayExperimentHelper::create(m_autoplayHelperClient.g et())) | 428 , m_autoplayHelper(AutoplayExperimentHelper::create(m_autoplayHelperClient.g et())) |
428 , m_remotePlaybackClient(nullptr) | 429 , m_remotePlaybackClient(nullptr) |
429 #if !ENABLE(OILPAN) | 430 #if !ENABLE(OILPAN) |
430 , m_weakPtrFactory(this) | 431 , m_weakPtrFactory(this) |
431 #endif | 432 #endif |
432 { | 433 { |
433 #if ENABLE(OILPAN) | 434 #if ENABLE(OILPAN) |
434 ThreadState::current()->registerPreFinalizer(this); | 435 ThreadState::current()->registerPreFinalizer(this); |
(...skipping 27 matching lines...) Expand all Loading... | |
462 | 463 |
463 setShouldDelayLoadEvent(false); | 464 setShouldDelayLoadEvent(false); |
464 | 465 |
465 if (m_textTracks) | 466 if (m_textTracks) |
466 m_textTracks->clearOwner(); | 467 m_textTracks->clearOwner(); |
467 m_audioTracks->shutdown(); | 468 m_audioTracks->shutdown(); |
468 m_videoTracks->shutdown(); | 469 m_videoTracks->shutdown(); |
469 | 470 |
470 closeMediaSource(); | 471 closeMediaSource(); |
471 | 472 |
473 if (m_resourceSelectionAlgorithmContinuationTask->isPending()) | |
474 m_resourceSelectionAlgorithmContinuationTask->cancel(); | |
475 | |
472 removeElementFromDocumentMap(this, &document()); | 476 removeElementFromDocumentMap(this, &document()); |
473 | 477 |
474 // Destroying the player may cause a resource load to be canceled, | 478 // Destroying the player may cause a resource load to be canceled, |
475 // which could result in LocalDOMWindow::dispatchWindowLoadEvent() being | 479 // which could result in LocalDOMWindow::dispatchWindowLoadEvent() being |
476 // called via ResourceFetch::didLoadResource() then | 480 // called via ResourceFetch::didLoadResource() then |
477 // FrameLoader::checkCompleted(). To prevent load event dispatching during | 481 // FrameLoader::checkCompleted(). To prevent load event dispatching during |
478 // object destruction, we use Document::incrementLoadEventDelayCount(). | 482 // object destruction, we use Document::incrementLoadEventDelayCount(). |
479 // See http://crbug.com/275223 for more details. | 483 // See http://crbug.com/275223 for more details. |
480 document().incrementLoadEventDelayCount(); | 484 document().incrementLoadEventDelayCount(); |
481 | 485 |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
668 void HTMLMediaElement::didRecalcStyle(StyleRecalcChange) | 672 void HTMLMediaElement::didRecalcStyle(StyleRecalcChange) |
669 { | 673 { |
670 if (layoutObject()) | 674 if (layoutObject()) |
671 layoutObject()->updateFromElement(); | 675 layoutObject()->updateFromElement(); |
672 } | 676 } |
673 | 677 |
674 void HTMLMediaElement::scheduleTextTrackResourceLoad() | 678 void HTMLMediaElement::scheduleTextTrackResourceLoad() |
675 { | 679 { |
676 WTF_LOG(Media, "HTMLMediaElement::scheduleTextTrackResourceLoad(%p)", this); | 680 WTF_LOG(Media, "HTMLMediaElement::scheduleTextTrackResourceLoad(%p)", this); |
677 | 681 |
678 m_pendingActionFlags |= LoadTextTrackResource; | 682 if (!m_textTrackLoadTimer.isActive()) |
679 | 683 m_textTrackLoadTimer.startOneShot(0, BLINK_FROM_HERE); |
680 if (!m_loadTimer.isActive()) | |
681 m_loadTimer.startOneShot(0, BLINK_FROM_HERE); | |
682 } | |
683 | |
684 void HTMLMediaElement::scheduleNextSourceChild() | |
685 { | |
686 // Schedule the timer to try the next <source> element WITHOUT resetting sta te ala invokeLoadAlgorithm. | |
687 m_pendingActionFlags |= LoadMediaResource; | |
688 m_loadTimer.startOneShot(0, BLINK_FROM_HERE); | |
689 } | 684 } |
690 | 685 |
691 void HTMLMediaElement::scheduleEvent(const AtomicString& eventName) | 686 void HTMLMediaElement::scheduleEvent(const AtomicString& eventName) |
692 { | 687 { |
693 scheduleEvent(Event::createCancelable(eventName)); | 688 scheduleEvent(Event::createCancelable(eventName)); |
694 } | 689 } |
695 | 690 |
696 void HTMLMediaElement::scheduleEvent(RawPtr<Event> event) | 691 void HTMLMediaElement::scheduleEvent(RawPtr<Event> event) |
697 { | 692 { |
698 #if LOG_MEDIA_EVENTS | 693 #if LOG_MEDIA_EVENTS |
699 WTF_LOG(Media, "HTMLMediaElement::scheduleEvent(%p) - scheduling '%s'", this , event->type().ascii().data()); | 694 WTF_LOG(Media, "HTMLMediaElement::scheduleEvent(%p) - scheduling '%s'", this , event->type().ascii().data()); |
700 #endif | 695 #endif |
701 m_asyncEventQueue->enqueueEvent(event); | 696 m_asyncEventQueue->enqueueEvent(event); |
702 } | 697 } |
703 | 698 |
704 void HTMLMediaElement::loadTimerFired(Timer<HTMLMediaElement>*) | 699 void HTMLMediaElement::textTrackLoadTimerFired(Timer<HTMLMediaElement>*) |
705 { | 700 { |
706 if (m_pendingActionFlags & LoadTextTrackResource) | 701 WTF_LOG(Media, "HTMLMediaElement::textTrackLoadTimerFired(%p)", this); |
707 honorUserPreferencesForAutomaticTextTrackSelection(); | 702 honorUserPreferencesForAutomaticTextTrackSelection(); |
708 | |
709 if (m_pendingActionFlags & LoadMediaResource) { | |
710 if (m_loadState == LoadingFromSourceElement) | |
711 loadNextSourceChild(); | |
712 else | |
713 loadInternal(); | |
714 } | |
715 | |
716 m_pendingActionFlags = 0; | |
717 } | 703 } |
718 | 704 |
719 MediaError* HTMLMediaElement::error() const | 705 MediaError* HTMLMediaElement::error() const |
720 { | 706 { |
721 return m_error; | 707 return m_error; |
722 } | 708 } |
723 | 709 |
724 void HTMLMediaElement::setSrc(const AtomicString& url) | 710 void HTMLMediaElement::setSrc(const AtomicString& url) |
725 { | 711 { |
726 setAttribute(srcAttr, url); | 712 setAttribute(srcAttr, url); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
767 // TODO(srirama.m): Currently m_ignorePreloadNone is reset before calling | 753 // TODO(srirama.m): Currently m_ignorePreloadNone is reset before calling |
768 // invokeLoadAlgorithm() in all places except load(). Move it inside here | 754 // invokeLoadAlgorithm() in all places except load(). Move it inside here |
769 // once microtask is implemented for "Await a stable state" step | 755 // once microtask is implemented for "Await a stable state" step |
770 // in resource selection algorithm. | 756 // in resource selection algorithm. |
771 void HTMLMediaElement::invokeLoadAlgorithm() | 757 void HTMLMediaElement::invokeLoadAlgorithm() |
772 { | 758 { |
773 WTF_LOG(Media, "HTMLMediaElement::invokeLoadAlgorithm(%p)", this); | 759 WTF_LOG(Media, "HTMLMediaElement::invokeLoadAlgorithm(%p)", this); |
774 | 760 |
775 // Perform the cleanup required for the resource load algorithm to run. | 761 // Perform the cleanup required for the resource load algorithm to run. |
776 stopPeriodicTimers(); | 762 stopPeriodicTimers(); |
777 m_loadTimer.stop(); | |
778 cancelDeferredLoad(); | 763 cancelDeferredLoad(); |
779 // FIXME: Figure out appropriate place to reset LoadTextTrackResource if nec essary and set m_pendingActionFlags to 0 here. | |
780 m_pendingActionFlags &= ~LoadMediaResource; | |
781 m_sentEndEvent = false; | 764 m_sentEndEvent = false; |
782 m_sentStalledEvent = false; | 765 m_sentStalledEvent = false; |
783 m_haveFiredLoadedData = false; | 766 m_haveFiredLoadedData = false; |
784 m_displayMode = Unknown; | 767 m_displayMode = Unknown; |
785 | 768 |
786 // 1 - Abort any already-running instance of the resource selection algorith m for this element. | 769 // 1 - Abort any already-running instance of the resource selection algorith m for this element. |
770 m_resourceSelectionAlgorithmContinuationTask->cancel(); | |
771 m_loadNextSourceChildOnErrorTask->cancel(); | |
787 m_loadState = WaitingForSource; | 772 m_loadState = WaitingForSource; |
788 m_currentSourceNode = nullptr; | 773 m_currentSourceNode = nullptr; |
789 | 774 |
790 // 2 - If there are any tasks from the media element's media element event t ask source in | 775 // 2 - If there are any tasks from the media element's media element event t ask source in |
791 // one of the task queues, then remove those tasks. | 776 // one of the task queues, then remove those tasks. |
792 cancelPendingEventsAndCallbacks(); | 777 cancelPendingEventsAndCallbacks(); |
793 | 778 |
794 rejectPlayPromises(AbortError, "The play() request was interrupted by a new load request."); | 779 rejectPlayPromises(AbortError, "The play() request was interrupted by a new load request."); |
795 | 780 |
796 // 3 - If the media element's networkState is set to NETWORK_LOADING or NETW ORK_IDLE, queue | 781 // 3 - If the media element's networkState is set to NETWORK_LOADING or NETW ORK_IDLE, queue |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
872 // so they are closer to the relevant spec steps. | 857 // so they are closer to the relevant spec steps. |
873 m_lastSeekTime = 0; | 858 m_lastSeekTime = 0; |
874 m_duration = std::numeric_limits<double>::quiet_NaN(); | 859 m_duration = std::numeric_limits<double>::quiet_NaN(); |
875 | 860 |
876 // 3 - Set the media element's delaying-the-load-event flag to true (this de lays the load event) | 861 // 3 - Set the media element's delaying-the-load-event flag to true (this de lays the load event) |
877 setShouldDelayLoadEvent(true); | 862 setShouldDelayLoadEvent(true); |
878 if (mediaControls()) | 863 if (mediaControls()) |
879 mediaControls()->reset(); | 864 mediaControls()->reset(); |
880 | 865 |
881 // 4 - Await a stable state, allowing the task that invoked this algorithm t o continue | 866 // 4 - Await a stable state, allowing the task that invoked this algorithm t o continue |
882 // TODO(srirama.m): Remove scheduleNextSourceChild() and post a microtask in stead. | 867 enqueueMicrotaskForResourceSelectionAlgorithmContinuation(); |
883 // See http://crbug.com/593289 for more details. | 868 } |
884 scheduleNextSourceChild(); | 869 |
870 void HTMLMediaElement::continueResourceSelectionAlgorithm() | |
871 { | |
872 WTF_LOG(Media, "HTMLMediaElement::continueResourceSelectionAlgorithm(%p)", t his); | |
873 loadInternal(); | |
874 } | |
875 | |
876 void HTMLMediaElement::enqueueMicrotaskForResourceSelectionAlgorithmContinuation () | |
philipj_slow
2016/04/19 14:52:44
This is called in just a single place, inline it?
| |
877 { | |
878 OwnPtr<WebTaskRunner::Task> task = adoptPtr(m_resourceSelectionAlgorithmCont inuationTask->cancelAndCreate()); | |
879 Microtask::enqueueMicrotask(task.release()); | |
885 } | 880 } |
886 | 881 |
887 void HTMLMediaElement::loadInternal() | 882 void HTMLMediaElement::loadInternal() |
888 { | 883 { |
889 // HTMLMediaElement::textTracksAreReady will need "... the text tracks whose mode was not in the | 884 // HTMLMediaElement::textTracksAreReady will need "... the text tracks whose mode was not in the |
890 // disabled state when the element's resource selection algorithm last start ed". | 885 // disabled state when the element's resource selection algorithm last start ed". |
891 m_textTracksWhenResourceSelectionBegan.clear(); | 886 m_textTracksWhenResourceSelectionBegan.clear(); |
892 if (m_textTracks) { | 887 if (m_textTracks) { |
893 for (unsigned i = 0; i < m_textTracks->length(); ++i) { | 888 for (unsigned i = 0; i < m_textTracks->length(); ++i) { |
894 TextTrack* track = m_textTracks->anonymousIndexedGetter(i); | 889 TextTrack* track = m_textTracks->anonymousIndexedGetter(i); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
977 return; | 972 return; |
978 } | 973 } |
979 | 974 |
980 // Reset the MediaPlayer and MediaSource if any | 975 // Reset the MediaPlayer and MediaSource if any |
981 resetMediaPlayerAndMediaSource(); | 976 resetMediaPlayerAndMediaSource(); |
982 | 977 |
983 m_loadState = LoadingFromSourceElement; | 978 m_loadState = LoadingFromSourceElement; |
984 loadResource(mediaURL, contentType); | 979 loadResource(mediaURL, contentType); |
985 } | 980 } |
986 | 981 |
982 void HTMLMediaElement::loadNextSourceChildOnError() | |
philipj_slow
2016/04/19 14:52:44
Maybe AfterError since it happens after awaiting a
| |
983 { | |
984 // 9.Otherwise.11 - Forget the media element's media-resource-specific track s. | |
985 forgetResourceSpecificTracks(); | |
986 loadNextSourceChild(); | |
987 } | |
988 | |
987 void HTMLMediaElement::loadResource(const KURL& url, ContentType& contentType) | 989 void HTMLMediaElement::loadResource(const KURL& url, ContentType& contentType) |
988 { | 990 { |
989 ASSERT(isMainThread()); | 991 ASSERT(isMainThread()); |
990 ASSERT(isSafeToLoadURL(url, Complain)); | 992 ASSERT(isSafeToLoadURL(url, Complain)); |
991 | 993 |
992 WTF_LOG(Media, "HTMLMediaElement::loadResource(%p, %s, %s)", this, urlForLog gingMedia(url).utf8().data(), contentType.raw().utf8().data()); | 994 WTF_LOG(Media, "HTMLMediaElement::loadResource(%p, %s, %s)", this, urlForLog gingMedia(url).utf8().data(), contentType.raw().utf8().data()); |
993 | 995 |
994 LocalFrame* frame = document().frame(); | 996 LocalFrame* frame = document().frame(); |
995 if (!frame) { | 997 if (!frame) { |
996 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); | 998 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1407 if (m_readyState < HAVE_METADATA && m_loadState == LoadingFromSourceElement) { | 1409 if (m_readyState < HAVE_METADATA && m_loadState == LoadingFromSourceElement) { |
1408 | 1410 |
1409 // resource selection algorithm | 1411 // resource selection algorithm |
1410 // Step 9.Otherwise.9 - Failed with elements: Queue a task, using the DO M manipulation task source, to fire a simple event named error at the candidate element. | 1412 // Step 9.Otherwise.9 - Failed with elements: Queue a task, using the DO M manipulation task source, to fire a simple event named error at the candidate element. |
1411 if (m_currentSourceNode) | 1413 if (m_currentSourceNode) |
1412 m_currentSourceNode->scheduleErrorEvent(); | 1414 m_currentSourceNode->scheduleErrorEvent(); |
1413 else | 1415 else |
1414 WTF_LOG(Media, "HTMLMediaElement::setNetworkState(%p) - error event not sent, <source> was removed", this); | 1416 WTF_LOG(Media, "HTMLMediaElement::setNetworkState(%p) - error event not sent, <source> was removed", this); |
1415 | 1417 |
1416 // 9.Otherwise.10 - Asynchronously await a stable state. The synchronous section consists of all the remaining steps of this algorithm until the algorit hm says the synchronous section has ended. | 1418 // 9.Otherwise.10 - Asynchronously await a stable state. The synchronous section consists of all the remaining steps of this algorithm until the algorit hm says the synchronous section has ended. |
1417 | |
1418 // 9.Otherwise.11 - Forget the media element's media-resource-specific t racks. | |
1419 forgetResourceSpecificTracks(); | |
1420 | |
1421 if (havePotentialSourceChild()) { | 1419 if (havePotentialSourceChild()) { |
1422 WTF_LOG(Media, "HTMLMediaElement::setNetworkState(%p) - scheduling n ext <source>", this); | 1420 WTF_LOG(Media, "HTMLMediaElement::setNetworkState(%p) - scheduling n ext <source>", this); |
1423 scheduleNextSourceChild(); | 1421 OwnPtr<WebTaskRunner::Task> task = adoptPtr(m_loadNextSourceChildOnE rrorTask->cancelAndCreate()); |
1422 Microtask::enqueueMicrotask(task.release()); | |
1424 } else { | 1423 } else { |
1425 WTF_LOG(Media, "HTMLMediaElement::setNetworkState(%p) - no more <sou rce> elements, waiting", this); | 1424 WTF_LOG(Media, "HTMLMediaElement::setNetworkState(%p) - no more <sou rce> elements, waiting", this); |
1426 waitForSourceChange(); | 1425 waitForSourceChange(); |
1427 } | 1426 } |
1428 | 1427 |
1429 return; | 1428 return; |
1430 } | 1429 } |
1431 | 1430 |
1432 if (error == WebMediaPlayer::NetworkStateNetworkError && m_readyState >= HAV E_METADATA) | 1431 if (error == WebMediaPlayer::NetworkStateNetworkError && m_readyState >= HAV E_METADATA) |
1433 mediaEngineError(MediaError::create(MediaError::MEDIA_ERR_NETWORK)); | 1432 mediaEngineError(MediaError::create(MediaError::MEDIA_ERR_NETWORK)); |
(...skipping 1348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2782 // 22. Asynchronously await a stable state... | 2781 // 22. Asynchronously await a stable state... |
2783 // 23. Set the element's delaying-the-load-event flag back to true (this del ays the load event again, in case | 2782 // 23. Set the element's delaying-the-load-event flag back to true (this del ays the load event again, in case |
2784 // it hasn't been fired yet). | 2783 // it hasn't been fired yet). |
2785 setShouldDelayLoadEvent(true); | 2784 setShouldDelayLoadEvent(true); |
2786 | 2785 |
2787 // 24. Set the networkState back to NETWORK_LOADING. | 2786 // 24. Set the networkState back to NETWORK_LOADING. |
2788 setNetworkState(NETWORK_LOADING); | 2787 setNetworkState(NETWORK_LOADING); |
2789 | 2788 |
2790 // 25. Jump back to the find next candidate step above. | 2789 // 25. Jump back to the find next candidate step above. |
2791 m_nextChildNodeToConsider = source; | 2790 m_nextChildNodeToConsider = source; |
2792 scheduleNextSourceChild(); | 2791 loadNextSourceChild(); |
2793 } | 2792 } |
2794 | 2793 |
2795 void HTMLMediaElement::sourceWasRemoved(HTMLSourceElement* source) | 2794 void HTMLMediaElement::sourceWasRemoved(HTMLSourceElement* source) |
2796 { | 2795 { |
2797 WTF_LOG(Media, "HTMLMediaElement::sourceWasRemoved(%p, %p)", this, source); | 2796 WTF_LOG(Media, "HTMLMediaElement::sourceWasRemoved(%p, %p)", this, source); |
2798 | 2797 |
2799 #if !LOG_DISABLED | 2798 #if !LOG_DISABLED |
2800 KURL url = source->getNonEmptyURLAttribute(srcAttr); | 2799 KURL url = source->getNonEmptyURLAttribute(srcAttr); |
2801 WTF_LOG(Media, "HTMLMediaElement::sourceWasRemoved(%p) - 'src' is %s", this, urlForLoggingMedia(url).utf8().data()); | 2800 WTF_LOG(Media, "HTMLMediaElement::sourceWasRemoved(%p) - 'src' is %s", this, urlForLoggingMedia(url).utf8().data()); |
2802 #endif | 2801 #endif |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3132 closeMediaSource(); | 3131 closeMediaSource(); |
3133 | 3132 |
3134 cancelDeferredLoad(); | 3133 cancelDeferredLoad(); |
3135 | 3134 |
3136 { | 3135 { |
3137 AudioSourceProviderClientLockScope scope(*this); | 3136 AudioSourceProviderClientLockScope scope(*this); |
3138 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); | 3137 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); |
3139 } | 3138 } |
3140 | 3139 |
3141 stopPeriodicTimers(); | 3140 stopPeriodicTimers(); |
3142 m_loadTimer.stop(); | 3141 m_textTrackLoadTimer.stop(); |
3143 | 3142 |
3144 m_pendingActionFlags = 0; | |
3145 m_loadState = WaitingForSource; | 3143 m_loadState = WaitingForSource; |
3146 | 3144 |
3147 // We can't cast if we don't have a media player. | 3145 // We can't cast if we don't have a media player. |
3148 m_remoteRoutesAvailable = false; | 3146 m_remoteRoutesAvailable = false; |
3149 m_playingRemotely = false; | 3147 m_playingRemotely = false; |
3150 if (mediaControls()) | 3148 if (mediaControls()) |
3151 mediaControls()->refreshCastButtonVisibilityWithoutUpdate(); | 3149 mediaControls()->refreshCastButtonVisibilityWithoutUpdate(); |
3152 | 3150 |
3153 if (layoutObject()) | 3151 if (layoutObject()) |
3154 layoutObject()->setShouldDoFullPaintInvalidation(); | 3152 layoutObject()->setShouldDoFullPaintInvalidation(); |
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3882 } | 3880 } |
3883 | 3881 |
3884 #if !ENABLE(OILPAN) | 3882 #if !ENABLE(OILPAN) |
3885 WeakPtr<HTMLMediaElement> HTMLMediaElement::createWeakPtr() | 3883 WeakPtr<HTMLMediaElement> HTMLMediaElement::createWeakPtr() |
3886 { | 3884 { |
3887 return m_weakPtrFactory.createWeakPtr(); | 3885 return m_weakPtrFactory.createWeakPtr(); |
3888 } | 3886 } |
3889 #endif | 3887 #endif |
3890 | 3888 |
3891 } // namespace blink | 3889 } // namespace blink |
OLD | NEW |