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

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: Rebase and code cleanup Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
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/inspector/ConsoleMessage.h" 62 #include "core/inspector/ConsoleMessage.h"
63 #include "core/layout/LayoutVideo.h" 63 #include "core/layout/LayoutVideo.h"
64 #include "core/layout/LayoutView.h" 64 #include "core/layout/LayoutView.h"
65 #include "core/layout/compositing/DeprecatedPaintLayerCompositor.h" 65 #include "core/layout/compositing/DeprecatedPaintLayerCompositor.h"
66 #include "core/loader/FrameLoader.h" 66 #include "core/loader/FrameLoader.h"
67 #include "core/loader/FrameLoaderClient.h"
67 #include "platform/ContentType.h" 68 #include "platform/ContentType.h"
68 #include "platform/Logging.h" 69 #include "platform/Logging.h"
69 #include "platform/MIMETypeFromURL.h" 70 #include "platform/MIMETypeFromURL.h"
70 #include "platform/MIMETypeRegistry.h" 71 #include "platform/MIMETypeRegistry.h"
71 #include "platform/RuntimeEnabledFeatures.h" 72 #include "platform/RuntimeEnabledFeatures.h"
72 #include "platform/UserGestureIndicator.h" 73 #include "platform/UserGestureIndicator.h"
74 #include "platform/audio/AudioBus.h"
75 #include "platform/audio/AudioSourceProviderClient.h"
73 #include "platform/graphics/GraphicsLayer.h" 76 #include "platform/graphics/GraphicsLayer.h"
74 #include "platform/weborigin/SecurityOrigin.h" 77 #include "platform/weborigin/SecurityOrigin.h"
75 #include "public/platform/Platform.h" 78 #include "public/platform/Platform.h"
79 #include "public/platform/WebAudioSourceProvider.h"
76 #include "public/platform/WebContentDecryptionModule.h" 80 #include "public/platform/WebContentDecryptionModule.h"
77 #include "public/platform/WebInbandTextTrack.h" 81 #include "public/platform/WebInbandTextTrack.h"
78 #include "wtf/CurrentTime.h" 82 #include "wtf/CurrentTime.h"
79 #include "wtf/MainThread.h" 83 #include "wtf/MainThread.h"
80 #include "wtf/MathExtras.h" 84 #include "wtf/MathExtras.h"
81 #include "wtf/text/CString.h" 85 #include "wtf/text/CString.h"
82 #include <limits> 86 #include <limits>
83 87
84 #if ENABLE(WEB_AUDIO) 88 #if ENABLE(WEB_AUDIO)
85 #include "platform/audio/AudioSourceProvider.h" 89 #include "platform/audio/AudioSourceProvider.h"
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 , m_lastSeekTime(0) 331 , m_lastSeekTime(0)
328 , m_previousProgressTime(std::numeric_limits<double>::max()) 332 , m_previousProgressTime(std::numeric_limits<double>::max())
329 , m_duration(std::numeric_limits<double>::quiet_NaN()) 333 , m_duration(std::numeric_limits<double>::quiet_NaN())
330 , m_lastTimeUpdateEventWallTime(0) 334 , m_lastTimeUpdateEventWallTime(0)
331 , m_lastTimeUpdateEventMovieTime(0) 335 , m_lastTimeUpdateEventMovieTime(0)
332 , m_defaultPlaybackStartPosition(0) 336 , m_defaultPlaybackStartPosition(0)
333 , m_loadState(WaitingForSource) 337 , m_loadState(WaitingForSource)
334 , m_deferredLoadState(NotDeferred) 338 , m_deferredLoadState(NotDeferred)
335 , m_deferredLoadTimer(this, &HTMLMediaElement::deferredLoadTimerFired) 339 , m_deferredLoadTimer(this, &HTMLMediaElement::deferredLoadTimerFired)
336 , m_webLayer(nullptr) 340 , m_webLayer(nullptr)
337 , m_preload(MediaPlayer::Auto) 341 , m_preload(WebMediaPlayer::PreloadAuto)
338 , m_displayMode(Unknown) 342 , m_displayMode(Unknown)
339 , m_cachedTime(std::numeric_limits<double>::quiet_NaN()) 343 , m_cachedTime(std::numeric_limits<double>::quiet_NaN())
340 , m_fragmentEndTime(std::numeric_limits<double>::quiet_NaN()) 344 , m_fragmentEndTime(std::numeric_limits<double>::quiet_NaN())
341 , m_pendingActionFlags(0) 345 , m_pendingActionFlags(0)
342 , m_userGestureRequiredForPlay(false) 346 , m_userGestureRequiredForPlay(false)
343 , m_playing(false) 347 , m_playing(false)
344 , m_shouldDelayLoadEvent(false) 348 , m_shouldDelayLoadEvent(false)
345 , m_haveFiredLoadedData(false) 349 , m_haveFiredLoadedData(false)
346 , m_autoplaying(true) 350 , m_autoplaying(true)
347 , m_muted(false) 351 , m_muted(false)
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 } 492 }
489 #endif 493 #endif
490 494
491 void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument) 495 void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument)
492 { 496 {
493 WTF_LOG(Media, "HTMLMediaElement::didMoveToNewDocument(%p)", this); 497 WTF_LOG(Media, "HTMLMediaElement::didMoveToNewDocument(%p)", this);
494 498
495 if (m_shouldDelayLoadEvent) { 499 if (m_shouldDelayLoadEvent) {
496 document().incrementLoadEventDelayCount(); 500 document().incrementLoadEventDelayCount();
497 // Note: Keeping the load event delay count increment on oldDocument tha t was added 501 // Note: Keeping the load event delay count increment on oldDocument tha t was added
498 // when m_shouldDelayLoadEvent was set so that destruction of m_player c an not 502 // when m_shouldDelayLoadEvent was set so that destruction of m_webMedia Player can not
499 // cause load event dispatching in oldDocument. 503 // cause load event dispatching in oldDocument.
500 } else { 504 } else {
501 // Incrementing the load event delay count so that destruction of m_play er can not 505 // Incrementing the load event delay count so that destruction of m_webM ediaPlayer can not
502 // cause load event dispatching in oldDocument. 506 // cause load event dispatching in oldDocument.
503 oldDocument.incrementLoadEventDelayCount(); 507 oldDocument.incrementLoadEventDelayCount();
504 } 508 }
505 509
506 removeElementFromDocumentMap(this, &oldDocument); 510 removeElementFromDocumentMap(this, &oldDocument);
507 addElementToDocumentMap(this, &document()); 511 addElementToDocumentMap(this, &document());
508 512
509 // FIXME: This is a temporary fix to prevent this object from causing the 513 // FIXME: This is a temporary fix to prevent this object from causing the
510 // MediaPlayer to dereference LocalFrame and FrameLoader pointers from the 514 // MediaPlayer to dereference LocalFrame and FrameLoader pointers from the
511 // previous document. A proper fix would provide a mechanism to allow this 515 // previous document. A proper fix would provide a mechanism to allow this
512 // object to refresh the MediaPlayer's LocalFrame and FrameLoader references on 516 // object to refresh the MediaPlayer's LocalFrame and FrameLoader references on
513 // document changes so that playback can be resumed properly. 517 // document changes so that playback can be resumed properly.
514 userCancelledLoad(); 518 userCancelledLoad();
515 519
516 // Decrement the load event delay count on oldDocument now that m_player has been destroyed 520 // Decrement the load event delay count on oldDocument now that m_webMediaPl ayer has been destroyed
517 // and there is no risk of dispatching a load event from within the destruct or. 521 // and there is no risk of dispatching a load event from within the destruct or.
518 oldDocument.decrementLoadEventDelayCount(); 522 oldDocument.decrementLoadEventDelayCount();
519 523
520 ActiveDOMObject::didMoveToNewExecutionContext(&document()); 524 ActiveDOMObject::didMoveToNewExecutionContext(&document());
521 HTMLElement::didMoveToNewDocument(oldDocument); 525 HTMLElement::didMoveToNewDocument(oldDocument);
522 } 526 }
523 527
524 bool HTMLMediaElement::supportsFocus() const 528 bool HTMLMediaElement::supportsFocus() const
525 { 529 {
526 if (ownerDocument()->isMediaDocument()) 530 if (ownerDocument()->isMediaDocument())
(...skipping 13 matching lines...) Expand all
540 if (name == srcAttr) { 544 if (name == srcAttr) {
541 // Trigger a reload, as long as the 'src' attribute is present. 545 // Trigger a reload, as long as the 'src' attribute is present.
542 if (!value.isNull()) { 546 if (!value.isNull()) {
543 clearMediaPlayer(LoadMediaResource); 547 clearMediaPlayer(LoadMediaResource);
544 scheduleDelayedAction(LoadMediaResource); 548 scheduleDelayedAction(LoadMediaResource);
545 } 549 }
546 } else if (name == controlsAttr) { 550 } else if (name == controlsAttr) {
547 configureMediaControls(); 551 configureMediaControls();
548 } else if (name == preloadAttr) { 552 } else if (name == preloadAttr) {
549 if (equalIgnoringCase(value, "none")) { 553 if (equalIgnoringCase(value, "none")) {
550 m_preload = MediaPlayer::None; 554 m_preload = WebMediaPlayer::PreloadNone;
551 } else if (equalIgnoringCase(value, "metadata")) { 555 } else if (equalIgnoringCase(value, "metadata")) {
552 m_preload = MediaPlayer::MetaData; 556 m_preload = WebMediaPlayer::PreloadMetaData;
553 } else { 557 } else {
554 // The spec does not define an "invalid value default" but "auto" is suggested as the 558 // The spec does not define an "invalid value default" but "auto" is suggested as the
555 // "missing value default", so use it for everything except "none" a nd "metadata" 559 // "missing value default", so use it for everything except "none" a nd "metadata"
556 m_preload = MediaPlayer::Auto; 560 m_preload = WebMediaPlayer::PreloadAuto;
557 } 561 }
558 562
559 // The attribute must be ignored if the autoplay attribute is present 563 // The attribute must be ignored if the autoplay attribute is present
560 if (m_player) 564 setPlayerPreload();
561 setPlayerPreload();
562
563 } else if (name == mediagroupAttr && RuntimeEnabledFeatures::mediaController Enabled()) { 565 } else if (name == mediagroupAttr && RuntimeEnabledFeatures::mediaController Enabled()) {
564 setMediaGroup(value); 566 setMediaGroup(value);
565 } else { 567 } else {
566 HTMLElement::parseAttribute(name, value); 568 HTMLElement::parseAttribute(name, value);
567 } 569 }
568 } 570 }
569 571
570 void HTMLMediaElement::finishParsingChildren() 572 void HTMLMediaElement::finishParsingChildren()
571 { 573 {
572 HTMLElement::finishParsingChildren(); 574 HTMLElement::finishParsingChildren();
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 m_mediaSource = nullptr; 999 m_mediaSource = nullptr;
998 attemptLoad = false; 1000 attemptLoad = false;
999 } 1001 }
1000 } 1002 }
1001 } 1003 }
1002 } 1004 }
1003 1005
1004 if (attemptLoad && canLoadURL(url, contentType, keySystem)) { 1006 if (attemptLoad && canLoadURL(url, contentType, keySystem)) {
1005 ASSERT(!webMediaPlayer()); 1007 ASSERT(!webMediaPlayer());
1006 1008
1007 if (!m_havePreparedToPlay && !autoplay() && m_preload == MediaPlayer::No ne) { 1009 if (!m_havePreparedToPlay && !autoplay() && m_preload == WebMediaPlayer: :PreloadNone) {
1008 WTF_LOG(Media, "HTMLMediaElement::loadResource(%p) : Delaying load b ecause preload == 'none'", this); 1010 WTF_LOG(Media, "HTMLMediaElement::loadResource(%p) : Delaying load b ecause preload == 'none'", this);
1009 deferLoad(); 1011 deferLoad();
1010 } else { 1012 } else {
1011 startPlayerLoad(); 1013 startPlayerLoad();
1012 } 1014 }
1013 } else { 1015 } else {
1014 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); 1016 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError);
1015 } 1017 }
1016 1018
1017 // If there is no poster to display, allow the media engine to render video frames as soon as 1019 // If there is no poster to display, allow the media engine to render video frames as soon as
(...skipping 18 matching lines...) Expand all
1036 // along with that potentially also specifying a setting for its 1038 // along with that potentially also specifying a setting for its
1037 // 'authentication flag' to control how user:pass embedded in a 1039 // 'authentication flag' to control how user:pass embedded in a
1038 // media resource URL should be treated, then update the handling 1040 // media resource URL should be treated, then update the handling
1039 // here to match. 1041 // here to match.
1040 KURL requestURL = m_currentSrc; 1042 KURL requestURL = m_currentSrc;
1041 if (!requestURL.user().isEmpty()) 1043 if (!requestURL.user().isEmpty())
1042 requestURL.setUser(String()); 1044 requestURL.setUser(String());
1043 if (!requestURL.pass().isEmpty()) 1045 if (!requestURL.pass().isEmpty())
1044 requestURL.setPass(String()); 1046 requestURL.setPass(String());
1045 1047
1046 m_player->load(loadType(), requestURL, corsMode()); 1048 prepareAndLoadMediaPlayer(requestURL);
1047 } 1049 }
1048 1050
1049 void HTMLMediaElement::setPlayerPreload() 1051 void HTMLMediaElement::setPlayerPreload()
1050 { 1052 {
1051 m_player->setPreload(effectivePreloadType()); 1053 if (m_webMediaPlayer)
1054 m_webMediaPlayer->setPreload(effectivePreloadType());
1052 1055
1053 if (loadIsDeferred() && m_preload != MediaPlayer::None) 1056 if (loadIsDeferred() && m_preload != WebMediaPlayer::PreloadNone)
1054 startDeferredLoad(); 1057 startDeferredLoad();
1055 } 1058 }
1056 1059
1057 bool HTMLMediaElement::loadIsDeferred() const 1060 bool HTMLMediaElement::loadIsDeferred() const
1058 { 1061 {
1059 return m_deferredLoadState != NotDeferred; 1062 return m_deferredLoadState != NotDeferred;
1060 } 1063 }
1061 1064
1062 void HTMLMediaElement::deferLoad() 1065 void HTMLMediaElement::deferLoad()
1063 { 1066 {
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
1307 1310
1308 void HTMLMediaElement::cancelPendingEventsAndCallbacks() 1311 void HTMLMediaElement::cancelPendingEventsAndCallbacks()
1309 { 1312 {
1310 WTF_LOG(Media, "HTMLMediaElement::cancelPendingEventsAndCallbacks(%p)", this ); 1313 WTF_LOG(Media, "HTMLMediaElement::cancelPendingEventsAndCallbacks(%p)", this );
1311 m_asyncEventQueue->cancelAllEvents(); 1314 m_asyncEventQueue->cancelAllEvents();
1312 1315
1313 for (HTMLSourceElement* source = Traversal<HTMLSourceElement>::firstChild(*t his); source; source = Traversal<HTMLSourceElement>::nextSibling(*source)) 1316 for (HTMLSourceElement* source = Traversal<HTMLSourceElement>::firstChild(*t his); source; source = Traversal<HTMLSourceElement>::nextSibling(*source))
1314 source->cancelPendingErrorEvent(); 1317 source->cancelPendingErrorEvent();
1315 } 1318 }
1316 1319
1317 void HTMLMediaElement::mediaPlayerNetworkStateChanged() 1320 void HTMLMediaElement::networkStateChanged()
1318 { 1321 {
1319 setNetworkState(webMediaPlayer()->networkState()); 1322 setNetworkState(webMediaPlayer()->networkState());
1320 } 1323 }
1321 1324
1322 void HTMLMediaElement::mediaLoadingFailed(WebMediaPlayer::NetworkState error) 1325 void HTMLMediaElement::mediaLoadingFailed(WebMediaPlayer::NetworkState error)
1323 { 1326 {
1324 stopPeriodicTimers(); 1327 stopPeriodicTimers();
1325 1328
1326 // If we failed while trying to load a <source> element, the movie was never parsed, and there are more 1329 // If we failed while trying to load a <source> element, the movie was never parsed, and there are more
1327 // <source> children, schedule the next one 1330 // <source> children, schedule the next one
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1398 1401
1399 if (state == WebMediaPlayer::NetworkStateLoaded) { 1402 if (state == WebMediaPlayer::NetworkStateLoaded) {
1400 if (m_networkState != NETWORK_IDLE) 1403 if (m_networkState != NETWORK_IDLE)
1401 changeNetworkStateFromLoadingToIdle(); 1404 changeNetworkStateFromLoadingToIdle();
1402 m_completelyLoaded = true; 1405 m_completelyLoaded = true;
1403 } 1406 }
1404 } 1407 }
1405 1408
1406 void HTMLMediaElement::changeNetworkStateFromLoadingToIdle() 1409 void HTMLMediaElement::changeNetworkStateFromLoadingToIdle()
1407 { 1410 {
1408 ASSERT(m_player);
1409 m_progressEventTimer.stop(); 1411 m_progressEventTimer.stop();
1410 1412
1411 // Schedule one last progress event so we guarantee that at least one is fir ed 1413 // Schedule one last progress event so we guarantee that at least one is fir ed
1412 // for files that load very quickly. 1414 // for files that load very quickly.
1413 if (webMediaPlayer() && webMediaPlayer()->didLoadingProgress()) 1415 if (webMediaPlayer() && webMediaPlayer()->didLoadingProgress())
1414 scheduleEvent(EventTypeNames::progress); 1416 scheduleEvent(EventTypeNames::progress);
1415 scheduleEvent(EventTypeNames::suspend); 1417 scheduleEvent(EventTypeNames::suspend);
1416 m_networkState = NETWORK_IDLE; 1418 m_networkState = NETWORK_IDLE;
1417 } 1419 }
1418 1420
1419 void HTMLMediaElement::mediaPlayerReadyStateChanged() 1421 void HTMLMediaElement::readyStateChanged()
1420 { 1422 {
1421 setReadyState(static_cast<ReadyState>(webMediaPlayer()->readyState())); 1423 setReadyState(static_cast<ReadyState>(webMediaPlayer()->readyState()));
1422 } 1424 }
1423 1425
1424 void HTMLMediaElement::setReadyState(ReadyState state) 1426 void HTMLMediaElement::setReadyState(ReadyState state)
1425 { 1427 {
1426 WTF_LOG(Media, "HTMLMediaElement::setReadyState(%p, %d) - current state is % d,", this, static_cast<int>(state), static_cast<int>(m_readyState)); 1428 WTF_LOG(Media, "HTMLMediaElement::setReadyState(%p, %d) - current state is % d,", this, static_cast<int>(state), static_cast<int>(m_readyState));
1427 1429
1428 // Set "wasPotentiallyPlaying" BEFORE updating m_readyState, potentiallyPlay ing() uses it 1430 // Set "wasPotentiallyPlaying" BEFORE updating m_readyState, potentiallyPlay ing() uses it
1429 bool wasPotentiallyPlaying = potentiallyPlaying(); 1431 bool wasPotentiallyPlaying = potentiallyPlaying();
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1567 mediaControls()->refreshClosedCaptionsButtonVisibility(); 1569 mediaControls()->refreshClosedCaptionsButtonVisibility();
1568 } 1570 }
1569 1571
1570 updatePlayState(); 1572 updatePlayState();
1571 updateMediaController(); 1573 updateMediaController();
1572 cueTimeline().updateActiveCues(currentTime()); 1574 cueTimeline().updateActiveCues(currentTime());
1573 } 1575 }
1574 1576
1575 void HTMLMediaElement::progressEventTimerFired(Timer<HTMLMediaElement>*) 1577 void HTMLMediaElement::progressEventTimerFired(Timer<HTMLMediaElement>*)
1576 { 1578 {
1577 ASSERT(m_player);
1578 if (m_networkState != NETWORK_LOADING) 1579 if (m_networkState != NETWORK_LOADING)
1579 return; 1580 return;
1580 1581
1581 double time = WTF::currentTime(); 1582 double time = WTF::currentTime();
1582 double timedelta = time - m_previousProgressTime; 1583 double timedelta = time - m_previousProgressTime;
1583 1584
1584 if (webMediaPlayer() && webMediaPlayer()->didLoadingProgress()) { 1585 if (webMediaPlayer() && webMediaPlayer()->didLoadingProgress()) {
1585 scheduleEvent(EventTypeNames::progress); 1586 scheduleEvent(EventTypeNames::progress);
1586 m_previousProgressTime = time; 1587 m_previousProgressTime = time;
1587 m_sentStalledEvent = false; 1588 m_sentStalledEvent = false;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1620 1621
1621 void HTMLMediaElement::seek(double time) 1622 void HTMLMediaElement::seek(double time)
1622 { 1623 {
1623 WTF_LOG(Media, "HTMLMediaElement::seek(%p, %f)", this, time); 1624 WTF_LOG(Media, "HTMLMediaElement::seek(%p, %f)", this, time);
1624 1625
1625 // 2 - If the media element's readyState is HAVE_NOTHING, abort these steps. 1626 // 2 - If the media element's readyState is HAVE_NOTHING, abort these steps.
1626 if (m_readyState == HAVE_NOTHING) 1627 if (m_readyState == HAVE_NOTHING)
1627 return; 1628 return;
1628 1629
1629 // If the media engine has been told to postpone loading data, let it go ahe ad now. 1630 // If the media engine has been told to postpone loading data, let it go ahe ad now.
1630 if (m_preload < MediaPlayer::Auto && m_readyState < HAVE_FUTURE_DATA) 1631 if (m_preload < WebMediaPlayer::PreloadAuto && m_readyState < HAVE_FUTURE_DA TA)
1631 prepareToPlay(); 1632 prepareToPlay();
1632 1633
1633 // Get the current time before setting m_seeking, m_lastSeekTime is returned once it is set. 1634 // Get the current time before setting m_seeking, m_lastSeekTime is returned once it is set.
1634 refreshCachedTime(); 1635 refreshCachedTime();
1635 // This is needed to avoid getting default playback start position from curr entTime(). 1636 // This is needed to avoid getting default playback start position from curr entTime().
1636 double now = m_cachedTime; 1637 double now = m_cachedTime;
1637 1638
1638 // 3 - If the element's seeking IDL attribute is true, then another instance of this algorithm is 1639 // 3 - If the element's seeking IDL attribute is true, then another instance of this algorithm is
1639 // already running. Abort that other instance of the algorithm without waiti ng for the step that 1640 // already running. Abort that other instance of the algorithm without waiti ng for the step that
1640 // it is running to complete. 1641 // it is running to complete.
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1794 if (m_readyState == HAVE_NOTHING) { 1795 if (m_readyState == HAVE_NOTHING) {
1795 m_defaultPlaybackStartPosition = time; 1796 m_defaultPlaybackStartPosition = time;
1796 return; 1797 return;
1797 } 1798 }
1798 1799
1799 seek(time); 1800 seek(time);
1800 } 1801 }
1801 1802
1802 double HTMLMediaElement::duration() const 1803 double HTMLMediaElement::duration() const
1803 { 1804 {
1804 // FIXME: remove m_player check once we figure out how m_player is going 1805 // FIXME: remove m_webMediaPlayer check once we figure out how
1805 // out of sync with readystate. m_player is cleared but readystate is not se t 1806 // m_webMediaPlayer is going out of sync with readystate.
1806 // to HAVE_NOTHING 1807 // m_webMediaPlayer is cleared but readystate is not set to HAVE_NOTHING.
1807 if (!m_player || m_readyState < HAVE_METADATA) 1808 if (!m_webMediaPlayer || m_readyState < HAVE_METADATA)
1808 return std::numeric_limits<double>::quiet_NaN(); 1809 return std::numeric_limits<double>::quiet_NaN();
1809 1810
1810 // FIXME: Refactor so m_duration is kept current (in both MSE and 1811 // FIXME: Refactor so m_duration is kept current (in both MSE and
1811 // non-MSE cases) once we have transitioned from HAVE_NOTHING -> 1812 // non-MSE cases) once we have transitioned from HAVE_NOTHING ->
1812 // HAVE_METADATA. Currently, m_duration may be out of date for at least MSE 1813 // HAVE_METADATA. Currently, m_duration may be out of date for at least MSE
1813 // case because MediaSource and SourceBuffer do not notify the element 1814 // case because MediaSource and SourceBuffer do not notify the element
1814 // directly upon duration changes caused by endOfStream, remove, or append 1815 // directly upon duration changes caused by endOfStream, remove, or append
1815 // operations; rather the notification is triggered by the WebMediaPlayer 1816 // operations; rather the notification is triggered by the WebMediaPlayer
1816 // implementation observing that the underlying engine has updated duration 1817 // implementation observing that the underlying engine has updated duration
1817 // and notifying the element to consult its MediaSource for current 1818 // and notifying the element to consult its MediaSource for current
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1866 } 1867 }
1867 1868
1868 HTMLMediaElement::DirectionOfPlayback HTMLMediaElement::directionOfPlayback() co nst 1869 HTMLMediaElement::DirectionOfPlayback HTMLMediaElement::directionOfPlayback() co nst
1869 { 1870 {
1870 return m_playbackRate >= 0 ? Forward : Backward; 1871 return m_playbackRate >= 0 ? Forward : Backward;
1871 } 1872 }
1872 1873
1873 void HTMLMediaElement::updatePlaybackRate() 1874 void HTMLMediaElement::updatePlaybackRate()
1874 { 1875 {
1875 double effectiveRate = effectivePlaybackRate(); 1876 double effectiveRate = effectivePlaybackRate();
1876 if (m_player && potentiallyPlaying()) 1877 // FIXME: remove m_webMediaPlayer check once we figure out how
1878 // m_webMediaPlayer is going out of sync with readystate.
1879 // m_webMediaPlayer is cleared but readystate is not set to HAVE_NOTHING.
1880 if (m_webMediaPlayer && potentiallyPlaying())
1877 webMediaPlayer()->setRate(effectiveRate); 1881 webMediaPlayer()->setRate(effectiveRate);
1878 } 1882 }
1879 1883
1880 bool HTMLMediaElement::ended() const 1884 bool HTMLMediaElement::ended() const
1881 { 1885 {
1882 // 4.8.10.8 Playing the media resource 1886 // 4.8.10.8 Playing the media resource
1883 // The ended attribute must return true if the media element has ended 1887 // The ended attribute must return true if the media element has ended
1884 // playback and the direction of playback is forwards, and false otherwise. 1888 // playback and the direction of playback is forwards, and false otherwise.
1885 return endedPlayback() && directionOfPlayback() == Forward; 1889 return endedPlayback() && directionOfPlayback() == Forward;
1886 } 1890 }
1887 1891
1888 bool HTMLMediaElement::autoplay() const 1892 bool HTMLMediaElement::autoplay() const
1889 { 1893 {
1890 return fastHasAttribute(autoplayAttr); 1894 return fastHasAttribute(autoplayAttr);
1891 } 1895 }
1892 1896
1893 String HTMLMediaElement::preload() const 1897 String HTMLMediaElement::preload() const
1894 { 1898 {
1895 switch (m_preload) { 1899 switch (m_preload) {
1896 case MediaPlayer::None: 1900 case WebMediaPlayer::PreloadNone:
1897 return "none"; 1901 return "none";
1898 break; 1902 break;
1899 case MediaPlayer::MetaData: 1903 case WebMediaPlayer::PreloadMetaData:
1900 return "metadata"; 1904 return "metadata";
1901 break; 1905 break;
1902 case MediaPlayer::Auto: 1906 case WebMediaPlayer::PreloadAuto:
1903 return "auto"; 1907 return "auto";
1904 break; 1908 break;
1905 } 1909 }
1906 1910
1907 ASSERT_NOT_REACHED(); 1911 ASSERT_NOT_REACHED();
1908 return String(); 1912 return String();
1909 } 1913 }
1910 1914
1911 void HTMLMediaElement::setPreload(const AtomicString& preload) 1915 void HTMLMediaElement::setPreload(const AtomicString& preload)
1912 { 1916 {
1913 WTF_LOG(Media, "HTMLMediaElement::setPreload(%p, %s)", this, preload.utf8(). data()); 1917 WTF_LOG(Media, "HTMLMediaElement::setPreload(%p, %s)", this, preload.utf8(). data());
1914 setAttribute(preloadAttr, preload); 1918 setAttribute(preloadAttr, preload);
1915 } 1919 }
1916 1920
1917 MediaPlayer::Preload HTMLMediaElement::effectivePreloadType() const 1921 WebMediaPlayer::Preload HTMLMediaElement::effectivePreloadType() const
1918 { 1922 {
1919 return autoplay() ? MediaPlayer::Auto : m_preload; 1923 return autoplay() ? WebMediaPlayer::PreloadAuto : m_preload;
1920 } 1924 }
1921 1925
1922 void HTMLMediaElement::play() 1926 void HTMLMediaElement::play()
1923 { 1927 {
1924 WTF_LOG(Media, "HTMLMediaElement::play(%p)", this); 1928 WTF_LOG(Media, "HTMLMediaElement::play(%p)", this);
1925 1929
1926 if (!UserGestureIndicator::processingUserGesture()) { 1930 if (!UserGestureIndicator::processingUserGesture()) {
1927 autoplayMediaEncountered(); 1931 autoplayMediaEncountered();
1928 if (m_userGestureRequiredForPlay) { 1932 if (m_userGestureRequiredForPlay) {
1929 String message = ExceptionMessages::failedToExecute("play", "HTMLMed iaElement", "API can only be initiated by a user gesture."); 1933 String message = ExceptionMessages::failedToExecute("play", "HTMLMed iaElement", "API can only be initiated by a user gesture.");
1930 document().executionContext()->addConsoleMessage(ConsoleMessage::cre ate(JSMessageSource, WarningMessageLevel, message)); 1934 document().executionContext()->addConsoleMessage(ConsoleMessage::cre ate(JSMessageSource, WarningMessageLevel, message));
1931 return; 1935 return;
1932 } 1936 }
1933 } else if (m_userGestureRequiredForPlay) { 1937 } else if (m_userGestureRequiredForPlay) {
1934 if (m_autoplayMediaCounted) 1938 if (m_autoplayMediaCounted)
1935 recordAutoplayMetric(AutoplayManualStart); 1939 recordAutoplayMetric(AutoplayManualStart);
1936 m_userGestureRequiredForPlay = false; 1940 m_userGestureRequiredForPlay = false;
1937 } 1941 }
1938 1942
1939 playInternal(); 1943 playInternal();
1940 } 1944 }
1941 1945
1942 void HTMLMediaElement::playInternal() 1946 void HTMLMediaElement::playInternal()
1943 { 1947 {
1944 WTF_LOG(Media, "HTMLMediaElement::playInternal(%p)", this); 1948 WTF_LOG(Media, "HTMLMediaElement::playInternal(%p)", this);
1945 1949
1946 // 4.8.10.9. Playing the media resource 1950 // 4.8.10.9. Playing the media resource
1947 if (!m_player || m_networkState == NETWORK_EMPTY) 1951 if (m_networkState == NETWORK_EMPTY)
1948 scheduleDelayedAction(LoadMediaResource); 1952 scheduleDelayedAction(LoadMediaResource);
1949 1953
1950 // Generally "ended" and "looping" are exclusive. Here, the loop attribute 1954 // Generally "ended" and "looping" are exclusive. Here, the loop attribute
1951 // is ignored to seek back to start in case loop was set after playback 1955 // is ignored to seek back to start in case loop was set after playback
1952 // ended. See http://crbug.com/364442 1956 // ended. See http://crbug.com/364442
1953 if (endedPlayback(LoopCondition::Ignored)) 1957 if (endedPlayback(LoopCondition::Ignored))
1954 seek(0); 1958 seek(0);
1955 1959
1956 if (m_mediaController) 1960 if (m_mediaController)
1957 m_mediaController->bringElementUpToSpeed(this); 1961 m_mediaController->bringElementUpToSpeed(this);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1997 double progress = playedTime / duration(); 2001 double progress = playedTime / duration();
1998 if (progress < 0.5) 2002 if (progress < 0.5)
1999 recordAutoplayMetric(AutoplayBailout); 2003 recordAutoplayMetric(AutoplayBailout);
2000 } 2004 }
2001 } 2005 }
2002 2006
2003 void HTMLMediaElement::pause() 2007 void HTMLMediaElement::pause()
2004 { 2008 {
2005 WTF_LOG(Media, "HTMLMediaElement::pause(%p)", this); 2009 WTF_LOG(Media, "HTMLMediaElement::pause(%p)", this);
2006 2010
2007 if (!m_player || m_networkState == NETWORK_EMPTY) 2011 if (m_networkState == NETWORK_EMPTY)
2008 scheduleDelayedAction(LoadMediaResource); 2012 scheduleDelayedAction(LoadMediaResource);
2009 2013
2010 m_autoplaying = false; 2014 m_autoplaying = false;
2011 2015
2012 if (!m_paused) { 2016 if (!m_paused) {
2013 if (m_initialPlayWithoutUserGestures) 2017 if (m_initialPlayWithoutUserGestures)
2014 gesturelessInitialPlayHalted(); 2018 gesturelessInitialPlayHalted();
2015 2019
2016 m_paused = true; 2020 m_paused = true;
2017 scheduleTimeupdateEvent(false); 2021 scheduleTimeupdateEvent(false);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
2142 { 2146 {
2143 if (m_playbackProgressTimer.isActive()) 2147 if (m_playbackProgressTimer.isActive())
2144 return; 2148 return;
2145 2149
2146 m_previousProgressTime = WTF::currentTime(); 2150 m_previousProgressTime = WTF::currentTime();
2147 m_playbackProgressTimer.startRepeating(maxTimeupdateEventFrequency, FROM_HER E); 2151 m_playbackProgressTimer.startRepeating(maxTimeupdateEventFrequency, FROM_HER E);
2148 } 2152 }
2149 2153
2150 void HTMLMediaElement::playbackProgressTimerFired(Timer<HTMLMediaElement>*) 2154 void HTMLMediaElement::playbackProgressTimerFired(Timer<HTMLMediaElement>*)
2151 { 2155 {
2152 ASSERT(m_player);
2153
2154 if (!std::isnan(m_fragmentEndTime) && currentTime() >= m_fragmentEndTime && directionOfPlayback() == Forward) { 2156 if (!std::isnan(m_fragmentEndTime) && currentTime() >= m_fragmentEndTime && directionOfPlayback() == Forward) {
2155 m_fragmentEndTime = std::numeric_limits<double>::quiet_NaN(); 2157 m_fragmentEndTime = std::numeric_limits<double>::quiet_NaN();
2156 if (!m_mediaController && !m_paused) { 2158 if (!m_mediaController && !m_paused) {
2157 UseCounter::count(document(), UseCounter::HTMLMediaElementPauseAtFra gmentEnd); 2159 UseCounter::count(document(), UseCounter::HTMLMediaElementPauseAtFra gmentEnd);
2158 // changes paused to true and fires a simple event named pause at th e media element. 2160 // changes paused to true and fires a simple event named pause at th e media element.
2159 pause(); 2161 pause();
2160 } 2162 }
2161 } 2163 }
2162 2164
2163 if (!m_seeking) 2165 if (!m_seeking)
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
2238 Vector<WebMediaPlayer::TrackId> enabledTrackIds; 2240 Vector<WebMediaPlayer::TrackId> enabledTrackIds;
2239 for (unsigned i = 0; i < audioTracks().length(); ++i) { 2241 for (unsigned i = 0; i < audioTracks().length(); ++i) {
2240 AudioTrack* track = audioTracks().anonymousIndexedGetter(i); 2242 AudioTrack* track = audioTracks().anonymousIndexedGetter(i);
2241 if (track->enabled()) 2243 if (track->enabled())
2242 enabledTrackIds.append(track->trackId()); 2244 enabledTrackIds.append(track->trackId());
2243 } 2245 }
2244 2246
2245 webMediaPlayer()->enabledAudioTracksChanged(enabledTrackIds); 2247 webMediaPlayer()->enabledAudioTracksChanged(enabledTrackIds);
2246 } 2248 }
2247 2249
2248 WebMediaPlayer::TrackId HTMLMediaElement::addAudioTrack(const String& id, WebMed iaPlayerClient::AudioTrackKind kind, const AtomicString& label, const AtomicStri ng& language, bool enabled) 2250 WebMediaPlayer::TrackId HTMLMediaElement::addAudioTrack(const WebString& id, bli nk::WebMediaPlayerClient::AudioTrackKind kind, const WebString& label, const Web String& language, bool enabled)
2249 { 2251 {
2250 AtomicString kindString = AudioKindToString(kind); 2252 AtomicString kindString = AudioKindToString(kind);
2251 WTF_LOG(Media, "HTMLMediaElement::addAudioTrack(%p, '%s', '%s', '%s', '%s', %d)", 2253 WTF_LOG(Media, "HTMLMediaElement::addAudioTrack(%p, '%s', '%s', '%s', '%s', %d)",
2252 this, id.ascii().data(), kindString.ascii().data(), label.ascii().data() , language.ascii().data(), enabled); 2254 this, id.latin1().data(), kindString.ascii().data(), label.latin1().data (), language.latin1().data(), enabled);
philipj_slow 2015/07/01 13:49:19 I think calling utf8() here is probably more appro
Srirama 2015/07/03 12:59:01 Done.
2253 2255
2254 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) 2256 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled())
2255 return 0; 2257 return 0;
2256 2258
2257 RefPtrWillBeRawPtr<AudioTrack> audioTrack = AudioTrack::create(id, kindStrin g, label, language, enabled); 2259 RefPtrWillBeRawPtr<AudioTrack> audioTrack = AudioTrack::create(id, kindStrin g, label, language, enabled);
2258 audioTracks().add(audioTrack); 2260 audioTracks().add(audioTrack);
2259 2261
2260 return audioTrack->trackId(); 2262 return audioTrack->trackId();
2261 } 2263 }
2262 2264
(...skipping 19 matching lines...) Expand all
2282 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); 2284 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled());
2283 2285
2284 if (selectedTrackId) 2286 if (selectedTrackId)
2285 videoTracks().trackSelected(*selectedTrackId); 2287 videoTracks().trackSelected(*selectedTrackId);
2286 2288
2287 // FIXME: Add call on m_mediaSource to notify it of track changes once the S ourceBuffer.videoTracks attribute is added. 2289 // FIXME: Add call on m_mediaSource to notify it of track changes once the S ourceBuffer.videoTracks attribute is added.
2288 2290
2289 webMediaPlayer()->selectedVideoTrackChanged(selectedTrackId); 2291 webMediaPlayer()->selectedVideoTrackChanged(selectedTrackId);
2290 } 2292 }
2291 2293
2292 WebMediaPlayer::TrackId HTMLMediaElement::addVideoTrack(const String& id, WebMed iaPlayerClient::VideoTrackKind kind, const AtomicString& label, const AtomicStri ng& language, bool selected) 2294 WebMediaPlayer::TrackId HTMLMediaElement::addVideoTrack(const WebString& id, bli nk::WebMediaPlayerClient::VideoTrackKind kind, const WebString& label, const Web String& language, bool selected)
2293 { 2295 {
2294 AtomicString kindString = VideoKindToString(kind); 2296 AtomicString kindString = VideoKindToString(kind);
2295 WTF_LOG(Media, "HTMLMediaElement::addVideoTrack(%p, '%s', '%s', '%s', '%s', %d)", 2297 WTF_LOG(Media, "HTMLMediaElement::addVideoTrack(%p, '%s', '%s', '%s', '%s', %d)",
2296 this, id.ascii().data(), kindString.ascii().data(), label.ascii().data() , language.ascii().data(), selected); 2298 this, id.latin1().data(), kindString.ascii().data(), label.latin1().data (), language.latin1().data(), selected);
philipj_slow 2015/07/01 13:49:19 Ditto.
Srirama 2015/07/03 12:59:02 Done.
2297 2299
2298 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) 2300 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled())
2299 return 0; 2301 return 0;
2300 2302
2301 // If another track was selected (potentially by the user), leave it selecte d. 2303 // If another track was selected (potentially by the user), leave it selecte d.
2302 if (selected && videoTracks().selectedIndex() != -1) 2304 if (selected && videoTracks().selectedIndex() != -1)
2303 selected = false; 2305 selected = false;
2304 2306
2305 RefPtrWillBeRawPtr<VideoTrack> videoTrack = VideoTrack::create(id, kindStrin g, label, language, selected); 2307 RefPtrWillBeRawPtr<VideoTrack> videoTrack = VideoTrack::create(id, kindStrin g, label, language, selected);
2306 videoTracks().add(videoTrack); 2308 videoTracks().add(videoTrack);
2307 2309
2308 return videoTrack->trackId(); 2310 return videoTrack->trackId();
2309 } 2311 }
2310 2312
2311 void HTMLMediaElement::removeVideoTrack(WebMediaPlayer::TrackId trackId) 2313 void HTMLMediaElement::removeVideoTrack(WebMediaPlayer::TrackId trackId)
2312 { 2314 {
2313 WTF_LOG(Media, "HTMLMediaElement::removeVideoTrack(%p)", this); 2315 WTF_LOG(Media, "HTMLMediaElement::removeVideoTrack(%p)", this);
2314 2316
2315 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) 2317 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled())
2316 return; 2318 return;
2317 2319
2318 videoTracks().remove(trackId); 2320 videoTracks().remove(trackId);
2319 } 2321 }
2320 2322
2321 void HTMLMediaElement::mediaPlayerDidAddTextTrack(WebInbandTextTrack* webTrack) 2323 void HTMLMediaElement::addTextTrack(WebInbandTextTrack* webTrack)
2322 { 2324 {
2323 // 4.8.10.12.2 Sourcing in-band text tracks 2325 // 4.8.10.12.2 Sourcing in-band text tracks
2324 // 1. Associate the relevant data with a new text track and its correspondin g new TextTrack object. 2326 // 1. Associate the relevant data with a new text track and its correspondin g new TextTrack object.
2325 RefPtrWillBeRawPtr<InbandTextTrack> textTrack = InbandTextTrack::create(webT rack); 2327 RefPtrWillBeRawPtr<InbandTextTrack> textTrack = InbandTextTrack::create(webT rack);
2326 2328
2327 // 2. Set the new text track's kind, label, and language based on the semant ics of the relevant data, 2329 // 2. Set the new text track's kind, label, and language based on the semant ics of the relevant data,
2328 // as defined by the relevant specification. If there is no label in that da ta, then the label must 2330 // as defined by the relevant specification. If there is no label in that da ta, then the label must
2329 // be set to the empty string. 2331 // be set to the empty string.
2330 // 3. Associate the text track list of cues with the rules for updating the text track rendering appropriate 2332 // 3. Associate the text track list of cues with the rules for updating the text track rendering appropriate
2331 // for the format in question. 2333 // for the format in question.
2332 // 4. If the new text track's kind is metadata, then set the text track in-b and metadata track dispatch type 2334 // 4. If the new text track's kind is metadata, then set the text track in-b and metadata track dispatch type
2333 // as follows, based on the type of the media resource: 2335 // as follows, based on the type of the media resource:
2334 // 5. Populate the new text track's list of cues with the cues parsed so far , folllowing the guidelines for exposing 2336 // 5. Populate the new text track's list of cues with the cues parsed so far , folllowing the guidelines for exposing
2335 // cues, and begin updating it dynamically as necessary. 2337 // cues, and begin updating it dynamically as necessary.
2336 // - Thess are all done by the media engine. 2338 // - Thess are all done by the media engine.
2337 2339
2338 // 6. Set the new text track's readiness state to loaded. 2340 // 6. Set the new text track's readiness state to loaded.
2339 textTrack->setReadinessState(TextTrack::Loaded); 2341 textTrack->setReadinessState(TextTrack::Loaded);
2340 2342
2341 // 7. Set the new text track's mode to the mode consistent with the user's p references and the requirements of 2343 // 7. Set the new text track's mode to the mode consistent with the user's p references and the requirements of
2342 // the relevant specification for the data. 2344 // the relevant specification for the data.
2343 // - This will happen in honorUserPreferencesForAutomaticTextTrackSelection () 2345 // - This will happen in honorUserPreferencesForAutomaticTextTrackSelection ()
2344 scheduleDelayedAction(LoadTextTrackResource); 2346 scheduleDelayedAction(LoadTextTrackResource);
2345 2347
2346 // 8. Add the new text track to the media element's list of text tracks. 2348 // 8. Add the new text track to the media element's list of text tracks.
2347 // 9. Fire an event with the name addtrack, that does not bubble and is not cancelable, and that uses the TrackEvent 2349 // 9. Fire an event with the name addtrack, that does not bubble and is not cancelable, and that uses the TrackEvent
2348 // interface, with the track attribute initialized to the text track's TextT rack object, at the media element's 2350 // interface, with the track attribute initialized to the text track's TextT rack object, at the media element's
2349 // textTracks attribute's TextTrackList object. 2351 // textTracks attribute's TextTrackList object.
2350 addTextTrack(textTrack.get()); 2352 mediaPlayerAddTextTrack(textTrack.get());
2351 } 2353 }
2352 2354
2353 void HTMLMediaElement::mediaPlayerDidRemoveTextTrack(WebInbandTextTrack* webTrac k) 2355 void HTMLMediaElement::removeTextTrack(WebInbandTextTrack* webTrack)
2354 { 2356 {
2355 if (!m_textTracks) 2357 if (!m_textTracks)
2356 return; 2358 return;
2357 2359
2358 // This cast is safe because we created the InbandTextTrack with the WebInba ndTextTrack 2360 // This cast is safe because we created the InbandTextTrack with the WebInba ndTextTrack
2359 // passed to mediaPlayerDidAddTextTrack. 2361 // passed to mediaPlayerDidAddTextTrack.
2360 RefPtrWillBeRawPtr<InbandTextTrack> textTrack = static_cast<InbandTextTrack* >(webTrack->client()); 2362 RefPtrWillBeRawPtr<InbandTextTrack> textTrack = static_cast<InbandTextTrack* >(webTrack->client());
2361 if (!textTrack) 2363 if (!textTrack)
2362 return; 2364 return;
2363 2365
2364 removeTextTrack(textTrack.get()); 2366 mediaPlayerRemoveTextTrack(textTrack.get());
2365 } 2367 }
2366 2368
2367 void HTMLMediaElement::textTracksChanged() 2369 void HTMLMediaElement::textTracksChanged()
2368 { 2370 {
2369 if (mediaControls()) 2371 if (mediaControls())
2370 mediaControls()->refreshClosedCaptionsButtonVisibility(); 2372 mediaControls()->refreshClosedCaptionsButtonVisibility();
2371 } 2373 }
2372 2374
2373 void HTMLMediaElement::addTextTrack(TextTrack* track) 2375 void HTMLMediaElement::mediaPlayerAddTextTrack(TextTrack* track)
2374 { 2376 {
2375 textTracks()->append(track); 2377 textTracks()->append(track);
2376 2378
2377 textTracksChanged(); 2379 textTracksChanged();
2378 } 2380 }
2379 2381
2380 void HTMLMediaElement::removeTextTrack(TextTrack* track) 2382 void HTMLMediaElement::mediaPlayerRemoveTextTrack(TextTrack* track)
2381 { 2383 {
2382 m_textTracks->remove(track); 2384 m_textTracks->remove(track);
2383 2385
2384 textTracksChanged(); 2386 textTracksChanged();
2385 } 2387 }
2386 2388
2387 void HTMLMediaElement::forgetResourceSpecificTracks() 2389 void HTMLMediaElement::forgetResourceSpecificTracks()
2388 { 2390 {
2389 // Implements the "forget the media element's media-resource-specific tracks " algorithm. 2391 // Implements the "forget the media element's media-resource-specific tracks " algorithm.
2390 // The order is explicitly specified as text, then audio, and finally video. Also 2392 // The order is explicitly specified as text, then audio, and finally video. Also
(...skipping 25 matching lines...) Expand all
2416 RefPtrWillBeRawPtr<TextTrack> textTrack = TextTrack::create(kind, label, lan guage); 2418 RefPtrWillBeRawPtr<TextTrack> textTrack = TextTrack::create(kind, label, lan guage);
2417 // ..., its text track readiness state to the text track loaded state, .. . 2419 // ..., its text track readiness state to the text track loaded state, .. .
2418 textTrack->setReadinessState(TextTrack::Loaded); 2420 textTrack->setReadinessState(TextTrack::Loaded);
2419 2421
2420 // 3. Add the new text track to the media element's list of text tracks. 2422 // 3. Add the new text track to the media element's list of text tracks.
2421 // 4. Queue a task to fire a trusted event with the name addtrack, that 2423 // 4. Queue a task to fire a trusted event with the name addtrack, that
2422 // does not bubble and is not cancelable, and that uses the TrackEvent 2424 // does not bubble and is not cancelable, and that uses the TrackEvent
2423 // interface, with the track attribute initialised to the new text 2425 // interface, with the track attribute initialised to the new text
2424 // track's TextTrack object, at the media element's textTracks 2426 // track's TextTrack object, at the media element's textTracks
2425 // attribute's TextTrackList object. 2427 // attribute's TextTrackList object.
2426 addTextTrack(textTrack.get()); 2428 mediaPlayerAddTextTrack(textTrack.get());
2427 2429
2428 // Note: Due to side effects when changing track parameters, we have to 2430 // Note: Due to side effects when changing track parameters, we have to
2429 // first append the track to the text track list. 2431 // first append the track to the text track list.
2430 // FIXME: Since setMode() will cause a 'change' event to be queued on the 2432 // FIXME: Since setMode() will cause a 'change' event to be queued on the
2431 // same task source as the 'addtrack' event (see above), the order is 2433 // same task source as the 'addtrack' event (see above), the order is
2432 // wrong. (The 'change' event shouldn't be fired at all in this case...) 2434 // wrong. (The 'change' event shouldn't be fired at all in this case...)
2433 2435
2434 // ..., its text track mode to the text track hidden mode, ... 2436 // ..., its text track mode to the text track hidden mode, ...
2435 textTrack->setMode(TextTrack::hiddenKeyword()); 2437 textTrack->setMode(TextTrack::hiddenKeyword());
2436 2438
(...skipping 12 matching lines...) Expand all
2449 void HTMLMediaElement::didAddTrackElement(HTMLTrackElement* trackElement) 2451 void HTMLMediaElement::didAddTrackElement(HTMLTrackElement* trackElement)
2450 { 2452 {
2451 // 4.8.10.12.3 Sourcing out-of-band text tracks 2453 // 4.8.10.12.3 Sourcing out-of-band text tracks
2452 // When a track element's parent element changes and the new parent is a med ia element, 2454 // When a track element's parent element changes and the new parent is a med ia element,
2453 // then the user agent must add the track element's corresponding text track to the 2455 // then the user agent must add the track element's corresponding text track to the
2454 // media element's list of text tracks ... [continues in TextTrackList::appe nd] 2456 // media element's list of text tracks ... [continues in TextTrackList::appe nd]
2455 RefPtrWillBeRawPtr<TextTrack> textTrack = trackElement->track(); 2457 RefPtrWillBeRawPtr<TextTrack> textTrack = trackElement->track();
2456 if (!textTrack) 2458 if (!textTrack)
2457 return; 2459 return;
2458 2460
2459 addTextTrack(textTrack.get()); 2461 mediaPlayerAddTextTrack(textTrack.get());
2460 2462
2461 // Do not schedule the track loading until parsing finishes so we don't star t before all tracks 2463 // Do not schedule the track loading until parsing finishes so we don't star t before all tracks
2462 // in the markup have been added. 2464 // in the markup have been added.
2463 if (isFinishedParsingChildren()) 2465 if (isFinishedParsingChildren())
2464 scheduleDelayedAction(LoadTextTrackResource); 2466 scheduleDelayedAction(LoadTextTrackResource);
2465 } 2467 }
2466 2468
2467 void HTMLMediaElement::didRemoveTrackElement(HTMLTrackElement* trackElement) 2469 void HTMLMediaElement::didRemoveTrackElement(HTMLTrackElement* trackElement)
2468 { 2470 {
2469 #if !LOG_DISABLED 2471 #if !LOG_DISABLED
2470 KURL url = trackElement->getNonEmptyURLAttribute(srcAttr); 2472 KURL url = trackElement->getNonEmptyURLAttribute(srcAttr);
2471 WTF_LOG(Media, "HTMLMediaElement::didRemoveTrackElement(%p) - 'src' is %s", this, urlForLoggingMedia(url).utf8().data()); 2473 WTF_LOG(Media, "HTMLMediaElement::didRemoveTrackElement(%p) - 'src' is %s", this, urlForLoggingMedia(url).utf8().data());
2472 #endif 2474 #endif
2473 2475
2474 RefPtrWillBeRawPtr<TextTrack> textTrack = trackElement->track(); 2476 RefPtrWillBeRawPtr<TextTrack> textTrack = trackElement->track();
2475 if (!textTrack) 2477 if (!textTrack)
2476 return; 2478 return;
2477 2479
2478 textTrack->setHasBeenConfigured(false); 2480 textTrack->setHasBeenConfigured(false);
2479 2481
2480 if (!m_textTracks) 2482 if (!m_textTracks)
2481 return; 2483 return;
2482 2484
2483 // 4.8.10.12.3 Sourcing out-of-band text tracks 2485 // 4.8.10.12.3 Sourcing out-of-band text tracks
2484 // When a track element's parent element changes and the old parent was a me dia element, 2486 // When a track element's parent element changes and the old parent was a me dia element,
2485 // then the user agent must remove the track element's corresponding text tr ack from the 2487 // then the user agent must remove the track element's corresponding text tr ack from the
2486 // media element's list of text tracks. 2488 // media element's list of text tracks.
2487 removeTextTrack(textTrack.get()); 2489 mediaPlayerRemoveTextTrack(textTrack.get());
2488 2490
2489 size_t index = m_textTracksWhenResourceSelectionBegan.find(textTrack.get()); 2491 size_t index = m_textTracksWhenResourceSelectionBegan.find(textTrack.get());
2490 if (index != kNotFound) 2492 if (index != kNotFound)
2491 m_textTracksWhenResourceSelectionBegan.remove(index); 2493 m_textTracksWhenResourceSelectionBegan.remove(index);
2492 } 2494 }
2493 2495
2494 void HTMLMediaElement::honorUserPreferencesForAutomaticTextTrackSelection() 2496 void HTMLMediaElement::honorUserPreferencesForAutomaticTextTrackSelection()
2495 { 2497 {
2496 if (!m_textTracks || !m_textTracks->length()) 2498 if (!m_textTracks || !m_textTracks->length())
2497 return; 2499 return;
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
2684 WTF_LOG(Media, "HTMLMediaElement::sourceRemoved(%p) - m_nextChildNodeToC onsider set to %p", this, m_nextChildNodeToConsider.get()); 2686 WTF_LOG(Media, "HTMLMediaElement::sourceRemoved(%p) - m_nextChildNodeToC onsider set to %p", this, m_nextChildNodeToConsider.get());
2685 } else if (source == m_currentSourceNode) { 2687 } else if (source == m_currentSourceNode) {
2686 // Clear the current source node pointer, but don't change the movie as the spec says: 2688 // Clear the current source node pointer, but don't change the movie as the spec says:
2687 // 4.8.8 - Dynamically modifying a source element and its attribute when the element is already 2689 // 4.8.8 - Dynamically modifying a source element and its attribute when the element is already
2688 // inserted in a video or audio element will have no effect. 2690 // inserted in a video or audio element will have no effect.
2689 m_currentSourceNode = nullptr; 2691 m_currentSourceNode = nullptr;
2690 WTF_LOG(Media, "HTMLMediaElement::sourceRemoved(%p) - m_currentSourceNod e set to 0", this); 2692 WTF_LOG(Media, "HTMLMediaElement::sourceRemoved(%p) - m_currentSourceNod e set to 0", this);
2691 } 2693 }
2692 } 2694 }
2693 2695
2694 void HTMLMediaElement::mediaPlayerTimeChanged() 2696 void HTMLMediaElement::timeChanged()
2695 { 2697 {
2696 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerTimeChanged(%p)", this); 2698 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerTimeChanged(%p)", this);
2697 2699
2698 cueTimeline().updateActiveCues(currentTime()); 2700 cueTimeline().updateActiveCues(currentTime());
2699 2701
2700 invalidateCachedTime(); 2702 invalidateCachedTime();
2701 2703
2702 // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with t he seek. 2704 // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with t he seek.
2703 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !webMediaPlayer()->see king()) 2705 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !webMediaPlayer()->see king())
2704 finishSeek(); 2706 finishSeek();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2737 // for the media element's current media controller. 2739 // for the media element's current media controller.
2738 updateMediaController(); 2740 updateMediaController();
2739 } 2741 }
2740 } else { 2742 } else {
2741 m_sentEndEvent = false; 2743 m_sentEndEvent = false;
2742 } 2744 }
2743 2745
2744 updatePlayState(); 2746 updatePlayState();
2745 } 2747 }
2746 2748
2747 void HTMLMediaElement::mediaPlayerDurationChanged() 2749 void HTMLMediaElement::durationChanged()
2748 { 2750 {
2749 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerDurationChanged(%p)", this); 2751 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p)", this);
2750 // FIXME: Change MediaPlayerClient & WebMediaPlayer to convey 2752 // FIXME: Change WebMediaPlayer to convey the currentTime
2751 // the currentTime when the duration change occured. The current 2753 // when the duration change occured. The current WebMediaPlayer
2752 // WebMediaPlayer implementations always clamp currentTime() to 2754 // implementations always clamp currentTime() to duration()
2753 // duration() so the requestSeek condition here is always false. 2755 // so the requestSeek condition here is always false.
2754 durationChanged(duration(), currentTime() > duration()); 2756 mediaPlayerDurationChanged(duration(), currentTime() > duration());
2755 } 2757 }
2756 2758
2757 void HTMLMediaElement::durationChanged(double duration, bool requestSeek) 2759 void HTMLMediaElement::mediaPlayerDurationChanged(double duration, bool requestS eek)
2758 { 2760 {
2759 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p, %f, %d)", this, durati on, requestSeek); 2761 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerDurationChanged(%p, %f, %d)", t his, duration, requestSeek);
2760 2762
2761 // Abort if duration unchanged. 2763 // Abort if duration unchanged.
2762 if (m_duration == duration) 2764 if (m_duration == duration)
2763 return; 2765 return;
2764 2766
2765 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p) : %f -> %f", this, m_d uration, duration); 2767 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p) : %f -> %f", this, m_d uration, duration);
2766 m_duration = duration; 2768 m_duration = duration;
2767 scheduleEvent(EventTypeNames::durationchange); 2769 scheduleEvent(EventTypeNames::durationchange);
2768 2770
2769 if (mediaControls()) 2771 if (mediaControls())
2770 mediaControls()->reset(); 2772 mediaControls()->reset();
2771 if (layoutObject()) 2773 if (layoutObject())
2772 layoutObject()->updateFromElement(); 2774 layoutObject()->updateFromElement();
2773 2775
2774 if (requestSeek) 2776 if (requestSeek)
2775 seek(duration); 2777 seek(duration);
2776 } 2778 }
2777 2779
2778 void HTMLMediaElement::mediaPlayerPlaybackStateChanged() 2780 void HTMLMediaElement::playbackStateChanged()
2779 { 2781 {
2780 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerPlaybackStateChanged(%p)", this ); 2782 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerPlaybackStateChanged(%p)", this );
2781 2783
2782 if (!webMediaPlayer()) 2784 if (!webMediaPlayer())
2783 return; 2785 return;
2784 2786
2785 if (webMediaPlayer()->paused()) 2787 if (webMediaPlayer()->paused())
2786 pause(); 2788 pause();
2787 else 2789 else
2788 playInternal(); 2790 playInternal();
(...skipping 24 matching lines...) Expand all
2813 } 2815 }
2814 2816
2815 void HTMLMediaElement::disconnectedFromRemoteDevice() 2817 void HTMLMediaElement::disconnectedFromRemoteDevice()
2816 { 2818 {
2817 m_playingRemotely = false; 2819 m_playingRemotely = false;
2818 if (mediaControls()) 2820 if (mediaControls())
2819 mediaControls()->stoppedCasting(); 2821 mediaControls()->stoppedCasting();
2820 } 2822 }
2821 2823
2822 // MediaPlayerPresentation methods 2824 // MediaPlayerPresentation methods
2823 void HTMLMediaElement::mediaPlayerRepaint() 2825 void HTMLMediaElement::repaint()
2824 { 2826 {
2825 if (m_webLayer) 2827 if (m_webLayer)
2826 m_webLayer->invalidate(); 2828 m_webLayer->invalidate();
2827 2829
2828 updateDisplayState(); 2830 updateDisplayState();
2829 if (layoutObject()) 2831 if (layoutObject())
2830 layoutObject()->setShouldDoFullPaintInvalidation(); 2832 layoutObject()->setShouldDoFullPaintInvalidation();
2831 } 2833 }
2832 2834
2833 void HTMLMediaElement::mediaPlayerSizeChanged() 2835 void HTMLMediaElement::sizeChanged()
2834 { 2836 {
2835 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerSizeChanged(%p)", this); 2837 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerSizeChanged(%p)", this);
2836 2838
2837 ASSERT(hasVideo()); // "resize" makes no sense absent video. 2839 ASSERT(hasVideo()); // "resize" makes no sense absent video.
2838 if (m_readyState > HAVE_NOTHING && isHTMLVideoElement()) 2840 if (m_readyState > HAVE_NOTHING && isHTMLVideoElement())
2839 scheduleEvent(EventTypeNames::resize); 2841 scheduleEvent(EventTypeNames::resize);
2840 2842
2841 if (layoutObject()) 2843 if (layoutObject())
2842 layoutObject()->updateFromElement(); 2844 layoutObject()->updateFromElement();
2843 } 2845 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2888 } 2890 }
2889 2891
2890 bool HTMLMediaElement::couldPlayIfEnoughData() const 2892 bool HTMLMediaElement::couldPlayIfEnoughData() const
2891 { 2893 {
2892 return !paused() && !endedPlayback() && !stoppedDueToErrors(); 2894 return !paused() && !endedPlayback() && !stoppedDueToErrors();
2893 } 2895 }
2894 2896
2895 bool HTMLMediaElement::endedPlayback(LoopCondition loopCondition) const 2897 bool HTMLMediaElement::endedPlayback(LoopCondition loopCondition) const
2896 { 2898 {
2897 double dur = duration(); 2899 double dur = duration();
2898 if (!m_player || std::isnan(dur)) 2900 if (std::isnan(dur))
2899 return false; 2901 return false;
2900 2902
2901 // 4.8.10.8 Playing the media resource 2903 // 4.8.10.8 Playing the media resource
2902 2904
2903 // A media element is said to have ended playback when the element's 2905 // A media element is said to have ended playback when the element's
2904 // readyState attribute is HAVE_METADATA or greater, 2906 // readyState attribute is HAVE_METADATA or greater,
2905 if (m_readyState < HAVE_METADATA) 2907 if (m_readyState < HAVE_METADATA)
2906 return false; 2908 return false;
2907 2909
2908 // and the current playback position is the end of the media resource and th e direction 2910 // and the current playback position is the end of the media resource and th e direction
(...skipping 15 matching lines...) Expand all
2924 RefPtrWillBeRawPtr<TimeRanges> seekableRanges = seekable(); 2926 RefPtrWillBeRawPtr<TimeRanges> seekableRanges = seekable();
2925 if (!seekableRanges->contain(currentTime())) 2927 if (!seekableRanges->contain(currentTime()))
2926 return true; 2928 return true;
2927 } 2929 }
2928 2930
2929 return false; 2931 return false;
2930 } 2932 }
2931 2933
2932 void HTMLMediaElement::updatePlayState() 2934 void HTMLMediaElement::updatePlayState()
2933 { 2935 {
2934 if (!m_player)
2935 return;
2936
2937 bool isPlaying = webMediaPlayer() && !webMediaPlayer()->paused(); 2936 bool isPlaying = webMediaPlayer() && !webMediaPlayer()->paused();
2938 bool shouldBePlaying = potentiallyPlaying(); 2937 bool shouldBePlaying = potentiallyPlaying();
2939 2938
2940 WTF_LOG(Media, "HTMLMediaElement::updatePlayState(%p) - shouldBePlaying = %s , isPlaying = %s", 2939 WTF_LOG(Media, "HTMLMediaElement::updatePlayState(%p) - shouldBePlaying = %s , isPlaying = %s",
2941 this, boolString(shouldBePlaying), boolString(isPlaying)); 2940 this, boolString(shouldBePlaying), boolString(isPlaying));
2942 2941
2943 if (shouldBePlaying) { 2942 if (shouldBePlaying) {
2944 setDisplayMode(Video); 2943 setDisplayMode(Video);
2945 invalidateCachedTime(); 2944 invalidateCachedTime();
2946 2945
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
3017 } else { 3016 } else {
3018 m_networkState = NETWORK_IDLE; 3017 m_networkState = NETWORK_IDLE;
3019 } 3018 }
3020 3019
3021 // 5 - Set the element's delaying-the-load-event flag to false. This stops d elaying the load event. 3020 // 5 - Set the element's delaying-the-load-event flag to false. This stops d elaying the load event.
3022 setShouldDelayLoadEvent(false); 3021 setShouldDelayLoadEvent(false);
3023 3022
3024 // 6 - Abort the overall resource selection algorithm. 3023 // 6 - Abort the overall resource selection algorithm.
3025 m_currentSourceNode = nullptr; 3024 m_currentSourceNode = nullptr;
3026 3025
3027 // Reset m_readyState since m_player is gone. 3026 // Reset m_readyState since m_webMediaPlayer is gone.
3028 m_readyState = HAVE_NOTHING; 3027 m_readyState = HAVE_NOTHING;
3029 invalidateCachedTime(); 3028 invalidateCachedTime();
3030 updateMediaController(); 3029 updateMediaController();
3031 cueTimeline().updateActiveCues(0); 3030 cueTimeline().updateActiveCues(0);
3032 } 3031 }
3033 3032
3034 void HTMLMediaElement::clearMediaPlayerAndAudioSourceProviderClientWithoutLockin g() 3033 void HTMLMediaElement::clearMediaPlayerAndAudioSourceProviderClientWithoutLockin g()
3035 { 3034 {
3036 #if ENABLE(WEB_AUDIO) 3035 #if ENABLE(WEB_AUDIO)
3037 if (audioSourceProvider()) 3036 if (audioSourceProvider())
3038 audioSourceProvider()->setClient(0); 3037 audioSourceProvider()->setClient(0);
3039 #endif 3038 #endif
3040 m_player.clear(); 3039 if (m_webMediaPlayer) {
3040 m_audioSourceProvider.wrap(0);
philipj_slow 2015/07/01 13:49:19 Use nullptr here, and why not in the above setClie
Srirama 2015/07/03 12:59:01 Done. Thanks for the info, generally i used to loo
philipj_slow 2015/07/06 11:07:10 Following local style is always the most important
3041 m_webMediaPlayer.clear();
3042 }
3041 } 3043 }
3042 3044
3043 void HTMLMediaElement::clearMediaPlayer(int flags) 3045 void HTMLMediaElement::clearMediaPlayer(int flags)
3044 { 3046 {
3045 forgetResourceSpecificTracks(); 3047 forgetResourceSpecificTracks();
3046 3048
3047 closeMediaSource(); 3049 closeMediaSource();
3048 3050
3049 cancelDeferredLoad(); 3051 cancelDeferredLoad();
3050 3052
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
3255 // the user agent should run the rules for updating the text track rendering 3257 // the user agent should run the rules for updating the text track rendering
3256 // of each of the text tracks in the video element's list of text tracks ... 3258 // of each of the text tracks in the video element's list of text tracks ...
3257 if (isHTMLVideoElement() && closedCaptionsVisible()) 3259 if (isHTMLVideoElement() && closedCaptionsVisible())
3258 ensureTextTrackContainer().updateDisplay(*this, TextTrackContainer::DidS tartExposingControls); 3260 ensureTextTrackContainer().updateDisplay(*this, TextTrackContainer::DidS tartExposingControls);
3259 } 3261 }
3260 3262
3261 void HTMLMediaElement::setClosedCaptionsVisible(bool closedCaptionVisible) 3263 void HTMLMediaElement::setClosedCaptionsVisible(bool closedCaptionVisible)
3262 { 3264 {
3263 WTF_LOG(Media, "HTMLMediaElement::setClosedCaptionsVisible(%p, %s)", this, b oolString(closedCaptionVisible)); 3265 WTF_LOG(Media, "HTMLMediaElement::setClosedCaptionsVisible(%p, %s)", this, b oolString(closedCaptionVisible));
3264 3266
3265 if (!m_player || !hasClosedCaptions()) 3267 if (!hasClosedCaptions())
3266 return; 3268 return;
3267 3269
3268 m_closedCaptionsVisible = closedCaptionVisible; 3270 m_closedCaptionsVisible = closedCaptionVisible;
3269 3271
3270 markCaptionAndSubtitleTracksAsUnconfigured(); 3272 markCaptionAndSubtitleTracksAsUnconfigured();
3271 m_processingPreferenceChange = true; 3273 m_processingPreferenceChange = true;
3272 honorUserPreferencesForAutomaticTextTrackSelection(); 3274 honorUserPreferencesForAutomaticTextTrackSelection();
3273 m_processingPreferenceChange = false; 3275 m_processingPreferenceChange = false;
3274 3276
3275 // As track visibility changed while m_processingPreferenceChange was set, 3277 // As track visibility changed while m_processingPreferenceChange was set,
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
3437 3439
3438 return nullptr; 3440 return nullptr;
3439 } 3441 }
3440 3442
3441 void HTMLMediaElement::createMediaPlayer() 3443 void HTMLMediaElement::createMediaPlayer()
3442 { 3444 {
3443 AudioSourceProviderClientLockScope scope(*this); 3445 AudioSourceProviderClientLockScope scope(*this);
3444 3446
3445 closeMediaSource(); 3447 closeMediaSource();
3446 3448
3447 m_player = MediaPlayer::create(this); 3449 if (m_webMediaPlayer) {
3450 m_audioSourceProvider.wrap(0);
philipj_slow 2015/07/01 13:49:18 Ditto.
Srirama 2015/07/03 12:59:01 Done.
3451 m_webMediaPlayer.clear();
3452 }
3448 3453
3449 // 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.
3450 m_remoteRoutesAvailable = false; 3455 m_remoteRoutesAvailable = false;
3451 m_playingRemotely = false; 3456 m_playingRemotely = false;
3452 3457
3453 #if ENABLE(WEB_AUDIO) 3458 #if ENABLE(WEB_AUDIO)
3454 if (m_audioSourceNode && audioSourceProvider()) { 3459 if (m_audioSourceNode && audioSourceProvider()) {
3455 // When creating the player, make sure its AudioSourceProvider knows abo ut the client. 3460 // When creating the player, make sure its AudioSourceProvider knows abo ut the client.
3456 audioSourceProvider()->setClient(m_audioSourceNode); 3461 audioSourceProvider()->setClient(m_audioSourceNode);
3457 } 3462 }
3458 #endif 3463 #endif
3459 } 3464 }
3460 3465
3461 #if ENABLE(WEB_AUDIO) 3466 #if ENABLE(WEB_AUDIO)
3462 void HTMLMediaElement::setAudioSourceNode(AudioSourceProviderClient* sourceNode) 3467 void HTMLMediaElement::setAudioSourceNode(AudioSourceProviderClient* sourceNode)
3463 { 3468 {
3464 ASSERT(isMainThread()); 3469 ASSERT(isMainThread());
3465 m_audioSourceNode = sourceNode; 3470 m_audioSourceNode = sourceNode;
3466 3471
3467 AudioSourceProviderClientLockScope scope(*this); 3472 AudioSourceProviderClientLockScope scope(*this);
3468 if (audioSourceProvider()) 3473 if (audioSourceProvider())
3469 audioSourceProvider()->setClient(m_audioSourceNode); 3474 audioSourceProvider()->setClient(m_audioSourceNode);
3470 } 3475 }
3471
3472 AudioSourceProvider* HTMLMediaElement::audioSourceProvider()
3473 {
3474 if (m_player)
3475 return m_player->audioSourceProvider();
3476
3477 return nullptr;
3478 }
3479 #endif 3476 #endif
3480 3477
3481 const AtomicString& HTMLMediaElement::mediaGroup() const 3478 const AtomicString& HTMLMediaElement::mediaGroup() const
3482 { 3479 {
3483 return fastGetAttribute(mediagroupAttr); 3480 return fastGetAttribute(mediagroupAttr);
3484 } 3481 }
3485 3482
3486 void HTMLMediaElement::setMediaGroup(const AtomicString& group) 3483 void HTMLMediaElement::setMediaGroup(const AtomicString& group)
3487 { 3484 {
3488 // When a media element is created with a mediagroup attribute, and when a m edia element's mediagroup 3485 // When a media element is created with a mediagroup attribute, and when a m edia element's mediagroup
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
3580 WebMediaPlayer::CORSMode HTMLMediaElement::corsMode() const 3577 WebMediaPlayer::CORSMode HTMLMediaElement::corsMode() const
3581 { 3578 {
3582 const AtomicString& crossOriginMode = fastGetAttribute(crossoriginAttr); 3579 const AtomicString& crossOriginMode = fastGetAttribute(crossoriginAttr);
3583 if (crossOriginMode.isNull()) 3580 if (crossOriginMode.isNull())
3584 return WebMediaPlayer::CORSModeUnspecified; 3581 return WebMediaPlayer::CORSModeUnspecified;
3585 if (equalIgnoringCase(crossOriginMode, "use-credentials")) 3582 if (equalIgnoringCase(crossOriginMode, "use-credentials"))
3586 return WebMediaPlayer::CORSModeUseCredentials; 3583 return WebMediaPlayer::CORSModeUseCredentials;
3587 return WebMediaPlayer::CORSModeAnonymous; 3584 return WebMediaPlayer::CORSModeAnonymous;
3588 } 3585 }
3589 3586
3590 void HTMLMediaElement::mediaPlayerSetWebLayer(WebLayer* webLayer) 3587 void HTMLMediaElement::setWebLayer(blink::WebLayer* webLayer)
3591 { 3588 {
3592 if (webLayer == m_webLayer) 3589 if (webLayer == m_webLayer)
3593 return; 3590 return;
3594 3591
3595 // If either of the layers is null we need to enable or disable compositing. This is done by triggering a style recalc. 3592 // If either of the layers is null we need to enable or disable compositing. This is done by triggering a style recalc.
3596 if ((!m_webLayer || !webLayer) 3593 if ((!m_webLayer || !webLayer)
3597 #if ENABLE(OILPAN) 3594 #if ENABLE(OILPAN)
3598 && !m_isFinalizing 3595 && !m_isFinalizing
3599 #endif 3596 #endif
3600 ) 3597 )
3601 setNeedsCompositingUpdate(); 3598 setNeedsCompositingUpdate();
3602 3599
3603 if (m_webLayer) 3600 if (m_webLayer)
3604 GraphicsLayer::unregisterContentsLayer(m_webLayer); 3601 GraphicsLayer::unregisterContentsLayer(m_webLayer);
3605 m_webLayer = webLayer; 3602 m_webLayer = webLayer;
3606 if (m_webLayer) 3603 if (m_webLayer)
3607 GraphicsLayer::registerContentsLayer(m_webLayer); 3604 GraphicsLayer::registerContentsLayer(m_webLayer);
3608 } 3605 }
3609 3606
3610 void HTMLMediaElement::mediaPlayerMediaSourceOpened(WebMediaSource* webMediaSour ce) 3607 void HTMLMediaElement::mediaSourceOpened(blink::WebMediaSource* webMediaSource)
3611 { 3608 {
3612 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource)); 3609 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource));
3613 } 3610 }
3614 3611
3615 bool HTMLMediaElement::isInteractiveContent() const 3612 bool HTMLMediaElement::isInteractiveContent() const
3616 { 3613 {
3617 return fastHasAttribute(controlsAttr); 3614 return fastHasAttribute(controlsAttr);
3618 } 3615 }
3619 3616
3620 void HTMLMediaElement::defaultEventHandler(Event* event) 3617 void HTMLMediaElement::defaultEventHandler(Event* event)
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
3671 3668
3672 // Enable the first audio track if an audio track hasn't been enabled yet. 3669 // Enable the first audio track if an audio track hasn't been enabled yet.
3673 if (audioTracks().length() > 0 && !audioTracks().hasEnabledTrack()) 3670 if (audioTracks().length() > 0 && !audioTracks().hasEnabledTrack())
3674 audioTracks().anonymousIndexedGetter(0)->setEnabled(true); 3671 audioTracks().anonymousIndexedGetter(0)->setEnabled(true);
3675 3672
3676 // Select the first video track if a video track hasn't been selected yet. 3673 // Select the first video track if a video track hasn't been selected yet.
3677 if (videoTracks().length() > 0 && videoTracks().selectedIndex() == -1) 3674 if (videoTracks().length() > 0 && videoTracks().selectedIndex() == -1)
3678 videoTracks().anonymousIndexedGetter(0)->setSelected(true); 3675 videoTracks().anonymousIndexedGetter(0)->setSelected(true);
3679 } 3676 }
3680 3677
3678 void HTMLMediaElement::prepareAndLoadMediaPlayer(const WTF::String& url)
philipj_slow 2015/07/01 13:49:19 Maybe this can simply be folded into startPlayerLo
Srirama 2015/07/03 12:59:02 Done. Moved it to startPlayerLoad
3679 {
3680 ASSERT(!m_webMediaPlayer);
3681
3682 WebURL poster = mediaPlayerPosterURL();
philipj_slow 2015/07/01 13:49:19 Inline this into the setPoster call as that's the
Srirama 2015/07/03 12:59:02 Done.
3683
3684 KURL kurl(ParsedURLString, url);
philipj_slow 2015/07/01 13:49:18 Move this down to where it is used, or maybe inlin
Srirama 2015/07/03 12:59:02 Done. Moved it down, but didn't inline it as it is
3685 LocalFrame* frame = document().frame();
3686 ASSERT(frame);
philipj_slow 2015/07/01 13:49:18 In the original code the case !webFrame case was h
Srirama 2015/07/03 12:59:01 Added similar check in executeDeferredLoad() to be
philipj_slow 2015/07/06 11:07:10 See new comment on the moved code.
3687 m_webMediaPlayer = frame->loader().client()->createWebMediaPlayer(this, kurl );
3688 if (!m_webMediaPlayer)
philipj_slow 2015/07/01 13:49:19 Can this happen, and should it be treated as a dec
Srirama 2015/07/03 12:59:02 It can previously because of webframe null case bu
philipj_slow 2015/07/06 11:07:10 Acknowledged.
3689 return;
3690
3691 if (layoutObject())
3692 layoutObject()->setShouldDoFullPaintInvalidation();
3693 #if ENABLE(WEB_AUDIO)
3694 // Make sure if we create/re-create the WebMediaPlayer that we update our wr apper.
3695 m_audioSourceProvider.wrap(m_webMediaPlayer->audioSourceProvider());
3696 #endif
3697 m_webMediaPlayer->setVolume(effectiveMediaVolume());
3698
3699 m_webMediaPlayer->setPoster(poster);
3700
3701 m_webMediaPlayer->setPreload(effectivePreloadType());
3702
3703 m_webMediaPlayer->load(loadType(), kurl, corsMode());
3704
3705 if (isFullscreen())
3706 m_webMediaPlayer->enterFullscreen();
3707 }
3708
3681 #if ENABLE(WEB_AUDIO) 3709 #if ENABLE(WEB_AUDIO)
3682 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) 3710 void HTMLMediaElement::clearWeakMembers(Visitor* visitor)
3683 { 3711 {
3684 if (!Heap::isHeapObjectAlive(m_audioSourceNode) && audioSourceProvider()) 3712 if (!Heap::isHeapObjectAlive(m_audioSourceNode) && audioSourceProvider())
3685 audioSourceProvider()->setClient(nullptr); 3713 audioSourceProvider()->setClient(nullptr);
3686 } 3714 }
3715
3716 void HTMLMediaElement::AudioSourceProviderImpl::wrap(WebAudioSourceProvider* pro vider)
philipj_slow 2015/07/01 13:49:19 I'd like someone who knows Web Audio to take a loo
Srirama 2015/07/03 12:59:01 Acknowledged.
3717 {
3718 MutexLocker locker(provideInputLock);
3719
3720 if (m_webAudioSourceProvider && provider != m_webAudioSourceProvider)
3721 m_webAudioSourceProvider->setClient(0);
3722
3723 m_webAudioSourceProvider = provider;
3724 if (m_webAudioSourceProvider)
3725 m_webAudioSourceProvider->setClient(m_client.get());
3726 }
3727
3728 void HTMLMediaElement::AudioSourceProviderImpl::setClient(AudioSourceProviderCli ent* client)
3729 {
3730 MutexLocker locker(provideInputLock);
3731
3732 if (client)
3733 m_client = new HTMLMediaElement::AudioClientImpl(client);
3734 else
3735 m_client.clear();
3736
3737 if (m_webAudioSourceProvider)
3738 m_webAudioSourceProvider->setClient(m_client.get());
3739 }
3740
3741 void HTMLMediaElement::AudioSourceProviderImpl::provideInput(blink::AudioBus* bu s, size_t framesToProcess)
3742 {
3743 ASSERT(bus);
3744 if (!bus)
3745 return;
3746
3747 MutexTryLocker tryLocker(provideInputLock);
3748 if (!tryLocker.locked() || !m_webAudioSourceProvider || !m_client.get()) {
3749 bus->zero();
3750 return;
3751 }
3752
3753 // Wrap the AudioBus channel data using WebVector.
3754 size_t n = bus->numberOfChannels();
3755 WebVector<float*> webAudioData(n);
3756 for (size_t i = 0; i < n; ++i)
3757 webAudioData[i] = bus->channel(i)->mutableData();
3758
3759 m_webAudioSourceProvider->provideInput(webAudioData, framesToProcess);
3760 }
3761
3762 void HTMLMediaElement::AudioClientImpl::setFormat(size_t numberOfChannels, float sampleRate)
3763 {
3764 if (m_client)
3765 m_client->setFormat(numberOfChannels, sampleRate);
3766 }
3767
3768 DEFINE_TRACE(HTMLMediaElement::AudioClientImpl)
3769 {
3770 visitor->trace(m_client);
3771 }
3687 #endif 3772 #endif
3688 3773
3689 } 3774 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698