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

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

Issue 1055503002: Eliminate MediaPlayer & MediaPlayerClient abstractions (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added separate interface for EncryptedMedia Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 #include "core/html/track/CueTimeline.h" 56 #include "core/html/track/CueTimeline.h"
57 #include "core/html/track/InbandTextTrack.h" 57 #include "core/html/track/InbandTextTrack.h"
58 #include "core/html/track/TextTrackContainer.h" 58 #include "core/html/track/TextTrackContainer.h"
59 #include "core/html/track/TextTrackList.h" 59 #include "core/html/track/TextTrackList.h"
60 #include "core/html/track/VideoTrack.h" 60 #include "core/html/track/VideoTrack.h"
61 #include "core/html/track/VideoTrackList.h" 61 #include "core/html/track/VideoTrackList.h"
62 #include "core/layout/LayoutVideo.h" 62 #include "core/layout/LayoutVideo.h"
63 #include "core/layout/LayoutView.h" 63 #include "core/layout/LayoutView.h"
64 #include "core/layout/compositing/DeprecatedPaintLayerCompositor.h" 64 #include "core/layout/compositing/DeprecatedPaintLayerCompositor.h"
65 #include "core/loader/FrameLoader.h" 65 #include "core/loader/FrameLoader.h"
66 #include "core/loader/FrameLoaderClient.h"
66 #include "platform/ContentType.h" 67 #include "platform/ContentType.h"
67 #include "platform/Logging.h" 68 #include "platform/Logging.h"
68 #include "platform/MIMETypeFromURL.h" 69 #include "platform/MIMETypeFromURL.h"
69 #include "platform/MIMETypeRegistry.h" 70 #include "platform/MIMETypeRegistry.h"
70 #include "platform/RuntimeEnabledFeatures.h" 71 #include "platform/RuntimeEnabledFeatures.h"
71 #include "platform/UserGestureIndicator.h" 72 #include "platform/UserGestureIndicator.h"
73 #include "platform/audio/AudioBus.h"
74 #include "platform/audio/AudioSourceProviderClient.h"
72 #include "platform/graphics/GraphicsLayer.h" 75 #include "platform/graphics/GraphicsLayer.h"
73 #include "platform/weborigin/SecurityOrigin.h" 76 #include "platform/weborigin/SecurityOrigin.h"
74 #include "public/platform/Platform.h" 77 #include "public/platform/Platform.h"
78 #include "public/platform/WebAudioSourceProvider.h"
75 #include "public/platform/WebContentDecryptionModule.h" 79 #include "public/platform/WebContentDecryptionModule.h"
76 #include "public/platform/WebInbandTextTrack.h" 80 #include "public/platform/WebInbandTextTrack.h"
77 #include "wtf/CurrentTime.h" 81 #include "wtf/CurrentTime.h"
78 #include "wtf/MathExtras.h" 82 #include "wtf/MathExtras.h"
79 #include "wtf/text/CString.h" 83 #include "wtf/text/CString.h"
80 #include <limits> 84 #include <limits>
81 85
82 #if ENABLE(WEB_AUDIO) 86 #if ENABLE(WEB_AUDIO)
83 #include "platform/audio/AudioSourceProvider.h" 87 #include "platform/audio/AudioSourceProvider.h"
84 #include "platform/audio/AudioSourceProviderClient.h" 88 #include "platform/audio/AudioSourceProviderClient.h"
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 , m_lastSeekTime(0) 327 , m_lastSeekTime(0)
324 , m_previousProgressTime(std::numeric_limits<double>::max()) 328 , m_previousProgressTime(std::numeric_limits<double>::max())
325 , m_duration(std::numeric_limits<double>::quiet_NaN()) 329 , m_duration(std::numeric_limits<double>::quiet_NaN())
326 , m_lastTimeUpdateEventWallTime(0) 330 , m_lastTimeUpdateEventWallTime(0)
327 , m_lastTimeUpdateEventMovieTime(0) 331 , m_lastTimeUpdateEventMovieTime(0)
328 , m_defaultPlaybackStartPosition(0) 332 , m_defaultPlaybackStartPosition(0)
329 , m_loadState(WaitingForSource) 333 , m_loadState(WaitingForSource)
330 , m_deferredLoadState(NotDeferred) 334 , m_deferredLoadState(NotDeferred)
331 , m_deferredLoadTimer(this, &HTMLMediaElement::deferredLoadTimerFired) 335 , m_deferredLoadTimer(this, &HTMLMediaElement::deferredLoadTimerFired)
332 , m_webLayer(nullptr) 336 , m_webLayer(nullptr)
333 , m_preload(MediaPlayer::Auto) 337 , m_preload(WebMediaPlayer::PreloadAuto)
334 , m_displayMode(Unknown) 338 , m_displayMode(Unknown)
335 , m_cachedTime(std::numeric_limits<double>::quiet_NaN()) 339 , m_cachedTime(std::numeric_limits<double>::quiet_NaN())
336 , m_fragmentEndTime(std::numeric_limits<double>::quiet_NaN()) 340 , m_fragmentEndTime(std::numeric_limits<double>::quiet_NaN())
337 , m_pendingActionFlags(0) 341 , m_pendingActionFlags(0)
338 , m_userGestureRequiredForPlay(false) 342 , m_userGestureRequiredForPlay(false)
339 , m_playing(false) 343 , m_playing(false)
340 , m_shouldDelayLoadEvent(false) 344 , m_shouldDelayLoadEvent(false)
341 , m_haveFiredLoadedData(false) 345 , m_haveFiredLoadedData(false)
342 , m_autoplaying(true) 346 , m_autoplaying(true)
343 , m_muted(false) 347 , m_muted(false)
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 } 483 }
480 #endif 484 #endif
481 485
482 void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument) 486 void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument)
483 { 487 {
484 WTF_LOG(Media, "HTMLMediaElement::didMoveToNewDocument(%p)", this); 488 WTF_LOG(Media, "HTMLMediaElement::didMoveToNewDocument(%p)", this);
485 489
486 if (m_shouldDelayLoadEvent) { 490 if (m_shouldDelayLoadEvent) {
487 document().incrementLoadEventDelayCount(); 491 document().incrementLoadEventDelayCount();
488 // Note: Keeping the load event delay count increment on oldDocument tha t was added 492 // 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 493 // when m_shouldDelayLoadEvent was set so that destruction of m_webMedia Player can not
490 // cause load event dispatching in oldDocument. 494 // cause load event dispatching in oldDocument.
491 } else { 495 } else {
492 // Incrementing the load event delay count so that destruction of m_play er can not 496 // Incrementing the load event delay count so that destruction of m_webM ediaPlayer can not
493 // cause load event dispatching in oldDocument. 497 // cause load event dispatching in oldDocument.
494 oldDocument.incrementLoadEventDelayCount(); 498 oldDocument.incrementLoadEventDelayCount();
495 } 499 }
496 500
497 removeElementFromDocumentMap(this, &oldDocument); 501 removeElementFromDocumentMap(this, &oldDocument);
498 addElementToDocumentMap(this, &document()); 502 addElementToDocumentMap(this, &document());
499 503
500 // FIXME: This is a temporary fix to prevent this object from causing the 504 // FIXME: This is a temporary fix to prevent this object from causing the
501 // MediaPlayer to dereference LocalFrame and FrameLoader pointers from the 505 // MediaPlayer to dereference LocalFrame and FrameLoader pointers from the
502 // previous document. A proper fix would provide a mechanism to allow this 506 // previous document. A proper fix would provide a mechanism to allow this
503 // object to refresh the MediaPlayer's LocalFrame and FrameLoader references on 507 // object to refresh the MediaPlayer's LocalFrame and FrameLoader references on
504 // document changes so that playback can be resumed properly. 508 // document changes so that playback can be resumed properly.
505 userCancelledLoad(); 509 userCancelledLoad();
506 510
507 // Decrement the load event delay count on oldDocument now that m_player has been destroyed 511 // 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. 512 // and there is no risk of dispatching a load event from within the destruct or.
509 oldDocument.decrementLoadEventDelayCount(); 513 oldDocument.decrementLoadEventDelayCount();
510 514
511 ActiveDOMObject::didMoveToNewExecutionContext(&document()); 515 ActiveDOMObject::didMoveToNewExecutionContext(&document());
512 HTMLElement::didMoveToNewDocument(oldDocument); 516 HTMLElement::didMoveToNewDocument(oldDocument);
513 } 517 }
514 518
515 bool HTMLMediaElement::supportsFocus() const 519 bool HTMLMediaElement::supportsFocus() const
516 { 520 {
517 if (ownerDocument()->isMediaDocument()) 521 if (ownerDocument()->isMediaDocument())
(...skipping 13 matching lines...) Expand all
531 if (name == srcAttr) { 535 if (name == srcAttr) {
532 // Trigger a reload, as long as the 'src' attribute is present. 536 // Trigger a reload, as long as the 'src' attribute is present.
533 if (!value.isNull()) { 537 if (!value.isNull()) {
534 clearMediaPlayer(LoadMediaResource); 538 clearMediaPlayer(LoadMediaResource);
535 scheduleDelayedAction(LoadMediaResource); 539 scheduleDelayedAction(LoadMediaResource);
536 } 540 }
537 } else if (name == controlsAttr) { 541 } else if (name == controlsAttr) {
538 configureMediaControls(); 542 configureMediaControls();
539 } else if (name == preloadAttr) { 543 } else if (name == preloadAttr) {
540 if (equalIgnoringCase(value, "none")) { 544 if (equalIgnoringCase(value, "none")) {
541 m_preload = MediaPlayer::None; 545 m_preload = WebMediaPlayer::PreloadNone;
542 } else if (equalIgnoringCase(value, "metadata")) { 546 } else if (equalIgnoringCase(value, "metadata")) {
543 m_preload = MediaPlayer::MetaData; 547 m_preload = WebMediaPlayer::PreloadMetaData;
544 } else { 548 } else {
545 // The spec does not define an "invalid value default" but "auto" is suggested as the 549 // 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" 550 // "missing value default", so use it for everything except "none" a nd "metadata"
547 m_preload = MediaPlayer::Auto; 551 m_preload = WebMediaPlayer::PreloadAuto;
548 } 552 }
549 553
550 // The attribute must be ignored if the autoplay attribute is present 554 // The attribute must be ignored if the autoplay attribute is present
551 if (!autoplay() && m_player) 555 if (!autoplay())
philipj_slow 2015/05/06 15:39:32 Is dropping the m_player bit entirely equivalent?
Srirama 2015/05/19 10:39:46 I have added the webmediaplayer check to be on saf
552 setPlayerPreload(); 556 setPlayerPreload();
553 557
554 } else if (name == mediagroupAttr && RuntimeEnabledFeatures::mediaController Enabled()) { 558 } else if (name == mediagroupAttr && RuntimeEnabledFeatures::mediaController Enabled()) {
555 setMediaGroup(value); 559 setMediaGroup(value);
556 } else { 560 } else {
557 HTMLElement::parseAttribute(name, value); 561 HTMLElement::parseAttribute(name, value);
558 } 562 }
559 } 563 }
560 564
561 void HTMLMediaElement::finishParsingChildren() 565 void HTMLMediaElement::finishParsingChildren()
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 m_mediaSource = nullptr; 986 m_mediaSource = nullptr;
983 attemptLoad = false; 987 attemptLoad = false;
984 } 988 }
985 } 989 }
986 } 990 }
987 } 991 }
988 992
989 if (attemptLoad && canLoadURL(url, contentType, keySystem)) { 993 if (attemptLoad && canLoadURL(url, contentType, keySystem)) {
990 ASSERT(!webMediaPlayer()); 994 ASSERT(!webMediaPlayer());
991 995
992 if (!m_havePreparedToPlay && !autoplay() && m_preload == MediaPlayer::No ne) { 996 if (!m_havePreparedToPlay && !autoplay() && m_preload == WebMediaPlayer: :PreloadNone) {
993 WTF_LOG(Media, "HTMLMediaElement::loadResource(%p) : Delaying load b ecause preload == 'none'", this); 997 WTF_LOG(Media, "HTMLMediaElement::loadResource(%p) : Delaying load b ecause preload == 'none'", this);
994 deferLoad(); 998 deferLoad();
995 } else { 999 } else {
996 startPlayerLoad(); 1000 startPlayerLoad();
997 } 1001 }
998 } else { 1002 } else {
999 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); 1003 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError);
1000 } 1004 }
1001 1005
1002 // If there is no poster to display, allow the media engine to render video frames as soon as 1006 // 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 1025 // along with that potentially also specifying a setting for its
1022 // 'authentication flag' to control how user:pass embedded in a 1026 // 'authentication flag' to control how user:pass embedded in a
1023 // media resource URL should be treated, then update the handling 1027 // media resource URL should be treated, then update the handling
1024 // here to match. 1028 // here to match.
1025 KURL requestURL = m_currentSrc; 1029 KURL requestURL = m_currentSrc;
1026 if (!requestURL.user().isEmpty()) 1030 if (!requestURL.user().isEmpty())
1027 requestURL.setUser(String()); 1031 requestURL.setUser(String());
1028 if (!requestURL.pass().isEmpty()) 1032 if (!requestURL.pass().isEmpty())
1029 requestURL.setPass(String()); 1033 requestURL.setPass(String());
1030 1034
1031 m_player->load(loadType(), requestURL, corsMode()); 1035 loadMediaPlayer(requestURL);
1032 } 1036 }
1033 1037
1034 void HTMLMediaElement::setPlayerPreload() 1038 void HTMLMediaElement::setPlayerPreload()
1035 { 1039 {
1036 m_player->setPreload(m_preload); 1040 if (m_webMediaPlayer)
philipj_slow 2015/05/06 15:39:33 The code doesn't looks quite like this any more, s
Srirama 2015/05/19 10:39:46 Rebased to latest.
1041 m_webMediaPlayer->setPreload(m_preload);
1037 1042
1038 if (loadIsDeferred() && m_preload != MediaPlayer::None) 1043 if (loadIsDeferred() && m_preload != WebMediaPlayer::PreloadNone)
1039 startDeferredLoad(); 1044 startDeferredLoad();
1040 } 1045 }
1041 1046
1042 bool HTMLMediaElement::loadIsDeferred() const 1047 bool HTMLMediaElement::loadIsDeferred() const
1043 { 1048 {
1044 return m_deferredLoadState != NotDeferred; 1049 return m_deferredLoadState != NotDeferred;
1045 } 1050 }
1046 1051
1047 void HTMLMediaElement::deferLoad() 1052 void HTMLMediaElement::deferLoad()
1048 { 1053 {
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
1292 1297
1293 void HTMLMediaElement::cancelPendingEventsAndCallbacks() 1298 void HTMLMediaElement::cancelPendingEventsAndCallbacks()
1294 { 1299 {
1295 WTF_LOG(Media, "HTMLMediaElement::cancelPendingEventsAndCallbacks(%p)", this ); 1300 WTF_LOG(Media, "HTMLMediaElement::cancelPendingEventsAndCallbacks(%p)", this );
1296 m_asyncEventQueue->cancelAllEvents(); 1301 m_asyncEventQueue->cancelAllEvents();
1297 1302
1298 for (HTMLSourceElement* source = Traversal<HTMLSourceElement>::firstChild(*t his); source; source = Traversal<HTMLSourceElement>::nextSibling(*source)) 1303 for (HTMLSourceElement* source = Traversal<HTMLSourceElement>::firstChild(*t his); source; source = Traversal<HTMLSourceElement>::nextSibling(*source))
1299 source->cancelPendingErrorEvent(); 1304 source->cancelPendingErrorEvent();
1300 } 1305 }
1301 1306
1302 void HTMLMediaElement::mediaPlayerNetworkStateChanged() 1307 void HTMLMediaElement::networkStateChanged()
1303 { 1308 {
1304 setNetworkState(webMediaPlayer()->networkState()); 1309 setNetworkState(webMediaPlayer()->networkState());
1305 } 1310 }
1306 1311
1307 void HTMLMediaElement::mediaLoadingFailed(WebMediaPlayer::NetworkState error) 1312 void HTMLMediaElement::mediaLoadingFailed(WebMediaPlayer::NetworkState error)
1308 { 1313 {
1309 stopPeriodicTimers(); 1314 stopPeriodicTimers();
1310 1315
1311 // If we failed while trying to load a <source> element, the movie was never parsed, and there are more 1316 // 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 1317 // <source> children, schedule the next one
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1383 1388
1384 if (state == WebMediaPlayer::NetworkStateLoaded) { 1389 if (state == WebMediaPlayer::NetworkStateLoaded) {
1385 if (m_networkState != NETWORK_IDLE) 1390 if (m_networkState != NETWORK_IDLE)
1386 changeNetworkStateFromLoadingToIdle(); 1391 changeNetworkStateFromLoadingToIdle();
1387 m_completelyLoaded = true; 1392 m_completelyLoaded = true;
1388 } 1393 }
1389 } 1394 }
1390 1395
1391 void HTMLMediaElement::changeNetworkStateFromLoadingToIdle() 1396 void HTMLMediaElement::changeNetworkStateFromLoadingToIdle()
1392 { 1397 {
1393 ASSERT(m_player);
1394 m_progressEventTimer.stop(); 1398 m_progressEventTimer.stop();
1395 1399
1396 // Schedule one last progress event so we guarantee that at least one is fir ed 1400 // Schedule one last progress event so we guarantee that at least one is fir ed
1397 // for files that load very quickly. 1401 // for files that load very quickly.
1398 if (webMediaPlayer() && webMediaPlayer()->didLoadingProgress()) 1402 if (webMediaPlayer() && webMediaPlayer()->didLoadingProgress())
1399 scheduleEvent(EventTypeNames::progress); 1403 scheduleEvent(EventTypeNames::progress);
1400 scheduleEvent(EventTypeNames::suspend); 1404 scheduleEvent(EventTypeNames::suspend);
1401 m_networkState = NETWORK_IDLE; 1405 m_networkState = NETWORK_IDLE;
1402 } 1406 }
1403 1407
1404 void HTMLMediaElement::mediaPlayerReadyStateChanged() 1408 void HTMLMediaElement::readyStateChanged()
1405 { 1409 {
1406 setReadyState(static_cast<ReadyState>(webMediaPlayer()->readyState())); 1410 setReadyState(static_cast<ReadyState>(webMediaPlayer()->readyState()));
1407 } 1411 }
1408 1412
1409 void HTMLMediaElement::setReadyState(ReadyState state) 1413 void HTMLMediaElement::setReadyState(ReadyState state)
1410 { 1414 {
1411 WTF_LOG(Media, "HTMLMediaElement::setReadyState(%p, %d) - current state is % d,", this, static_cast<int>(state), static_cast<int>(m_readyState)); 1415 WTF_LOG(Media, "HTMLMediaElement::setReadyState(%p, %d) - current state is % d,", this, static_cast<int>(state), static_cast<int>(m_readyState));
1412 1416
1413 // Set "wasPotentiallyPlaying" BEFORE updating m_readyState, potentiallyPlay ing() uses it 1417 // Set "wasPotentiallyPlaying" BEFORE updating m_readyState, potentiallyPlay ing() uses it
1414 bool wasPotentiallyPlaying = potentiallyPlaying(); 1418 bool wasPotentiallyPlaying = potentiallyPlaying();
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1549 mediaControls()->refreshClosedCaptionsButtonVisibility(); 1553 mediaControls()->refreshClosedCaptionsButtonVisibility();
1550 } 1554 }
1551 1555
1552 updatePlayState(); 1556 updatePlayState();
1553 updateMediaController(); 1557 updateMediaController();
1554 cueTimeline().updateActiveCues(currentTime()); 1558 cueTimeline().updateActiveCues(currentTime());
1555 } 1559 }
1556 1560
1557 void HTMLMediaElement::progressEventTimerFired(Timer<HTMLMediaElement>*) 1561 void HTMLMediaElement::progressEventTimerFired(Timer<HTMLMediaElement>*)
1558 { 1562 {
1559 ASSERT(m_player);
1560 if (m_networkState != NETWORK_LOADING) 1563 if (m_networkState != NETWORK_LOADING)
1561 return; 1564 return;
1562 1565
1563 double time = WTF::currentTime(); 1566 double time = WTF::currentTime();
1564 double timedelta = time - m_previousProgressTime; 1567 double timedelta = time - m_previousProgressTime;
1565 1568
1566 if (webMediaPlayer() && webMediaPlayer()->didLoadingProgress()) { 1569 if (webMediaPlayer() && webMediaPlayer()->didLoadingProgress()) {
1567 scheduleEvent(EventTypeNames::progress); 1570 scheduleEvent(EventTypeNames::progress);
1568 m_previousProgressTime = time; 1571 m_previousProgressTime = time;
1569 m_sentStalledEvent = false; 1572 m_sentStalledEvent = false;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1602 1605
1603 void HTMLMediaElement::seek(double time) 1606 void HTMLMediaElement::seek(double time)
1604 { 1607 {
1605 WTF_LOG(Media, "HTMLMediaElement::seek(%p, %f)", this, time); 1608 WTF_LOG(Media, "HTMLMediaElement::seek(%p, %f)", this, time);
1606 1609
1607 // 2 - If the media element's readyState is HAVE_NOTHING, abort these steps. 1610 // 2 - If the media element's readyState is HAVE_NOTHING, abort these steps.
1608 if (m_readyState == HAVE_NOTHING) 1611 if (m_readyState == HAVE_NOTHING)
1609 return; 1612 return;
1610 1613
1611 // If the media engine has been told to postpone loading data, let it go ahe ad now. 1614 // 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) 1615 if (m_preload < WebMediaPlayer::PreloadAuto && m_readyState < HAVE_FUTURE_DA TA)
1613 prepareToPlay(); 1616 prepareToPlay();
1614 1617
1615 // Get the current time before setting m_seeking, m_lastSeekTime is returned once it is set. 1618 // Get the current time before setting m_seeking, m_lastSeekTime is returned once it is set.
1616 refreshCachedTime(); 1619 refreshCachedTime();
1617 // This is needed to avoid getting default playback start position from curr entTime(). 1620 // This is needed to avoid getting default playback start position from curr entTime().
1618 double now = m_cachedTime; 1621 double now = m_cachedTime;
1619 1622
1620 // 3 - If the element's seeking IDL attribute is true, then another instance of this algorithm is 1623 // 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 1624 // already running. Abort that other instance of the algorithm without waiti ng for the step that
1622 // it is running to complete. 1625 // it is running to complete.
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1776 if (m_readyState == HAVE_NOTHING) { 1779 if (m_readyState == HAVE_NOTHING) {
1777 m_defaultPlaybackStartPosition = time; 1780 m_defaultPlaybackStartPosition = time;
1778 return; 1781 return;
1779 } 1782 }
1780 1783
1781 seek(time); 1784 seek(time);
1782 } 1785 }
1783 1786
1784 double HTMLMediaElement::duration() const 1787 double HTMLMediaElement::duration() const
1785 { 1788 {
1786 // FIXME: remove m_player check once we figure out how m_player is going 1789 // FIXME: remove m_webMediaPlayer check once we figure out how m_webMediaPla yer is going
philipj_slow 2015/05/06 15:39:33 It seems somewhat likely that this problem will ma
Srirama 2015/05/19 10:39:46 keeping it for time being as per the below comment
1787 // out of sync with readystate. m_player is cleared but readystate is not se t 1790 // out of sync with readystate. m_webMediaPlayer is cleared but readystate i s not set
1788 // to HAVE_NOTHING 1791 // to HAVE_NOTHING
1789 if (!m_player || m_readyState < HAVE_METADATA) 1792 if (!m_webMediaPlayer || m_readyState < HAVE_METADATA)
1790 return std::numeric_limits<double>::quiet_NaN(); 1793 return std::numeric_limits<double>::quiet_NaN();
1791 1794
1792 // FIXME: Refactor so m_duration is kept current (in both MSE and 1795 // FIXME: Refactor so m_duration is kept current (in both MSE and
1793 // non-MSE cases) once we have transitioned from HAVE_NOTHING -> 1796 // 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 1797 // 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 1798 // case because MediaSource and SourceBuffer do not notify the element
1796 // directly upon duration changes caused by endOfStream, remove, or append 1799 // directly upon duration changes caused by endOfStream, remove, or append
1797 // operations; rather the notification is triggered by the WebMediaPlayer 1800 // operations; rather the notification is triggered by the WebMediaPlayer
1798 // implementation observing that the underlying engine has updated duration 1801 // implementation observing that the underlying engine has updated duration
1799 // and notifying the element to consult its MediaSource for current 1802 // and notifying the element to consult its MediaSource for current
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1848 } 1851 }
1849 1852
1850 HTMLMediaElement::DirectionOfPlayback HTMLMediaElement::directionOfPlayback() co nst 1853 HTMLMediaElement::DirectionOfPlayback HTMLMediaElement::directionOfPlayback() co nst
1851 { 1854 {
1852 return m_playbackRate >= 0 ? Forward : Backward; 1855 return m_playbackRate >= 0 ? Forward : Backward;
1853 } 1856 }
1854 1857
1855 void HTMLMediaElement::updatePlaybackRate() 1858 void HTMLMediaElement::updatePlaybackRate()
1856 { 1859 {
1857 double effectiveRate = effectivePlaybackRate(); 1860 double effectiveRate = effectivePlaybackRate();
1858 if (m_player && potentiallyPlaying()) 1861 if (potentiallyPlaying())
philipj_slow 2015/05/06 15:39:32 This doesn't quite jive with the FIXME in HTMLMedi
Srirama 2015/05/19 10:39:46 Logically what you were saying is correct, in both
1859 webMediaPlayer()->setRate(effectiveRate); 1862 webMediaPlayer()->setRate(effectiveRate);
1860 } 1863 }
1861 1864
1862 bool HTMLMediaElement::ended() const 1865 bool HTMLMediaElement::ended() const
1863 { 1866 {
1864 // 4.8.10.8 Playing the media resource 1867 // 4.8.10.8 Playing the media resource
1865 // The ended attribute must return true if the media element has ended 1868 // The ended attribute must return true if the media element has ended
1866 // playback and the direction of playback is forwards, and false otherwise. 1869 // playback and the direction of playback is forwards, and false otherwise.
1867 return endedPlayback() && directionOfPlayback() == Forward; 1870 return endedPlayback() && directionOfPlayback() == Forward;
1868 } 1871 }
1869 1872
1870 bool HTMLMediaElement::autoplay() const 1873 bool HTMLMediaElement::autoplay() const
1871 { 1874 {
1872 return fastHasAttribute(autoplayAttr); 1875 return fastHasAttribute(autoplayAttr);
1873 } 1876 }
1874 1877
1875 String HTMLMediaElement::preload() const 1878 String HTMLMediaElement::preload() const
1876 { 1879 {
1877 switch (m_preload) { 1880 switch (m_preload) {
1878 case MediaPlayer::None: 1881 case WebMediaPlayer::PreloadNone:
1879 return "none"; 1882 return "none";
1880 break; 1883 break;
1881 case MediaPlayer::MetaData: 1884 case WebMediaPlayer::PreloadMetaData:
1882 return "metadata"; 1885 return "metadata";
1883 break; 1886 break;
1884 case MediaPlayer::Auto: 1887 case WebMediaPlayer::PreloadAuto:
1885 return "auto"; 1888 return "auto";
1886 break; 1889 break;
1887 } 1890 }
1888 1891
1889 ASSERT_NOT_REACHED(); 1892 ASSERT_NOT_REACHED();
1890 return String(); 1893 return String();
1891 } 1894 }
1892 1895
1893 void HTMLMediaElement::setPreload(const AtomicString& preload) 1896 void HTMLMediaElement::setPreload(const AtomicString& preload)
1894 { 1897 {
(...skipping 16 matching lines...) Expand all
1911 } 1914 }
1912 1915
1913 playInternal(); 1916 playInternal();
1914 } 1917 }
1915 1918
1916 void HTMLMediaElement::playInternal() 1919 void HTMLMediaElement::playInternal()
1917 { 1920 {
1918 WTF_LOG(Media, "HTMLMediaElement::playInternal(%p)", this); 1921 WTF_LOG(Media, "HTMLMediaElement::playInternal(%p)", this);
1919 1922
1920 // 4.8.10.9. Playing the media resource 1923 // 4.8.10.9. Playing the media resource
1921 if (!m_player || m_networkState == NETWORK_EMPTY) 1924 if (m_networkState == NETWORK_EMPTY)
1922 scheduleDelayedAction(LoadMediaResource); 1925 scheduleDelayedAction(LoadMediaResource);
1923 1926
1924 // Generally "ended" and "looping" are exclusive. Here, the loop attribute 1927 // 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 1928 // is ignored to seek back to start in case loop was set after playback
1926 // ended. See http://crbug.com/364442 1929 // ended. See http://crbug.com/364442
1927 if (endedPlayback(LoopCondition::Ignored)) 1930 if (endedPlayback(LoopCondition::Ignored))
1928 seek(0); 1931 seek(0);
1929 1932
1930 if (m_mediaController) 1933 if (m_mediaController)
1931 m_mediaController->bringElementUpToSpeed(this); 1934 m_mediaController->bringElementUpToSpeed(this);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1971 double progress = playedTime / duration(); 1974 double progress = playedTime / duration();
1972 if (progress < 0.5) 1975 if (progress < 0.5)
1973 recordAutoplayMetric(AutoplayBailout); 1976 recordAutoplayMetric(AutoplayBailout);
1974 } 1977 }
1975 } 1978 }
1976 1979
1977 void HTMLMediaElement::pause() 1980 void HTMLMediaElement::pause()
1978 { 1981 {
1979 WTF_LOG(Media, "HTMLMediaElement::pause(%p)", this); 1982 WTF_LOG(Media, "HTMLMediaElement::pause(%p)", this);
1980 1983
1981 if (!m_player || m_networkState == NETWORK_EMPTY) 1984 if (m_networkState == NETWORK_EMPTY)
1982 scheduleDelayedAction(LoadMediaResource); 1985 scheduleDelayedAction(LoadMediaResource);
1983 1986
1984 m_autoplaying = false; 1987 m_autoplaying = false;
1985 1988
1986 if (!m_paused) { 1989 if (!m_paused) {
1987 if (m_initialPlayWithoutUserGestures) 1990 if (m_initialPlayWithoutUserGestures)
1988 gesturelessInitialPlayHalted(); 1991 gesturelessInitialPlayHalted();
1989 1992
1990 m_paused = true; 1993 m_paused = true;
1991 scheduleTimeupdateEvent(false); 1994 scheduleTimeupdateEvent(false);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
2116 { 2119 {
2117 if (m_playbackProgressTimer.isActive()) 2120 if (m_playbackProgressTimer.isActive())
2118 return; 2121 return;
2119 2122
2120 m_previousProgressTime = WTF::currentTime(); 2123 m_previousProgressTime = WTF::currentTime();
2121 m_playbackProgressTimer.startRepeating(maxTimeupdateEventFrequency, FROM_HER E); 2124 m_playbackProgressTimer.startRepeating(maxTimeupdateEventFrequency, FROM_HER E);
2122 } 2125 }
2123 2126
2124 void HTMLMediaElement::playbackProgressTimerFired(Timer<HTMLMediaElement>*) 2127 void HTMLMediaElement::playbackProgressTimerFired(Timer<HTMLMediaElement>*)
2125 { 2128 {
2126 ASSERT(m_player); 2129 ASSERT(m_webMediaPlayer);
2127 2130
2128 if (!std::isnan(m_fragmentEndTime) && currentTime() >= m_fragmentEndTime && directionOfPlayback() == Forward) { 2131 if (!std::isnan(m_fragmentEndTime) && currentTime() >= m_fragmentEndTime && directionOfPlayback() == Forward) {
2129 m_fragmentEndTime = std::numeric_limits<double>::quiet_NaN(); 2132 m_fragmentEndTime = std::numeric_limits<double>::quiet_NaN();
2130 if (!m_mediaController && !m_paused) { 2133 if (!m_mediaController && !m_paused) {
2131 UseCounter::count(document(), UseCounter::HTMLMediaElementPauseAtFra gmentEnd); 2134 UseCounter::count(document(), UseCounter::HTMLMediaElementPauseAtFra gmentEnd);
2132 // changes paused to true and fires a simple event named pause at th e media element. 2135 // changes paused to true and fires a simple event named pause at th e media element.
2133 pause(); 2136 pause();
2134 } 2137 }
2135 } 2138 }
2136 2139
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
2212 Vector<WebMediaPlayer::TrackId> enabledTrackIds; 2215 Vector<WebMediaPlayer::TrackId> enabledTrackIds;
2213 for (unsigned i = 0; i < audioTracks().length(); ++i) { 2216 for (unsigned i = 0; i < audioTracks().length(); ++i) {
2214 AudioTrack* track = audioTracks().anonymousIndexedGetter(i); 2217 AudioTrack* track = audioTracks().anonymousIndexedGetter(i);
2215 if (track->enabled()) 2218 if (track->enabled())
2216 enabledTrackIds.append(track->trackId()); 2219 enabledTrackIds.append(track->trackId());
2217 } 2220 }
2218 2221
2219 webMediaPlayer()->enabledAudioTracksChanged(enabledTrackIds); 2222 webMediaPlayer()->enabledAudioTracksChanged(enabledTrackIds);
2220 } 2223 }
2221 2224
2222 WebMediaPlayer::TrackId HTMLMediaElement::addAudioTrack(const String& id, blink: :WebMediaPlayerClient::AudioTrackKind kind, const AtomicString& label, const Ato micString& language, bool enabled) 2225 WebMediaPlayer::TrackId HTMLMediaElement::addAudioTrack(const WebString& id, bli nk::WebMediaPlayerClient::AudioTrackKind kind, const WebString& label, const Web String& language, bool enabled)
2223 { 2226 {
2224 AtomicString kindString = AudioKindToString(kind); 2227 AtomicString kindString = AudioKindToString(kind);
2225 WTF_LOG(Media, "HTMLMediaElement::addAudioTrack(%p, '%s', '%s', '%s', '%s', %d)", 2228 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); 2229 this, id.latin1().data(), kindString.ascii().data(), label.latin1().data (), language.latin1().data(), enabled);
2227 2230
2228 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) 2231 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled())
2229 return 0; 2232 return 0;
2230 2233
2231 RefPtrWillBeRawPtr<AudioTrack> audioTrack = AudioTrack::create(id, kindStrin g, label, language, enabled); 2234 RefPtrWillBeRawPtr<AudioTrack> audioTrack = AudioTrack::create(id, kindStrin g, label, language, enabled);
2232 audioTracks().add(audioTrack); 2235 audioTracks().add(audioTrack);
2233 2236
2234 return audioTrack->trackId(); 2237 return audioTrack->trackId();
2235 } 2238 }
2236 2239
(...skipping 19 matching lines...) Expand all
2256 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); 2259 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled());
2257 2260
2258 if (selectedTrackId) 2261 if (selectedTrackId)
2259 videoTracks().trackSelected(*selectedTrackId); 2262 videoTracks().trackSelected(*selectedTrackId);
2260 2263
2261 // FIXME: Add call on m_mediaSource to notify it of track changes once the S ourceBuffer.videoTracks attribute is added. 2264 // FIXME: Add call on m_mediaSource to notify it of track changes once the S ourceBuffer.videoTracks attribute is added.
2262 2265
2263 webMediaPlayer()->selectedVideoTrackChanged(selectedTrackId); 2266 webMediaPlayer()->selectedVideoTrackChanged(selectedTrackId);
2264 } 2267 }
2265 2268
2266 WebMediaPlayer::TrackId HTMLMediaElement::addVideoTrack(const String& id, blink: :WebMediaPlayerClient::VideoTrackKind kind, const AtomicString& label, const Ato micString& language, bool selected) 2269 WebMediaPlayer::TrackId HTMLMediaElement::addVideoTrack(const WebString& id, bli nk::WebMediaPlayerClient::VideoTrackKind kind, const WebString& label, const Web String& language, bool selected)
2267 { 2270 {
2268 AtomicString kindString = VideoKindToString(kind); 2271 AtomicString kindString = VideoKindToString(kind);
2269 WTF_LOG(Media, "HTMLMediaElement::addVideoTrack(%p, '%s', '%s', '%s', '%s', %d)", 2272 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); 2273 this, id.latin1().data(), kindString.ascii().data(), label.latin1().data (), language.latin1().data(), selected);
2271 2274
2272 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) 2275 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled())
2273 return 0; 2276 return 0;
2274 2277
2275 // If another track was selected (potentially by the user), leave it selecte d. 2278 // If another track was selected (potentially by the user), leave it selecte d.
2276 if (selected && videoTracks().selectedIndex() != -1) 2279 if (selected && videoTracks().selectedIndex() != -1)
2277 selected = false; 2280 selected = false;
2278 2281
2279 RefPtrWillBeRawPtr<VideoTrack> videoTrack = VideoTrack::create(id, kindStrin g, label, language, selected); 2282 RefPtrWillBeRawPtr<VideoTrack> videoTrack = VideoTrack::create(id, kindStrin g, label, language, selected);
2280 videoTracks().add(videoTrack); 2283 videoTracks().add(videoTrack);
2281 2284
2282 return videoTrack->trackId(); 2285 return videoTrack->trackId();
2283 } 2286 }
2284 2287
2285 void HTMLMediaElement::removeVideoTrack(WebMediaPlayer::TrackId trackId) 2288 void HTMLMediaElement::removeVideoTrack(WebMediaPlayer::TrackId trackId)
2286 { 2289 {
2287 WTF_LOG(Media, "HTMLMediaElement::removeVideoTrack(%p)", this); 2290 WTF_LOG(Media, "HTMLMediaElement::removeVideoTrack(%p)", this);
2288 2291
2289 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) 2292 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled())
2290 return; 2293 return;
2291 2294
2292 videoTracks().remove(trackId); 2295 videoTracks().remove(trackId);
2293 } 2296 }
2294 2297
2295 void HTMLMediaElement::mediaPlayerDidAddTextTrack(WebInbandTextTrack* webTrack) 2298 void HTMLMediaElement::addTextTrack(WebInbandTextTrack* webTrack)
2296 { 2299 {
2297 // 4.8.10.12.2 Sourcing in-band text tracks 2300 // 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. 2301 // 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); 2302 RefPtrWillBeRawPtr<InbandTextTrack> textTrack = InbandTextTrack::create(webT rack);
2300 2303
2301 // 2. Set the new text track's kind, label, and language based on the semant ics of the relevant data, 2304 // 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 2305 // 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. 2306 // 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 2307 // 3. Associate the text track list of cues with the rules for updating the text track rendering appropriate
2305 // for the format in question. 2308 // 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 2309 // 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: 2310 // 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 2311 // 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. 2312 // cues, and begin updating it dynamically as necessary.
2310 // - Thess are all done by the media engine. 2313 // - Thess are all done by the media engine.
2311 2314
2312 // 6. Set the new text track's readiness state to loaded. 2315 // 6. Set the new text track's readiness state to loaded.
2313 textTrack->setReadinessState(TextTrack::Loaded); 2316 textTrack->setReadinessState(TextTrack::Loaded);
2314 2317
2315 // 7. Set the new text track's mode to the mode consistent with the user's p references and the requirements of 2318 // 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. 2319 // the relevant specification for the data.
2317 // - This will happen in honorUserPreferencesForAutomaticTextTrackSelection () 2320 // - This will happen in honorUserPreferencesForAutomaticTextTrackSelection ()
2318 scheduleDelayedAction(LoadTextTrackResource); 2321 scheduleDelayedAction(LoadTextTrackResource);
2319 2322
2320 // 8. Add the new text track to the media element's list of text tracks. 2323 // 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 2324 // 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 2325 // 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. 2326 // textTracks attribute's TextTrackList object.
2324 addTextTrack(textTrack.get()); 2327 mediaPlayerAddTextTrack(textTrack.get());
2325 } 2328 }
2326 2329
2327 void HTMLMediaElement::mediaPlayerDidRemoveTextTrack(WebInbandTextTrack* webTrac k) 2330 void HTMLMediaElement::removeTextTrack(WebInbandTextTrack* webTrack)
2328 { 2331 {
2329 if (!m_textTracks) 2332 if (!m_textTracks)
2330 return; 2333 return;
2331 2334
2332 // This cast is safe because we created the InbandTextTrack with the WebInba ndTextTrack 2335 // This cast is safe because we created the InbandTextTrack with the WebInba ndTextTrack
2333 // passed to mediaPlayerDidAddTextTrack. 2336 // passed to mediaPlayerDidAddTextTrack.
2334 RefPtrWillBeRawPtr<InbandTextTrack> textTrack = static_cast<InbandTextTrack* >(webTrack->client()); 2337 RefPtrWillBeRawPtr<InbandTextTrack> textTrack = static_cast<InbandTextTrack* >(webTrack->client());
2335 if (!textTrack) 2338 if (!textTrack)
2336 return; 2339 return;
2337 2340
2338 removeTextTrack(textTrack.get()); 2341 mediaPlayerRemoveTextTrack(textTrack.get());
2339 } 2342 }
2340 2343
2341 void HTMLMediaElement::textTracksChanged() 2344 void HTMLMediaElement::textTracksChanged()
2342 { 2345 {
2343 if (mediaControls()) 2346 if (mediaControls())
2344 mediaControls()->refreshClosedCaptionsButtonVisibility(); 2347 mediaControls()->refreshClosedCaptionsButtonVisibility();
2345 } 2348 }
2346 2349
2347 void HTMLMediaElement::addTextTrack(TextTrack* track) 2350 void HTMLMediaElement::mediaPlayerAddTextTrack(TextTrack* track)
2348 { 2351 {
2349 textTracks()->append(track); 2352 textTracks()->append(track);
2350 2353
2351 textTracksChanged(); 2354 textTracksChanged();
2352 } 2355 }
2353 2356
2354 void HTMLMediaElement::removeTextTrack(TextTrack* track) 2357 void HTMLMediaElement::mediaPlayerRemoveTextTrack(TextTrack* track)
2355 { 2358 {
2356 m_textTracks->remove(track); 2359 m_textTracks->remove(track);
2357 2360
2358 textTracksChanged(); 2361 textTracksChanged();
2359 } 2362 }
2360 2363
2361 void HTMLMediaElement::forgetResourceSpecificTracks() 2364 void HTMLMediaElement::forgetResourceSpecificTracks()
2362 { 2365 {
2363 // Implements the "forget the media element's media-resource-specific tracks " algorithm. 2366 // 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 2367 // 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); 2393 RefPtrWillBeRawPtr<TextTrack> textTrack = TextTrack::create(kind, label, lan guage);
2391 // ..., its text track readiness state to the text track loaded state, .. . 2394 // ..., its text track readiness state to the text track loaded state, .. .
2392 textTrack->setReadinessState(TextTrack::Loaded); 2395 textTrack->setReadinessState(TextTrack::Loaded);
2393 2396
2394 // 3. Add the new text track to the media element's list of text tracks. 2397 // 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 2398 // 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 2399 // does not bubble and is not cancelable, and that uses the TrackEvent
2397 // interface, with the track attribute initialised to the new text 2400 // interface, with the track attribute initialised to the new text
2398 // track's TextTrack object, at the media element's textTracks 2401 // track's TextTrack object, at the media element's textTracks
2399 // attribute's TextTrackList object. 2402 // attribute's TextTrackList object.
2400 addTextTrack(textTrack.get()); 2403 mediaPlayerAddTextTrack(textTrack.get());
2401 2404
2402 // Note: Due to side effects when changing track parameters, we have to 2405 // Note: Due to side effects when changing track parameters, we have to
2403 // first append the track to the text track list. 2406 // first append the track to the text track list.
2404 // FIXME: Since setMode() will cause a 'change' event to be queued on the 2407 // 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 2408 // 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...) 2409 // wrong. (The 'change' event shouldn't be fired at all in this case...)
2407 2410
2408 // ..., its text track mode to the text track hidden mode, ... 2411 // ..., its text track mode to the text track hidden mode, ...
2409 textTrack->setMode(TextTrack::hiddenKeyword()); 2412 textTrack->setMode(TextTrack::hiddenKeyword());
2410 2413
(...skipping 12 matching lines...) Expand all
2423 void HTMLMediaElement::didAddTrackElement(HTMLTrackElement* trackElement) 2426 void HTMLMediaElement::didAddTrackElement(HTMLTrackElement* trackElement)
2424 { 2427 {
2425 // 4.8.10.12.3 Sourcing out-of-band text tracks 2428 // 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, 2429 // 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 2430 // 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] 2431 // media element's list of text tracks ... [continues in TextTrackList::appe nd]
2429 RefPtrWillBeRawPtr<TextTrack> textTrack = trackElement->track(); 2432 RefPtrWillBeRawPtr<TextTrack> textTrack = trackElement->track();
2430 if (!textTrack) 2433 if (!textTrack)
2431 return; 2434 return;
2432 2435
2433 addTextTrack(textTrack.get()); 2436 mediaPlayerAddTextTrack(textTrack.get());
2434 2437
2435 // Do not schedule the track loading until parsing finishes so we don't star t before all tracks 2438 // 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. 2439 // in the markup have been added.
2437 if (isFinishedParsingChildren()) 2440 if (isFinishedParsingChildren())
2438 scheduleDelayedAction(LoadTextTrackResource); 2441 scheduleDelayedAction(LoadTextTrackResource);
2439 } 2442 }
2440 2443
2441 void HTMLMediaElement::didRemoveTrackElement(HTMLTrackElement* trackElement) 2444 void HTMLMediaElement::didRemoveTrackElement(HTMLTrackElement* trackElement)
2442 { 2445 {
2443 #if !LOG_DISABLED 2446 #if !LOG_DISABLED
2444 KURL url = trackElement->getNonEmptyURLAttribute(srcAttr); 2447 KURL url = trackElement->getNonEmptyURLAttribute(srcAttr);
2445 WTF_LOG(Media, "HTMLMediaElement::didRemoveTrackElement(%p) - 'src' is %s", this, urlForLoggingMedia(url).utf8().data()); 2448 WTF_LOG(Media, "HTMLMediaElement::didRemoveTrackElement(%p) - 'src' is %s", this, urlForLoggingMedia(url).utf8().data());
2446 #endif 2449 #endif
2447 2450
2448 RefPtrWillBeRawPtr<TextTrack> textTrack = trackElement->track(); 2451 RefPtrWillBeRawPtr<TextTrack> textTrack = trackElement->track();
2449 if (!textTrack) 2452 if (!textTrack)
2450 return; 2453 return;
2451 2454
2452 textTrack->setHasBeenConfigured(false); 2455 textTrack->setHasBeenConfigured(false);
2453 2456
2454 if (!m_textTracks) 2457 if (!m_textTracks)
2455 return; 2458 return;
2456 2459
2457 // 4.8.10.12.3 Sourcing out-of-band text tracks 2460 // 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, 2461 // 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 2462 // then the user agent must remove the track element's corresponding text tr ack from the
2460 // media element's list of text tracks. 2463 // media element's list of text tracks.
2461 removeTextTrack(textTrack.get()); 2464 mediaPlayerRemoveTextTrack(textTrack.get());
2462 2465
2463 size_t index = m_textTracksWhenResourceSelectionBegan.find(textTrack.get()); 2466 size_t index = m_textTracksWhenResourceSelectionBegan.find(textTrack.get());
2464 if (index != kNotFound) 2467 if (index != kNotFound)
2465 m_textTracksWhenResourceSelectionBegan.remove(index); 2468 m_textTracksWhenResourceSelectionBegan.remove(index);
2466 } 2469 }
2467 2470
2468 void HTMLMediaElement::honorUserPreferencesForAutomaticTextTrackSelection() 2471 void HTMLMediaElement::honorUserPreferencesForAutomaticTextTrackSelection()
2469 { 2472 {
2470 if (!m_textTracks || !m_textTracks->length()) 2473 if (!m_textTracks || !m_textTracks->length())
2471 return; 2474 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()); 2661 WTF_LOG(Media, "HTMLMediaElement::sourceRemoved(%p) - m_nextChildNodeToC onsider set to %p", this, m_nextChildNodeToConsider.get());
2659 } else if (source == m_currentSourceNode) { 2662 } else if (source == m_currentSourceNode) {
2660 // Clear the current source node pointer, but don't change the movie as the spec says: 2663 // 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 2664 // 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. 2665 // inserted in a video or audio element will have no effect.
2663 m_currentSourceNode = nullptr; 2666 m_currentSourceNode = nullptr;
2664 WTF_LOG(Media, "HTMLMediaElement::sourceRemoved(%p) - m_currentSourceNod e set to 0", this); 2667 WTF_LOG(Media, "HTMLMediaElement::sourceRemoved(%p) - m_currentSourceNod e set to 0", this);
2665 } 2668 }
2666 } 2669 }
2667 2670
2668 void HTMLMediaElement::mediaPlayerTimeChanged() 2671 void HTMLMediaElement::timeChanged()
2669 { 2672 {
2670 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerTimeChanged(%p)", this); 2673 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerTimeChanged(%p)", this);
2671 2674
2672 cueTimeline().updateActiveCues(currentTime()); 2675 cueTimeline().updateActiveCues(currentTime());
2673 2676
2674 invalidateCachedTime(); 2677 invalidateCachedTime();
2675 2678
2676 // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with t he seek. 2679 // 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()) 2680 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !webMediaPlayer()->see king())
2678 finishSeek(); 2681 finishSeek();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2711 // for the media element's current media controller. 2714 // for the media element's current media controller.
2712 updateMediaController(); 2715 updateMediaController();
2713 } 2716 }
2714 } else { 2717 } else {
2715 m_sentEndEvent = false; 2718 m_sentEndEvent = false;
2716 } 2719 }
2717 2720
2718 updatePlayState(); 2721 updatePlayState();
2719 } 2722 }
2720 2723
2721 void HTMLMediaElement::mediaPlayerDurationChanged() 2724 void HTMLMediaElement::durationChanged()
2722 { 2725 {
2723 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerDurationChanged(%p)", this); 2726 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p)", this);
2724 // FIXME: Change MediaPlayerClient & WebMediaPlayer to convey 2727 // FIXME: Change MediaPlayerClient & WebMediaPlayer to convey
philipj_slow 2015/05/06 15:39:32 MediaPlayerClient is gone.
Srirama 2015/05/19 10:39:46 Done.
2725 // the currentTime when the duration change occured. The current 2728 // the currentTime when the duration change occured. The current
2726 // WebMediaPlayer implementations always clamp currentTime() to 2729 // WebMediaPlayer implementations always clamp currentTime() to
2727 // duration() so the requestSeek condition here is always false. 2730 // duration() so the requestSeek condition here is always false.
2728 durationChanged(duration(), currentTime() > duration()); 2731 mediaPlayerDurationChanged(duration(), currentTime() > duration());
2729 } 2732 }
2730 2733
2731 void HTMLMediaElement::durationChanged(double duration, bool requestSeek) 2734 void HTMLMediaElement::mediaPlayerDurationChanged(double duration, bool requestS eek)
2732 { 2735 {
2733 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p, %f, %d)", this, durati on, requestSeek); 2736 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerDurationChanged(%p, %f, %d)", t his, duration, requestSeek);
2734 2737
2735 // Abort if duration unchanged. 2738 // Abort if duration unchanged.
2736 if (m_duration == duration) 2739 if (m_duration == duration)
2737 return; 2740 return;
2738 2741
2739 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p) : %f -> %f", this, m_d uration, duration); 2742 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p) : %f -> %f", this, m_d uration, duration);
2740 m_duration = duration; 2743 m_duration = duration;
2741 scheduleEvent(EventTypeNames::durationchange); 2744 scheduleEvent(EventTypeNames::durationchange);
2742 2745
2743 if (mediaControls()) 2746 if (mediaControls())
2744 mediaControls()->reset(); 2747 mediaControls()->reset();
2745 if (layoutObject()) 2748 if (layoutObject())
2746 layoutObject()->updateFromElement(); 2749 layoutObject()->updateFromElement();
2747 2750
2748 if (requestSeek) 2751 if (requestSeek)
2749 seek(duration); 2752 seek(duration);
2750 } 2753 }
2751 2754
2752 void HTMLMediaElement::mediaPlayerPlaybackStateChanged() 2755 void HTMLMediaElement::playbackStateChanged()
2753 { 2756 {
2754 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerPlaybackStateChanged(%p)", this ); 2757 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerPlaybackStateChanged(%p)", this );
2755 2758
2756 if (!webMediaPlayer()) 2759 if (!webMediaPlayer())
2757 return; 2760 return;
2758 2761
2759 if (webMediaPlayer()->paused()) 2762 if (webMediaPlayer()->paused())
2760 pause(); 2763 pause();
2761 else 2764 else
2762 playInternal(); 2765 playInternal();
2763 } 2766 }
2764 2767
2765 void HTMLMediaElement::mediaPlayerRequestFullscreen() 2768 void HTMLMediaElement::requestFullscreen()
philipj_slow 2015/05/06 15:39:32 This name is a bit tricky, it could be seen as an
Srirama 2015/05/19 10:39:46 It is like this because we are overriding the func
2766 { 2769 {
2767 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerRequestFullscreen(%p)", this); 2770 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerRequestFullscreen(%p)", this);
2768 2771
2769 // The player is responsible for only invoking this callback in response to 2772 // 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. 2773 // user interaction or when it is technically required to play the video.
2771 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); 2774 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture);
2772 2775
2773 enterFullscreen(); 2776 enterFullscreen();
2774 } 2777 }
2775 2778
2776 void HTMLMediaElement::mediaPlayerRequestSeek(double time) 2779 void HTMLMediaElement::requestSeek(double time)
philipj_slow 2015/05/06 15:39:32 I think in this case too the old name is good beca
Srirama 2015/05/19 10:39:46 Same as above.
2777 { 2780 {
2778 // The player is the source of this seek request. 2781 // The player is the source of this seek request.
2779 if (m_mediaController) { 2782 if (m_mediaController) {
2780 m_mediaController->setCurrentTime(time); 2783 m_mediaController->setCurrentTime(time);
2781 return; 2784 return;
2782 } 2785 }
2783 setCurrentTime(time, ASSERT_NO_EXCEPTION); 2786 setCurrentTime(time, ASSERT_NO_EXCEPTION);
2784 } 2787 }
2785 2788
2786 void HTMLMediaElement::remoteRouteAvailabilityChanged(bool routesAvailable) 2789 void HTMLMediaElement::remoteRouteAvailabilityChanged(bool routesAvailable)
(...skipping 11 matching lines...) Expand all
2798 } 2801 }
2799 2802
2800 void HTMLMediaElement::disconnectedFromRemoteDevice() 2803 void HTMLMediaElement::disconnectedFromRemoteDevice()
2801 { 2804 {
2802 m_playingRemotely = false; 2805 m_playingRemotely = false;
2803 if (mediaControls()) 2806 if (mediaControls())
2804 mediaControls()->stoppedCasting(); 2807 mediaControls()->stoppedCasting();
2805 } 2808 }
2806 2809
2807 // MediaPlayerPresentation methods 2810 // MediaPlayerPresentation methods
2808 void HTMLMediaElement::mediaPlayerRepaint() 2811 void HTMLMediaElement::repaint()
2809 { 2812 {
2810 if (m_webLayer) 2813 if (m_webLayer)
2811 m_webLayer->invalidate(); 2814 m_webLayer->invalidate();
2812 2815
2813 updateDisplayState(); 2816 updateDisplayState();
2814 if (layoutObject()) 2817 if (layoutObject())
2815 layoutObject()->setShouldDoFullPaintInvalidation(); 2818 layoutObject()->setShouldDoFullPaintInvalidation();
2816 } 2819 }
2817 2820
2818 void HTMLMediaElement::mediaPlayerSizeChanged() 2821 void HTMLMediaElement::sizeChanged()
2819 { 2822 {
2820 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerSizeChanged(%p)", this); 2823 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerSizeChanged(%p)", this);
2821 2824
2822 ASSERT(hasVideo()); // "resize" makes no sense absent video. 2825 ASSERT(hasVideo()); // "resize" makes no sense absent video.
2823 if (m_readyState > HAVE_NOTHING && isHTMLVideoElement()) 2826 if (m_readyState > HAVE_NOTHING && isHTMLVideoElement())
2824 scheduleEvent(EventTypeNames::resize); 2827 scheduleEvent(EventTypeNames::resize);
2825 2828
2826 if (layoutObject()) 2829 if (layoutObject())
2827 layoutObject()->updateFromElement(); 2830 layoutObject()->updateFromElement();
2828 } 2831 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2873 } 2876 }
2874 2877
2875 bool HTMLMediaElement::couldPlayIfEnoughData() const 2878 bool HTMLMediaElement::couldPlayIfEnoughData() const
2876 { 2879 {
2877 return !paused() && !endedPlayback() && !stoppedDueToErrors(); 2880 return !paused() && !endedPlayback() && !stoppedDueToErrors();
2878 } 2881 }
2879 2882
2880 bool HTMLMediaElement::endedPlayback(LoopCondition loopCondition) const 2883 bool HTMLMediaElement::endedPlayback(LoopCondition loopCondition) const
2881 { 2884 {
2882 double dur = duration(); 2885 double dur = duration();
2883 if (!m_player || std::isnan(dur)) 2886 if (std::isnan(dur))
2884 return false; 2887 return false;
2885 2888
2886 // 4.8.10.8 Playing the media resource 2889 // 4.8.10.8 Playing the media resource
2887 2890
2888 // A media element is said to have ended playback when the element's 2891 // A media element is said to have ended playback when the element's
2889 // readyState attribute is HAVE_METADATA or greater, 2892 // readyState attribute is HAVE_METADATA or greater,
2890 if (m_readyState < HAVE_METADATA) 2893 if (m_readyState < HAVE_METADATA)
2891 return false; 2894 return false;
2892 2895
2893 // and the current playback position is the end of the media resource and th e direction 2896 // 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(); 2912 RefPtrWillBeRawPtr<TimeRanges> seekableRanges = seekable();
2910 if (!seekableRanges->contain(currentTime())) 2913 if (!seekableRanges->contain(currentTime()))
2911 return true; 2914 return true;
2912 } 2915 }
2913 2916
2914 return false; 2917 return false;
2915 } 2918 }
2916 2919
2917 void HTMLMediaElement::updatePlayState() 2920 void HTMLMediaElement::updatePlayState()
2918 { 2921 {
2919 if (!m_player)
2920 return;
2921
2922 bool isPlaying = webMediaPlayer() && !webMediaPlayer()->paused(); 2922 bool isPlaying = webMediaPlayer() && !webMediaPlayer()->paused();
2923 bool shouldBePlaying = potentiallyPlaying(); 2923 bool shouldBePlaying = potentiallyPlaying();
2924 2924
2925 WTF_LOG(Media, "HTMLMediaElement::updatePlayState(%p) - shouldBePlaying = %s , isPlaying = %s", 2925 WTF_LOG(Media, "HTMLMediaElement::updatePlayState(%p) - shouldBePlaying = %s , isPlaying = %s",
2926 this, boolString(shouldBePlaying), boolString(isPlaying)); 2926 this, boolString(shouldBePlaying), boolString(isPlaying));
2927 2927
2928 if (shouldBePlaying) { 2928 if (shouldBePlaying) {
2929 setDisplayMode(Video); 2929 setDisplayMode(Video);
2930 invalidateCachedTime(); 2930 invalidateCachedTime();
2931 2931
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
3002 } else { 3002 } else {
3003 m_networkState = NETWORK_IDLE; 3003 m_networkState = NETWORK_IDLE;
3004 } 3004 }
3005 3005
3006 // 5 - Set the element's delaying-the-load-event flag to false. This stops d elaying the load event. 3006 // 5 - Set the element's delaying-the-load-event flag to false. This stops d elaying the load event.
3007 setShouldDelayLoadEvent(false); 3007 setShouldDelayLoadEvent(false);
3008 3008
3009 // 6 - Abort the overall resource selection algorithm. 3009 // 6 - Abort the overall resource selection algorithm.
3010 m_currentSourceNode = nullptr; 3010 m_currentSourceNode = nullptr;
3011 3011
3012 // Reset m_readyState since m_player is gone. 3012 // Reset m_readyState since m_webMediaPlayer is gone.
3013 m_readyState = HAVE_NOTHING; 3013 m_readyState = HAVE_NOTHING;
3014 invalidateCachedTime(); 3014 invalidateCachedTime();
3015 updateMediaController(); 3015 updateMediaController();
3016 cueTimeline().updateActiveCues(0); 3016 cueTimeline().updateActiveCues(0);
3017 } 3017 }
3018 3018
3019 void HTMLMediaElement::clearMediaPlayerAndAudioSourceProviderClientWithoutLockin g() 3019 void HTMLMediaElement::clearMediaPlayerAndAudioSourceProviderClientWithoutLockin g()
3020 { 3020 {
3021 #if ENABLE(WEB_AUDIO) 3021 #if ENABLE(WEB_AUDIO)
3022 if (audioSourceProvider()) 3022 if (audioSourceProvider())
3023 audioSourceProvider()->setClient(0); 3023 audioSourceProvider()->setClient(0);
3024 #endif 3024 #endif
3025 m_player.clear(); 3025 m_webMediaPlayer.clear(); // Revisit
3026 } 3026 }
3027 3027
3028 void HTMLMediaElement::clearMediaPlayer(int flags) 3028 void HTMLMediaElement::clearMediaPlayer(int flags)
3029 { 3029 {
3030 forgetResourceSpecificTracks(); 3030 forgetResourceSpecificTracks();
3031 3031
3032 closeMediaSource(); 3032 closeMediaSource();
3033 3033
3034 cancelDeferredLoad(); 3034 cancelDeferredLoad();
3035 3035
(...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 3237 // 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 ... 3238 // of each of the text tracks in the video element's list of text tracks ...
3239 if (isHTMLVideoElement() && closedCaptionsVisible()) 3239 if (isHTMLVideoElement() && closedCaptionsVisible())
3240 ensureTextTrackContainer().updateDisplay(*this, TextTrackContainer::DidS tartExposingControls); 3240 ensureTextTrackContainer().updateDisplay(*this, TextTrackContainer::DidS tartExposingControls);
3241 } 3241 }
3242 3242
3243 void HTMLMediaElement::setClosedCaptionsVisible(bool closedCaptionVisible) 3243 void HTMLMediaElement::setClosedCaptionsVisible(bool closedCaptionVisible)
3244 { 3244 {
3245 WTF_LOG(Media, "HTMLMediaElement::setClosedCaptionsVisible(%p, %s)", this, b oolString(closedCaptionVisible)); 3245 WTF_LOG(Media, "HTMLMediaElement::setClosedCaptionsVisible(%p, %s)", this, b oolString(closedCaptionVisible));
3246 3246
3247 if (!m_player || !hasClosedCaptions()) 3247 if (!hasClosedCaptions())
3248 return; 3248 return;
3249 3249
3250 m_closedCaptionsVisible = closedCaptionVisible; 3250 m_closedCaptionsVisible = closedCaptionVisible;
3251 3251
3252 markCaptionAndSubtitleTracksAsUnconfigured(); 3252 markCaptionAndSubtitleTracksAsUnconfigured();
3253 m_processingPreferenceChange = true; 3253 m_processingPreferenceChange = true;
3254 honorUserPreferencesForAutomaticTextTrackSelection(); 3254 honorUserPreferencesForAutomaticTextTrackSelection();
3255 m_processingPreferenceChange = false; 3255 m_processingPreferenceChange = false;
3256 3256
3257 // As track visibility changed while m_processingPreferenceChange was set, 3257 // As track visibility changed while m_processingPreferenceChange was set,
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
3419 3419
3420 return nullptr; 3420 return nullptr;
3421 } 3421 }
3422 3422
3423 void HTMLMediaElement::createMediaPlayer() 3423 void HTMLMediaElement::createMediaPlayer()
3424 { 3424 {
3425 AudioSourceProviderClientLockScope scope(*this); 3425 AudioSourceProviderClientLockScope scope(*this);
3426 3426
3427 closeMediaSource(); 3427 closeMediaSource();
3428 3428
3429 m_player = MediaPlayer::create(this);
3430
3431 // We haven't yet found out if any remote routes are available. 3429 // We haven't yet found out if any remote routes are available.
3432 m_remoteRoutesAvailable = false; 3430 m_remoteRoutesAvailable = false;
3433 m_playingRemotely = false; 3431 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 } 3432 }
3442 3433
3443 #if ENABLE(WEB_AUDIO) 3434 #if ENABLE(WEB_AUDIO)
3444 void HTMLMediaElement::setAudioSourceNode(AudioSourceProviderClient* sourceNode) 3435 void HTMLMediaElement::setAudioSourceNode(AudioSourceProviderClient* sourceNode)
3445 { 3436 {
3446 m_audioSourceNode = sourceNode; 3437 m_audioSourceNode = sourceNode;
3447 3438
3448 AudioSourceProviderClientLockScope scope(*this); 3439 AudioSourceProviderClientLockScope scope(*this);
3449 if (audioSourceProvider()) 3440 if (audioSourceProvider())
3450 audioSourceProvider()->setClient(m_audioSourceNode); 3441 audioSourceProvider()->setClient(m_audioSourceNode);
3451 } 3442 }
3452 3443
3453 AudioSourceProvider* HTMLMediaElement::audioSourceProvider() 3444 AudioSourceProvider* HTMLMediaElement::audioSourceProvider()
3454 { 3445 {
3455 if (m_player) 3446 // null check
3456 return m_player->audioSourceProvider(); 3447 return &m_audioSourceProvider;
3457
3458 return nullptr;
3459 } 3448 }
3460 #endif 3449 #endif
3461 3450
3462 const AtomicString& HTMLMediaElement::mediaGroup() const 3451 const AtomicString& HTMLMediaElement::mediaGroup() const
3463 { 3452 {
3464 return fastGetAttribute(mediagroupAttr); 3453 return fastGetAttribute(mediagroupAttr);
3465 } 3454 }
3466 3455
3467 void HTMLMediaElement::setMediaGroup(const AtomicString& group) 3456 void HTMLMediaElement::setMediaGroup(const AtomicString& group)
3468 { 3457 {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
3561 WebMediaPlayer::CORSMode HTMLMediaElement::corsMode() const 3550 WebMediaPlayer::CORSMode HTMLMediaElement::corsMode() const
3562 { 3551 {
3563 const AtomicString& crossOriginMode = fastGetAttribute(crossoriginAttr); 3552 const AtomicString& crossOriginMode = fastGetAttribute(crossoriginAttr);
3564 if (crossOriginMode.isNull()) 3553 if (crossOriginMode.isNull())
3565 return WebMediaPlayer::CORSModeUnspecified; 3554 return WebMediaPlayer::CORSModeUnspecified;
3566 if (equalIgnoringCase(crossOriginMode, "use-credentials")) 3555 if (equalIgnoringCase(crossOriginMode, "use-credentials"))
3567 return WebMediaPlayer::CORSModeUseCredentials; 3556 return WebMediaPlayer::CORSModeUseCredentials;
3568 return WebMediaPlayer::CORSModeAnonymous; 3557 return WebMediaPlayer::CORSModeAnonymous;
3569 } 3558 }
3570 3559
3571 void HTMLMediaElement::mediaPlayerSetWebLayer(blink::WebLayer* webLayer) 3560 void HTMLMediaElement::setWebLayer(blink::WebLayer* webLayer)
3572 { 3561 {
3573 if (webLayer == m_webLayer) 3562 if (webLayer == m_webLayer)
3574 return; 3563 return;
3575 3564
3576 // If either of the layers is null we need to enable or disable compositing. This is done by triggering a style recalc. 3565 // 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) 3566 if ((!m_webLayer || !webLayer)
3578 #if ENABLE(OILPAN) 3567 #if ENABLE(OILPAN)
3579 && !m_isFinalizing 3568 && !m_isFinalizing
3580 #endif 3569 #endif
3581 ) 3570 )
3582 setNeedsCompositingUpdate(); 3571 setNeedsCompositingUpdate();
3583 3572
3584 if (m_webLayer) 3573 if (m_webLayer)
3585 GraphicsLayer::unregisterContentsLayer(m_webLayer); 3574 GraphicsLayer::unregisterContentsLayer(m_webLayer);
3586 m_webLayer = webLayer; 3575 m_webLayer = webLayer;
3587 if (m_webLayer) 3576 if (m_webLayer)
3588 GraphicsLayer::registerContentsLayer(m_webLayer); 3577 GraphicsLayer::registerContentsLayer(m_webLayer);
3589 } 3578 }
3590 3579
3591 void HTMLMediaElement::mediaPlayerMediaSourceOpened(blink::WebMediaSource* webMe diaSource) 3580 void HTMLMediaElement::mediaSourceOpened(blink::WebMediaSource* webMediaSource)
3592 { 3581 {
3593 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource)); 3582 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource));
3594 } 3583 }
3595 3584
3596 bool HTMLMediaElement::isInteractiveContent() const 3585 bool HTMLMediaElement::isInteractiveContent() const
3597 { 3586 {
3598 return fastHasAttribute(controlsAttr); 3587 return fastHasAttribute(controlsAttr);
3599 } 3588 }
3600 3589
3601 void HTMLMediaElement::defaultEventHandler(Event* event) 3590 void HTMLMediaElement::defaultEventHandler(Event* event)
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
3652 3641
3653 // Enable the first audio track if an audio track hasn't been enabled yet. 3642 // Enable the first audio track if an audio track hasn't been enabled yet.
3654 if (audioTracks().length() > 0 && !audioTracks().hasEnabledTrack()) 3643 if (audioTracks().length() > 0 && !audioTracks().hasEnabledTrack())
3655 audioTracks().anonymousIndexedGetter(0)->setEnabled(true); 3644 audioTracks().anonymousIndexedGetter(0)->setEnabled(true);
3656 3645
3657 // Select the first video track if a video track hasn't been selected yet. 3646 // Select the first video track if a video track hasn't been selected yet.
3658 if (videoTracks().length() > 0 && videoTracks().selectedIndex() == -1) 3647 if (videoTracks().length() > 0 && videoTracks().selectedIndex() == -1)
3659 videoTracks().anonymousIndexedGetter(0)->setSelected(true); 3648 videoTracks().anonymousIndexedGetter(0)->setSelected(true);
3660 } 3649 }
3661 3650
3651 void HTMLMediaElement::loadMediaPlayer(const WTF::String& url)
philipj_slow 2015/05/06 15:39:33 loadMediaPlayer() as a name isn't only part of wha
Srirama 2015/05/19 10:39:46 I renamed it to prepareAndLoadMediaPlayer to be co
3652 {
3653 ASSERT(!m_webMediaPlayer);
3654
3655 WebURL poster = mediaPlayerPosterURL();
3656
3657 KURL kurl(ParsedURLString, url);
3658 LocalFrame* frame = document().frame();
3659 ASSERT(frame);
3660 m_webMediaPlayer = frame->loader().client()->createWebMediaPlayer(this, kurl );
3661 if (!m_webMediaPlayer)
3662 return;
3663
3664 #if ENABLE(WEB_AUDIO)
3665 // Make sure if we create/re-create the WebMediaPlayer that we update our wr apper.
3666 m_audioSourceProvider.wrap(m_webMediaPlayer->audioSourceProvider());
3667 #endif
3668 m_webMediaPlayer->setVolume(effectiveMediaVolume());
3669
3670 m_webMediaPlayer->setPoster(poster);
3671
3672 m_webMediaPlayer->setPreload(preloadType());
3673
3674 m_webMediaPlayer->load(loadType(), kurl, corsMode());
3675
3676 if (isFullscreen())
3677 m_webMediaPlayer->enterFullscreen();
3678 }
3679
3662 #if ENABLE(WEB_AUDIO) 3680 #if ENABLE(WEB_AUDIO)
3663 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) 3681 void HTMLMediaElement::clearWeakMembers(Visitor* visitor)
3664 { 3682 {
3665 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) 3683 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider())
3666 audioSourceProvider()->setClient(nullptr); 3684 audioSourceProvider()->setClient(nullptr);
3667 } 3685 }
3686
3687 void HTMLMediaElement::AudioSourceProviderImpl::wrap(WebAudioSourceProvider* pro vider)
3688 {
3689 MutexLocker locker(provideInputLock);
3690
3691 if (m_webAudioSourceProvider && provider != m_webAudioSourceProvider)
3692 m_webAudioSourceProvider->setClient(0);
3693
3694 m_webAudioSourceProvider = provider;
3695 if (m_webAudioSourceProvider)
3696 m_webAudioSourceProvider->setClient(m_client.get());
3697 }
3698
3699 void HTMLMediaElement::AudioSourceProviderImpl::setClient(AudioSourceProviderCli ent* client)
3700 {
3701 MutexLocker locker(provideInputLock);
3702
3703 if (client)
3704 m_client = new HTMLMediaElement::AudioClientImpl(client);
3705 else
3706 m_client.clear();
3707
3708 if (m_webAudioSourceProvider)
3709 m_webAudioSourceProvider->setClient(m_client.get());
3710 }
3711
3712 void HTMLMediaElement::AudioSourceProviderImpl::provideInput(blink::AudioBus* bu s, size_t framesToProcess)
3713 {
3714 ASSERT(bus);
3715 if (!bus)
3716 return;
3717
3718 MutexTryLocker tryLocker(provideInputLock);
3719 if (!tryLocker.locked() || !m_webAudioSourceProvider || !m_client.get()) {
3720 bus->zero();
3721 return;
3722 }
3723
3724 // Wrap the AudioBus channel data using WebVector.
3725 size_t n = bus->numberOfChannels();
3726 WebVector<float*> webAudioData(n);
3727 for (size_t i = 0; i < n; ++i)
3728 webAudioData[i] = bus->channel(i)->mutableData();
3729
3730 m_webAudioSourceProvider->provideInput(webAudioData, framesToProcess);
3731 }
3732
3733 void HTMLMediaElement::AudioClientImpl::setFormat(size_t numberOfChannels, float sampleRate)
3734 {
3735 if (m_client)
3736 m_client->setFormat(numberOfChannels, sampleRate);
3737 }
3738
3739 DEFINE_TRACE(HTMLMediaElement::AudioClientImpl)
3740 {
3741 visitor->trace(m_client);
3742 }
3668 #endif 3743 #endif
3669 3744
3670 } 3745 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698