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

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

Powered by Google App Engine
This is Rietveld 408576698