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

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: Move createMediaPlayer() to FrameLoaderClient to avoid deps rule violation 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"
67 #include "modules/encryptedmedia/HTMLMediaElementEncryptedMedia.h"
ddorwin 2015/05/01 17:09:28 This is not allowed.
66 #include "platform/ContentType.h" 68 #include "platform/ContentType.h"
67 #include "platform/Logging.h" 69 #include "platform/Logging.h"
68 #include "platform/MIMETypeFromURL.h" 70 #include "platform/MIMETypeFromURL.h"
69 #include "platform/MIMETypeRegistry.h" 71 #include "platform/MIMETypeRegistry.h"
70 #include "platform/RuntimeEnabledFeatures.h" 72 #include "platform/RuntimeEnabledFeatures.h"
71 #include "platform/UserGestureIndicator.h" 73 #include "platform/UserGestureIndicator.h"
74 #include "platform/audio/AudioBus.h"
75 #include "platform/audio/AudioSourceProviderClient.h"
72 #include "platform/graphics/GraphicsLayer.h" 76 #include "platform/graphics/GraphicsLayer.h"
73 #include "platform/weborigin/SecurityOrigin.h" 77 #include "platform/weborigin/SecurityOrigin.h"
74 #include "public/platform/Platform.h" 78 #include "public/platform/Platform.h"
79 #include "public/platform/WebAudioSourceProvider.h"
75 #include "public/platform/WebContentDecryptionModule.h" 80 #include "public/platform/WebContentDecryptionModule.h"
76 #include "public/platform/WebInbandTextTrack.h" 81 #include "public/platform/WebInbandTextTrack.h"
77 #include "wtf/CurrentTime.h" 82 #include "wtf/CurrentTime.h"
78 #include "wtf/MathExtras.h" 83 #include "wtf/MathExtras.h"
79 #include "wtf/text/CString.h" 84 #include "wtf/text/CString.h"
80 #include <limits> 85 #include <limits>
81 86
82 #if ENABLE(WEB_AUDIO) 87 #if ENABLE(WEB_AUDIO)
83 #include "platform/audio/AudioSourceProvider.h" 88 #include "platform/audio/AudioSourceProvider.h"
84 #include "platform/audio/AudioSourceProviderClient.h" 89 #include "platform/audio/AudioSourceProviderClient.h"
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 , m_lastSeekTime(0) 328 , m_lastSeekTime(0)
324 , m_previousProgressTime(std::numeric_limits<double>::max()) 329 , m_previousProgressTime(std::numeric_limits<double>::max())
325 , m_duration(std::numeric_limits<double>::quiet_NaN()) 330 , m_duration(std::numeric_limits<double>::quiet_NaN())
326 , m_lastTimeUpdateEventWallTime(0) 331 , m_lastTimeUpdateEventWallTime(0)
327 , m_lastTimeUpdateEventMovieTime(0) 332 , m_lastTimeUpdateEventMovieTime(0)
328 , m_defaultPlaybackStartPosition(0) 333 , m_defaultPlaybackStartPosition(0)
329 , m_loadState(WaitingForSource) 334 , m_loadState(WaitingForSource)
330 , m_deferredLoadState(NotDeferred) 335 , m_deferredLoadState(NotDeferred)
331 , m_deferredLoadTimer(this, &HTMLMediaElement::deferredLoadTimerFired) 336 , m_deferredLoadTimer(this, &HTMLMediaElement::deferredLoadTimerFired)
332 , m_webLayer(nullptr) 337 , m_webLayer(nullptr)
333 , m_preload(MediaPlayer::Auto) 338 , m_preload(WebMediaPlayer::PreloadAuto)
334 , m_displayMode(Unknown) 339 , m_displayMode(Unknown)
335 , m_cachedTime(std::numeric_limits<double>::quiet_NaN()) 340 , m_cachedTime(std::numeric_limits<double>::quiet_NaN())
336 , m_fragmentEndTime(std::numeric_limits<double>::quiet_NaN()) 341 , m_fragmentEndTime(std::numeric_limits<double>::quiet_NaN())
337 , m_pendingActionFlags(0) 342 , m_pendingActionFlags(0)
338 , m_userGestureRequiredForPlay(false) 343 , m_userGestureRequiredForPlay(false)
339 , m_playing(false) 344 , m_playing(false)
340 , m_shouldDelayLoadEvent(false) 345 , m_shouldDelayLoadEvent(false)
341 , m_haveFiredLoadedData(false) 346 , m_haveFiredLoadedData(false)
342 , m_autoplaying(true) 347 , m_autoplaying(true)
343 , m_muted(false) 348 , m_muted(false)
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 } 484 }
480 #endif 485 #endif
481 486
482 void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument) 487 void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument)
483 { 488 {
484 WTF_LOG(Media, "HTMLMediaElement::didMoveToNewDocument(%p)", this); 489 WTF_LOG(Media, "HTMLMediaElement::didMoveToNewDocument(%p)", this);
485 490
486 if (m_shouldDelayLoadEvent) { 491 if (m_shouldDelayLoadEvent) {
487 document().incrementLoadEventDelayCount(); 492 document().incrementLoadEventDelayCount();
488 // 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
489 // 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
490 // cause load event dispatching in oldDocument. 495 // cause load event dispatching in oldDocument.
491 } else { 496 } else {
492 // 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
493 // cause load event dispatching in oldDocument. 498 // cause load event dispatching in oldDocument.
494 oldDocument.incrementLoadEventDelayCount(); 499 oldDocument.incrementLoadEventDelayCount();
495 } 500 }
496 501
497 removeElementFromDocumentMap(this, &oldDocument); 502 removeElementFromDocumentMap(this, &oldDocument);
498 addElementToDocumentMap(this, &document()); 503 addElementToDocumentMap(this, &document());
499 504
500 // 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
501 // MediaPlayer to dereference LocalFrame and FrameLoader pointers from the 506 // MediaPlayer to dereference LocalFrame and FrameLoader pointers from the
502 // 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
503 // object to refresh the MediaPlayer's LocalFrame and FrameLoader references on 508 // object to refresh the MediaPlayer's LocalFrame and FrameLoader references on
504 // document changes so that playback can be resumed properly. 509 // document changes so that playback can be resumed properly.
505 userCancelledLoad(); 510 userCancelledLoad();
506 511
507 // 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
508 // 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.
509 oldDocument.decrementLoadEventDelayCount(); 514 oldDocument.decrementLoadEventDelayCount();
510 515
511 ActiveDOMObject::didMoveToNewExecutionContext(&document()); 516 ActiveDOMObject::didMoveToNewExecutionContext(&document());
512 HTMLElement::didMoveToNewDocument(oldDocument); 517 HTMLElement::didMoveToNewDocument(oldDocument);
513 } 518 }
514 519
515 bool HTMLMediaElement::supportsFocus() const 520 bool HTMLMediaElement::supportsFocus() const
516 { 521 {
517 if (ownerDocument()->isMediaDocument()) 522 if (ownerDocument()->isMediaDocument())
(...skipping 13 matching lines...) Expand all
531 if (name == srcAttr) { 536 if (name == srcAttr) {
532 // Trigger a reload, as long as the 'src' attribute is present. 537 // Trigger a reload, as long as the 'src' attribute is present.
533 if (!value.isNull()) { 538 if (!value.isNull()) {
534 clearMediaPlayer(LoadMediaResource); 539 clearMediaPlayer(LoadMediaResource);
535 scheduleDelayedAction(LoadMediaResource); 540 scheduleDelayedAction(LoadMediaResource);
536 } 541 }
537 } else if (name == controlsAttr) { 542 } else if (name == controlsAttr) {
538 configureMediaControls(); 543 configureMediaControls();
539 } else if (name == preloadAttr) { 544 } else if (name == preloadAttr) {
540 if (equalIgnoringCase(value, "none")) { 545 if (equalIgnoringCase(value, "none")) {
541 m_preload = MediaPlayer::None; 546 m_preload = WebMediaPlayer::PreloadNone;
542 } else if (equalIgnoringCase(value, "metadata")) { 547 } else if (equalIgnoringCase(value, "metadata")) {
543 m_preload = MediaPlayer::MetaData; 548 m_preload = WebMediaPlayer::PreloadMetaData;
544 } else { 549 } else {
545 // 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
546 // "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"
547 m_preload = MediaPlayer::Auto; 552 m_preload = WebMediaPlayer::PreloadAuto;
548 } 553 }
549 554
550 // The attribute must be ignored if the autoplay attribute is present 555 // The attribute must be ignored if the autoplay attribute is present
551 if (!autoplay() && m_player) 556 if (!autoplay())
552 setPlayerPreload(); 557 setPlayerPreload();
553 558
554 } else if (name == mediagroupAttr && RuntimeEnabledFeatures::mediaController Enabled()) { 559 } else if (name == mediagroupAttr && RuntimeEnabledFeatures::mediaController Enabled()) {
555 setMediaGroup(value); 560 setMediaGroup(value);
556 } else { 561 } else {
557 HTMLElement::parseAttribute(name, value); 562 HTMLElement::parseAttribute(name, value);
558 } 563 }
559 } 564 }
560 565
561 void HTMLMediaElement::finishParsingChildren() 566 void HTMLMediaElement::finishParsingChildren()
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 m_mediaSource = nullptr; 987 m_mediaSource = nullptr;
983 attemptLoad = false; 988 attemptLoad = false;
984 } 989 }
985 } 990 }
986 } 991 }
987 } 992 }
988 993
989 if (attemptLoad && canLoadURL(url, contentType, keySystem)) { 994 if (attemptLoad && canLoadURL(url, contentType, keySystem)) {
990 ASSERT(!webMediaPlayer()); 995 ASSERT(!webMediaPlayer());
991 996
992 if (!m_havePreparedToPlay && !autoplay() && m_preload == MediaPlayer::No ne) { 997 if (!m_havePreparedToPlay && !autoplay() && m_preload == WebMediaPlayer: :PreloadNone) {
993 WTF_LOG(Media, "HTMLMediaElement::loadResource(%p) : Delaying load b ecause preload == 'none'", this); 998 WTF_LOG(Media, "HTMLMediaElement::loadResource(%p) : Delaying load b ecause preload == 'none'", this);
994 deferLoad(); 999 deferLoad();
995 } else { 1000 } else {
996 startPlayerLoad(); 1001 startPlayerLoad();
997 } 1002 }
998 } else { 1003 } else {
999 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); 1004 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError);
1000 } 1005 }
1001 1006
1002 // If there is no poster to display, allow the media engine to render video frames as soon as 1007 // If there is no poster to display, allow the media engine to render video frames as soon as
(...skipping 18 matching lines...) Expand all
1021 // along with that potentially also specifying a setting for its 1026 // along with that potentially also specifying a setting for its
1022 // 'authentication flag' to control how user:pass embedded in a 1027 // 'authentication flag' to control how user:pass embedded in a
1023 // media resource URL should be treated, then update the handling 1028 // media resource URL should be treated, then update the handling
1024 // here to match. 1029 // here to match.
1025 KURL requestURL = m_currentSrc; 1030 KURL requestURL = m_currentSrc;
1026 if (!requestURL.user().isEmpty()) 1031 if (!requestURL.user().isEmpty())
1027 requestURL.setUser(String()); 1032 requestURL.setUser(String());
1028 if (!requestURL.pass().isEmpty()) 1033 if (!requestURL.pass().isEmpty())
1029 requestURL.setPass(String()); 1034 requestURL.setPass(String());
1030 1035
1031 m_player->load(loadType(), requestURL, corsMode()); 1036 loadMediaPlayer(requestURL);
1032 } 1037 }
1033 1038
1034 void HTMLMediaElement::setPlayerPreload() 1039 void HTMLMediaElement::setPlayerPreload()
1035 { 1040 {
1036 m_player->setPreload(m_preload); 1041 if (m_webMediaPlayer) // Revisit m_webMediaPlayer check
1042 m_webMediaPlayer->setPreload(m_preload);
1037 1043
1038 if (loadIsDeferred() && m_preload != MediaPlayer::None) 1044 if (loadIsDeferred() && m_preload != WebMediaPlayer::PreloadNone)
1039 startDeferredLoad(); 1045 startDeferredLoad();
1040 } 1046 }
1041 1047
1042 bool HTMLMediaElement::loadIsDeferred() const 1048 bool HTMLMediaElement::loadIsDeferred() const
1043 { 1049 {
1044 return m_deferredLoadState != NotDeferred; 1050 return m_deferredLoadState != NotDeferred;
1045 } 1051 }
1046 1052
1047 void HTMLMediaElement::deferLoad() 1053 void HTMLMediaElement::deferLoad()
1048 { 1054 {
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
1292 1298
1293 void HTMLMediaElement::cancelPendingEventsAndCallbacks() 1299 void HTMLMediaElement::cancelPendingEventsAndCallbacks()
1294 { 1300 {
1295 WTF_LOG(Media, "HTMLMediaElement::cancelPendingEventsAndCallbacks(%p)", this ); 1301 WTF_LOG(Media, "HTMLMediaElement::cancelPendingEventsAndCallbacks(%p)", this );
1296 m_asyncEventQueue->cancelAllEvents(); 1302 m_asyncEventQueue->cancelAllEvents();
1297 1303
1298 for (HTMLSourceElement* source = Traversal<HTMLSourceElement>::firstChild(*t his); source; source = Traversal<HTMLSourceElement>::nextSibling(*source)) 1304 for (HTMLSourceElement* source = Traversal<HTMLSourceElement>::firstChild(*t his); source; source = Traversal<HTMLSourceElement>::nextSibling(*source))
1299 source->cancelPendingErrorEvent(); 1305 source->cancelPendingErrorEvent();
1300 } 1306 }
1301 1307
1302 void HTMLMediaElement::mediaPlayerNetworkStateChanged() 1308 void HTMLMediaElement::networkStateChanged()
1303 { 1309 {
1304 setNetworkState(webMediaPlayer()->networkState()); 1310 setNetworkState(webMediaPlayer()->networkState());
1305 } 1311 }
1306 1312
1307 void HTMLMediaElement::mediaLoadingFailed(WebMediaPlayer::NetworkState error) 1313 void HTMLMediaElement::mediaLoadingFailed(WebMediaPlayer::NetworkState error)
1308 { 1314 {
1309 stopPeriodicTimers(); 1315 stopPeriodicTimers();
1310 1316
1311 // If we failed while trying to load a <source> element, the movie was never parsed, and there are more 1317 // If we failed while trying to load a <source> element, the movie was never parsed, and there are more
1312 // <source> children, schedule the next one 1318 // <source> children, schedule the next one
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1383 1389
1384 if (state == WebMediaPlayer::NetworkStateLoaded) { 1390 if (state == WebMediaPlayer::NetworkStateLoaded) {
1385 if (m_networkState != NETWORK_IDLE) 1391 if (m_networkState != NETWORK_IDLE)
1386 changeNetworkStateFromLoadingToIdle(); 1392 changeNetworkStateFromLoadingToIdle();
1387 m_completelyLoaded = true; 1393 m_completelyLoaded = true;
1388 } 1394 }
1389 } 1395 }
1390 1396
1391 void HTMLMediaElement::changeNetworkStateFromLoadingToIdle() 1397 void HTMLMediaElement::changeNetworkStateFromLoadingToIdle()
1392 { 1398 {
1393 ASSERT(m_player); 1399 // ASSERT(m_player); // Revisit
1394 m_progressEventTimer.stop(); 1400 m_progressEventTimer.stop();
1395 1401
1396 // Schedule one last progress event so we guarantee that at least one is fir ed 1402 // Schedule one last progress event so we guarantee that at least one is fir ed
1397 // for files that load very quickly. 1403 // for files that load very quickly.
1398 if (webMediaPlayer() && webMediaPlayer()->didLoadingProgress()) 1404 if (webMediaPlayer() && webMediaPlayer()->didLoadingProgress())
1399 scheduleEvent(EventTypeNames::progress); 1405 scheduleEvent(EventTypeNames::progress);
1400 scheduleEvent(EventTypeNames::suspend); 1406 scheduleEvent(EventTypeNames::suspend);
1401 m_networkState = NETWORK_IDLE; 1407 m_networkState = NETWORK_IDLE;
1402 } 1408 }
1403 1409
1404 void HTMLMediaElement::mediaPlayerReadyStateChanged() 1410 void HTMLMediaElement::readyStateChanged()
1405 { 1411 {
1406 setReadyState(static_cast<ReadyState>(webMediaPlayer()->readyState())); 1412 setReadyState(static_cast<ReadyState>(webMediaPlayer()->readyState()));
1407 } 1413 }
1408 1414
1409 void HTMLMediaElement::setReadyState(ReadyState state) 1415 void HTMLMediaElement::setReadyState(ReadyState state)
1410 { 1416 {
1411 WTF_LOG(Media, "HTMLMediaElement::setReadyState(%p, %d) - current state is % d,", this, static_cast<int>(state), static_cast<int>(m_readyState)); 1417 WTF_LOG(Media, "HTMLMediaElement::setReadyState(%p, %d) - current state is % d,", this, static_cast<int>(state), static_cast<int>(m_readyState));
1412 1418
1413 // Set "wasPotentiallyPlaying" BEFORE updating m_readyState, potentiallyPlay ing() uses it 1419 // Set "wasPotentiallyPlaying" BEFORE updating m_readyState, potentiallyPlay ing() uses it
1414 bool wasPotentiallyPlaying = potentiallyPlaying(); 1420 bool wasPotentiallyPlaying = potentiallyPlaying();
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1549 mediaControls()->refreshClosedCaptionsButtonVisibility(); 1555 mediaControls()->refreshClosedCaptionsButtonVisibility();
1550 } 1556 }
1551 1557
1552 updatePlayState(); 1558 updatePlayState();
1553 updateMediaController(); 1559 updateMediaController();
1554 cueTimeline().updateActiveCues(currentTime()); 1560 cueTimeline().updateActiveCues(currentTime());
1555 } 1561 }
1556 1562
1557 void HTMLMediaElement::progressEventTimerFired(Timer<HTMLMediaElement>*) 1563 void HTMLMediaElement::progressEventTimerFired(Timer<HTMLMediaElement>*)
1558 { 1564 {
1559 ASSERT(m_player); 1565 // ASSERT(m_player); // Revisit
1560 if (m_networkState != NETWORK_LOADING) 1566 if (m_networkState != NETWORK_LOADING)
1561 return; 1567 return;
1562 1568
1563 double time = WTF::currentTime(); 1569 double time = WTF::currentTime();
1564 double timedelta = time - m_previousProgressTime; 1570 double timedelta = time - m_previousProgressTime;
1565 1571
1566 if (webMediaPlayer() && webMediaPlayer()->didLoadingProgress()) { 1572 if (webMediaPlayer() && webMediaPlayer()->didLoadingProgress()) {
1567 scheduleEvent(EventTypeNames::progress); 1573 scheduleEvent(EventTypeNames::progress);
1568 m_previousProgressTime = time; 1574 m_previousProgressTime = time;
1569 m_sentStalledEvent = false; 1575 m_sentStalledEvent = false;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1602 1608
1603 void HTMLMediaElement::seek(double time) 1609 void HTMLMediaElement::seek(double time)
1604 { 1610 {
1605 WTF_LOG(Media, "HTMLMediaElement::seek(%p, %f)", this, time); 1611 WTF_LOG(Media, "HTMLMediaElement::seek(%p, %f)", this, time);
1606 1612
1607 // 2 - If the media element's readyState is HAVE_NOTHING, abort these steps. 1613 // 2 - If the media element's readyState is HAVE_NOTHING, abort these steps.
1608 if (m_readyState == HAVE_NOTHING) 1614 if (m_readyState == HAVE_NOTHING)
1609 return; 1615 return;
1610 1616
1611 // If the media engine has been told to postpone loading data, let it go ahe ad now. 1617 // If the media engine has been told to postpone loading data, let it go ahe ad now.
1612 if (m_preload < MediaPlayer::Auto && m_readyState < HAVE_FUTURE_DATA) 1618 if (m_preload < WebMediaPlayer::PreloadAuto && m_readyState < HAVE_FUTURE_DA TA)
1613 prepareToPlay(); 1619 prepareToPlay();
1614 1620
1615 // Get the current time before setting m_seeking, m_lastSeekTime is returned once it is set. 1621 // Get the current time before setting m_seeking, m_lastSeekTime is returned once it is set.
1616 refreshCachedTime(); 1622 refreshCachedTime();
1617 // This is needed to avoid getting default playback start position from curr entTime(). 1623 // This is needed to avoid getting default playback start position from curr entTime().
1618 double now = m_cachedTime; 1624 double now = m_cachedTime;
1619 1625
1620 // 3 - If the element's seeking IDL attribute is true, then another instance of this algorithm is 1626 // 3 - If the element's seeking IDL attribute is true, then another instance of this algorithm is
1621 // already running. Abort that other instance of the algorithm without waiti ng for the step that 1627 // already running. Abort that other instance of the algorithm without waiti ng for the step that
1622 // it is running to complete. 1628 // it is running to complete.
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1776 if (m_readyState == HAVE_NOTHING) { 1782 if (m_readyState == HAVE_NOTHING) {
1777 m_defaultPlaybackStartPosition = time; 1783 m_defaultPlaybackStartPosition = time;
1778 return; 1784 return;
1779 } 1785 }
1780 1786
1781 seek(time); 1787 seek(time);
1782 } 1788 }
1783 1789
1784 double HTMLMediaElement::duration() const 1790 double HTMLMediaElement::duration() const
1785 { 1791 {
1786 // FIXME: remove m_player check once we figure out how m_player is going 1792 // FIXME: remove m_webMediaPlayer check once we figure out how m_webMediaPla yer is going
1787 // out of sync with readystate. m_player is cleared but readystate is not se t 1793 // out of sync with readystate. m_webMediaPlayer is cleared but readystate i s not set
1788 // to HAVE_NOTHING 1794 // to HAVE_NOTHING
1789 if (!m_player || m_readyState < HAVE_METADATA) 1795 if (!m_webMediaPlayer || m_readyState < HAVE_METADATA) // Revisit !m_webMedi aPlayer check
1790 return std::numeric_limits<double>::quiet_NaN(); 1796 return std::numeric_limits<double>::quiet_NaN();
1791 1797
1792 // FIXME: Refactor so m_duration is kept current (in both MSE and 1798 // FIXME: Refactor so m_duration is kept current (in both MSE and
1793 // non-MSE cases) once we have transitioned from HAVE_NOTHING -> 1799 // non-MSE cases) once we have transitioned from HAVE_NOTHING ->
1794 // HAVE_METADATA. Currently, m_duration may be out of date for at least MSE 1800 // HAVE_METADATA. Currently, m_duration may be out of date for at least MSE
1795 // case because MediaSource and SourceBuffer do not notify the element 1801 // case because MediaSource and SourceBuffer do not notify the element
1796 // directly upon duration changes caused by endOfStream, remove, or append 1802 // directly upon duration changes caused by endOfStream, remove, or append
1797 // operations; rather the notification is triggered by the WebMediaPlayer 1803 // operations; rather the notification is triggered by the WebMediaPlayer
1798 // implementation observing that the underlying engine has updated duration 1804 // implementation observing that the underlying engine has updated duration
1799 // and notifying the element to consult its MediaSource for current 1805 // and notifying the element to consult its MediaSource for current
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1848 } 1854 }
1849 1855
1850 HTMLMediaElement::DirectionOfPlayback HTMLMediaElement::directionOfPlayback() co nst 1856 HTMLMediaElement::DirectionOfPlayback HTMLMediaElement::directionOfPlayback() co nst
1851 { 1857 {
1852 return m_playbackRate >= 0 ? Forward : Backward; 1858 return m_playbackRate >= 0 ? Forward : Backward;
1853 } 1859 }
1854 1860
1855 void HTMLMediaElement::updatePlaybackRate() 1861 void HTMLMediaElement::updatePlaybackRate()
1856 { 1862 {
1857 double effectiveRate = effectivePlaybackRate(); 1863 double effectiveRate = effectivePlaybackRate();
1858 if (m_player && potentiallyPlaying()) 1864 if (m_webMediaPlayer && potentiallyPlaying()) // Revisit !m_webMediaPlayer c heck
1859 webMediaPlayer()->setRate(effectiveRate); 1865 webMediaPlayer()->setRate(effectiveRate);
1860 } 1866 }
1861 1867
1862 bool HTMLMediaElement::ended() const 1868 bool HTMLMediaElement::ended() const
1863 { 1869 {
1864 // 4.8.10.8 Playing the media resource 1870 // 4.8.10.8 Playing the media resource
1865 // The ended attribute must return true if the media element has ended 1871 // The ended attribute must return true if the media element has ended
1866 // playback and the direction of playback is forwards, and false otherwise. 1872 // playback and the direction of playback is forwards, and false otherwise.
1867 return endedPlayback() && directionOfPlayback() == Forward; 1873 return endedPlayback() && directionOfPlayback() == Forward;
1868 } 1874 }
1869 1875
1870 bool HTMLMediaElement::autoplay() const 1876 bool HTMLMediaElement::autoplay() const
1871 { 1877 {
1872 return fastHasAttribute(autoplayAttr); 1878 return fastHasAttribute(autoplayAttr);
1873 } 1879 }
1874 1880
1875 String HTMLMediaElement::preload() const 1881 String HTMLMediaElement::preload() const
1876 { 1882 {
1877 switch (m_preload) { 1883 switch (m_preload) {
1878 case MediaPlayer::None: 1884 case WebMediaPlayer::PreloadNone:
1879 return "none"; 1885 return "none";
1880 break; 1886 break;
1881 case MediaPlayer::MetaData: 1887 case WebMediaPlayer::PreloadMetaData:
1882 return "metadata"; 1888 return "metadata";
1883 break; 1889 break;
1884 case MediaPlayer::Auto: 1890 case WebMediaPlayer::PreloadAuto:
1885 return "auto"; 1891 return "auto";
1886 break; 1892 break;
1887 } 1893 }
1888 1894
1889 ASSERT_NOT_REACHED(); 1895 ASSERT_NOT_REACHED();
1890 return String(); 1896 return String();
1891 } 1897 }
1892 1898
1893 void HTMLMediaElement::setPreload(const AtomicString& preload) 1899 void HTMLMediaElement::setPreload(const AtomicString& preload)
1894 { 1900 {
(...skipping 16 matching lines...) Expand all
1911 } 1917 }
1912 1918
1913 playInternal(); 1919 playInternal();
1914 } 1920 }
1915 1921
1916 void HTMLMediaElement::playInternal() 1922 void HTMLMediaElement::playInternal()
1917 { 1923 {
1918 WTF_LOG(Media, "HTMLMediaElement::playInternal(%p)", this); 1924 WTF_LOG(Media, "HTMLMediaElement::playInternal(%p)", this);
1919 1925
1920 // 4.8.10.9. Playing the media resource 1926 // 4.8.10.9. Playing the media resource
1921 if (!m_player || m_networkState == NETWORK_EMPTY) 1927 if (!m_webMediaPlayer || m_networkState == NETWORK_EMPTY) // Revisit !m_webM ediaPlayer check
1922 scheduleDelayedAction(LoadMediaResource); 1928 scheduleDelayedAction(LoadMediaResource);
1923 1929
1924 // Generally "ended" and "looping" are exclusive. Here, the loop attribute 1930 // Generally "ended" and "looping" are exclusive. Here, the loop attribute
1925 // is ignored to seek back to start in case loop was set after playback 1931 // is ignored to seek back to start in case loop was set after playback
1926 // ended. See http://crbug.com/364442 1932 // ended. See http://crbug.com/364442
1927 if (endedPlayback(LoopCondition::Ignored)) 1933 if (endedPlayback(LoopCondition::Ignored))
1928 seek(0); 1934 seek(0);
1929 1935
1930 if (m_mediaController) 1936 if (m_mediaController)
1931 m_mediaController->bringElementUpToSpeed(this); 1937 m_mediaController->bringElementUpToSpeed(this);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1971 double progress = playedTime / duration(); 1977 double progress = playedTime / duration();
1972 if (progress < 0.5) 1978 if (progress < 0.5)
1973 recordAutoplayMetric(AutoplayBailout); 1979 recordAutoplayMetric(AutoplayBailout);
1974 } 1980 }
1975 } 1981 }
1976 1982
1977 void HTMLMediaElement::pause() 1983 void HTMLMediaElement::pause()
1978 { 1984 {
1979 WTF_LOG(Media, "HTMLMediaElement::pause(%p)", this); 1985 WTF_LOG(Media, "HTMLMediaElement::pause(%p)", this);
1980 1986
1981 if (!m_player || m_networkState == NETWORK_EMPTY) 1987 if (!m_webMediaPlayer || m_networkState == NETWORK_EMPTY) // Revisit !m_webM ediaPlayer check
1982 scheduleDelayedAction(LoadMediaResource); 1988 scheduleDelayedAction(LoadMediaResource);
1983 1989
1984 m_autoplaying = false; 1990 m_autoplaying = false;
1985 1991
1986 if (!m_paused) { 1992 if (!m_paused) {
1987 if (m_initialPlayWithoutUserGestures) 1993 if (m_initialPlayWithoutUserGestures)
1988 gesturelessInitialPlayHalted(); 1994 gesturelessInitialPlayHalted();
1989 1995
1990 m_paused = true; 1996 m_paused = true;
1991 scheduleTimeupdateEvent(false); 1997 scheduleTimeupdateEvent(false);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
2116 { 2122 {
2117 if (m_playbackProgressTimer.isActive()) 2123 if (m_playbackProgressTimer.isActive())
2118 return; 2124 return;
2119 2125
2120 m_previousProgressTime = WTF::currentTime(); 2126 m_previousProgressTime = WTF::currentTime();
2121 m_playbackProgressTimer.startRepeating(maxTimeupdateEventFrequency, FROM_HER E); 2127 m_playbackProgressTimer.startRepeating(maxTimeupdateEventFrequency, FROM_HER E);
2122 } 2128 }
2123 2129
2124 void HTMLMediaElement::playbackProgressTimerFired(Timer<HTMLMediaElement>*) 2130 void HTMLMediaElement::playbackProgressTimerFired(Timer<HTMLMediaElement>*)
2125 { 2131 {
2126 ASSERT(m_player); 2132 ASSERT(m_webMediaPlayer); // Revisit m_webMediaPlayer check
2127 2133
2128 if (!std::isnan(m_fragmentEndTime) && currentTime() >= m_fragmentEndTime && directionOfPlayback() == Forward) { 2134 if (!std::isnan(m_fragmentEndTime) && currentTime() >= m_fragmentEndTime && directionOfPlayback() == Forward) {
2129 m_fragmentEndTime = std::numeric_limits<double>::quiet_NaN(); 2135 m_fragmentEndTime = std::numeric_limits<double>::quiet_NaN();
2130 if (!m_mediaController && !m_paused) { 2136 if (!m_mediaController && !m_paused) {
2131 UseCounter::count(document(), UseCounter::HTMLMediaElementPauseAtFra gmentEnd); 2137 UseCounter::count(document(), UseCounter::HTMLMediaElementPauseAtFra gmentEnd);
2132 // changes paused to true and fires a simple event named pause at th e media element. 2138 // changes paused to true and fires a simple event named pause at th e media element.
2133 pause(); 2139 pause();
2134 } 2140 }
2135 } 2141 }
2136 2142
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
2212 Vector<WebMediaPlayer::TrackId> enabledTrackIds; 2218 Vector<WebMediaPlayer::TrackId> enabledTrackIds;
2213 for (unsigned i = 0; i < audioTracks().length(); ++i) { 2219 for (unsigned i = 0; i < audioTracks().length(); ++i) {
2214 AudioTrack* track = audioTracks().anonymousIndexedGetter(i); 2220 AudioTrack* track = audioTracks().anonymousIndexedGetter(i);
2215 if (track->enabled()) 2221 if (track->enabled())
2216 enabledTrackIds.append(track->trackId()); 2222 enabledTrackIds.append(track->trackId());
2217 } 2223 }
2218 2224
2219 webMediaPlayer()->enabledAudioTracksChanged(enabledTrackIds); 2225 webMediaPlayer()->enabledAudioTracksChanged(enabledTrackIds);
2220 } 2226 }
2221 2227
2222 WebMediaPlayer::TrackId HTMLMediaElement::addAudioTrack(const String& id, blink: :WebMediaPlayerClient::AudioTrackKind kind, const AtomicString& label, const Ato micString& language, bool enabled) 2228 WebMediaPlayer::TrackId HTMLMediaElement::addAudioTrack(const WebString& id, bli nk::WebMediaPlayerClient::AudioTrackKind kind, const WebString& label, const Web String& language, bool enabled)
2223 { 2229 {
2224 AtomicString kindString = AudioKindToString(kind); 2230 AtomicString kindString = AudioKindToString(kind);
2225 WTF_LOG(Media, "HTMLMediaElement::addAudioTrack(%p, '%s', '%s', '%s', '%s', %d)", 2231 WTF_LOG(Media, "HTMLMediaElement::addAudioTrack(%p, '%s', '%s', '%s', '%s', %d)",
2226 this, id.ascii().data(), kindString.ascii().data(), label.ascii().data() , language.ascii().data(), enabled); 2232 this, id.latin1().data(), kindString.ascii().data(), label.latin1().data (), language.latin1().data(), enabled);
2227 2233
2228 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) 2234 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled())
2229 return 0; 2235 return 0;
2230 2236
2231 RefPtrWillBeRawPtr<AudioTrack> audioTrack = AudioTrack::create(id, kindStrin g, label, language, enabled); 2237 RefPtrWillBeRawPtr<AudioTrack> audioTrack = AudioTrack::create(id, kindStrin g, label, language, enabled);
2232 audioTracks().add(audioTrack); 2238 audioTracks().add(audioTrack);
2233 2239
2234 return audioTrack->trackId(); 2240 return audioTrack->trackId();
2235 } 2241 }
2236 2242
(...skipping 19 matching lines...) Expand all
2256 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); 2262 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled());
2257 2263
2258 if (selectedTrackId) 2264 if (selectedTrackId)
2259 videoTracks().trackSelected(*selectedTrackId); 2265 videoTracks().trackSelected(*selectedTrackId);
2260 2266
2261 // FIXME: Add call on m_mediaSource to notify it of track changes once the S ourceBuffer.videoTracks attribute is added. 2267 // FIXME: Add call on m_mediaSource to notify it of track changes once the S ourceBuffer.videoTracks attribute is added.
2262 2268
2263 webMediaPlayer()->selectedVideoTrackChanged(selectedTrackId); 2269 webMediaPlayer()->selectedVideoTrackChanged(selectedTrackId);
2264 } 2270 }
2265 2271
2266 WebMediaPlayer::TrackId HTMLMediaElement::addVideoTrack(const String& id, blink: :WebMediaPlayerClient::VideoTrackKind kind, const AtomicString& label, const Ato micString& language, bool selected) 2272 WebMediaPlayer::TrackId HTMLMediaElement::addVideoTrack(const WebString& id, bli nk::WebMediaPlayerClient::VideoTrackKind kind, const WebString& label, const Web String& language, bool selected)
2267 { 2273 {
2268 AtomicString kindString = VideoKindToString(kind); 2274 AtomicString kindString = VideoKindToString(kind);
2269 WTF_LOG(Media, "HTMLMediaElement::addVideoTrack(%p, '%s', '%s', '%s', '%s', %d)", 2275 WTF_LOG(Media, "HTMLMediaElement::addVideoTrack(%p, '%s', '%s', '%s', '%s', %d)",
2270 this, id.ascii().data(), kindString.ascii().data(), label.ascii().data() , language.ascii().data(), selected); 2276 this, id.latin1().data(), kindString.ascii().data(), label.latin1().data (), language.latin1().data(), selected);
2271 2277
2272 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) 2278 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled())
2273 return 0; 2279 return 0;
2274 2280
2275 // If another track was selected (potentially by the user), leave it selecte d. 2281 // If another track was selected (potentially by the user), leave it selecte d.
2276 if (selected && videoTracks().selectedIndex() != -1) 2282 if (selected && videoTracks().selectedIndex() != -1)
2277 selected = false; 2283 selected = false;
2278 2284
2279 RefPtrWillBeRawPtr<VideoTrack> videoTrack = VideoTrack::create(id, kindStrin g, label, language, selected); 2285 RefPtrWillBeRawPtr<VideoTrack> videoTrack = VideoTrack::create(id, kindStrin g, label, language, selected);
2280 videoTracks().add(videoTrack); 2286 videoTracks().add(videoTrack);
2281 2287
2282 return videoTrack->trackId(); 2288 return videoTrack->trackId();
2283 } 2289 }
2284 2290
2285 void HTMLMediaElement::removeVideoTrack(WebMediaPlayer::TrackId trackId) 2291 void HTMLMediaElement::removeVideoTrack(WebMediaPlayer::TrackId trackId)
2286 { 2292 {
2287 WTF_LOG(Media, "HTMLMediaElement::removeVideoTrack(%p)", this); 2293 WTF_LOG(Media, "HTMLMediaElement::removeVideoTrack(%p)", this);
2288 2294
2289 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) 2295 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled())
2290 return; 2296 return;
2291 2297
2292 videoTracks().remove(trackId); 2298 videoTracks().remove(trackId);
2293 } 2299 }
2294 2300
2295 void HTMLMediaElement::mediaPlayerDidAddTextTrack(WebInbandTextTrack* webTrack) 2301 void HTMLMediaElement::addTextTrack(WebInbandTextTrack* webTrack)
2296 { 2302 {
2297 // 4.8.10.12.2 Sourcing in-band text tracks 2303 // 4.8.10.12.2 Sourcing in-band text tracks
2298 // 1. Associate the relevant data with a new text track and its correspondin g new TextTrack object. 2304 // 1. Associate the relevant data with a new text track and its correspondin g new TextTrack object.
2299 RefPtrWillBeRawPtr<InbandTextTrack> textTrack = InbandTextTrack::create(webT rack); 2305 RefPtrWillBeRawPtr<InbandTextTrack> textTrack = InbandTextTrack::create(webT rack);
2300 2306
2301 // 2. Set the new text track's kind, label, and language based on the semant ics of the relevant data, 2307 // 2. Set the new text track's kind, label, and language based on the semant ics of the relevant data,
2302 // as defined by the relevant specification. If there is no label in that da ta, then the label must 2308 // as defined by the relevant specification. If there is no label in that da ta, then the label must
2303 // be set to the empty string. 2309 // be set to the empty string.
2304 // 3. Associate the text track list of cues with the rules for updating the text track rendering appropriate 2310 // 3. Associate the text track list of cues with the rules for updating the text track rendering appropriate
2305 // for the format in question. 2311 // for the format in question.
2306 // 4. If the new text track's kind is metadata, then set the text track in-b and metadata track dispatch type 2312 // 4. If the new text track's kind is metadata, then set the text track in-b and metadata track dispatch type
2307 // as follows, based on the type of the media resource: 2313 // as follows, based on the type of the media resource:
2308 // 5. Populate the new text track's list of cues with the cues parsed so far , folllowing the guidelines for exposing 2314 // 5. Populate the new text track's list of cues with the cues parsed so far , folllowing the guidelines for exposing
2309 // cues, and begin updating it dynamically as necessary. 2315 // cues, and begin updating it dynamically as necessary.
2310 // - Thess are all done by the media engine. 2316 // - Thess are all done by the media engine.
2311 2317
2312 // 6. Set the new text track's readiness state to loaded. 2318 // 6. Set the new text track's readiness state to loaded.
2313 textTrack->setReadinessState(TextTrack::Loaded); 2319 textTrack->setReadinessState(TextTrack::Loaded);
2314 2320
2315 // 7. Set the new text track's mode to the mode consistent with the user's p references and the requirements of 2321 // 7. Set the new text track's mode to the mode consistent with the user's p references and the requirements of
2316 // the relevant specification for the data. 2322 // the relevant specification for the data.
2317 // - This will happen in honorUserPreferencesForAutomaticTextTrackSelection () 2323 // - This will happen in honorUserPreferencesForAutomaticTextTrackSelection ()
2318 scheduleDelayedAction(LoadTextTrackResource); 2324 scheduleDelayedAction(LoadTextTrackResource);
2319 2325
2320 // 8. Add the new text track to the media element's list of text tracks. 2326 // 8. Add the new text track to the media element's list of text tracks.
2321 // 9. Fire an event with the name addtrack, that does not bubble and is not cancelable, and that uses the TrackEvent 2327 // 9. Fire an event with the name addtrack, that does not bubble and is not cancelable, and that uses the TrackEvent
2322 // interface, with the track attribute initialized to the text track's TextT rack object, at the media element's 2328 // interface, with the track attribute initialized to the text track's TextT rack object, at the media element's
2323 // textTracks attribute's TextTrackList object. 2329 // textTracks attribute's TextTrackList object.
2324 addTextTrack(textTrack.get()); 2330 mediaPlayerAddTextTrack(textTrack.get());
2325 } 2331 }
2326 2332
2327 void HTMLMediaElement::mediaPlayerDidRemoveTextTrack(WebInbandTextTrack* webTrac k) 2333 void HTMLMediaElement::removeTextTrack(WebInbandTextTrack* webTrack)
2328 { 2334 {
2329 if (!m_textTracks) 2335 if (!m_textTracks)
2330 return; 2336 return;
2331 2337
2332 // This cast is safe because we created the InbandTextTrack with the WebInba ndTextTrack 2338 // This cast is safe because we created the InbandTextTrack with the WebInba ndTextTrack
2333 // passed to mediaPlayerDidAddTextTrack. 2339 // passed to mediaPlayerDidAddTextTrack.
2334 RefPtrWillBeRawPtr<InbandTextTrack> textTrack = static_cast<InbandTextTrack* >(webTrack->client()); 2340 RefPtrWillBeRawPtr<InbandTextTrack> textTrack = static_cast<InbandTextTrack* >(webTrack->client());
2335 if (!textTrack) 2341 if (!textTrack)
2336 return; 2342 return;
2337 2343
2338 removeTextTrack(textTrack.get()); 2344 mediaPlayerRemoveTextTrack(textTrack.get());
2339 } 2345 }
2340 2346
2341 void HTMLMediaElement::textTracksChanged() 2347 void HTMLMediaElement::textTracksChanged()
2342 { 2348 {
2343 if (mediaControls()) 2349 if (mediaControls())
2344 mediaControls()->refreshClosedCaptionsButtonVisibility(); 2350 mediaControls()->refreshClosedCaptionsButtonVisibility();
2345 } 2351 }
2346 2352
2347 void HTMLMediaElement::addTextTrack(TextTrack* track) 2353 void HTMLMediaElement::mediaPlayerAddTextTrack(TextTrack* track)
2348 { 2354 {
2349 textTracks()->append(track); 2355 textTracks()->append(track);
2350 2356
2351 textTracksChanged(); 2357 textTracksChanged();
2352 } 2358 }
2353 2359
2354 void HTMLMediaElement::removeTextTrack(TextTrack* track) 2360 void HTMLMediaElement::mediaPlayerRemoveTextTrack(TextTrack* track)
2355 { 2361 {
2356 m_textTracks->remove(track); 2362 m_textTracks->remove(track);
2357 2363
2358 textTracksChanged(); 2364 textTracksChanged();
2359 } 2365 }
2360 2366
2361 void HTMLMediaElement::forgetResourceSpecificTracks() 2367 void HTMLMediaElement::forgetResourceSpecificTracks()
2362 { 2368 {
2363 // Implements the "forget the media element's media-resource-specific tracks " algorithm. 2369 // Implements the "forget the media element's media-resource-specific tracks " algorithm.
2364 // The order is explicitly specified as text, then audio, and finally video. Also 2370 // The order is explicitly specified as text, then audio, and finally video. Also
(...skipping 25 matching lines...) Expand all
2390 RefPtrWillBeRawPtr<TextTrack> textTrack = TextTrack::create(kind, label, lan guage); 2396 RefPtrWillBeRawPtr<TextTrack> textTrack = TextTrack::create(kind, label, lan guage);
2391 // ..., its text track readiness state to the text track loaded state, .. . 2397 // ..., its text track readiness state to the text track loaded state, .. .
2392 textTrack->setReadinessState(TextTrack::Loaded); 2398 textTrack->setReadinessState(TextTrack::Loaded);
2393 2399
2394 // 3. Add the new text track to the media element's list of text tracks. 2400 // 3. Add the new text track to the media element's list of text tracks.
2395 // 4. Queue a task to fire a trusted event with the name addtrack, that 2401 // 4. Queue a task to fire a trusted event with the name addtrack, that
2396 // does not bubble and is not cancelable, and that uses the TrackEvent 2402 // does not bubble and is not cancelable, and that uses the TrackEvent
2397 // interface, with the track attribute initialised to the new text 2403 // interface, with the track attribute initialised to the new text
2398 // track's TextTrack object, at the media element's textTracks 2404 // track's TextTrack object, at the media element's textTracks
2399 // attribute's TextTrackList object. 2405 // attribute's TextTrackList object.
2400 addTextTrack(textTrack.get()); 2406 mediaPlayerAddTextTrack(textTrack.get());
2401 2407
2402 // Note: Due to side effects when changing track parameters, we have to 2408 // Note: Due to side effects when changing track parameters, we have to
2403 // first append the track to the text track list. 2409 // first append the track to the text track list.
2404 // FIXME: Since setMode() will cause a 'change' event to be queued on the 2410 // FIXME: Since setMode() will cause a 'change' event to be queued on the
2405 // same task source as the 'addtrack' event (see above), the order is 2411 // same task source as the 'addtrack' event (see above), the order is
2406 // wrong. (The 'change' event shouldn't be fired at all in this case...) 2412 // wrong. (The 'change' event shouldn't be fired at all in this case...)
2407 2413
2408 // ..., its text track mode to the text track hidden mode, ... 2414 // ..., its text track mode to the text track hidden mode, ...
2409 textTrack->setMode(TextTrack::hiddenKeyword()); 2415 textTrack->setMode(TextTrack::hiddenKeyword());
2410 2416
(...skipping 12 matching lines...) Expand all
2423 void HTMLMediaElement::didAddTrackElement(HTMLTrackElement* trackElement) 2429 void HTMLMediaElement::didAddTrackElement(HTMLTrackElement* trackElement)
2424 { 2430 {
2425 // 4.8.10.12.3 Sourcing out-of-band text tracks 2431 // 4.8.10.12.3 Sourcing out-of-band text tracks
2426 // When a track element's parent element changes and the new parent is a med ia element, 2432 // When a track element's parent element changes and the new parent is a med ia element,
2427 // then the user agent must add the track element's corresponding text track to the 2433 // then the user agent must add the track element's corresponding text track to the
2428 // media element's list of text tracks ... [continues in TextTrackList::appe nd] 2434 // media element's list of text tracks ... [continues in TextTrackList::appe nd]
2429 RefPtrWillBeRawPtr<TextTrack> textTrack = trackElement->track(); 2435 RefPtrWillBeRawPtr<TextTrack> textTrack = trackElement->track();
2430 if (!textTrack) 2436 if (!textTrack)
2431 return; 2437 return;
2432 2438
2433 addTextTrack(textTrack.get()); 2439 mediaPlayerAddTextTrack(textTrack.get());
2434 2440
2435 // Do not schedule the track loading until parsing finishes so we don't star t before all tracks 2441 // Do not schedule the track loading until parsing finishes so we don't star t before all tracks
2436 // in the markup have been added. 2442 // in the markup have been added.
2437 if (isFinishedParsingChildren()) 2443 if (isFinishedParsingChildren())
2438 scheduleDelayedAction(LoadTextTrackResource); 2444 scheduleDelayedAction(LoadTextTrackResource);
2439 } 2445 }
2440 2446
2441 void HTMLMediaElement::didRemoveTrackElement(HTMLTrackElement* trackElement) 2447 void HTMLMediaElement::didRemoveTrackElement(HTMLTrackElement* trackElement)
2442 { 2448 {
2443 #if !LOG_DISABLED 2449 #if !LOG_DISABLED
2444 KURL url = trackElement->getNonEmptyURLAttribute(srcAttr); 2450 KURL url = trackElement->getNonEmptyURLAttribute(srcAttr);
2445 WTF_LOG(Media, "HTMLMediaElement::didRemoveTrackElement(%p) - 'src' is %s", this, urlForLoggingMedia(url).utf8().data()); 2451 WTF_LOG(Media, "HTMLMediaElement::didRemoveTrackElement(%p) - 'src' is %s", this, urlForLoggingMedia(url).utf8().data());
2446 #endif 2452 #endif
2447 2453
2448 RefPtrWillBeRawPtr<TextTrack> textTrack = trackElement->track(); 2454 RefPtrWillBeRawPtr<TextTrack> textTrack = trackElement->track();
2449 if (!textTrack) 2455 if (!textTrack)
2450 return; 2456 return;
2451 2457
2452 textTrack->setHasBeenConfigured(false); 2458 textTrack->setHasBeenConfigured(false);
2453 2459
2454 if (!m_textTracks) 2460 if (!m_textTracks)
2455 return; 2461 return;
2456 2462
2457 // 4.8.10.12.3 Sourcing out-of-band text tracks 2463 // 4.8.10.12.3 Sourcing out-of-band text tracks
2458 // When a track element's parent element changes and the old parent was a me dia element, 2464 // When a track element's parent element changes and the old parent was a me dia element,
2459 // then the user agent must remove the track element's corresponding text tr ack from the 2465 // then the user agent must remove the track element's corresponding text tr ack from the
2460 // media element's list of text tracks. 2466 // media element's list of text tracks.
2461 removeTextTrack(textTrack.get()); 2467 mediaPlayerRemoveTextTrack(textTrack.get());
2462 2468
2463 size_t index = m_textTracksWhenResourceSelectionBegan.find(textTrack.get()); 2469 size_t index = m_textTracksWhenResourceSelectionBegan.find(textTrack.get());
2464 if (index != kNotFound) 2470 if (index != kNotFound)
2465 m_textTracksWhenResourceSelectionBegan.remove(index); 2471 m_textTracksWhenResourceSelectionBegan.remove(index);
2466 } 2472 }
2467 2473
2468 void HTMLMediaElement::honorUserPreferencesForAutomaticTextTrackSelection() 2474 void HTMLMediaElement::honorUserPreferencesForAutomaticTextTrackSelection()
2469 { 2475 {
2470 if (!m_textTracks || !m_textTracks->length()) 2476 if (!m_textTracks || !m_textTracks->length())
2471 return; 2477 return;
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
2658 WTF_LOG(Media, "HTMLMediaElement::sourceRemoved(%p) - m_nextChildNodeToC onsider set to %p", this, m_nextChildNodeToConsider.get()); 2664 WTF_LOG(Media, "HTMLMediaElement::sourceRemoved(%p) - m_nextChildNodeToC onsider set to %p", this, m_nextChildNodeToConsider.get());
2659 } else if (source == m_currentSourceNode) { 2665 } else if (source == m_currentSourceNode) {
2660 // Clear the current source node pointer, but don't change the movie as the spec says: 2666 // Clear the current source node pointer, but don't change the movie as the spec says:
2661 // 4.8.8 - Dynamically modifying a source element and its attribute when the element is already 2667 // 4.8.8 - Dynamically modifying a source element and its attribute when the element is already
2662 // inserted in a video or audio element will have no effect. 2668 // inserted in a video or audio element will have no effect.
2663 m_currentSourceNode = nullptr; 2669 m_currentSourceNode = nullptr;
2664 WTF_LOG(Media, "HTMLMediaElement::sourceRemoved(%p) - m_currentSourceNod e set to 0", this); 2670 WTF_LOG(Media, "HTMLMediaElement::sourceRemoved(%p) - m_currentSourceNod e set to 0", this);
2665 } 2671 }
2666 } 2672 }
2667 2673
2668 void HTMLMediaElement::mediaPlayerTimeChanged() 2674 void HTMLMediaElement::timeChanged()
2669 { 2675 {
2670 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerTimeChanged(%p)", this); 2676 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerTimeChanged(%p)", this);
2671 2677
2672 cueTimeline().updateActiveCues(currentTime()); 2678 cueTimeline().updateActiveCues(currentTime());
2673 2679
2674 invalidateCachedTime(); 2680 invalidateCachedTime();
2675 2681
2676 // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with t he seek. 2682 // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with t he seek.
2677 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !webMediaPlayer()->see king()) 2683 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !webMediaPlayer()->see king())
2678 finishSeek(); 2684 finishSeek();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2711 // for the media element's current media controller. 2717 // for the media element's current media controller.
2712 updateMediaController(); 2718 updateMediaController();
2713 } 2719 }
2714 } else { 2720 } else {
2715 m_sentEndEvent = false; 2721 m_sentEndEvent = false;
2716 } 2722 }
2717 2723
2718 updatePlayState(); 2724 updatePlayState();
2719 } 2725 }
2720 2726
2721 void HTMLMediaElement::mediaPlayerDurationChanged() 2727 void HTMLMediaElement::durationChanged()
2722 { 2728 {
2723 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerDurationChanged(%p)", this); 2729 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p)", this);
2724 // FIXME: Change MediaPlayerClient & WebMediaPlayer to convey 2730 // FIXME: Change MediaPlayerClient & WebMediaPlayer to convey
2725 // the currentTime when the duration change occured. The current 2731 // the currentTime when the duration change occured. The current
2726 // WebMediaPlayer implementations always clamp currentTime() to 2732 // WebMediaPlayer implementations always clamp currentTime() to
2727 // duration() so the requestSeek condition here is always false. 2733 // duration() so the requestSeek condition here is always false.
2728 durationChanged(duration(), currentTime() > duration()); 2734 mediaPlayerDurationChanged(duration(), currentTime() > duration());
2729 } 2735 }
2730 2736
2731 void HTMLMediaElement::durationChanged(double duration, bool requestSeek) 2737 void HTMLMediaElement::mediaPlayerDurationChanged(double duration, bool requestS eek)
2732 { 2738 {
2733 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p, %f, %d)", this, durati on, requestSeek); 2739 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerDurationChanged(%p, %f, %d)", t his, duration, requestSeek);
2734 2740
2735 // Abort if duration unchanged. 2741 // Abort if duration unchanged.
2736 if (m_duration == duration) 2742 if (m_duration == duration)
2737 return; 2743 return;
2738 2744
2739 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p) : %f -> %f", this, m_d uration, duration); 2745 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p) : %f -> %f", this, m_d uration, duration);
2740 m_duration = duration; 2746 m_duration = duration;
2741 scheduleEvent(EventTypeNames::durationchange); 2747 scheduleEvent(EventTypeNames::durationchange);
2742 2748
2743 if (mediaControls()) 2749 if (mediaControls())
2744 mediaControls()->reset(); 2750 mediaControls()->reset();
2745 if (layoutObject()) 2751 if (layoutObject())
2746 layoutObject()->updateFromElement(); 2752 layoutObject()->updateFromElement();
2747 2753
2748 if (requestSeek) 2754 if (requestSeek)
2749 seek(duration); 2755 seek(duration);
2750 } 2756 }
2751 2757
2752 void HTMLMediaElement::mediaPlayerPlaybackStateChanged() 2758 void HTMLMediaElement::playbackStateChanged()
2753 { 2759 {
2754 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerPlaybackStateChanged(%p)", this ); 2760 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerPlaybackStateChanged(%p)", this );
2755 2761
2756 if (!webMediaPlayer()) 2762 if (!webMediaPlayer())
2757 return; 2763 return;
2758 2764
2759 if (webMediaPlayer()->paused()) 2765 if (webMediaPlayer()->paused())
2760 pause(); 2766 pause();
2761 else 2767 else
2762 playInternal(); 2768 playInternal();
2763 } 2769 }
2764 2770
2765 void HTMLMediaElement::mediaPlayerRequestFullscreen() 2771 void HTMLMediaElement::keyAdded(const WebString& keySystem, const WebString& ses sionId)
2772 {
2773 HTMLMediaElementEncryptedMedia::keyAdded(*this, keySystem, sessionId);
2774 }
2775
2776 void HTMLMediaElement::keyError(const WebString& keySystem, const WebString& ses sionId, MediaKeyErrorCode errorCode, unsigned short systemCode)
2777 {
2778 HTMLMediaElementEncryptedMedia::keyError(*this, keySystem, sessionId, errorC ode, systemCode);
2779 }
2780
2781 void HTMLMediaElement::keyMessage(const WebString& keySystem, const WebString& s essionId, const unsigned char* message, unsigned messageLength, const WebURL& de faultURL)
2782 {
2783 HTMLMediaElementEncryptedMedia::keyMessage(*this, keySystem, sessionId, mess age, messageLength, defaultURL);
2784 }
2785
2786 void HTMLMediaElement::encrypted(WebEncryptedMediaInitDataType initDataType, con st unsigned char* initData, unsigned initDataLength)
2787 {
2788 HTMLMediaElementEncryptedMedia::encrypted(*this, initDataType, initData, ini tDataLength);
2789 }
2790
2791 void HTMLMediaElement::didBlockPlaybackWaitingForKey()
2792 {
2793 HTMLMediaElementEncryptedMedia::didBlockPlaybackWaitingForKey(*this);
2794 }
2795
2796 void HTMLMediaElement::didResumePlaybackBlockedForKey()
2797 {
2798 HTMLMediaElementEncryptedMedia::didResumePlaybackBlockedForKey(*this);
2799 }
2800
2801 void HTMLMediaElement::requestFullscreen()
2766 { 2802 {
2767 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerRequestFullscreen(%p)", this); 2803 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerRequestFullscreen(%p)", this);
2768 2804
2769 // The player is responsible for only invoking this callback in response to 2805 // The player is responsible for only invoking this callback in response to
2770 // user interaction or when it is technically required to play the video. 2806 // user interaction or when it is technically required to play the video.
2771 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); 2807 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture);
2772 2808
2773 enterFullscreen(); 2809 enterFullscreen();
2774 } 2810 }
2775 2811
2776 void HTMLMediaElement::mediaPlayerRequestSeek(double time) 2812 void HTMLMediaElement::requestSeek(double time)
2777 { 2813 {
2778 // The player is the source of this seek request. 2814 // The player is the source of this seek request.
2779 if (m_mediaController) { 2815 if (m_mediaController) {
2780 m_mediaController->setCurrentTime(time); 2816 m_mediaController->setCurrentTime(time);
2781 return; 2817 return;
2782 } 2818 }
2783 setCurrentTime(time, ASSERT_NO_EXCEPTION); 2819 setCurrentTime(time, ASSERT_NO_EXCEPTION);
2784 } 2820 }
2785 2821
2786 void HTMLMediaElement::remoteRouteAvailabilityChanged(bool routesAvailable) 2822 void HTMLMediaElement::remoteRouteAvailabilityChanged(bool routesAvailable)
(...skipping 11 matching lines...) Expand all
2798 } 2834 }
2799 2835
2800 void HTMLMediaElement::disconnectedFromRemoteDevice() 2836 void HTMLMediaElement::disconnectedFromRemoteDevice()
2801 { 2837 {
2802 m_playingRemotely = false; 2838 m_playingRemotely = false;
2803 if (mediaControls()) 2839 if (mediaControls())
2804 mediaControls()->stoppedCasting(); 2840 mediaControls()->stoppedCasting();
2805 } 2841 }
2806 2842
2807 // MediaPlayerPresentation methods 2843 // MediaPlayerPresentation methods
2808 void HTMLMediaElement::mediaPlayerRepaint() 2844 void HTMLMediaElement::repaint()
2809 { 2845 {
2810 if (m_webLayer) 2846 if (m_webLayer)
2811 m_webLayer->invalidate(); 2847 m_webLayer->invalidate();
2812 2848
2813 updateDisplayState(); 2849 updateDisplayState();
2814 if (layoutObject()) 2850 if (layoutObject())
2815 layoutObject()->setShouldDoFullPaintInvalidation(); 2851 layoutObject()->setShouldDoFullPaintInvalidation();
2816 } 2852 }
2817 2853
2818 void HTMLMediaElement::mediaPlayerSizeChanged() 2854 void HTMLMediaElement::sizeChanged()
2819 { 2855 {
2820 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerSizeChanged(%p)", this); 2856 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerSizeChanged(%p)", this);
2821 2857
2822 ASSERT(hasVideo()); // "resize" makes no sense absent video. 2858 ASSERT(hasVideo()); // "resize" makes no sense absent video.
2823 if (m_readyState > HAVE_NOTHING && isHTMLVideoElement()) 2859 if (m_readyState > HAVE_NOTHING && isHTMLVideoElement())
2824 scheduleEvent(EventTypeNames::resize); 2860 scheduleEvent(EventTypeNames::resize);
2825 2861
2826 if (layoutObject()) 2862 if (layoutObject())
2827 layoutObject()->updateFromElement(); 2863 layoutObject()->updateFromElement();
2828 } 2864 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2873 } 2909 }
2874 2910
2875 bool HTMLMediaElement::couldPlayIfEnoughData() const 2911 bool HTMLMediaElement::couldPlayIfEnoughData() const
2876 { 2912 {
2877 return !paused() && !endedPlayback() && !stoppedDueToErrors(); 2913 return !paused() && !endedPlayback() && !stoppedDueToErrors();
2878 } 2914 }
2879 2915
2880 bool HTMLMediaElement::endedPlayback(LoopCondition loopCondition) const 2916 bool HTMLMediaElement::endedPlayback(LoopCondition loopCondition) const
2881 { 2917 {
2882 double dur = duration(); 2918 double dur = duration();
2883 if (!m_player || std::isnan(dur)) 2919 if (!m_webMediaPlayer || std::isnan(dur)) // Revisit !m_webMediaPlayer check
2884 return false; 2920 return false;
2885 2921
2886 // 4.8.10.8 Playing the media resource 2922 // 4.8.10.8 Playing the media resource
2887 2923
2888 // A media element is said to have ended playback when the element's 2924 // A media element is said to have ended playback when the element's
2889 // readyState attribute is HAVE_METADATA or greater, 2925 // readyState attribute is HAVE_METADATA or greater,
2890 if (m_readyState < HAVE_METADATA) 2926 if (m_readyState < HAVE_METADATA)
2891 return false; 2927 return false;
2892 2928
2893 // and the current playback position is the end of the media resource and th e direction 2929 // and the current playback position is the end of the media resource and th e direction
(...skipping 15 matching lines...) Expand all
2909 RefPtrWillBeRawPtr<TimeRanges> seekableRanges = seekable(); 2945 RefPtrWillBeRawPtr<TimeRanges> seekableRanges = seekable();
2910 if (!seekableRanges->contain(currentTime())) 2946 if (!seekableRanges->contain(currentTime()))
2911 return true; 2947 return true;
2912 } 2948 }
2913 2949
2914 return false; 2950 return false;
2915 } 2951 }
2916 2952
2917 void HTMLMediaElement::updatePlayState() 2953 void HTMLMediaElement::updatePlayState()
2918 { 2954 {
2919 if (!m_player) 2955 /*if (!m_player) // Revisit
2920 return; 2956 return;*/
2921 2957
2922 bool isPlaying = webMediaPlayer() && !webMediaPlayer()->paused(); 2958 bool isPlaying = webMediaPlayer() && !webMediaPlayer()->paused();
2923 bool shouldBePlaying = potentiallyPlaying(); 2959 bool shouldBePlaying = potentiallyPlaying();
2924 2960
2925 WTF_LOG(Media, "HTMLMediaElement::updatePlayState(%p) - shouldBePlaying = %s , isPlaying = %s", 2961 WTF_LOG(Media, "HTMLMediaElement::updatePlayState(%p) - shouldBePlaying = %s , isPlaying = %s",
2926 this, boolString(shouldBePlaying), boolString(isPlaying)); 2962 this, boolString(shouldBePlaying), boolString(isPlaying));
2927 2963
2928 if (shouldBePlaying) { 2964 if (shouldBePlaying) {
2929 setDisplayMode(Video); 2965 setDisplayMode(Video);
2930 invalidateCachedTime(); 2966 invalidateCachedTime();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
3002 } else { 3038 } else {
3003 m_networkState = NETWORK_IDLE; 3039 m_networkState = NETWORK_IDLE;
3004 } 3040 }
3005 3041
3006 // 5 - Set the element's delaying-the-load-event flag to false. This stops d elaying the load event. 3042 // 5 - Set the element's delaying-the-load-event flag to false. This stops d elaying the load event.
3007 setShouldDelayLoadEvent(false); 3043 setShouldDelayLoadEvent(false);
3008 3044
3009 // 6 - Abort the overall resource selection algorithm. 3045 // 6 - Abort the overall resource selection algorithm.
3010 m_currentSourceNode = nullptr; 3046 m_currentSourceNode = nullptr;
3011 3047
3012 // Reset m_readyState since m_player is gone. 3048 // Reset m_readyState since m_webMediaPlayer is gone.
3013 m_readyState = HAVE_NOTHING; 3049 m_readyState = HAVE_NOTHING;
3014 invalidateCachedTime(); 3050 invalidateCachedTime();
3015 updateMediaController(); 3051 updateMediaController();
3016 cueTimeline().updateActiveCues(0); 3052 cueTimeline().updateActiveCues(0);
3017 } 3053 }
3018 3054
3019 void HTMLMediaElement::clearMediaPlayerAndAudioSourceProviderClientWithoutLockin g() 3055 void HTMLMediaElement::clearMediaPlayerAndAudioSourceProviderClientWithoutLockin g()
3020 { 3056 {
3021 #if ENABLE(WEB_AUDIO) 3057 #if ENABLE(WEB_AUDIO)
3022 if (audioSourceProvider()) 3058 if (audioSourceProvider())
3023 audioSourceProvider()->setClient(0); 3059 audioSourceProvider()->setClient(0);
3024 #endif 3060 #endif
3025 m_player.clear(); 3061 m_webMediaPlayer.clear(); // Revisit
3026 } 3062 }
3027 3063
3028 void HTMLMediaElement::clearMediaPlayer(int flags) 3064 void HTMLMediaElement::clearMediaPlayer(int flags)
3029 { 3065 {
3030 forgetResourceSpecificTracks(); 3066 forgetResourceSpecificTracks();
3031 3067
3032 closeMediaSource(); 3068 closeMediaSource();
3033 3069
3034 cancelDeferredLoad(); 3070 cancelDeferredLoad();
3035 3071
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
3237 // the user agent should run the rules for updating the text track rendering 3273 // the user agent should run the rules for updating the text track rendering
3238 // of each of the text tracks in the video element's list of text tracks ... 3274 // of each of the text tracks in the video element's list of text tracks ...
3239 if (isHTMLVideoElement() && closedCaptionsVisible()) 3275 if (isHTMLVideoElement() && closedCaptionsVisible())
3240 ensureTextTrackContainer().updateDisplay(*this, TextTrackContainer::DidS tartExposingControls); 3276 ensureTextTrackContainer().updateDisplay(*this, TextTrackContainer::DidS tartExposingControls);
3241 } 3277 }
3242 3278
3243 void HTMLMediaElement::setClosedCaptionsVisible(bool closedCaptionVisible) 3279 void HTMLMediaElement::setClosedCaptionsVisible(bool closedCaptionVisible)
3244 { 3280 {
3245 WTF_LOG(Media, "HTMLMediaElement::setClosedCaptionsVisible(%p, %s)", this, b oolString(closedCaptionVisible)); 3281 WTF_LOG(Media, "HTMLMediaElement::setClosedCaptionsVisible(%p, %s)", this, b oolString(closedCaptionVisible));
3246 3282
3247 if (!m_player || !hasClosedCaptions()) 3283 if (!m_webMediaPlayer || !hasClosedCaptions()) // Revisit !m_webMediaPlayer check
3248 return; 3284 return;
3249 3285
3250 m_closedCaptionsVisible = closedCaptionVisible; 3286 m_closedCaptionsVisible = closedCaptionVisible;
3251 3287
3252 markCaptionAndSubtitleTracksAsUnconfigured(); 3288 markCaptionAndSubtitleTracksAsUnconfigured();
3253 m_processingPreferenceChange = true; 3289 m_processingPreferenceChange = true;
3254 honorUserPreferencesForAutomaticTextTrackSelection(); 3290 honorUserPreferencesForAutomaticTextTrackSelection();
3255 m_processingPreferenceChange = false; 3291 m_processingPreferenceChange = false;
3256 3292
3257 // As track visibility changed while m_processingPreferenceChange was set, 3293 // As track visibility changed while m_processingPreferenceChange was set,
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
3419 3455
3420 return nullptr; 3456 return nullptr;
3421 } 3457 }
3422 3458
3423 void HTMLMediaElement::createMediaPlayer() 3459 void HTMLMediaElement::createMediaPlayer()
3424 { 3460 {
3425 AudioSourceProviderClientLockScope scope(*this); 3461 AudioSourceProviderClientLockScope scope(*this);
3426 3462
3427 closeMediaSource(); 3463 closeMediaSource();
3428 3464
3429 m_player = MediaPlayer::create(this);
3430
3431 // We haven't yet found out if any remote routes are available. 3465 // We haven't yet found out if any remote routes are available.
3432 m_remoteRoutesAvailable = false; 3466 m_remoteRoutesAvailable = false;
3433 m_playingRemotely = false; 3467 m_playingRemotely = false;
3434
3435 #if ENABLE(WEB_AUDIO)
3436 if (m_audioSourceNode && audioSourceProvider()) {
3437 // When creating the player, make sure its AudioSourceProvider knows abo ut the client.
3438 audioSourceProvider()->setClient(m_audioSourceNode);
3439 }
3440 #endif
3441 } 3468 }
3442 3469
3443 #if ENABLE(WEB_AUDIO) 3470 #if ENABLE(WEB_AUDIO)
3444 void HTMLMediaElement::setAudioSourceNode(AudioSourceProviderClient* sourceNode) 3471 void HTMLMediaElement::setAudioSourceNode(AudioSourceProviderClient* sourceNode)
3445 { 3472 {
3446 m_audioSourceNode = sourceNode; 3473 m_audioSourceNode = sourceNode;
3447 3474
3448 AudioSourceProviderClientLockScope scope(*this); 3475 AudioSourceProviderClientLockScope scope(*this);
3449 if (audioSourceProvider()) 3476 if (audioSourceProvider())
3450 audioSourceProvider()->setClient(m_audioSourceNode); 3477 audioSourceProvider()->setClient(m_audioSourceNode);
3451 } 3478 }
3452 3479
3453 AudioSourceProvider* HTMLMediaElement::audioSourceProvider() 3480 AudioSourceProvider* HTMLMediaElement::audioSourceProvider()
3454 { 3481 {
3455 if (m_player) 3482 // null check
3456 return m_player->audioSourceProvider(); 3483 return &m_audioSourceProvider;
3457
3458 return nullptr;
3459 } 3484 }
3460 #endif 3485 #endif
3461 3486
3462 const AtomicString& HTMLMediaElement::mediaGroup() const 3487 const AtomicString& HTMLMediaElement::mediaGroup() const
3463 { 3488 {
3464 return fastGetAttribute(mediagroupAttr); 3489 return fastGetAttribute(mediagroupAttr);
3465 } 3490 }
3466 3491
3467 void HTMLMediaElement::setMediaGroup(const AtomicString& group) 3492 void HTMLMediaElement::setMediaGroup(const AtomicString& group)
3468 { 3493 {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
3561 WebMediaPlayer::CORSMode HTMLMediaElement::corsMode() const 3586 WebMediaPlayer::CORSMode HTMLMediaElement::corsMode() const
3562 { 3587 {
3563 const AtomicString& crossOriginMode = fastGetAttribute(crossoriginAttr); 3588 const AtomicString& crossOriginMode = fastGetAttribute(crossoriginAttr);
3564 if (crossOriginMode.isNull()) 3589 if (crossOriginMode.isNull())
3565 return WebMediaPlayer::CORSModeUnspecified; 3590 return WebMediaPlayer::CORSModeUnspecified;
3566 if (equalIgnoringCase(crossOriginMode, "use-credentials")) 3591 if (equalIgnoringCase(crossOriginMode, "use-credentials"))
3567 return WebMediaPlayer::CORSModeUseCredentials; 3592 return WebMediaPlayer::CORSModeUseCredentials;
3568 return WebMediaPlayer::CORSModeAnonymous; 3593 return WebMediaPlayer::CORSModeAnonymous;
3569 } 3594 }
3570 3595
3571 void HTMLMediaElement::mediaPlayerSetWebLayer(blink::WebLayer* webLayer) 3596 void HTMLMediaElement::setWebLayer(blink::WebLayer* webLayer)
3572 { 3597 {
3573 if (webLayer == m_webLayer) 3598 if (webLayer == m_webLayer)
3574 return; 3599 return;
3575 3600
3576 // If either of the layers is null we need to enable or disable compositing. This is done by triggering a style recalc. 3601 // If either of the layers is null we need to enable or disable compositing. This is done by triggering a style recalc.
3577 if ((!m_webLayer || !webLayer) 3602 if ((!m_webLayer || !webLayer)
3578 #if ENABLE(OILPAN) 3603 #if ENABLE(OILPAN)
3579 && !m_isFinalizing 3604 && !m_isFinalizing
3580 #endif 3605 #endif
3581 ) 3606 )
3582 setNeedsCompositingUpdate(); 3607 setNeedsCompositingUpdate();
3583 3608
3584 if (m_webLayer) 3609 if (m_webLayer)
3585 GraphicsLayer::unregisterContentsLayer(m_webLayer); 3610 GraphicsLayer::unregisterContentsLayer(m_webLayer);
3586 m_webLayer = webLayer; 3611 m_webLayer = webLayer;
3587 if (m_webLayer) 3612 if (m_webLayer)
3588 GraphicsLayer::registerContentsLayer(m_webLayer); 3613 GraphicsLayer::registerContentsLayer(m_webLayer);
3589 } 3614 }
3590 3615
3591 void HTMLMediaElement::mediaPlayerMediaSourceOpened(blink::WebMediaSource* webMe diaSource) 3616 void HTMLMediaElement::mediaSourceOpened(blink::WebMediaSource* webMediaSource)
3592 { 3617 {
3593 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource)); 3618 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource));
3594 } 3619 }
3595 3620
3596 bool HTMLMediaElement::isInteractiveContent() const 3621 bool HTMLMediaElement::isInteractiveContent() const
3597 { 3622 {
3598 return fastHasAttribute(controlsAttr); 3623 return fastHasAttribute(controlsAttr);
3599 } 3624 }
3600 3625
3601 void HTMLMediaElement::defaultEventHandler(Event* event) 3626 void HTMLMediaElement::defaultEventHandler(Event* event)
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
3652 3677
3653 // Enable the first audio track if an audio track hasn't been enabled yet. 3678 // Enable the first audio track if an audio track hasn't been enabled yet.
3654 if (audioTracks().length() > 0 && !audioTracks().hasEnabledTrack()) 3679 if (audioTracks().length() > 0 && !audioTracks().hasEnabledTrack())
3655 audioTracks().anonymousIndexedGetter(0)->setEnabled(true); 3680 audioTracks().anonymousIndexedGetter(0)->setEnabled(true);
3656 3681
3657 // Select the first video track if a video track hasn't been selected yet. 3682 // Select the first video track if a video track hasn't been selected yet.
3658 if (videoTracks().length() > 0 && videoTracks().selectedIndex() == -1) 3683 if (videoTracks().length() > 0 && videoTracks().selectedIndex() == -1)
3659 videoTracks().anonymousIndexedGetter(0)->setSelected(true); 3684 videoTracks().anonymousIndexedGetter(0)->setSelected(true);
3660 } 3685 }
3661 3686
3687 void HTMLMediaElement::loadMediaPlayer(const WTF::String& url)
3688 {
3689 ASSERT(!m_webMediaPlayer);
3690
3691 WebURL poster = mediaPlayerPosterURL();
3692
3693 KURL kurl(ParsedURLString, url);
3694 LocalFrame* frame = document().frame();
3695 ASSERT(frame);
3696 m_webMediaPlayer = frame->loader().client()->createWebMediaPlayer(this, kurl );
3697 if (!m_webMediaPlayer)
3698 return;
3699
3700 #if ENABLE(WEB_AUDIO)
3701 // Make sure if we create/re-create the WebMediaPlayer that we update our wr apper.
3702 m_audioSourceProvider.wrap(m_webMediaPlayer->audioSourceProvider());
3703 #endif
3704 m_webMediaPlayer->setVolume(effectiveMediaVolume());
3705
3706 m_webMediaPlayer->setPoster(poster);
3707
3708 m_webMediaPlayer->setPreload(preloadType());
3709
3710 m_webMediaPlayer->load(loadType(), kurl, corsMode());
3711
3712 if (isFullscreen())
3713 m_webMediaPlayer->enterFullscreen();
3714 }
3715
3662 #if ENABLE(WEB_AUDIO) 3716 #if ENABLE(WEB_AUDIO)
3663 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) 3717 void HTMLMediaElement::clearWeakMembers(Visitor* visitor)
3664 { 3718 {
3665 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) 3719 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider())
3666 audioSourceProvider()->setClient(nullptr); 3720 audioSourceProvider()->setClient(nullptr);
3667 } 3721 }
3722
3723 void HTMLMediaElement::AudioSourceProviderImpl::wrap(WebAudioSourceProvider* pro vider)
3724 {
3725 MutexLocker locker(provideInputLock);
3726
3727 if (m_webAudioSourceProvider && provider != m_webAudioSourceProvider)
3728 m_webAudioSourceProvider->setClient(0);
3729
3730 m_webAudioSourceProvider = provider;
3731 if (m_webAudioSourceProvider)
3732 m_webAudioSourceProvider->setClient(m_client.get());
3733 }
3734
3735 void HTMLMediaElement::AudioSourceProviderImpl::setClient(AudioSourceProviderCli ent* client)
3736 {
3737 MutexLocker locker(provideInputLock);
3738
3739 if (client)
3740 m_client = new HTMLMediaElement::AudioClientImpl(client);
3741 else
3742 m_client.clear();
3743
3744 if (m_webAudioSourceProvider)
3745 m_webAudioSourceProvider->setClient(m_client.get());
3746 }
3747
3748 void HTMLMediaElement::AudioSourceProviderImpl::provideInput(blink::AudioBus* bu s, size_t framesToProcess)
3749 {
3750 ASSERT(bus);
3751 if (!bus)
3752 return;
3753
3754 MutexTryLocker tryLocker(provideInputLock);
3755 if (!tryLocker.locked() || !m_webAudioSourceProvider || !m_client.get()) {
3756 bus->zero();
3757 return;
3758 }
3759
3760 // Wrap the AudioBus channel data using WebVector.
3761 size_t n = bus->numberOfChannels();
3762 WebVector<float*> webAudioData(n);
3763 for (size_t i = 0; i < n; ++i)
3764 webAudioData[i] = bus->channel(i)->mutableData();
3765
3766 m_webAudioSourceProvider->provideInput(webAudioData, framesToProcess);
3767 }
3768
3769 void HTMLMediaElement::AudioClientImpl::setFormat(size_t numberOfChannels, float sampleRate)
3770 {
3771 if (m_client)
3772 m_client->setFormat(numberOfChannels, sampleRate);
3773 }
3774
3775 DEFINE_TRACE(HTMLMediaElement::AudioClientImpl)
3776 {
3777 visitor->trace(m_client);
3778 }
3668 #endif 3779 #endif
3669 3780
3670 } 3781 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698