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

Side by Side Diff: Source/core/html/HTMLMediaElement.cpp

Issue 1055503002: Eliminate MediaPlayer & MediaPlayerClient abstractions (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: added new path for createMediaPlayer Created 5 years, 7 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) 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
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 #include "core/html/track/CueTimeline.h" 56 #include "core/html/track/CueTimeline.h"
57 #include "core/html/track/InbandTextTrack.h" 57 #include "core/html/track/InbandTextTrack.h"
58 #include "core/html/track/TextTrackContainer.h" 58 #include "core/html/track/TextTrackContainer.h"
59 #include "core/html/track/TextTrackList.h" 59 #include "core/html/track/TextTrackList.h"
60 #include "core/html/track/VideoTrack.h" 60 #include "core/html/track/VideoTrack.h"
61 #include "core/html/track/VideoTrackList.h" 61 #include "core/html/track/VideoTrackList.h"
62 #include "core/layout/LayoutVideo.h" 62 #include "core/layout/LayoutVideo.h"
63 #include "core/layout/LayoutView.h" 63 #include "core/layout/LayoutView.h"
64 #include "core/layout/compositing/DeprecatedPaintLayerCompositor.h" 64 #include "core/layout/compositing/DeprecatedPaintLayerCompositor.h"
65 #include "core/loader/FrameLoader.h" 65 #include "core/loader/FrameLoader.h"
66 #include "core/loader/FrameLoaderClient.h"
66 #include "platform/ContentType.h" 67 #include "platform/ContentType.h"
67 #include "platform/Logging.h" 68 #include "platform/Logging.h"
68 #include "platform/MIMETypeFromURL.h" 69 #include "platform/MIMETypeFromURL.h"
69 #include "platform/MIMETypeRegistry.h" 70 #include "platform/MIMETypeRegistry.h"
70 #include "platform/RuntimeEnabledFeatures.h" 71 #include "platform/RuntimeEnabledFeatures.h"
71 #include "platform/UserGestureIndicator.h" 72 #include "platform/UserGestureIndicator.h"
73 #include "platform/audio/AudioBus.h"
74 #include "platform/audio/AudioSourceProviderClient.h"
72 #include "platform/graphics/GraphicsLayer.h" 75 #include "platform/graphics/GraphicsLayer.h"
73 #include "platform/weborigin/SecurityOrigin.h" 76 #include "platform/weborigin/SecurityOrigin.h"
74 #include "public/platform/Platform.h" 77 #include "public/platform/Platform.h"
78 #include "public/platform/WebAudioSourceProvider.h"
75 #include "public/platform/WebContentDecryptionModule.h" 79 #include "public/platform/WebContentDecryptionModule.h"
76 #include "public/platform/WebInbandTextTrack.h" 80 #include "public/platform/WebInbandTextTrack.h"
77 #include "wtf/CurrentTime.h" 81 #include "wtf/CurrentTime.h"
78 #include "wtf/MainThread.h" 82 #include "wtf/MainThread.h"
79 #include "wtf/MathExtras.h" 83 #include "wtf/MathExtras.h"
80 #include "wtf/text/CString.h" 84 #include "wtf/text/CString.h"
81 #include <limits> 85 #include <limits>
82 86
83 #if ENABLE(WEB_AUDIO) 87 #if ENABLE(WEB_AUDIO)
84 #include "platform/audio/AudioSourceProvider.h" 88 #include "platform/audio/AudioSourceProvider.h"
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 , m_lastSeekTime(0) 328 , m_lastSeekTime(0)
325 , m_previousProgressTime(std::numeric_limits<double>::max()) 329 , m_previousProgressTime(std::numeric_limits<double>::max())
326 , m_duration(std::numeric_limits<double>::quiet_NaN()) 330 , m_duration(std::numeric_limits<double>::quiet_NaN())
327 , m_lastTimeUpdateEventWallTime(0) 331 , m_lastTimeUpdateEventWallTime(0)
328 , m_lastTimeUpdateEventMovieTime(0) 332 , m_lastTimeUpdateEventMovieTime(0)
329 , m_defaultPlaybackStartPosition(0) 333 , m_defaultPlaybackStartPosition(0)
330 , m_loadState(WaitingForSource) 334 , m_loadState(WaitingForSource)
331 , m_deferredLoadState(NotDeferred) 335 , m_deferredLoadState(NotDeferred)
332 , m_deferredLoadTimer(this, &HTMLMediaElement::deferredLoadTimerFired) 336 , m_deferredLoadTimer(this, &HTMLMediaElement::deferredLoadTimerFired)
333 , m_webLayer(nullptr) 337 , m_webLayer(nullptr)
334 , m_preload(MediaPlayer::Auto) 338 , m_preload(WebMediaPlayer::PreloadAuto)
335 , m_displayMode(Unknown) 339 , m_displayMode(Unknown)
336 , m_cachedTime(std::numeric_limits<double>::quiet_NaN()) 340 , m_cachedTime(std::numeric_limits<double>::quiet_NaN())
337 , m_fragmentEndTime(std::numeric_limits<double>::quiet_NaN()) 341 , m_fragmentEndTime(std::numeric_limits<double>::quiet_NaN())
338 , m_pendingActionFlags(0) 342 , m_pendingActionFlags(0)
339 , m_userGestureRequiredForPlay(false) 343 , m_userGestureRequiredForPlay(false)
340 , m_playing(false) 344 , m_playing(false)
341 , m_shouldDelayLoadEvent(false) 345 , m_shouldDelayLoadEvent(false)
342 , m_haveFiredLoadedData(false) 346 , m_haveFiredLoadedData(false)
343 , m_autoplaying(true) 347 , m_autoplaying(true)
344 , m_muted(false) 348 , m_muted(false)
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 } 484 }
481 #endif 485 #endif
482 486
483 void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument) 487 void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument)
484 { 488 {
485 WTF_LOG(Media, "HTMLMediaElement::didMoveToNewDocument(%p)", this); 489 WTF_LOG(Media, "HTMLMediaElement::didMoveToNewDocument(%p)", this);
486 490
487 if (m_shouldDelayLoadEvent) { 491 if (m_shouldDelayLoadEvent) {
488 document().incrementLoadEventDelayCount(); 492 document().incrementLoadEventDelayCount();
489 // Note: Keeping the load event delay count increment on oldDocument tha t was added 493 // Note: Keeping the load event delay count increment on oldDocument tha t was added
490 // when m_shouldDelayLoadEvent was set so that destruction of m_player c an not 494 // when m_shouldDelayLoadEvent was set so that destruction of m_webMedia Player can not
491 // cause load event dispatching in oldDocument. 495 // cause load event dispatching in oldDocument.
492 } else { 496 } else {
493 // Incrementing the load event delay count so that destruction of m_play er can not 497 // Incrementing the load event delay count so that destruction of m_webM ediaPlayer can not
494 // cause load event dispatching in oldDocument. 498 // cause load event dispatching in oldDocument.
495 oldDocument.incrementLoadEventDelayCount(); 499 oldDocument.incrementLoadEventDelayCount();
496 } 500 }
497 501
498 removeElementFromDocumentMap(this, &oldDocument); 502 removeElementFromDocumentMap(this, &oldDocument);
499 addElementToDocumentMap(this, &document()); 503 addElementToDocumentMap(this, &document());
500 504
501 // FIXME: This is a temporary fix to prevent this object from causing the 505 // FIXME: This is a temporary fix to prevent this object from causing the
502 // MediaPlayer to dereference LocalFrame and FrameLoader pointers from the 506 // MediaPlayer to dereference LocalFrame and FrameLoader pointers from the
503 // previous document. A proper fix would provide a mechanism to allow this 507 // previous document. A proper fix would provide a mechanism to allow this
504 // object to refresh the MediaPlayer's LocalFrame and FrameLoader references on 508 // object to refresh the MediaPlayer's LocalFrame and FrameLoader references on
505 // document changes so that playback can be resumed properly. 509 // document changes so that playback can be resumed properly.
506 userCancelledLoad(); 510 userCancelledLoad();
507 511
508 // Decrement the load event delay count on oldDocument now that m_player has been destroyed 512 // Decrement the load event delay count on oldDocument now that m_webMediaPl ayer has been destroyed
509 // and there is no risk of dispatching a load event from within the destruct or. 513 // and there is no risk of dispatching a load event from within the destruct or.
510 oldDocument.decrementLoadEventDelayCount(); 514 oldDocument.decrementLoadEventDelayCount();
511 515
512 ActiveDOMObject::didMoveToNewExecutionContext(&document()); 516 ActiveDOMObject::didMoveToNewExecutionContext(&document());
513 HTMLElement::didMoveToNewDocument(oldDocument); 517 HTMLElement::didMoveToNewDocument(oldDocument);
514 } 518 }
515 519
516 bool HTMLMediaElement::supportsFocus() const 520 bool HTMLMediaElement::supportsFocus() const
517 { 521 {
518 if (ownerDocument()->isMediaDocument()) 522 if (ownerDocument()->isMediaDocument())
(...skipping 13 matching lines...) Expand all
532 if (name == srcAttr) { 536 if (name == srcAttr) {
533 // Trigger a reload, as long as the 'src' attribute is present. 537 // Trigger a reload, as long as the 'src' attribute is present.
534 if (!value.isNull()) { 538 if (!value.isNull()) {
535 clearMediaPlayer(LoadMediaResource); 539 clearMediaPlayer(LoadMediaResource);
536 scheduleDelayedAction(LoadMediaResource); 540 scheduleDelayedAction(LoadMediaResource);
537 } 541 }
538 } else if (name == controlsAttr) { 542 } else if (name == controlsAttr) {
539 configureMediaControls(); 543 configureMediaControls();
540 } else if (name == preloadAttr) { 544 } else if (name == preloadAttr) {
541 if (equalIgnoringCase(value, "none")) { 545 if (equalIgnoringCase(value, "none")) {
542 m_preload = MediaPlayer::None; 546 m_preload = WebMediaPlayer::PreloadNone;
543 } else if (equalIgnoringCase(value, "metadata")) { 547 } else if (equalIgnoringCase(value, "metadata")) {
544 m_preload = MediaPlayer::MetaData; 548 m_preload = WebMediaPlayer::PreloadMetaData;
545 } else { 549 } else {
546 // The spec does not define an "invalid value default" but "auto" is suggested as the 550 // The spec does not define an "invalid value default" but "auto" is suggested as the
547 // "missing value default", so use it for everything except "none" a nd "metadata" 551 // "missing value default", so use it for everything except "none" a nd "metadata"
548 m_preload = MediaPlayer::Auto; 552 m_preload = WebMediaPlayer::PreloadAuto;
549 } 553 }
550 554
551 // The attribute must be ignored if the autoplay attribute is present 555 // The attribute must be ignored if the autoplay attribute is present
552 if (m_player) 556 if (m_webMediaPlayer)
553 setPlayerPreload(); 557 setPlayerPreload();
554
555 } else if (name == mediagroupAttr && RuntimeEnabledFeatures::mediaController Enabled()) { 558 } else if (name == mediagroupAttr && RuntimeEnabledFeatures::mediaController Enabled()) {
556 setMediaGroup(value); 559 setMediaGroup(value);
557 } else { 560 } else {
558 HTMLElement::parseAttribute(name, value); 561 HTMLElement::parseAttribute(name, value);
559 } 562 }
560 } 563 }
561 564
562 void HTMLMediaElement::finishParsingChildren() 565 void HTMLMediaElement::finishParsingChildren()
563 { 566 {
564 HTMLElement::finishParsingChildren(); 567 HTMLElement::finishParsingChildren();
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 m_mediaSource = nullptr; 991 m_mediaSource = nullptr;
989 attemptLoad = false; 992 attemptLoad = false;
990 } 993 }
991 } 994 }
992 } 995 }
993 } 996 }
994 997
995 if (attemptLoad && canLoadURL(url, contentType, keySystem)) { 998 if (attemptLoad && canLoadURL(url, contentType, keySystem)) {
996 ASSERT(!webMediaPlayer()); 999 ASSERT(!webMediaPlayer());
997 1000
998 if (!m_havePreparedToPlay && !autoplay() && m_preload == MediaPlayer::No ne) { 1001 if (!m_havePreparedToPlay && !autoplay() && m_preload == WebMediaPlayer: :PreloadNone) {
999 WTF_LOG(Media, "HTMLMediaElement::loadResource(%p) : Delaying load b ecause preload == 'none'", this); 1002 WTF_LOG(Media, "HTMLMediaElement::loadResource(%p) : Delaying load b ecause preload == 'none'", this);
1000 deferLoad(); 1003 deferLoad();
1001 } else { 1004 } else {
1002 startPlayerLoad(); 1005 startPlayerLoad();
1003 } 1006 }
1004 } else { 1007 } else {
1005 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); 1008 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError);
1006 } 1009 }
1007 1010
1008 // If there is no poster to display, allow the media engine to render video frames as soon as 1011 // If there is no poster to display, allow the media engine to render video frames as soon as
(...skipping 18 matching lines...) Expand all
1027 // along with that potentially also specifying a setting for its 1030 // along with that potentially also specifying a setting for its
1028 // 'authentication flag' to control how user:pass embedded in a 1031 // 'authentication flag' to control how user:pass embedded in a
1029 // media resource URL should be treated, then update the handling 1032 // media resource URL should be treated, then update the handling
1030 // here to match. 1033 // here to match.
1031 KURL requestURL = m_currentSrc; 1034 KURL requestURL = m_currentSrc;
1032 if (!requestURL.user().isEmpty()) 1035 if (!requestURL.user().isEmpty())
1033 requestURL.setUser(String()); 1036 requestURL.setUser(String());
1034 if (!requestURL.pass().isEmpty()) 1037 if (!requestURL.pass().isEmpty())
1035 requestURL.setPass(String()); 1038 requestURL.setPass(String());
1036 1039
1037 m_player->load(loadType(), requestURL, corsMode()); 1040 prepareAndLoadMediaPlayer(requestURL);
1038 } 1041 }
1039 1042
1040 void HTMLMediaElement::setPlayerPreload() 1043 void HTMLMediaElement::setPlayerPreload()
1041 { 1044 {
1042 m_player->setPreload(effectivePreloadType()); 1045 if (m_webMediaPlayer)
1046 m_webMediaPlayer->setPreload(effectivePreloadType());
1043 1047
1044 if (loadIsDeferred() && m_preload != MediaPlayer::None) 1048 if (loadIsDeferred() && m_preload != WebMediaPlayer::PreloadNone)
1045 startDeferredLoad(); 1049 startDeferredLoad();
1046 } 1050 }
1047 1051
1048 bool HTMLMediaElement::loadIsDeferred() const 1052 bool HTMLMediaElement::loadIsDeferred() const
1049 { 1053 {
1050 return m_deferredLoadState != NotDeferred; 1054 return m_deferredLoadState != NotDeferred;
1051 } 1055 }
1052 1056
1053 void HTMLMediaElement::deferLoad() 1057 void HTMLMediaElement::deferLoad()
1054 { 1058 {
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
1298 1302
1299 void HTMLMediaElement::cancelPendingEventsAndCallbacks() 1303 void HTMLMediaElement::cancelPendingEventsAndCallbacks()
1300 { 1304 {
1301 WTF_LOG(Media, "HTMLMediaElement::cancelPendingEventsAndCallbacks(%p)", this ); 1305 WTF_LOG(Media, "HTMLMediaElement::cancelPendingEventsAndCallbacks(%p)", this );
1302 m_asyncEventQueue->cancelAllEvents(); 1306 m_asyncEventQueue->cancelAllEvents();
1303 1307
1304 for (HTMLSourceElement* source = Traversal<HTMLSourceElement>::firstChild(*t his); source; source = Traversal<HTMLSourceElement>::nextSibling(*source)) 1308 for (HTMLSourceElement* source = Traversal<HTMLSourceElement>::firstChild(*t his); source; source = Traversal<HTMLSourceElement>::nextSibling(*source))
1305 source->cancelPendingErrorEvent(); 1309 source->cancelPendingErrorEvent();
1306 } 1310 }
1307 1311
1308 void HTMLMediaElement::mediaPlayerNetworkStateChanged() 1312 void HTMLMediaElement::networkStateChanged()
1309 { 1313 {
1310 setNetworkState(webMediaPlayer()->networkState()); 1314 setNetworkState(webMediaPlayer()->networkState());
1311 } 1315 }
1312 1316
1313 void HTMLMediaElement::mediaLoadingFailed(WebMediaPlayer::NetworkState error) 1317 void HTMLMediaElement::mediaLoadingFailed(WebMediaPlayer::NetworkState error)
1314 { 1318 {
1315 stopPeriodicTimers(); 1319 stopPeriodicTimers();
1316 1320
1317 // If we failed while trying to load a <source> element, the movie was never parsed, and there are more 1321 // If we failed while trying to load a <source> element, the movie was never parsed, and there are more
1318 // <source> children, schedule the next one 1322 // <source> children, schedule the next one
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1389 1393
1390 if (state == WebMediaPlayer::NetworkStateLoaded) { 1394 if (state == WebMediaPlayer::NetworkStateLoaded) {
1391 if (m_networkState != NETWORK_IDLE) 1395 if (m_networkState != NETWORK_IDLE)
1392 changeNetworkStateFromLoadingToIdle(); 1396 changeNetworkStateFromLoadingToIdle();
1393 m_completelyLoaded = true; 1397 m_completelyLoaded = true;
1394 } 1398 }
1395 } 1399 }
1396 1400
1397 void HTMLMediaElement::changeNetworkStateFromLoadingToIdle() 1401 void HTMLMediaElement::changeNetworkStateFromLoadingToIdle()
1398 { 1402 {
1399 ASSERT(m_player);
1400 m_progressEventTimer.stop(); 1403 m_progressEventTimer.stop();
1401 1404
1402 // Schedule one last progress event so we guarantee that at least one is fir ed 1405 // Schedule one last progress event so we guarantee that at least one is fir ed
1403 // for files that load very quickly. 1406 // for files that load very quickly.
1404 if (webMediaPlayer() && webMediaPlayer()->didLoadingProgress()) 1407 if (webMediaPlayer() && webMediaPlayer()->didLoadingProgress())
1405 scheduleEvent(EventTypeNames::progress); 1408 scheduleEvent(EventTypeNames::progress);
1406 scheduleEvent(EventTypeNames::suspend); 1409 scheduleEvent(EventTypeNames::suspend);
1407 m_networkState = NETWORK_IDLE; 1410 m_networkState = NETWORK_IDLE;
1408 } 1411 }
1409 1412
1410 void HTMLMediaElement::mediaPlayerReadyStateChanged() 1413 void HTMLMediaElement::readyStateChanged()
1411 { 1414 {
1412 setReadyState(static_cast<ReadyState>(webMediaPlayer()->readyState())); 1415 setReadyState(static_cast<ReadyState>(webMediaPlayer()->readyState()));
1413 } 1416 }
1414 1417
1415 void HTMLMediaElement::setReadyState(ReadyState state) 1418 void HTMLMediaElement::setReadyState(ReadyState state)
1416 { 1419 {
1417 WTF_LOG(Media, "HTMLMediaElement::setReadyState(%p, %d) - current state is % d,", this, static_cast<int>(state), static_cast<int>(m_readyState)); 1420 WTF_LOG(Media, "HTMLMediaElement::setReadyState(%p, %d) - current state is % d,", this, static_cast<int>(state), static_cast<int>(m_readyState));
1418 1421
1419 // Set "wasPotentiallyPlaying" BEFORE updating m_readyState, potentiallyPlay ing() uses it 1422 // Set "wasPotentiallyPlaying" BEFORE updating m_readyState, potentiallyPlay ing() uses it
1420 bool wasPotentiallyPlaying = potentiallyPlaying(); 1423 bool wasPotentiallyPlaying = potentiallyPlaying();
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1555 mediaControls()->refreshClosedCaptionsButtonVisibility(); 1558 mediaControls()->refreshClosedCaptionsButtonVisibility();
1556 } 1559 }
1557 1560
1558 updatePlayState(); 1561 updatePlayState();
1559 updateMediaController(); 1562 updateMediaController();
1560 cueTimeline().updateActiveCues(currentTime()); 1563 cueTimeline().updateActiveCues(currentTime());
1561 } 1564 }
1562 1565
1563 void HTMLMediaElement::progressEventTimerFired(Timer<HTMLMediaElement>*) 1566 void HTMLMediaElement::progressEventTimerFired(Timer<HTMLMediaElement>*)
1564 { 1567 {
1565 ASSERT(m_player);
1566 if (m_networkState != NETWORK_LOADING) 1568 if (m_networkState != NETWORK_LOADING)
1567 return; 1569 return;
1568 1570
1569 double time = WTF::currentTime(); 1571 double time = WTF::currentTime();
1570 double timedelta = time - m_previousProgressTime; 1572 double timedelta = time - m_previousProgressTime;
1571 1573
1572 if (webMediaPlayer() && webMediaPlayer()->didLoadingProgress()) { 1574 if (webMediaPlayer() && webMediaPlayer()->didLoadingProgress()) {
1573 scheduleEvent(EventTypeNames::progress); 1575 scheduleEvent(EventTypeNames::progress);
1574 m_previousProgressTime = time; 1576 m_previousProgressTime = time;
1575 m_sentStalledEvent = false; 1577 m_sentStalledEvent = false;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1608 1610
1609 void HTMLMediaElement::seek(double time) 1611 void HTMLMediaElement::seek(double time)
1610 { 1612 {
1611 WTF_LOG(Media, "HTMLMediaElement::seek(%p, %f)", this, time); 1613 WTF_LOG(Media, "HTMLMediaElement::seek(%p, %f)", this, time);
1612 1614
1613 // 2 - If the media element's readyState is HAVE_NOTHING, abort these steps. 1615 // 2 - If the media element's readyState is HAVE_NOTHING, abort these steps.
1614 if (m_readyState == HAVE_NOTHING) 1616 if (m_readyState == HAVE_NOTHING)
1615 return; 1617 return;
1616 1618
1617 // If the media engine has been told to postpone loading data, let it go ahe ad now. 1619 // If the media engine has been told to postpone loading data, let it go ahe ad now.
1618 if (m_preload < MediaPlayer::Auto && m_readyState < HAVE_FUTURE_DATA) 1620 if (m_preload < WebMediaPlayer::PreloadAuto && m_readyState < HAVE_FUTURE_DA TA)
1619 prepareToPlay(); 1621 prepareToPlay();
1620 1622
1621 // Get the current time before setting m_seeking, m_lastSeekTime is returned once it is set. 1623 // Get the current time before setting m_seeking, m_lastSeekTime is returned once it is set.
1622 refreshCachedTime(); 1624 refreshCachedTime();
1623 // This is needed to avoid getting default playback start position from curr entTime(). 1625 // This is needed to avoid getting default playback start position from curr entTime().
1624 double now = m_cachedTime; 1626 double now = m_cachedTime;
1625 1627
1626 // 3 - If the element's seeking IDL attribute is true, then another instance of this algorithm is 1628 // 3 - If the element's seeking IDL attribute is true, then another instance of this algorithm is
1627 // already running. Abort that other instance of the algorithm without waiti ng for the step that 1629 // already running. Abort that other instance of the algorithm without waiti ng for the step that
1628 // it is running to complete. 1630 // it is running to complete.
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1782 if (m_readyState == HAVE_NOTHING) { 1784 if (m_readyState == HAVE_NOTHING) {
1783 m_defaultPlaybackStartPosition = time; 1785 m_defaultPlaybackStartPosition = time;
1784 return; 1786 return;
1785 } 1787 }
1786 1788
1787 seek(time); 1789 seek(time);
1788 } 1790 }
1789 1791
1790 double HTMLMediaElement::duration() const 1792 double HTMLMediaElement::duration() const
1791 { 1793 {
1792 // FIXME: remove m_player check once we figure out how m_player is going 1794 // FIXME: remove m_webMediaPlayer check once we figure out how
1793 // out of sync with readystate. m_player is cleared but readystate is not se t 1795 // m_webMediaPlayer is going out of sync with readystate.
1794 // to HAVE_NOTHING 1796 // m_webMediaPlayer is cleared but readystate is not set to HAVE_NOTHING.
1795 if (!m_player || m_readyState < HAVE_METADATA) 1797 if (!m_webMediaPlayer || m_readyState < HAVE_METADATA)
1796 return std::numeric_limits<double>::quiet_NaN(); 1798 return std::numeric_limits<double>::quiet_NaN();
1797 1799
1798 // FIXME: Refactor so m_duration is kept current (in both MSE and 1800 // FIXME: Refactor so m_duration is kept current (in both MSE and
1799 // non-MSE cases) once we have transitioned from HAVE_NOTHING -> 1801 // non-MSE cases) once we have transitioned from HAVE_NOTHING ->
1800 // HAVE_METADATA. Currently, m_duration may be out of date for at least MSE 1802 // HAVE_METADATA. Currently, m_duration may be out of date for at least MSE
1801 // case because MediaSource and SourceBuffer do not notify the element 1803 // case because MediaSource and SourceBuffer do not notify the element
1802 // directly upon duration changes caused by endOfStream, remove, or append 1804 // directly upon duration changes caused by endOfStream, remove, or append
1803 // operations; rather the notification is triggered by the WebMediaPlayer 1805 // operations; rather the notification is triggered by the WebMediaPlayer
1804 // implementation observing that the underlying engine has updated duration 1806 // implementation observing that the underlying engine has updated duration
1805 // and notifying the element to consult its MediaSource for current 1807 // and notifying the element to consult its MediaSource for current
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1854 } 1856 }
1855 1857
1856 HTMLMediaElement::DirectionOfPlayback HTMLMediaElement::directionOfPlayback() co nst 1858 HTMLMediaElement::DirectionOfPlayback HTMLMediaElement::directionOfPlayback() co nst
1857 { 1859 {
1858 return m_playbackRate >= 0 ? Forward : Backward; 1860 return m_playbackRate >= 0 ? Forward : Backward;
1859 } 1861 }
1860 1862
1861 void HTMLMediaElement::updatePlaybackRate() 1863 void HTMLMediaElement::updatePlaybackRate()
1862 { 1864 {
1863 double effectiveRate = effectivePlaybackRate(); 1865 double effectiveRate = effectivePlaybackRate();
1864 if (m_player && potentiallyPlaying()) 1866 // FIXME: remove m_webMediaPlayer check once we figure out how
1867 // m_webMediaPlayer is going out of sync with readystate.
1868 // m_webMediaPlayer is cleared but readystate is not set to HAVE_NOTHING.
1869 if (m_webMediaPlayer && potentiallyPlaying())
1865 webMediaPlayer()->setRate(effectiveRate); 1870 webMediaPlayer()->setRate(effectiveRate);
1866 } 1871 }
1867 1872
1868 bool HTMLMediaElement::ended() const 1873 bool HTMLMediaElement::ended() const
1869 { 1874 {
1870 // 4.8.10.8 Playing the media resource 1875 // 4.8.10.8 Playing the media resource
1871 // The ended attribute must return true if the media element has ended 1876 // The ended attribute must return true if the media element has ended
1872 // playback and the direction of playback is forwards, and false otherwise. 1877 // playback and the direction of playback is forwards, and false otherwise.
1873 return endedPlayback() && directionOfPlayback() == Forward; 1878 return endedPlayback() && directionOfPlayback() == Forward;
1874 } 1879 }
1875 1880
1876 bool HTMLMediaElement::autoplay() const 1881 bool HTMLMediaElement::autoplay() const
1877 { 1882 {
1878 return fastHasAttribute(autoplayAttr); 1883 return fastHasAttribute(autoplayAttr);
1879 } 1884 }
1880 1885
1881 String HTMLMediaElement::preload() const 1886 String HTMLMediaElement::preload() const
1882 { 1887 {
1883 switch (m_preload) { 1888 switch (m_preload) {
1884 case MediaPlayer::None: 1889 case WebMediaPlayer::PreloadNone:
1885 return "none"; 1890 return "none";
1886 break; 1891 break;
1887 case MediaPlayer::MetaData: 1892 case WebMediaPlayer::PreloadMetaData:
1888 return "metadata"; 1893 return "metadata";
1889 break; 1894 break;
1890 case MediaPlayer::Auto: 1895 case WebMediaPlayer::PreloadAuto:
1891 return "auto"; 1896 return "auto";
1892 break; 1897 break;
1893 } 1898 }
1894 1899
1895 ASSERT_NOT_REACHED(); 1900 ASSERT_NOT_REACHED();
1896 return String(); 1901 return String();
1897 } 1902 }
1898 1903
1899 void HTMLMediaElement::setPreload(const AtomicString& preload) 1904 void HTMLMediaElement::setPreload(const AtomicString& preload)
1900 { 1905 {
1901 WTF_LOG(Media, "HTMLMediaElement::setPreload(%p, %s)", this, preload.utf8(). data()); 1906 WTF_LOG(Media, "HTMLMediaElement::setPreload(%p, %s)", this, preload.utf8(). data());
1902 setAttribute(preloadAttr, preload); 1907 setAttribute(preloadAttr, preload);
1903 } 1908 }
1904 1909
1905 MediaPlayer::Preload HTMLMediaElement::effectivePreloadType() const 1910 WebMediaPlayer::Preload HTMLMediaElement::effectivePreloadType() const
1906 { 1911 {
1907 return autoplay() ? MediaPlayer::Auto : m_preload; 1912 return autoplay() ? WebMediaPlayer::PreloadAuto : m_preload;
1908 } 1913 }
1909 1914
1910 void HTMLMediaElement::play() 1915 void HTMLMediaElement::play()
1911 { 1916 {
1912 WTF_LOG(Media, "HTMLMediaElement::play(%p)", this); 1917 WTF_LOG(Media, "HTMLMediaElement::play(%p)", this);
1913 1918
1914 if (!UserGestureIndicator::processingUserGesture()) { 1919 if (!UserGestureIndicator::processingUserGesture()) {
1915 autoplayMediaEncountered(); 1920 autoplayMediaEncountered();
1916 if (m_userGestureRequiredForPlay) 1921 if (m_userGestureRequiredForPlay)
1917 return; 1922 return;
1918 } else if (m_userGestureRequiredForPlay) { 1923 } else if (m_userGestureRequiredForPlay) {
1919 if (m_autoplayMediaCounted) 1924 if (m_autoplayMediaCounted)
1920 recordAutoplayMetric(AutoplayManualStart); 1925 recordAutoplayMetric(AutoplayManualStart);
1921 m_userGestureRequiredForPlay = false; 1926 m_userGestureRequiredForPlay = false;
1922 } 1927 }
1923 1928
1924 playInternal(); 1929 playInternal();
1925 } 1930 }
1926 1931
1927 void HTMLMediaElement::playInternal() 1932 void HTMLMediaElement::playInternal()
1928 { 1933 {
1929 WTF_LOG(Media, "HTMLMediaElement::playInternal(%p)", this); 1934 WTF_LOG(Media, "HTMLMediaElement::playInternal(%p)", this);
1930 1935
1931 // 4.8.10.9. Playing the media resource 1936 // 4.8.10.9. Playing the media resource
1932 if (!m_player || m_networkState == NETWORK_EMPTY) 1937 if (m_networkState == NETWORK_EMPTY)
1933 scheduleDelayedAction(LoadMediaResource); 1938 scheduleDelayedAction(LoadMediaResource);
1934 1939
1935 // Generally "ended" and "looping" are exclusive. Here, the loop attribute 1940 // Generally "ended" and "looping" are exclusive. Here, the loop attribute
1936 // is ignored to seek back to start in case loop was set after playback 1941 // is ignored to seek back to start in case loop was set after playback
1937 // ended. See http://crbug.com/364442 1942 // ended. See http://crbug.com/364442
1938 if (endedPlayback(LoopCondition::Ignored)) 1943 if (endedPlayback(LoopCondition::Ignored))
1939 seek(0); 1944 seek(0);
1940 1945
1941 if (m_mediaController) 1946 if (m_mediaController)
1942 m_mediaController->bringElementUpToSpeed(this); 1947 m_mediaController->bringElementUpToSpeed(this);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1982 double progress = playedTime / duration(); 1987 double progress = playedTime / duration();
1983 if (progress < 0.5) 1988 if (progress < 0.5)
1984 recordAutoplayMetric(AutoplayBailout); 1989 recordAutoplayMetric(AutoplayBailout);
1985 } 1990 }
1986 } 1991 }
1987 1992
1988 void HTMLMediaElement::pause() 1993 void HTMLMediaElement::pause()
1989 { 1994 {
1990 WTF_LOG(Media, "HTMLMediaElement::pause(%p)", this); 1995 WTF_LOG(Media, "HTMLMediaElement::pause(%p)", this);
1991 1996
1992 if (!m_player || m_networkState == NETWORK_EMPTY) 1997 if (m_networkState == NETWORK_EMPTY)
1993 scheduleDelayedAction(LoadMediaResource); 1998 scheduleDelayedAction(LoadMediaResource);
1994 1999
1995 m_autoplaying = false; 2000 m_autoplaying = false;
1996 2001
1997 if (!m_paused) { 2002 if (!m_paused) {
1998 if (m_initialPlayWithoutUserGestures) 2003 if (m_initialPlayWithoutUserGestures)
1999 gesturelessInitialPlayHalted(); 2004 gesturelessInitialPlayHalted();
2000 2005
2001 m_paused = true; 2006 m_paused = true;
2002 scheduleTimeupdateEvent(false); 2007 scheduleTimeupdateEvent(false);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
2127 { 2132 {
2128 if (m_playbackProgressTimer.isActive()) 2133 if (m_playbackProgressTimer.isActive())
2129 return; 2134 return;
2130 2135
2131 m_previousProgressTime = WTF::currentTime(); 2136 m_previousProgressTime = WTF::currentTime();
2132 m_playbackProgressTimer.startRepeating(maxTimeupdateEventFrequency, FROM_HER E); 2137 m_playbackProgressTimer.startRepeating(maxTimeupdateEventFrequency, FROM_HER E);
2133 } 2138 }
2134 2139
2135 void HTMLMediaElement::playbackProgressTimerFired(Timer<HTMLMediaElement>*) 2140 void HTMLMediaElement::playbackProgressTimerFired(Timer<HTMLMediaElement>*)
2136 { 2141 {
2137 ASSERT(m_player);
2138
2139 if (!std::isnan(m_fragmentEndTime) && currentTime() >= m_fragmentEndTime && directionOfPlayback() == Forward) { 2142 if (!std::isnan(m_fragmentEndTime) && currentTime() >= m_fragmentEndTime && directionOfPlayback() == Forward) {
2140 m_fragmentEndTime = std::numeric_limits<double>::quiet_NaN(); 2143 m_fragmentEndTime = std::numeric_limits<double>::quiet_NaN();
2141 if (!m_mediaController && !m_paused) { 2144 if (!m_mediaController && !m_paused) {
2142 UseCounter::count(document(), UseCounter::HTMLMediaElementPauseAtFra gmentEnd); 2145 UseCounter::count(document(), UseCounter::HTMLMediaElementPauseAtFra gmentEnd);
2143 // changes paused to true and fires a simple event named pause at th e media element. 2146 // changes paused to true and fires a simple event named pause at th e media element.
2144 pause(); 2147 pause();
2145 } 2148 }
2146 } 2149 }
2147 2150
2148 if (!m_seeking) 2151 if (!m_seeking)
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
2223 Vector<WebMediaPlayer::TrackId> enabledTrackIds; 2226 Vector<WebMediaPlayer::TrackId> enabledTrackIds;
2224 for (unsigned i = 0; i < audioTracks().length(); ++i) { 2227 for (unsigned i = 0; i < audioTracks().length(); ++i) {
2225 AudioTrack* track = audioTracks().anonymousIndexedGetter(i); 2228 AudioTrack* track = audioTracks().anonymousIndexedGetter(i);
2226 if (track->enabled()) 2229 if (track->enabled())
2227 enabledTrackIds.append(track->trackId()); 2230 enabledTrackIds.append(track->trackId());
2228 } 2231 }
2229 2232
2230 webMediaPlayer()->enabledAudioTracksChanged(enabledTrackIds); 2233 webMediaPlayer()->enabledAudioTracksChanged(enabledTrackIds);
2231 } 2234 }
2232 2235
2233 WebMediaPlayer::TrackId HTMLMediaElement::addAudioTrack(const String& id, WebMed iaPlayerClient::AudioTrackKind kind, const AtomicString& label, const AtomicStri ng& language, bool enabled) 2236 WebMediaPlayer::TrackId HTMLMediaElement::addAudioTrack(const WebString& id, bli nk::WebMediaPlayerClient::AudioTrackKind kind, const WebString& label, const Web String& language, bool enabled)
2234 { 2237 {
2235 AtomicString kindString = AudioKindToString(kind); 2238 AtomicString kindString = AudioKindToString(kind);
2236 WTF_LOG(Media, "HTMLMediaElement::addAudioTrack(%p, '%s', '%s', '%s', '%s', %d)", 2239 WTF_LOG(Media, "HTMLMediaElement::addAudioTrack(%p, '%s', '%s', '%s', '%s', %d)",
2237 this, id.ascii().data(), kindString.ascii().data(), label.ascii().data() , language.ascii().data(), enabled); 2240 this, id.latin1().data(), kindString.ascii().data(), label.latin1().data (), language.latin1().data(), enabled);
2238 2241
2239 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) 2242 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled())
2240 return 0; 2243 return 0;
2241 2244
2242 RefPtrWillBeRawPtr<AudioTrack> audioTrack = AudioTrack::create(id, kindStrin g, label, language, enabled); 2245 RefPtrWillBeRawPtr<AudioTrack> audioTrack = AudioTrack::create(id, kindStrin g, label, language, enabled);
2243 audioTracks().add(audioTrack); 2246 audioTracks().add(audioTrack);
2244 2247
2245 return audioTrack->trackId(); 2248 return audioTrack->trackId();
2246 } 2249 }
2247 2250
(...skipping 19 matching lines...) Expand all
2267 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); 2270 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled());
2268 2271
2269 if (selectedTrackId) 2272 if (selectedTrackId)
2270 videoTracks().trackSelected(*selectedTrackId); 2273 videoTracks().trackSelected(*selectedTrackId);
2271 2274
2272 // FIXME: Add call on m_mediaSource to notify it of track changes once the S ourceBuffer.videoTracks attribute is added. 2275 // FIXME: Add call on m_mediaSource to notify it of track changes once the S ourceBuffer.videoTracks attribute is added.
2273 2276
2274 webMediaPlayer()->selectedVideoTrackChanged(selectedTrackId); 2277 webMediaPlayer()->selectedVideoTrackChanged(selectedTrackId);
2275 } 2278 }
2276 2279
2277 WebMediaPlayer::TrackId HTMLMediaElement::addVideoTrack(const String& id, WebMed iaPlayerClient::VideoTrackKind kind, const AtomicString& label, const AtomicStri ng& language, bool selected) 2280 WebMediaPlayer::TrackId HTMLMediaElement::addVideoTrack(const WebString& id, bli nk::WebMediaPlayerClient::VideoTrackKind kind, const WebString& label, const Web String& language, bool selected)
2278 { 2281 {
2279 AtomicString kindString = VideoKindToString(kind); 2282 AtomicString kindString = VideoKindToString(kind);
2280 WTF_LOG(Media, "HTMLMediaElement::addVideoTrack(%p, '%s', '%s', '%s', '%s', %d)", 2283 WTF_LOG(Media, "HTMLMediaElement::addVideoTrack(%p, '%s', '%s', '%s', '%s', %d)",
2281 this, id.ascii().data(), kindString.ascii().data(), label.ascii().data() , language.ascii().data(), selected); 2284 this, id.latin1().data(), kindString.ascii().data(), label.latin1().data (), language.latin1().data(), selected);
2282 2285
2283 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) 2286 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled())
2284 return 0; 2287 return 0;
2285 2288
2286 // If another track was selected (potentially by the user), leave it selecte d. 2289 // If another track was selected (potentially by the user), leave it selecte d.
2287 if (selected && videoTracks().selectedIndex() != -1) 2290 if (selected && videoTracks().selectedIndex() != -1)
2288 selected = false; 2291 selected = false;
2289 2292
2290 RefPtrWillBeRawPtr<VideoTrack> videoTrack = VideoTrack::create(id, kindStrin g, label, language, selected); 2293 RefPtrWillBeRawPtr<VideoTrack> videoTrack = VideoTrack::create(id, kindStrin g, label, language, selected);
2291 videoTracks().add(videoTrack); 2294 videoTracks().add(videoTrack);
2292 2295
2293 return videoTrack->trackId(); 2296 return videoTrack->trackId();
2294 } 2297 }
2295 2298
2296 void HTMLMediaElement::removeVideoTrack(WebMediaPlayer::TrackId trackId) 2299 void HTMLMediaElement::removeVideoTrack(WebMediaPlayer::TrackId trackId)
2297 { 2300 {
2298 WTF_LOG(Media, "HTMLMediaElement::removeVideoTrack(%p)", this); 2301 WTF_LOG(Media, "HTMLMediaElement::removeVideoTrack(%p)", this);
2299 2302
2300 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) 2303 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled())
2301 return; 2304 return;
2302 2305
2303 videoTracks().remove(trackId); 2306 videoTracks().remove(trackId);
2304 } 2307 }
2305 2308
2306 void HTMLMediaElement::mediaPlayerDidAddTextTrack(WebInbandTextTrack* webTrack) 2309 void HTMLMediaElement::addTextTrack(WebInbandTextTrack* webTrack)
2307 { 2310 {
2308 // 4.8.10.12.2 Sourcing in-band text tracks 2311 // 4.8.10.12.2 Sourcing in-band text tracks
2309 // 1. Associate the relevant data with a new text track and its correspondin g new TextTrack object. 2312 // 1. Associate the relevant data with a new text track and its correspondin g new TextTrack object.
2310 RefPtrWillBeRawPtr<InbandTextTrack> textTrack = InbandTextTrack::create(webT rack); 2313 RefPtrWillBeRawPtr<InbandTextTrack> textTrack = InbandTextTrack::create(webT rack);
2311 2314
2312 // 2. Set the new text track's kind, label, and language based on the semant ics of the relevant data, 2315 // 2. Set the new text track's kind, label, and language based on the semant ics of the relevant data,
2313 // as defined by the relevant specification. If there is no label in that da ta, then the label must 2316 // as defined by the relevant specification. If there is no label in that da ta, then the label must
2314 // be set to the empty string. 2317 // be set to the empty string.
2315 // 3. Associate the text track list of cues with the rules for updating the text track rendering appropriate 2318 // 3. Associate the text track list of cues with the rules for updating the text track rendering appropriate
2316 // for the format in question. 2319 // for the format in question.
2317 // 4. If the new text track's kind is metadata, then set the text track in-b and metadata track dispatch type 2320 // 4. If the new text track's kind is metadata, then set the text track in-b and metadata track dispatch type
2318 // as follows, based on the type of the media resource: 2321 // as follows, based on the type of the media resource:
2319 // 5. Populate the new text track's list of cues with the cues parsed so far , folllowing the guidelines for exposing 2322 // 5. Populate the new text track's list of cues with the cues parsed so far , folllowing the guidelines for exposing
2320 // cues, and begin updating it dynamically as necessary. 2323 // cues, and begin updating it dynamically as necessary.
2321 // - Thess are all done by the media engine. 2324 // - Thess are all done by the media engine.
2322 2325
2323 // 6. Set the new text track's readiness state to loaded. 2326 // 6. Set the new text track's readiness state to loaded.
2324 textTrack->setReadinessState(TextTrack::Loaded); 2327 textTrack->setReadinessState(TextTrack::Loaded);
2325 2328
2326 // 7. Set the new text track's mode to the mode consistent with the user's p references and the requirements of 2329 // 7. Set the new text track's mode to the mode consistent with the user's p references and the requirements of
2327 // the relevant specification for the data. 2330 // the relevant specification for the data.
2328 // - This will happen in honorUserPreferencesForAutomaticTextTrackSelection () 2331 // - This will happen in honorUserPreferencesForAutomaticTextTrackSelection ()
2329 scheduleDelayedAction(LoadTextTrackResource); 2332 scheduleDelayedAction(LoadTextTrackResource);
2330 2333
2331 // 8. Add the new text track to the media element's list of text tracks. 2334 // 8. Add the new text track to the media element's list of text tracks.
2332 // 9. Fire an event with the name addtrack, that does not bubble and is not cancelable, and that uses the TrackEvent 2335 // 9. Fire an event with the name addtrack, that does not bubble and is not cancelable, and that uses the TrackEvent
2333 // interface, with the track attribute initialized to the text track's TextT rack object, at the media element's 2336 // interface, with the track attribute initialized to the text track's TextT rack object, at the media element's
2334 // textTracks attribute's TextTrackList object. 2337 // textTracks attribute's TextTrackList object.
2335 addTextTrack(textTrack.get()); 2338 mediaPlayerAddTextTrack(textTrack.get());
2336 } 2339 }
2337 2340
2338 void HTMLMediaElement::mediaPlayerDidRemoveTextTrack(WebInbandTextTrack* webTrac k) 2341 void HTMLMediaElement::removeTextTrack(WebInbandTextTrack* webTrack)
2339 { 2342 {
2340 if (!m_textTracks) 2343 if (!m_textTracks)
2341 return; 2344 return;
2342 2345
2343 // This cast is safe because we created the InbandTextTrack with the WebInba ndTextTrack 2346 // This cast is safe because we created the InbandTextTrack with the WebInba ndTextTrack
2344 // passed to mediaPlayerDidAddTextTrack. 2347 // passed to mediaPlayerDidAddTextTrack.
2345 RefPtrWillBeRawPtr<InbandTextTrack> textTrack = static_cast<InbandTextTrack* >(webTrack->client()); 2348 RefPtrWillBeRawPtr<InbandTextTrack> textTrack = static_cast<InbandTextTrack* >(webTrack->client());
2346 if (!textTrack) 2349 if (!textTrack)
2347 return; 2350 return;
2348 2351
2349 removeTextTrack(textTrack.get()); 2352 mediaPlayerRemoveTextTrack(textTrack.get());
2350 } 2353 }
2351 2354
2352 void HTMLMediaElement::textTracksChanged() 2355 void HTMLMediaElement::textTracksChanged()
2353 { 2356 {
2354 if (mediaControls()) 2357 if (mediaControls())
2355 mediaControls()->refreshClosedCaptionsButtonVisibility(); 2358 mediaControls()->refreshClosedCaptionsButtonVisibility();
2356 } 2359 }
2357 2360
2358 void HTMLMediaElement::addTextTrack(TextTrack* track) 2361 void HTMLMediaElement::mediaPlayerAddTextTrack(TextTrack* track)
2359 { 2362 {
2360 textTracks()->append(track); 2363 textTracks()->append(track);
2361 2364
2362 textTracksChanged(); 2365 textTracksChanged();
2363 } 2366 }
2364 2367
2365 void HTMLMediaElement::removeTextTrack(TextTrack* track) 2368 void HTMLMediaElement::mediaPlayerRemoveTextTrack(TextTrack* track)
2366 { 2369 {
2367 m_textTracks->remove(track); 2370 m_textTracks->remove(track);
2368 2371
2369 textTracksChanged(); 2372 textTracksChanged();
2370 } 2373 }
2371 2374
2372 void HTMLMediaElement::forgetResourceSpecificTracks() 2375 void HTMLMediaElement::forgetResourceSpecificTracks()
2373 { 2376 {
2374 // Implements the "forget the media element's media-resource-specific tracks " algorithm. 2377 // Implements the "forget the media element's media-resource-specific tracks " algorithm.
2375 // The order is explicitly specified as text, then audio, and finally video. Also 2378 // The order is explicitly specified as text, then audio, and finally video. Also
(...skipping 25 matching lines...) Expand all
2401 RefPtrWillBeRawPtr<TextTrack> textTrack = TextTrack::create(kind, label, lan guage); 2404 RefPtrWillBeRawPtr<TextTrack> textTrack = TextTrack::create(kind, label, lan guage);
2402 // ..., its text track readiness state to the text track loaded state, .. . 2405 // ..., its text track readiness state to the text track loaded state, .. .
2403 textTrack->setReadinessState(TextTrack::Loaded); 2406 textTrack->setReadinessState(TextTrack::Loaded);
2404 2407
2405 // 3. Add the new text track to the media element's list of text tracks. 2408 // 3. Add the new text track to the media element's list of text tracks.
2406 // 4. Queue a task to fire a trusted event with the name addtrack, that 2409 // 4. Queue a task to fire a trusted event with the name addtrack, that
2407 // does not bubble and is not cancelable, and that uses the TrackEvent 2410 // does not bubble and is not cancelable, and that uses the TrackEvent
2408 // interface, with the track attribute initialised to the new text 2411 // interface, with the track attribute initialised to the new text
2409 // track's TextTrack object, at the media element's textTracks 2412 // track's TextTrack object, at the media element's textTracks
2410 // attribute's TextTrackList object. 2413 // attribute's TextTrackList object.
2411 addTextTrack(textTrack.get()); 2414 mediaPlayerAddTextTrack(textTrack.get());
2412 2415
2413 // Note: Due to side effects when changing track parameters, we have to 2416 // Note: Due to side effects when changing track parameters, we have to
2414 // first append the track to the text track list. 2417 // first append the track to the text track list.
2415 // FIXME: Since setMode() will cause a 'change' event to be queued on the 2418 // FIXME: Since setMode() will cause a 'change' event to be queued on the
2416 // same task source as the 'addtrack' event (see above), the order is 2419 // same task source as the 'addtrack' event (see above), the order is
2417 // wrong. (The 'change' event shouldn't be fired at all in this case...) 2420 // wrong. (The 'change' event shouldn't be fired at all in this case...)
2418 2421
2419 // ..., its text track mode to the text track hidden mode, ... 2422 // ..., its text track mode to the text track hidden mode, ...
2420 textTrack->setMode(TextTrack::hiddenKeyword()); 2423 textTrack->setMode(TextTrack::hiddenKeyword());
2421 2424
(...skipping 12 matching lines...) Expand all
2434 void HTMLMediaElement::didAddTrackElement(HTMLTrackElement* trackElement) 2437 void HTMLMediaElement::didAddTrackElement(HTMLTrackElement* trackElement)
2435 { 2438 {
2436 // 4.8.10.12.3 Sourcing out-of-band text tracks 2439 // 4.8.10.12.3 Sourcing out-of-band text tracks
2437 // When a track element's parent element changes and the new parent is a med ia element, 2440 // When a track element's parent element changes and the new parent is a med ia element,
2438 // then the user agent must add the track element's corresponding text track to the 2441 // then the user agent must add the track element's corresponding text track to the
2439 // media element's list of text tracks ... [continues in TextTrackList::appe nd] 2442 // media element's list of text tracks ... [continues in TextTrackList::appe nd]
2440 RefPtrWillBeRawPtr<TextTrack> textTrack = trackElement->track(); 2443 RefPtrWillBeRawPtr<TextTrack> textTrack = trackElement->track();
2441 if (!textTrack) 2444 if (!textTrack)
2442 return; 2445 return;
2443 2446
2444 addTextTrack(textTrack.get()); 2447 mediaPlayerAddTextTrack(textTrack.get());
2445 2448
2446 // Do not schedule the track loading until parsing finishes so we don't star t before all tracks 2449 // Do not schedule the track loading until parsing finishes so we don't star t before all tracks
2447 // in the markup have been added. 2450 // in the markup have been added.
2448 if (isFinishedParsingChildren()) 2451 if (isFinishedParsingChildren())
2449 scheduleDelayedAction(LoadTextTrackResource); 2452 scheduleDelayedAction(LoadTextTrackResource);
2450 } 2453 }
2451 2454
2452 void HTMLMediaElement::didRemoveTrackElement(HTMLTrackElement* trackElement) 2455 void HTMLMediaElement::didRemoveTrackElement(HTMLTrackElement* trackElement)
2453 { 2456 {
2454 #if !LOG_DISABLED 2457 #if !LOG_DISABLED
2455 KURL url = trackElement->getNonEmptyURLAttribute(srcAttr); 2458 KURL url = trackElement->getNonEmptyURLAttribute(srcAttr);
2456 WTF_LOG(Media, "HTMLMediaElement::didRemoveTrackElement(%p) - 'src' is %s", this, urlForLoggingMedia(url).utf8().data()); 2459 WTF_LOG(Media, "HTMLMediaElement::didRemoveTrackElement(%p) - 'src' is %s", this, urlForLoggingMedia(url).utf8().data());
2457 #endif 2460 #endif
2458 2461
2459 RefPtrWillBeRawPtr<TextTrack> textTrack = trackElement->track(); 2462 RefPtrWillBeRawPtr<TextTrack> textTrack = trackElement->track();
2460 if (!textTrack) 2463 if (!textTrack)
2461 return; 2464 return;
2462 2465
2463 textTrack->setHasBeenConfigured(false); 2466 textTrack->setHasBeenConfigured(false);
2464 2467
2465 if (!m_textTracks) 2468 if (!m_textTracks)
2466 return; 2469 return;
2467 2470
2468 // 4.8.10.12.3 Sourcing out-of-band text tracks 2471 // 4.8.10.12.3 Sourcing out-of-band text tracks
2469 // When a track element's parent element changes and the old parent was a me dia element, 2472 // When a track element's parent element changes and the old parent was a me dia element,
2470 // then the user agent must remove the track element's corresponding text tr ack from the 2473 // then the user agent must remove the track element's corresponding text tr ack from the
2471 // media element's list of text tracks. 2474 // media element's list of text tracks.
2472 removeTextTrack(textTrack.get()); 2475 mediaPlayerRemoveTextTrack(textTrack.get());
2473 2476
2474 size_t index = m_textTracksWhenResourceSelectionBegan.find(textTrack.get()); 2477 size_t index = m_textTracksWhenResourceSelectionBegan.find(textTrack.get());
2475 if (index != kNotFound) 2478 if (index != kNotFound)
2476 m_textTracksWhenResourceSelectionBegan.remove(index); 2479 m_textTracksWhenResourceSelectionBegan.remove(index);
2477 } 2480 }
2478 2481
2479 void HTMLMediaElement::honorUserPreferencesForAutomaticTextTrackSelection() 2482 void HTMLMediaElement::honorUserPreferencesForAutomaticTextTrackSelection()
2480 { 2483 {
2481 if (!m_textTracks || !m_textTracks->length()) 2484 if (!m_textTracks || !m_textTracks->length())
2482 return; 2485 return;
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
2669 WTF_LOG(Media, "HTMLMediaElement::sourceRemoved(%p) - m_nextChildNodeToC onsider set to %p", this, m_nextChildNodeToConsider.get()); 2672 WTF_LOG(Media, "HTMLMediaElement::sourceRemoved(%p) - m_nextChildNodeToC onsider set to %p", this, m_nextChildNodeToConsider.get());
2670 } else if (source == m_currentSourceNode) { 2673 } else if (source == m_currentSourceNode) {
2671 // Clear the current source node pointer, but don't change the movie as the spec says: 2674 // Clear the current source node pointer, but don't change the movie as the spec says:
2672 // 4.8.8 - Dynamically modifying a source element and its attribute when the element is already 2675 // 4.8.8 - Dynamically modifying a source element and its attribute when the element is already
2673 // inserted in a video or audio element will have no effect. 2676 // inserted in a video or audio element will have no effect.
2674 m_currentSourceNode = nullptr; 2677 m_currentSourceNode = nullptr;
2675 WTF_LOG(Media, "HTMLMediaElement::sourceRemoved(%p) - m_currentSourceNod e set to 0", this); 2678 WTF_LOG(Media, "HTMLMediaElement::sourceRemoved(%p) - m_currentSourceNod e set to 0", this);
2676 } 2679 }
2677 } 2680 }
2678 2681
2679 void HTMLMediaElement::mediaPlayerTimeChanged() 2682 void HTMLMediaElement::timeChanged()
2680 { 2683 {
2681 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerTimeChanged(%p)", this); 2684 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerTimeChanged(%p)", this);
2682 2685
2683 cueTimeline().updateActiveCues(currentTime()); 2686 cueTimeline().updateActiveCues(currentTime());
2684 2687
2685 invalidateCachedTime(); 2688 invalidateCachedTime();
2686 2689
2687 // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with t he seek. 2690 // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with t he seek.
2688 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !webMediaPlayer()->see king()) 2691 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !webMediaPlayer()->see king())
2689 finishSeek(); 2692 finishSeek();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2722 // for the media element's current media controller. 2725 // for the media element's current media controller.
2723 updateMediaController(); 2726 updateMediaController();
2724 } 2727 }
2725 } else { 2728 } else {
2726 m_sentEndEvent = false; 2729 m_sentEndEvent = false;
2727 } 2730 }
2728 2731
2729 updatePlayState(); 2732 updatePlayState();
2730 } 2733 }
2731 2734
2732 void HTMLMediaElement::mediaPlayerDurationChanged() 2735 void HTMLMediaElement::durationChanged()
2733 { 2736 {
2734 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerDurationChanged(%p)", this); 2737 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p)", this);
2735 // FIXME: Change MediaPlayerClient & WebMediaPlayer to convey 2738 // FIXME: Change WebMediaPlayer to convey the currentTime
2736 // the currentTime when the duration change occured. The current 2739 // when the duration change occured. The current WebMediaPlayer
2737 // WebMediaPlayer implementations always clamp currentTime() to 2740 // implementations always clamp currentTime() to duration()
2738 // duration() so the requestSeek condition here is always false. 2741 // so the requestSeek condition here is always false.
2739 durationChanged(duration(), currentTime() > duration()); 2742 mediaPlayerDurationChanged(duration(), currentTime() > duration());
2740 } 2743 }
2741 2744
2742 void HTMLMediaElement::durationChanged(double duration, bool requestSeek) 2745 void HTMLMediaElement::mediaPlayerDurationChanged(double duration, bool requestS eek)
2743 { 2746 {
2744 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p, %f, %d)", this, durati on, requestSeek); 2747 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerDurationChanged(%p, %f, %d)", t his, duration, requestSeek);
2745 2748
2746 // Abort if duration unchanged. 2749 // Abort if duration unchanged.
2747 if (m_duration == duration) 2750 if (m_duration == duration)
2748 return; 2751 return;
2749 2752
2750 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p) : %f -> %f", this, m_d uration, duration); 2753 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p) : %f -> %f", this, m_d uration, duration);
2751 m_duration = duration; 2754 m_duration = duration;
2752 scheduleEvent(EventTypeNames::durationchange); 2755 scheduleEvent(EventTypeNames::durationchange);
2753 2756
2754 if (mediaControls()) 2757 if (mediaControls())
2755 mediaControls()->reset(); 2758 mediaControls()->reset();
2756 if (layoutObject()) 2759 if (layoutObject())
2757 layoutObject()->updateFromElement(); 2760 layoutObject()->updateFromElement();
2758 2761
2759 if (requestSeek) 2762 if (requestSeek)
2760 seek(duration); 2763 seek(duration);
2761 } 2764 }
2762 2765
2763 void HTMLMediaElement::mediaPlayerPlaybackStateChanged() 2766 void HTMLMediaElement::playbackStateChanged()
2764 { 2767 {
2765 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerPlaybackStateChanged(%p)", this ); 2768 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerPlaybackStateChanged(%p)", this );
2766 2769
2767 if (!webMediaPlayer()) 2770 if (!webMediaPlayer())
2768 return; 2771 return;
2769 2772
2770 if (webMediaPlayer()->paused()) 2773 if (webMediaPlayer()->paused())
2771 pause(); 2774 pause();
2772 else 2775 else
2773 playInternal(); 2776 playInternal();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2808 mediaControls()->startedCasting(); 2811 mediaControls()->startedCasting();
2809 } 2812 }
2810 2813
2811 void HTMLMediaElement::disconnectedFromRemoteDevice() 2814 void HTMLMediaElement::disconnectedFromRemoteDevice()
2812 { 2815 {
2813 m_playingRemotely = false; 2816 m_playingRemotely = false;
2814 if (mediaControls()) 2817 if (mediaControls())
2815 mediaControls()->stoppedCasting(); 2818 mediaControls()->stoppedCasting();
2816 } 2819 }
2817 2820
2821 void HTMLMediaElement::keyAdded(const WebString& keySystem, const WebString& ses sionId)
2822 {
2823 }
2824
2825 void HTMLMediaElement::keyError(const WebString& keySystem, const WebString& ses sionId, MediaKeyErrorCode errorCode, unsigned short systemCode)
2826 {
2827 }
2828
2829 void HTMLMediaElement::keyMessage(const WebString& keySystem, const WebString& s essionId, const unsigned char* message, unsigned messageLength, const WebURL& de faultURL)
2830 {
2831 }
2832
2833 void HTMLMediaElement::encrypted(WebEncryptedMediaInitDataType initDataType, con st unsigned char* initData, unsigned initDataLength)
2834 {
2835 }
2836
2837 void HTMLMediaElement::didBlockPlaybackWaitingForKey()
2838 {
2839 }
2840
2841 void HTMLMediaElement::didResumePlaybackBlockedForKey()
2842 {
2843 }
2844
2818 // MediaPlayerPresentation methods 2845 // MediaPlayerPresentation methods
2819 void HTMLMediaElement::mediaPlayerRepaint() 2846 void HTMLMediaElement::repaint()
2820 { 2847 {
2821 if (m_webLayer) 2848 if (m_webLayer)
2822 m_webLayer->invalidate(); 2849 m_webLayer->invalidate();
2823 2850
2824 updateDisplayState(); 2851 updateDisplayState();
2825 if (layoutObject()) 2852 if (layoutObject())
2826 layoutObject()->setShouldDoFullPaintInvalidation(); 2853 layoutObject()->setShouldDoFullPaintInvalidation();
2827 } 2854 }
2828 2855
2829 void HTMLMediaElement::mediaPlayerSizeChanged() 2856 void HTMLMediaElement::sizeChanged()
2830 { 2857 {
2831 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerSizeChanged(%p)", this); 2858 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerSizeChanged(%p)", this);
2832 2859
2833 ASSERT(hasVideo()); // "resize" makes no sense absent video. 2860 ASSERT(hasVideo()); // "resize" makes no sense absent video.
2834 if (m_readyState > HAVE_NOTHING && isHTMLVideoElement()) 2861 if (m_readyState > HAVE_NOTHING && isHTMLVideoElement())
2835 scheduleEvent(EventTypeNames::resize); 2862 scheduleEvent(EventTypeNames::resize);
2836 2863
2837 if (layoutObject()) 2864 if (layoutObject())
2838 layoutObject()->updateFromElement(); 2865 layoutObject()->updateFromElement();
2839 } 2866 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2884 } 2911 }
2885 2912
2886 bool HTMLMediaElement::couldPlayIfEnoughData() const 2913 bool HTMLMediaElement::couldPlayIfEnoughData() const
2887 { 2914 {
2888 return !paused() && !endedPlayback() && !stoppedDueToErrors(); 2915 return !paused() && !endedPlayback() && !stoppedDueToErrors();
2889 } 2916 }
2890 2917
2891 bool HTMLMediaElement::endedPlayback(LoopCondition loopCondition) const 2918 bool HTMLMediaElement::endedPlayback(LoopCondition loopCondition) const
2892 { 2919 {
2893 double dur = duration(); 2920 double dur = duration();
2894 if (!m_player || std::isnan(dur)) 2921 if (std::isnan(dur))
2895 return false; 2922 return false;
2896 2923
2897 // 4.8.10.8 Playing the media resource 2924 // 4.8.10.8 Playing the media resource
2898 2925
2899 // A media element is said to have ended playback when the element's 2926 // A media element is said to have ended playback when the element's
2900 // readyState attribute is HAVE_METADATA or greater, 2927 // readyState attribute is HAVE_METADATA or greater,
2901 if (m_readyState < HAVE_METADATA) 2928 if (m_readyState < HAVE_METADATA)
2902 return false; 2929 return false;
2903 2930
2904 // and the current playback position is the end of the media resource and th e direction 2931 // and the current playback position is the end of the media resource and th e direction
(...skipping 15 matching lines...) Expand all
2920 RefPtrWillBeRawPtr<TimeRanges> seekableRanges = seekable(); 2947 RefPtrWillBeRawPtr<TimeRanges> seekableRanges = seekable();
2921 if (!seekableRanges->contain(currentTime())) 2948 if (!seekableRanges->contain(currentTime()))
2922 return true; 2949 return true;
2923 } 2950 }
2924 2951
2925 return false; 2952 return false;
2926 } 2953 }
2927 2954
2928 void HTMLMediaElement::updatePlayState() 2955 void HTMLMediaElement::updatePlayState()
2929 { 2956 {
2930 if (!m_player)
2931 return;
2932
2933 bool isPlaying = webMediaPlayer() && !webMediaPlayer()->paused(); 2957 bool isPlaying = webMediaPlayer() && !webMediaPlayer()->paused();
2934 bool shouldBePlaying = potentiallyPlaying(); 2958 bool shouldBePlaying = potentiallyPlaying();
2935 2959
2936 WTF_LOG(Media, "HTMLMediaElement::updatePlayState(%p) - shouldBePlaying = %s , isPlaying = %s", 2960 WTF_LOG(Media, "HTMLMediaElement::updatePlayState(%p) - shouldBePlaying = %s , isPlaying = %s",
2937 this, boolString(shouldBePlaying), boolString(isPlaying)); 2961 this, boolString(shouldBePlaying), boolString(isPlaying));
2938 2962
2939 if (shouldBePlaying) { 2963 if (shouldBePlaying) {
2940 setDisplayMode(Video); 2964 setDisplayMode(Video);
2941 invalidateCachedTime(); 2965 invalidateCachedTime();
2942 2966
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
3013 } else { 3037 } else {
3014 m_networkState = NETWORK_IDLE; 3038 m_networkState = NETWORK_IDLE;
3015 } 3039 }
3016 3040
3017 // 5 - Set the element's delaying-the-load-event flag to false. This stops d elaying the load event. 3041 // 5 - Set the element's delaying-the-load-event flag to false. This stops d elaying the load event.
3018 setShouldDelayLoadEvent(false); 3042 setShouldDelayLoadEvent(false);
3019 3043
3020 // 6 - Abort the overall resource selection algorithm. 3044 // 6 - Abort the overall resource selection algorithm.
3021 m_currentSourceNode = nullptr; 3045 m_currentSourceNode = nullptr;
3022 3046
3023 // Reset m_readyState since m_player is gone. 3047 // Reset m_readyState since m_webMediaPlayer is gone.
3024 m_readyState = HAVE_NOTHING; 3048 m_readyState = HAVE_NOTHING;
3025 invalidateCachedTime(); 3049 invalidateCachedTime();
3026 updateMediaController(); 3050 updateMediaController();
3027 cueTimeline().updateActiveCues(0); 3051 cueTimeline().updateActiveCues(0);
3028 } 3052 }
3029 3053
3030 void HTMLMediaElement::clearMediaPlayerAndAudioSourceProviderClientWithoutLockin g() 3054 void HTMLMediaElement::clearMediaPlayerAndAudioSourceProviderClientWithoutLockin g()
3031 { 3055 {
3032 #if ENABLE(WEB_AUDIO) 3056 #if ENABLE(WEB_AUDIO)
3033 if (audioSourceProvider()) 3057 if (audioSourceProvider())
3034 audioSourceProvider()->setClient(0); 3058 audioSourceProvider()->setClient(0);
3035 #endif 3059 #endif
3036 m_player.clear(); 3060 if (m_webMediaPlayer)
3061 m_webMediaPlayer.clear();
3037 } 3062 }
3038 3063
3039 void HTMLMediaElement::clearMediaPlayer(int flags) 3064 void HTMLMediaElement::clearMediaPlayer(int flags)
3040 { 3065 {
3041 forgetResourceSpecificTracks(); 3066 forgetResourceSpecificTracks();
3042 3067
3043 closeMediaSource(); 3068 closeMediaSource();
3044 3069
3045 cancelDeferredLoad(); 3070 cancelDeferredLoad();
3046 3071
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
3234 // the user agent should run the rules for updating the text track rendering 3259 // the user agent should run the rules for updating the text track rendering
3235 // of each of the text tracks in the video element's list of text tracks ... 3260 // of each of the text tracks in the video element's list of text tracks ...
3236 if (isHTMLVideoElement() && closedCaptionsVisible()) 3261 if (isHTMLVideoElement() && closedCaptionsVisible())
3237 ensureTextTrackContainer().updateDisplay(*this, TextTrackContainer::DidS tartExposingControls); 3262 ensureTextTrackContainer().updateDisplay(*this, TextTrackContainer::DidS tartExposingControls);
3238 } 3263 }
3239 3264
3240 void HTMLMediaElement::setClosedCaptionsVisible(bool closedCaptionVisible) 3265 void HTMLMediaElement::setClosedCaptionsVisible(bool closedCaptionVisible)
3241 { 3266 {
3242 WTF_LOG(Media, "HTMLMediaElement::setClosedCaptionsVisible(%p, %s)", this, b oolString(closedCaptionVisible)); 3267 WTF_LOG(Media, "HTMLMediaElement::setClosedCaptionsVisible(%p, %s)", this, b oolString(closedCaptionVisible));
3243 3268
3244 if (!m_player || !hasClosedCaptions()) 3269 if (!hasClosedCaptions())
3245 return; 3270 return;
3246 3271
3247 m_closedCaptionsVisible = closedCaptionVisible; 3272 m_closedCaptionsVisible = closedCaptionVisible;
3248 3273
3249 markCaptionAndSubtitleTracksAsUnconfigured(); 3274 markCaptionAndSubtitleTracksAsUnconfigured();
3250 m_processingPreferenceChange = true; 3275 m_processingPreferenceChange = true;
3251 honorUserPreferencesForAutomaticTextTrackSelection(); 3276 honorUserPreferencesForAutomaticTextTrackSelection();
3252 m_processingPreferenceChange = false; 3277 m_processingPreferenceChange = false;
3253 3278
3254 // As track visibility changed while m_processingPreferenceChange was set, 3279 // As track visibility changed while m_processingPreferenceChange was set,
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
3416 3441
3417 return nullptr; 3442 return nullptr;
3418 } 3443 }
3419 3444
3420 void HTMLMediaElement::createMediaPlayer() 3445 void HTMLMediaElement::createMediaPlayer()
3421 { 3446 {
3422 AudioSourceProviderClientLockScope scope(*this); 3447 AudioSourceProviderClientLockScope scope(*this);
3423 3448
3424 closeMediaSource(); 3449 closeMediaSource();
3425 3450
3426 m_player = MediaPlayer::create(this); 3451 if (m_webMediaPlayer)
3452 m_webMediaPlayer.clear();
3427 3453
3428 // We haven't yet found out if any remote routes are available. 3454 // We haven't yet found out if any remote routes are available.
3429 m_remoteRoutesAvailable = false; 3455 m_remoteRoutesAvailable = false;
3430 m_playingRemotely = false; 3456 m_playingRemotely = false;
3431
3432 #if ENABLE(WEB_AUDIO)
3433 if (m_audioSourceNode && audioSourceProvider()) {
3434 // When creating the player, make sure its AudioSourceProvider knows abo ut the client.
3435 audioSourceProvider()->setClient(m_audioSourceNode);
3436 }
3437 #endif
3438 } 3457 }
3439 3458
3440 #if ENABLE(WEB_AUDIO) 3459 #if ENABLE(WEB_AUDIO)
3441 void HTMLMediaElement::setAudioSourceNode(AudioSourceProviderClient* sourceNode) 3460 void HTMLMediaElement::setAudioSourceNode(AudioSourceProviderClient* sourceNode)
3442 { 3461 {
3443 ASSERT(isMainThread()); 3462 ASSERT(isMainThread());
3444 m_audioSourceNode = sourceNode; 3463 m_audioSourceNode = sourceNode;
3445 3464
3446 AudioSourceProviderClientLockScope scope(*this); 3465 AudioSourceProviderClientLockScope scope(*this);
3447 if (audioSourceProvider()) 3466 if (audioSourceProvider())
3448 audioSourceProvider()->setClient(m_audioSourceNode); 3467 audioSourceProvider()->setClient(m_audioSourceNode);
3449 } 3468 }
3450 3469
3451 AudioSourceProvider* HTMLMediaElement::audioSourceProvider() 3470 AudioSourceProvider* HTMLMediaElement::audioSourceProvider()
3452 { 3471 {
3453 if (m_player) 3472 if (m_webMediaPlayer)
3454 return m_player->audioSourceProvider(); 3473 return &m_audioSourceProvider;
3455 3474
3456 return nullptr; 3475 return nullptr;
3457 } 3476 }
3458 #endif 3477 #endif
3459 3478
3460 const AtomicString& HTMLMediaElement::mediaGroup() const 3479 const AtomicString& HTMLMediaElement::mediaGroup() const
3461 { 3480 {
3462 return fastGetAttribute(mediagroupAttr); 3481 return fastGetAttribute(mediagroupAttr);
3463 } 3482 }
3464 3483
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
3559 WebMediaPlayer::CORSMode HTMLMediaElement::corsMode() const 3578 WebMediaPlayer::CORSMode HTMLMediaElement::corsMode() const
3560 { 3579 {
3561 const AtomicString& crossOriginMode = fastGetAttribute(crossoriginAttr); 3580 const AtomicString& crossOriginMode = fastGetAttribute(crossoriginAttr);
3562 if (crossOriginMode.isNull()) 3581 if (crossOriginMode.isNull())
3563 return WebMediaPlayer::CORSModeUnspecified; 3582 return WebMediaPlayer::CORSModeUnspecified;
3564 if (equalIgnoringCase(crossOriginMode, "use-credentials")) 3583 if (equalIgnoringCase(crossOriginMode, "use-credentials"))
3565 return WebMediaPlayer::CORSModeUseCredentials; 3584 return WebMediaPlayer::CORSModeUseCredentials;
3566 return WebMediaPlayer::CORSModeAnonymous; 3585 return WebMediaPlayer::CORSModeAnonymous;
3567 } 3586 }
3568 3587
3569 void HTMLMediaElement::mediaPlayerSetWebLayer(WebLayer* webLayer) 3588 void HTMLMediaElement::setWebLayer(blink::WebLayer* webLayer)
3570 { 3589 {
3571 if (webLayer == m_webLayer) 3590 if (webLayer == m_webLayer)
3572 return; 3591 return;
3573 3592
3574 // If either of the layers is null we need to enable or disable compositing. This is done by triggering a style recalc. 3593 // If either of the layers is null we need to enable or disable compositing. This is done by triggering a style recalc.
3575 if ((!m_webLayer || !webLayer) 3594 if ((!m_webLayer || !webLayer)
3576 #if ENABLE(OILPAN) 3595 #if ENABLE(OILPAN)
3577 && !m_isFinalizing 3596 && !m_isFinalizing
3578 #endif 3597 #endif
3579 ) 3598 )
3580 setNeedsCompositingUpdate(); 3599 setNeedsCompositingUpdate();
3581 3600
3582 if (m_webLayer) 3601 if (m_webLayer)
3583 GraphicsLayer::unregisterContentsLayer(m_webLayer); 3602 GraphicsLayer::unregisterContentsLayer(m_webLayer);
3584 m_webLayer = webLayer; 3603 m_webLayer = webLayer;
3585 if (m_webLayer) 3604 if (m_webLayer)
3586 GraphicsLayer::registerContentsLayer(m_webLayer); 3605 GraphicsLayer::registerContentsLayer(m_webLayer);
3587 } 3606 }
3588 3607
3589 void HTMLMediaElement::mediaPlayerMediaSourceOpened(WebMediaSource* webMediaSour ce) 3608 void HTMLMediaElement::mediaSourceOpened(blink::WebMediaSource* webMediaSource)
3590 { 3609 {
3591 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource)); 3610 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource));
3592 } 3611 }
3593 3612
3594 bool HTMLMediaElement::isInteractiveContent() const 3613 bool HTMLMediaElement::isInteractiveContent() const
3595 { 3614 {
3596 return fastHasAttribute(controlsAttr); 3615 return fastHasAttribute(controlsAttr);
3597 } 3616 }
3598 3617
3599 void HTMLMediaElement::defaultEventHandler(Event* event) 3618 void HTMLMediaElement::defaultEventHandler(Event* event)
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
3650 3669
3651 // Enable the first audio track if an audio track hasn't been enabled yet. 3670 // Enable the first audio track if an audio track hasn't been enabled yet.
3652 if (audioTracks().length() > 0 && !audioTracks().hasEnabledTrack()) 3671 if (audioTracks().length() > 0 && !audioTracks().hasEnabledTrack())
3653 audioTracks().anonymousIndexedGetter(0)->setEnabled(true); 3672 audioTracks().anonymousIndexedGetter(0)->setEnabled(true);
3654 3673
3655 // Select the first video track if a video track hasn't been selected yet. 3674 // Select the first video track if a video track hasn't been selected yet.
3656 if (videoTracks().length() > 0 && videoTracks().selectedIndex() == -1) 3675 if (videoTracks().length() > 0 && videoTracks().selectedIndex() == -1)
3657 videoTracks().anonymousIndexedGetter(0)->setSelected(true); 3676 videoTracks().anonymousIndexedGetter(0)->setSelected(true);
3658 } 3677 }
3659 3678
3679 void HTMLMediaElement::prepareAndLoadMediaPlayer(const WTF::String& url)
3680 {
3681 ASSERT(!m_webMediaPlayer);
3682
3683 WebURL poster = mediaPlayerPosterURL();
3684
3685 KURL kurl(ParsedURLString, url);
3686 LocalFrame* frame = document().frame();
3687 ASSERT(frame);
3688 m_webMediaPlayer = frame->loader().client()->createWebMediaPlayer(this, kurl );
3689 if (!m_webMediaPlayer)
3690 return;
3691
3692 #if ENABLE(WEB_AUDIO)
3693 // Make sure if we create/re-create the WebMediaPlayer that we update our wr apper.
3694 m_audioSourceProvider.wrap(m_webMediaPlayer->audioSourceProvider());
3695 #endif
3696 m_webMediaPlayer->setVolume(effectiveMediaVolume());
3697
3698 m_webMediaPlayer->setPoster(poster);
3699
3700 m_webMediaPlayer->setPreload(effectivePreloadType());
3701
3702 m_webMediaPlayer->load(loadType(), kurl, corsMode());
3703
3704 if (isFullscreen())
3705 m_webMediaPlayer->enterFullscreen();
3706 }
3707
3660 #if ENABLE(WEB_AUDIO) 3708 #if ENABLE(WEB_AUDIO)
3661 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) 3709 void HTMLMediaElement::clearWeakMembers(Visitor* visitor)
3662 { 3710 {
3663 if (!visitor->isHeapObjectAlive(m_audioSourceNode) && audioSourceProvider()) 3711 if (!visitor->isHeapObjectAlive(m_audioSourceNode) && audioSourceProvider())
3664 audioSourceProvider()->setClient(nullptr); 3712 audioSourceProvider()->setClient(nullptr);
3665 } 3713 }
3714
3715 void HTMLMediaElement::AudioSourceProviderImpl::wrap(WebAudioSourceProvider* pro vider)
3716 {
3717 MutexLocker locker(provideInputLock);
3718
3719 if (m_webAudioSourceProvider && provider != m_webAudioSourceProvider)
3720 m_webAudioSourceProvider->setClient(0);
3721
3722 m_webAudioSourceProvider = provider;
3723 if (m_webAudioSourceProvider)
3724 m_webAudioSourceProvider->setClient(m_client.get());
3725 }
3726
3727 void HTMLMediaElement::AudioSourceProviderImpl::setClient(AudioSourceProviderCli ent* client)
3728 {
3729 MutexLocker locker(provideInputLock);
3730
3731 if (client)
3732 m_client = new HTMLMediaElement::AudioClientImpl(client);
3733 else
3734 m_client.clear();
3735
3736 if (m_webAudioSourceProvider)
3737 m_webAudioSourceProvider->setClient(m_client.get());
3738 }
3739
3740 void HTMLMediaElement::AudioSourceProviderImpl::provideInput(blink::AudioBus* bu s, size_t framesToProcess)
3741 {
3742 ASSERT(bus);
3743 if (!bus)
3744 return;
3745
3746 MutexTryLocker tryLocker(provideInputLock);
3747 if (!tryLocker.locked() || !m_webAudioSourceProvider || !m_client.get()) {
3748 bus->zero();
3749 return;
3750 }
3751
3752 // Wrap the AudioBus channel data using WebVector.
3753 size_t n = bus->numberOfChannels();
3754 WebVector<float*> webAudioData(n);
3755 for (size_t i = 0; i < n; ++i)
3756 webAudioData[i] = bus->channel(i)->mutableData();
3757
3758 m_webAudioSourceProvider->provideInput(webAudioData, framesToProcess);
3759 }
3760
3761 void HTMLMediaElement::AudioClientImpl::setFormat(size_t numberOfChannels, float sampleRate)
3762 {
3763 if (m_client)
3764 m_client->setFormat(numberOfChannels, sampleRate);
3765 }
3766
3767 DEFINE_TRACE(HTMLMediaElement::AudioClientImpl)
3768 {
3769 visitor->trace(m_client);
3770 }
3666 #endif 3771 #endif
3667 3772
3668 } 3773 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698