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