Chromium Code Reviews| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 #include "core/html/track/InbandTextTrack.h" | 57 #include "core/html/track/InbandTextTrack.h" |
| 58 #include "core/html/track/TextTrackContainer.h" | 58 #include "core/html/track/TextTrackContainer.h" |
| 59 #include "core/html/track/TextTrackList.h" | 59 #include "core/html/track/TextTrackList.h" |
| 60 #include "core/html/track/VideoTrack.h" | 60 #include "core/html/track/VideoTrack.h" |
| 61 #include "core/html/track/VideoTrackList.h" | 61 #include "core/html/track/VideoTrackList.h" |
| 62 #include "core/inspector/ConsoleMessage.h" | 62 #include "core/inspector/ConsoleMessage.h" |
| 63 #include "core/layout/LayoutVideo.h" | 63 #include "core/layout/LayoutVideo.h" |
| 64 #include "core/layout/LayoutView.h" | 64 #include "core/layout/LayoutView.h" |
| 65 #include "core/layout/compositing/DeprecatedPaintLayerCompositor.h" | 65 #include "core/layout/compositing/DeprecatedPaintLayerCompositor.h" |
| 66 #include "core/loader/FrameLoader.h" | 66 #include "core/loader/FrameLoader.h" |
| 67 #include "core/loader/FrameLoaderClient.h" | |
| 67 #include "platform/ContentType.h" | 68 #include "platform/ContentType.h" |
| 68 #include "platform/Logging.h" | 69 #include "platform/Logging.h" |
| 69 #include "platform/MIMETypeFromURL.h" | 70 #include "platform/MIMETypeFromURL.h" |
| 70 #include "platform/MIMETypeRegistry.h" | 71 #include "platform/MIMETypeRegistry.h" |
| 71 #include "platform/RuntimeEnabledFeatures.h" | 72 #include "platform/RuntimeEnabledFeatures.h" |
| 72 #include "platform/UserGestureIndicator.h" | 73 #include "platform/UserGestureIndicator.h" |
| 74 #include "platform/audio/AudioBus.h" | |
| 75 #include "platform/audio/AudioSourceProviderClient.h" | |
| 73 #include "platform/graphics/GraphicsLayer.h" | 76 #include "platform/graphics/GraphicsLayer.h" |
| 74 #include "platform/weborigin/SecurityOrigin.h" | 77 #include "platform/weborigin/SecurityOrigin.h" |
| 75 #include "public/platform/Platform.h" | 78 #include "public/platform/Platform.h" |
| 79 #include "public/platform/WebAudioSourceProvider.h" | |
| 76 #include "public/platform/WebContentDecryptionModule.h" | 80 #include "public/platform/WebContentDecryptionModule.h" |
| 77 #include "public/platform/WebInbandTextTrack.h" | 81 #include "public/platform/WebInbandTextTrack.h" |
| 78 #include "wtf/CurrentTime.h" | 82 #include "wtf/CurrentTime.h" |
| 79 #include "wtf/MainThread.h" | 83 #include "wtf/MainThread.h" |
| 80 #include "wtf/MathExtras.h" | 84 #include "wtf/MathExtras.h" |
| 81 #include "wtf/text/CString.h" | 85 #include "wtf/text/CString.h" |
| 82 #include <limits> | 86 #include <limits> |
| 83 | 87 |
| 84 #if ENABLE(WEB_AUDIO) | 88 #if ENABLE(WEB_AUDIO) |
| 85 #include "platform/audio/AudioSourceProvider.h" | 89 #include "platform/audio/AudioSourceProvider.h" |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 327 , m_lastSeekTime(0) | 331 , m_lastSeekTime(0) |
| 328 , m_previousProgressTime(std::numeric_limits<double>::max()) | 332 , m_previousProgressTime(std::numeric_limits<double>::max()) |
| 329 , m_duration(std::numeric_limits<double>::quiet_NaN()) | 333 , m_duration(std::numeric_limits<double>::quiet_NaN()) |
| 330 , m_lastTimeUpdateEventWallTime(0) | 334 , m_lastTimeUpdateEventWallTime(0) |
| 331 , m_lastTimeUpdateEventMovieTime(0) | 335 , m_lastTimeUpdateEventMovieTime(0) |
| 332 , m_defaultPlaybackStartPosition(0) | 336 , m_defaultPlaybackStartPosition(0) |
| 333 , m_loadState(WaitingForSource) | 337 , m_loadState(WaitingForSource) |
| 334 , m_deferredLoadState(NotDeferred) | 338 , m_deferredLoadState(NotDeferred) |
| 335 , m_deferredLoadTimer(this, &HTMLMediaElement::deferredLoadTimerFired) | 339 , m_deferredLoadTimer(this, &HTMLMediaElement::deferredLoadTimerFired) |
| 336 , m_webLayer(nullptr) | 340 , m_webLayer(nullptr) |
| 337 , m_preload(MediaPlayer::Auto) | 341 , m_preload(WebMediaPlayer::PreloadAuto) |
| 338 , m_displayMode(Unknown) | 342 , m_displayMode(Unknown) |
| 339 , m_cachedTime(std::numeric_limits<double>::quiet_NaN()) | 343 , m_cachedTime(std::numeric_limits<double>::quiet_NaN()) |
| 340 , m_fragmentEndTime(std::numeric_limits<double>::quiet_NaN()) | 344 , m_fragmentEndTime(std::numeric_limits<double>::quiet_NaN()) |
| 341 , m_pendingActionFlags(0) | 345 , m_pendingActionFlags(0) |
| 342 , m_userGestureRequiredForPlay(false) | 346 , m_userGestureRequiredForPlay(false) |
| 343 , m_playing(false) | 347 , m_playing(false) |
| 344 , m_shouldDelayLoadEvent(false) | 348 , m_shouldDelayLoadEvent(false) |
| 345 , m_haveFiredLoadedData(false) | 349 , m_haveFiredLoadedData(false) |
| 346 , m_autoplaying(true) | 350 , m_autoplaying(true) |
| 347 , m_muted(false) | 351 , m_muted(false) |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 488 } | 492 } |
| 489 #endif | 493 #endif |
| 490 | 494 |
| 491 void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument) | 495 void HTMLMediaElement::didMoveToNewDocument(Document& oldDocument) |
| 492 { | 496 { |
| 493 WTF_LOG(Media, "HTMLMediaElement::didMoveToNewDocument(%p)", this); | 497 WTF_LOG(Media, "HTMLMediaElement::didMoveToNewDocument(%p)", this); |
| 494 | 498 |
| 495 if (m_shouldDelayLoadEvent) { | 499 if (m_shouldDelayLoadEvent) { |
| 496 document().incrementLoadEventDelayCount(); | 500 document().incrementLoadEventDelayCount(); |
| 497 // Note: Keeping the load event delay count increment on oldDocument tha t was added | 501 // Note: Keeping the load event delay count increment on oldDocument tha t was added |
| 498 // when m_shouldDelayLoadEvent was set so that destruction of m_player c an not | 502 // when m_shouldDelayLoadEvent was set so that destruction of m_webMedia Player can not |
| 499 // cause load event dispatching in oldDocument. | 503 // cause load event dispatching in oldDocument. |
| 500 } else { | 504 } else { |
| 501 // Incrementing the load event delay count so that destruction of m_play er can not | 505 // Incrementing the load event delay count so that destruction of m_webM ediaPlayer can not |
| 502 // cause load event dispatching in oldDocument. | 506 // cause load event dispatching in oldDocument. |
| 503 oldDocument.incrementLoadEventDelayCount(); | 507 oldDocument.incrementLoadEventDelayCount(); |
| 504 } | 508 } |
| 505 | 509 |
| 506 removeElementFromDocumentMap(this, &oldDocument); | 510 removeElementFromDocumentMap(this, &oldDocument); |
| 507 addElementToDocumentMap(this, &document()); | 511 addElementToDocumentMap(this, &document()); |
| 508 | 512 |
| 509 // FIXME: This is a temporary fix to prevent this object from causing the | 513 // FIXME: This is a temporary fix to prevent this object from causing the |
| 510 // MediaPlayer to dereference LocalFrame and FrameLoader pointers from the | 514 // MediaPlayer to dereference LocalFrame and FrameLoader pointers from the |
| 511 // previous document. A proper fix would provide a mechanism to allow this | 515 // previous document. A proper fix would provide a mechanism to allow this |
| 512 // object to refresh the MediaPlayer's LocalFrame and FrameLoader references on | 516 // object to refresh the MediaPlayer's LocalFrame and FrameLoader references on |
| 513 // document changes so that playback can be resumed properly. | 517 // document changes so that playback can be resumed properly. |
| 514 userCancelledLoad(); | 518 userCancelledLoad(); |
| 515 | 519 |
| 516 // Decrement the load event delay count on oldDocument now that m_player has been destroyed | 520 // Decrement the load event delay count on oldDocument now that m_webMediaPl ayer has been destroyed |
| 517 // and there is no risk of dispatching a load event from within the destruct or. | 521 // and there is no risk of dispatching a load event from within the destruct or. |
| 518 oldDocument.decrementLoadEventDelayCount(); | 522 oldDocument.decrementLoadEventDelayCount(); |
| 519 | 523 |
| 520 ActiveDOMObject::didMoveToNewExecutionContext(&document()); | 524 ActiveDOMObject::didMoveToNewExecutionContext(&document()); |
| 521 HTMLElement::didMoveToNewDocument(oldDocument); | 525 HTMLElement::didMoveToNewDocument(oldDocument); |
| 522 } | 526 } |
| 523 | 527 |
| 524 bool HTMLMediaElement::supportsFocus() const | 528 bool HTMLMediaElement::supportsFocus() const |
| 525 { | 529 { |
| 526 if (ownerDocument()->isMediaDocument()) | 530 if (ownerDocument()->isMediaDocument()) |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 540 if (name == srcAttr) { | 544 if (name == srcAttr) { |
| 541 // Trigger a reload, as long as the 'src' attribute is present. | 545 // Trigger a reload, as long as the 'src' attribute is present. |
| 542 if (!value.isNull()) { | 546 if (!value.isNull()) { |
| 543 clearMediaPlayer(LoadMediaResource); | 547 clearMediaPlayer(LoadMediaResource); |
| 544 scheduleDelayedAction(LoadMediaResource); | 548 scheduleDelayedAction(LoadMediaResource); |
| 545 } | 549 } |
| 546 } else if (name == controlsAttr) { | 550 } else if (name == controlsAttr) { |
| 547 configureMediaControls(); | 551 configureMediaControls(); |
| 548 } else if (name == preloadAttr) { | 552 } else if (name == preloadAttr) { |
| 549 if (equalIgnoringCase(value, "none")) { | 553 if (equalIgnoringCase(value, "none")) { |
| 550 m_preload = MediaPlayer::None; | 554 m_preload = WebMediaPlayer::PreloadNone; |
| 551 } else if (equalIgnoringCase(value, "metadata")) { | 555 } else if (equalIgnoringCase(value, "metadata")) { |
| 552 m_preload = MediaPlayer::MetaData; | 556 m_preload = WebMediaPlayer::PreloadMetaData; |
| 553 } else { | 557 } else { |
| 554 // The spec does not define an "invalid value default" but "auto" is suggested as the | 558 // The spec does not define an "invalid value default" but "auto" is suggested as the |
| 555 // "missing value default", so use it for everything except "none" a nd "metadata" | 559 // "missing value default", so use it for everything except "none" a nd "metadata" |
| 556 m_preload = MediaPlayer::Auto; | 560 m_preload = WebMediaPlayer::PreloadAuto; |
| 557 } | 561 } |
| 558 | 562 |
| 559 // The attribute must be ignored if the autoplay attribute is present | 563 // The attribute must be ignored if the autoplay attribute is present |
| 560 if (m_player) | 564 setPlayerPreload(); |
| 561 setPlayerPreload(); | |
| 562 | |
| 563 } else if (name == mediagroupAttr && RuntimeEnabledFeatures::mediaController Enabled()) { | 565 } else if (name == mediagroupAttr && RuntimeEnabledFeatures::mediaController Enabled()) { |
| 564 setMediaGroup(value); | 566 setMediaGroup(value); |
| 565 } else { | 567 } else { |
| 566 HTMLElement::parseAttribute(name, value); | 568 HTMLElement::parseAttribute(name, value); |
| 567 } | 569 } |
| 568 } | 570 } |
| 569 | 571 |
| 570 void HTMLMediaElement::finishParsingChildren() | 572 void HTMLMediaElement::finishParsingChildren() |
| 571 { | 573 { |
| 572 HTMLElement::finishParsingChildren(); | 574 HTMLElement::finishParsingChildren(); |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 997 m_mediaSource = nullptr; | 999 m_mediaSource = nullptr; |
| 998 attemptLoad = false; | 1000 attemptLoad = false; |
| 999 } | 1001 } |
| 1000 } | 1002 } |
| 1001 } | 1003 } |
| 1002 } | 1004 } |
| 1003 | 1005 |
| 1004 if (attemptLoad && canLoadURL(url, contentType, keySystem)) { | 1006 if (attemptLoad && canLoadURL(url, contentType, keySystem)) { |
| 1005 ASSERT(!webMediaPlayer()); | 1007 ASSERT(!webMediaPlayer()); |
| 1006 | 1008 |
| 1007 if (!m_havePreparedToPlay && !autoplay() && m_preload == MediaPlayer::No ne) { | 1009 if (!m_havePreparedToPlay && !autoplay() && m_preload == WebMediaPlayer: :PreloadNone) { |
| 1008 WTF_LOG(Media, "HTMLMediaElement::loadResource(%p) : Delaying load b ecause preload == 'none'", this); | 1010 WTF_LOG(Media, "HTMLMediaElement::loadResource(%p) : Delaying load b ecause preload == 'none'", this); |
| 1009 deferLoad(); | 1011 deferLoad(); |
| 1010 } else { | 1012 } else { |
| 1011 startPlayerLoad(); | 1013 startPlayerLoad(); |
| 1012 } | 1014 } |
| 1013 } else { | 1015 } else { |
| 1014 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); | 1016 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); |
| 1015 } | 1017 } |
| 1016 | 1018 |
| 1017 // If there is no poster to display, allow the media engine to render video frames as soon as | 1019 // If there is no poster to display, allow the media engine to render video frames as soon as |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 1036 // along with that potentially also specifying a setting for its | 1038 // along with that potentially also specifying a setting for its |
| 1037 // 'authentication flag' to control how user:pass embedded in a | 1039 // 'authentication flag' to control how user:pass embedded in a |
| 1038 // media resource URL should be treated, then update the handling | 1040 // media resource URL should be treated, then update the handling |
| 1039 // here to match. | 1041 // here to match. |
| 1040 KURL requestURL = m_currentSrc; | 1042 KURL requestURL = m_currentSrc; |
| 1041 if (!requestURL.user().isEmpty()) | 1043 if (!requestURL.user().isEmpty()) |
| 1042 requestURL.setUser(String()); | 1044 requestURL.setUser(String()); |
| 1043 if (!requestURL.pass().isEmpty()) | 1045 if (!requestURL.pass().isEmpty()) |
| 1044 requestURL.setPass(String()); | 1046 requestURL.setPass(String()); |
| 1045 | 1047 |
| 1046 m_player->load(loadType(), requestURL, corsMode()); | 1048 ASSERT(!m_webMediaPlayer); |
|
philipj_slow
2015/07/06 11:07:10
Perhaps move this to the top of the function.
Srirama
2015/07/09 15:19:37
Done.
| |
| 1049 | |
| 1050 LocalFrame* frame = document().frame(); | |
|
philipj_slow
2015/07/06 11:07:10
I think handling the null case here instead of in
Srirama
2015/07/09 15:19:37
Done. Added TODO for time being, will investigate
| |
| 1051 KURL kurl(ParsedURLString, requestURL); | |
| 1052 m_webMediaPlayer = frame->loader().client()->createWebMediaPlayer(this, kurl ); | |
| 1053 if (!m_webMediaPlayer) { | |
| 1054 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); | |
| 1055 return; | |
| 1056 } | |
| 1057 | |
| 1058 if (layoutObject()) | |
| 1059 layoutObject()->setShouldDoFullPaintInvalidation(); | |
| 1060 #if ENABLE(WEB_AUDIO) | |
| 1061 // Make sure if we create/re-create the WebMediaPlayer that we update our wr apper. | |
| 1062 m_audioSourceProvider.wrap(m_webMediaPlayer->audioSourceProvider()); | |
| 1063 #endif | |
| 1064 m_webMediaPlayer->setVolume(effectiveMediaVolume()); | |
| 1065 | |
| 1066 m_webMediaPlayer->setPoster(posterImageURL()); | |
| 1067 | |
| 1068 m_webMediaPlayer->setPreload(effectivePreloadType()); | |
| 1069 | |
| 1070 m_webMediaPlayer->load(loadType(), kurl, corsMode()); | |
| 1071 | |
| 1072 if (isFullscreen()) | |
| 1073 m_webMediaPlayer->enterFullscreen(); | |
| 1047 } | 1074 } |
| 1048 | 1075 |
| 1049 void HTMLMediaElement::setPlayerPreload() | 1076 void HTMLMediaElement::setPlayerPreload() |
| 1050 { | 1077 { |
| 1051 m_player->setPreload(effectivePreloadType()); | 1078 if (m_webMediaPlayer) |
| 1079 m_webMediaPlayer->setPreload(effectivePreloadType()); | |
| 1052 | 1080 |
| 1053 if (loadIsDeferred() && m_preload != MediaPlayer::None) | 1081 if (loadIsDeferred() && m_preload != WebMediaPlayer::PreloadNone) |
| 1054 startDeferredLoad(); | 1082 startDeferredLoad(); |
| 1055 } | 1083 } |
| 1056 | 1084 |
| 1057 bool HTMLMediaElement::loadIsDeferred() const | 1085 bool HTMLMediaElement::loadIsDeferred() const |
| 1058 { | 1086 { |
| 1059 return m_deferredLoadState != NotDeferred; | 1087 return m_deferredLoadState != NotDeferred; |
| 1060 } | 1088 } |
| 1061 | 1089 |
| 1062 void HTMLMediaElement::deferLoad() | 1090 void HTMLMediaElement::deferLoad() |
| 1063 { | 1091 { |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 1091 // This is assumed to be whatever 'event' ended up calling this method. | 1119 // This is assumed to be whatever 'event' ended up calling this method. |
| 1092 cancelDeferredLoad(); | 1120 cancelDeferredLoad(); |
| 1093 // 6. Set the element's delaying-the-load-event flag back to true (this | 1121 // 6. Set the element's delaying-the-load-event flag back to true (this |
| 1094 // delays the load event again, in case it hasn't been fired yet). | 1122 // delays the load event again, in case it hasn't been fired yet). |
| 1095 setShouldDelayLoadEvent(true); | 1123 setShouldDelayLoadEvent(true); |
| 1096 // 7. Set the networkState to NETWORK_LOADING. | 1124 // 7. Set the networkState to NETWORK_LOADING. |
| 1097 m_networkState = NETWORK_LOADING; | 1125 m_networkState = NETWORK_LOADING; |
| 1098 | 1126 |
| 1099 startProgressEventTimer(); | 1127 startProgressEventTimer(); |
| 1100 | 1128 |
| 1129 if (!document().frame()) { | |
| 1130 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); | |
| 1131 return; | |
| 1132 } | |
| 1101 startPlayerLoad(); | 1133 startPlayerLoad(); |
| 1102 } | 1134 } |
| 1103 | 1135 |
| 1104 void HTMLMediaElement::startDeferredLoad() | 1136 void HTMLMediaElement::startDeferredLoad() |
| 1105 { | 1137 { |
| 1106 if (m_deferredLoadState == WaitingForTrigger) { | 1138 if (m_deferredLoadState == WaitingForTrigger) { |
| 1107 executeDeferredLoad(); | 1139 executeDeferredLoad(); |
| 1108 return; | 1140 return; |
| 1109 } | 1141 } |
| 1110 ASSERT(m_deferredLoadState == WaitingForStopDelayingLoadEventTask); | 1142 ASSERT(m_deferredLoadState == WaitingForStopDelayingLoadEventTask); |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1307 | 1339 |
| 1308 void HTMLMediaElement::cancelPendingEventsAndCallbacks() | 1340 void HTMLMediaElement::cancelPendingEventsAndCallbacks() |
| 1309 { | 1341 { |
| 1310 WTF_LOG(Media, "HTMLMediaElement::cancelPendingEventsAndCallbacks(%p)", this ); | 1342 WTF_LOG(Media, "HTMLMediaElement::cancelPendingEventsAndCallbacks(%p)", this ); |
| 1311 m_asyncEventQueue->cancelAllEvents(); | 1343 m_asyncEventQueue->cancelAllEvents(); |
| 1312 | 1344 |
| 1313 for (HTMLSourceElement* source = Traversal<HTMLSourceElement>::firstChild(*t his); source; source = Traversal<HTMLSourceElement>::nextSibling(*source)) | 1345 for (HTMLSourceElement* source = Traversal<HTMLSourceElement>::firstChild(*t his); source; source = Traversal<HTMLSourceElement>::nextSibling(*source)) |
| 1314 source->cancelPendingErrorEvent(); | 1346 source->cancelPendingErrorEvent(); |
| 1315 } | 1347 } |
| 1316 | 1348 |
| 1317 void HTMLMediaElement::mediaPlayerNetworkStateChanged() | 1349 void HTMLMediaElement::networkStateChanged() |
| 1318 { | 1350 { |
| 1319 setNetworkState(webMediaPlayer()->networkState()); | 1351 setNetworkState(webMediaPlayer()->networkState()); |
| 1320 } | 1352 } |
| 1321 | 1353 |
| 1322 void HTMLMediaElement::mediaLoadingFailed(WebMediaPlayer::NetworkState error) | 1354 void HTMLMediaElement::mediaLoadingFailed(WebMediaPlayer::NetworkState error) |
| 1323 { | 1355 { |
| 1324 stopPeriodicTimers(); | 1356 stopPeriodicTimers(); |
| 1325 | 1357 |
| 1326 // If we failed while trying to load a <source> element, the movie was never parsed, and there are more | 1358 // If we failed while trying to load a <source> element, the movie was never parsed, and there are more |
| 1327 // <source> children, schedule the next one | 1359 // <source> children, schedule the next one |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1398 | 1430 |
| 1399 if (state == WebMediaPlayer::NetworkStateLoaded) { | 1431 if (state == WebMediaPlayer::NetworkStateLoaded) { |
| 1400 if (m_networkState != NETWORK_IDLE) | 1432 if (m_networkState != NETWORK_IDLE) |
| 1401 changeNetworkStateFromLoadingToIdle(); | 1433 changeNetworkStateFromLoadingToIdle(); |
| 1402 m_completelyLoaded = true; | 1434 m_completelyLoaded = true; |
| 1403 } | 1435 } |
| 1404 } | 1436 } |
| 1405 | 1437 |
| 1406 void HTMLMediaElement::changeNetworkStateFromLoadingToIdle() | 1438 void HTMLMediaElement::changeNetworkStateFromLoadingToIdle() |
| 1407 { | 1439 { |
| 1408 ASSERT(m_player); | |
| 1409 m_progressEventTimer.stop(); | 1440 m_progressEventTimer.stop(); |
| 1410 | 1441 |
| 1411 // Schedule one last progress event so we guarantee that at least one is fir ed | 1442 // Schedule one last progress event so we guarantee that at least one is fir ed |
| 1412 // for files that load very quickly. | 1443 // for files that load very quickly. |
| 1413 if (webMediaPlayer() && webMediaPlayer()->didLoadingProgress()) | 1444 if (webMediaPlayer() && webMediaPlayer()->didLoadingProgress()) |
| 1414 scheduleEvent(EventTypeNames::progress); | 1445 scheduleEvent(EventTypeNames::progress); |
| 1415 scheduleEvent(EventTypeNames::suspend); | 1446 scheduleEvent(EventTypeNames::suspend); |
| 1416 m_networkState = NETWORK_IDLE; | 1447 m_networkState = NETWORK_IDLE; |
| 1417 } | 1448 } |
| 1418 | 1449 |
| 1419 void HTMLMediaElement::mediaPlayerReadyStateChanged() | 1450 void HTMLMediaElement::readyStateChanged() |
| 1420 { | 1451 { |
| 1421 setReadyState(static_cast<ReadyState>(webMediaPlayer()->readyState())); | 1452 setReadyState(static_cast<ReadyState>(webMediaPlayer()->readyState())); |
| 1422 } | 1453 } |
| 1423 | 1454 |
| 1424 void HTMLMediaElement::setReadyState(ReadyState state) | 1455 void HTMLMediaElement::setReadyState(ReadyState state) |
| 1425 { | 1456 { |
| 1426 WTF_LOG(Media, "HTMLMediaElement::setReadyState(%p, %d) - current state is % d,", this, static_cast<int>(state), static_cast<int>(m_readyState)); | 1457 WTF_LOG(Media, "HTMLMediaElement::setReadyState(%p, %d) - current state is % d,", this, static_cast<int>(state), static_cast<int>(m_readyState)); |
| 1427 | 1458 |
| 1428 // Set "wasPotentiallyPlaying" BEFORE updating m_readyState, potentiallyPlay ing() uses it | 1459 // Set "wasPotentiallyPlaying" BEFORE updating m_readyState, potentiallyPlay ing() uses it |
| 1429 bool wasPotentiallyPlaying = potentiallyPlaying(); | 1460 bool wasPotentiallyPlaying = potentiallyPlaying(); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1567 mediaControls()->refreshClosedCaptionsButtonVisibility(); | 1598 mediaControls()->refreshClosedCaptionsButtonVisibility(); |
| 1568 } | 1599 } |
| 1569 | 1600 |
| 1570 updatePlayState(); | 1601 updatePlayState(); |
| 1571 updateMediaController(); | 1602 updateMediaController(); |
| 1572 cueTimeline().updateActiveCues(currentTime()); | 1603 cueTimeline().updateActiveCues(currentTime()); |
| 1573 } | 1604 } |
| 1574 | 1605 |
| 1575 void HTMLMediaElement::progressEventTimerFired(Timer<HTMLMediaElement>*) | 1606 void HTMLMediaElement::progressEventTimerFired(Timer<HTMLMediaElement>*) |
| 1576 { | 1607 { |
| 1577 ASSERT(m_player); | |
| 1578 if (m_networkState != NETWORK_LOADING) | 1608 if (m_networkState != NETWORK_LOADING) |
| 1579 return; | 1609 return; |
| 1580 | 1610 |
| 1581 double time = WTF::currentTime(); | 1611 double time = WTF::currentTime(); |
| 1582 double timedelta = time - m_previousProgressTime; | 1612 double timedelta = time - m_previousProgressTime; |
| 1583 | 1613 |
| 1584 if (webMediaPlayer() && webMediaPlayer()->didLoadingProgress()) { | 1614 if (webMediaPlayer() && webMediaPlayer()->didLoadingProgress()) { |
| 1585 scheduleEvent(EventTypeNames::progress); | 1615 scheduleEvent(EventTypeNames::progress); |
| 1586 m_previousProgressTime = time; | 1616 m_previousProgressTime = time; |
| 1587 m_sentStalledEvent = false; | 1617 m_sentStalledEvent = false; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1620 | 1650 |
| 1621 void HTMLMediaElement::seek(double time) | 1651 void HTMLMediaElement::seek(double time) |
| 1622 { | 1652 { |
| 1623 WTF_LOG(Media, "HTMLMediaElement::seek(%p, %f)", this, time); | 1653 WTF_LOG(Media, "HTMLMediaElement::seek(%p, %f)", this, time); |
| 1624 | 1654 |
| 1625 // 2 - If the media element's readyState is HAVE_NOTHING, abort these steps. | 1655 // 2 - If the media element's readyState is HAVE_NOTHING, abort these steps. |
| 1626 if (m_readyState == HAVE_NOTHING) | 1656 if (m_readyState == HAVE_NOTHING) |
| 1627 return; | 1657 return; |
| 1628 | 1658 |
| 1629 // If the media engine has been told to postpone loading data, let it go ahe ad now. | 1659 // If the media engine has been told to postpone loading data, let it go ahe ad now. |
| 1630 if (m_preload < MediaPlayer::Auto && m_readyState < HAVE_FUTURE_DATA) | 1660 if (m_preload < WebMediaPlayer::PreloadAuto && m_readyState < HAVE_FUTURE_DA TA) |
| 1631 prepareToPlay(); | 1661 prepareToPlay(); |
| 1632 | 1662 |
| 1633 // Get the current time before setting m_seeking, m_lastSeekTime is returned once it is set. | 1663 // Get the current time before setting m_seeking, m_lastSeekTime is returned once it is set. |
| 1634 refreshCachedTime(); | 1664 refreshCachedTime(); |
| 1635 // This is needed to avoid getting default playback start position from curr entTime(). | 1665 // This is needed to avoid getting default playback start position from curr entTime(). |
| 1636 double now = m_cachedTime; | 1666 double now = m_cachedTime; |
| 1637 | 1667 |
| 1638 // 3 - If the element's seeking IDL attribute is true, then another instance of this algorithm is | 1668 // 3 - If the element's seeking IDL attribute is true, then another instance of this algorithm is |
| 1639 // already running. Abort that other instance of the algorithm without waiti ng for the step that | 1669 // already running. Abort that other instance of the algorithm without waiti ng for the step that |
| 1640 // it is running to complete. | 1670 // it is running to complete. |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1794 if (m_readyState == HAVE_NOTHING) { | 1824 if (m_readyState == HAVE_NOTHING) { |
| 1795 m_defaultPlaybackStartPosition = time; | 1825 m_defaultPlaybackStartPosition = time; |
| 1796 return; | 1826 return; |
| 1797 } | 1827 } |
| 1798 | 1828 |
| 1799 seek(time); | 1829 seek(time); |
| 1800 } | 1830 } |
| 1801 | 1831 |
| 1802 double HTMLMediaElement::duration() const | 1832 double HTMLMediaElement::duration() const |
| 1803 { | 1833 { |
| 1804 // FIXME: remove m_player check once we figure out how m_player is going | 1834 // FIXME: remove m_webMediaPlayer check once we figure out how |
| 1805 // out of sync with readystate. m_player is cleared but readystate is not se t | 1835 // m_webMediaPlayer is going out of sync with readystate. |
| 1806 // to HAVE_NOTHING | 1836 // m_webMediaPlayer is cleared but readystate is not set to HAVE_NOTHING. |
| 1807 if (!m_player || m_readyState < HAVE_METADATA) | 1837 if (!m_webMediaPlayer || m_readyState < HAVE_METADATA) |
| 1808 return std::numeric_limits<double>::quiet_NaN(); | 1838 return std::numeric_limits<double>::quiet_NaN(); |
| 1809 | 1839 |
| 1810 // FIXME: Refactor so m_duration is kept current (in both MSE and | 1840 // FIXME: Refactor so m_duration is kept current (in both MSE and |
| 1811 // non-MSE cases) once we have transitioned from HAVE_NOTHING -> | 1841 // non-MSE cases) once we have transitioned from HAVE_NOTHING -> |
| 1812 // HAVE_METADATA. Currently, m_duration may be out of date for at least MSE | 1842 // HAVE_METADATA. Currently, m_duration may be out of date for at least MSE |
| 1813 // case because MediaSource and SourceBuffer do not notify the element | 1843 // case because MediaSource and SourceBuffer do not notify the element |
| 1814 // directly upon duration changes caused by endOfStream, remove, or append | 1844 // directly upon duration changes caused by endOfStream, remove, or append |
| 1815 // operations; rather the notification is triggered by the WebMediaPlayer | 1845 // operations; rather the notification is triggered by the WebMediaPlayer |
| 1816 // implementation observing that the underlying engine has updated duration | 1846 // implementation observing that the underlying engine has updated duration |
| 1817 // and notifying the element to consult its MediaSource for current | 1847 // and notifying the element to consult its MediaSource for current |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1866 } | 1896 } |
| 1867 | 1897 |
| 1868 HTMLMediaElement::DirectionOfPlayback HTMLMediaElement::directionOfPlayback() co nst | 1898 HTMLMediaElement::DirectionOfPlayback HTMLMediaElement::directionOfPlayback() co nst |
| 1869 { | 1899 { |
| 1870 return m_playbackRate >= 0 ? Forward : Backward; | 1900 return m_playbackRate >= 0 ? Forward : Backward; |
| 1871 } | 1901 } |
| 1872 | 1902 |
| 1873 void HTMLMediaElement::updatePlaybackRate() | 1903 void HTMLMediaElement::updatePlaybackRate() |
| 1874 { | 1904 { |
| 1875 double effectiveRate = effectivePlaybackRate(); | 1905 double effectiveRate = effectivePlaybackRate(); |
| 1876 if (m_player && potentiallyPlaying()) | 1906 // FIXME: remove m_webMediaPlayer check once we figure out how |
| 1907 // m_webMediaPlayer is going out of sync with readystate. | |
| 1908 // m_webMediaPlayer is cleared but readystate is not set to HAVE_NOTHING. | |
| 1909 if (m_webMediaPlayer && potentiallyPlaying()) | |
| 1877 webMediaPlayer()->setRate(effectiveRate); | 1910 webMediaPlayer()->setRate(effectiveRate); |
| 1878 } | 1911 } |
| 1879 | 1912 |
| 1880 bool HTMLMediaElement::ended() const | 1913 bool HTMLMediaElement::ended() const |
| 1881 { | 1914 { |
| 1882 // 4.8.10.8 Playing the media resource | 1915 // 4.8.10.8 Playing the media resource |
| 1883 // The ended attribute must return true if the media element has ended | 1916 // The ended attribute must return true if the media element has ended |
| 1884 // playback and the direction of playback is forwards, and false otherwise. | 1917 // playback and the direction of playback is forwards, and false otherwise. |
| 1885 return endedPlayback() && directionOfPlayback() == Forward; | 1918 return endedPlayback() && directionOfPlayback() == Forward; |
| 1886 } | 1919 } |
| 1887 | 1920 |
| 1888 bool HTMLMediaElement::autoplay() const | 1921 bool HTMLMediaElement::autoplay() const |
| 1889 { | 1922 { |
| 1890 return fastHasAttribute(autoplayAttr); | 1923 return fastHasAttribute(autoplayAttr); |
| 1891 } | 1924 } |
| 1892 | 1925 |
| 1893 String HTMLMediaElement::preload() const | 1926 String HTMLMediaElement::preload() const |
| 1894 { | 1927 { |
| 1895 switch (m_preload) { | 1928 switch (m_preload) { |
| 1896 case MediaPlayer::None: | 1929 case WebMediaPlayer::PreloadNone: |
| 1897 return "none"; | 1930 return "none"; |
| 1898 break; | 1931 break; |
| 1899 case MediaPlayer::MetaData: | 1932 case WebMediaPlayer::PreloadMetaData: |
| 1900 return "metadata"; | 1933 return "metadata"; |
| 1901 break; | 1934 break; |
| 1902 case MediaPlayer::Auto: | 1935 case WebMediaPlayer::PreloadAuto: |
| 1903 return "auto"; | 1936 return "auto"; |
| 1904 break; | 1937 break; |
| 1905 } | 1938 } |
| 1906 | 1939 |
| 1907 ASSERT_NOT_REACHED(); | 1940 ASSERT_NOT_REACHED(); |
| 1908 return String(); | 1941 return String(); |
| 1909 } | 1942 } |
| 1910 | 1943 |
| 1911 void HTMLMediaElement::setPreload(const AtomicString& preload) | 1944 void HTMLMediaElement::setPreload(const AtomicString& preload) |
| 1912 { | 1945 { |
| 1913 WTF_LOG(Media, "HTMLMediaElement::setPreload(%p, %s)", this, preload.utf8(). data()); | 1946 WTF_LOG(Media, "HTMLMediaElement::setPreload(%p, %s)", this, preload.utf8(). data()); |
| 1914 setAttribute(preloadAttr, preload); | 1947 setAttribute(preloadAttr, preload); |
| 1915 } | 1948 } |
| 1916 | 1949 |
| 1917 MediaPlayer::Preload HTMLMediaElement::effectivePreloadType() const | 1950 WebMediaPlayer::Preload HTMLMediaElement::effectivePreloadType() const |
| 1918 { | 1951 { |
| 1919 return autoplay() ? MediaPlayer::Auto : m_preload; | 1952 return autoplay() ? WebMediaPlayer::PreloadAuto : m_preload; |
| 1920 } | 1953 } |
| 1921 | 1954 |
| 1922 void HTMLMediaElement::play() | 1955 void HTMLMediaElement::play() |
| 1923 { | 1956 { |
| 1924 WTF_LOG(Media, "HTMLMediaElement::play(%p)", this); | 1957 WTF_LOG(Media, "HTMLMediaElement::play(%p)", this); |
| 1925 | 1958 |
| 1926 if (!UserGestureIndicator::processingUserGesture()) { | 1959 if (!UserGestureIndicator::processingUserGesture()) { |
| 1927 autoplayMediaEncountered(); | 1960 autoplayMediaEncountered(); |
| 1928 if (m_userGestureRequiredForPlay) { | 1961 if (m_userGestureRequiredForPlay) { |
| 1929 String message = ExceptionMessages::failedToExecute("play", "HTMLMed iaElement", "API can only be initiated by a user gesture."); | 1962 String message = ExceptionMessages::failedToExecute("play", "HTMLMed iaElement", "API can only be initiated by a user gesture."); |
| 1930 document().executionContext()->addConsoleMessage(ConsoleMessage::cre ate(JSMessageSource, WarningMessageLevel, message)); | 1963 document().executionContext()->addConsoleMessage(ConsoleMessage::cre ate(JSMessageSource, WarningMessageLevel, message)); |
| 1931 return; | 1964 return; |
| 1932 } | 1965 } |
| 1933 } else if (m_userGestureRequiredForPlay) { | 1966 } else if (m_userGestureRequiredForPlay) { |
| 1934 if (m_autoplayMediaCounted) | 1967 if (m_autoplayMediaCounted) |
| 1935 recordAutoplayMetric(AutoplayManualStart); | 1968 recordAutoplayMetric(AutoplayManualStart); |
| 1936 m_userGestureRequiredForPlay = false; | 1969 m_userGestureRequiredForPlay = false; |
| 1937 } | 1970 } |
| 1938 | 1971 |
| 1939 playInternal(); | 1972 playInternal(); |
| 1940 } | 1973 } |
| 1941 | 1974 |
| 1942 void HTMLMediaElement::playInternal() | 1975 void HTMLMediaElement::playInternal() |
| 1943 { | 1976 { |
| 1944 WTF_LOG(Media, "HTMLMediaElement::playInternal(%p)", this); | 1977 WTF_LOG(Media, "HTMLMediaElement::playInternal(%p)", this); |
| 1945 | 1978 |
| 1946 // 4.8.10.9. Playing the media resource | 1979 // 4.8.10.9. Playing the media resource |
| 1947 if (!m_player || m_networkState == NETWORK_EMPTY) | 1980 if (m_networkState == NETWORK_EMPTY) |
| 1948 scheduleDelayedAction(LoadMediaResource); | 1981 scheduleDelayedAction(LoadMediaResource); |
| 1949 | 1982 |
| 1950 // Generally "ended" and "looping" are exclusive. Here, the loop attribute | 1983 // Generally "ended" and "looping" are exclusive. Here, the loop attribute |
| 1951 // is ignored to seek back to start in case loop was set after playback | 1984 // is ignored to seek back to start in case loop was set after playback |
| 1952 // ended. See http://crbug.com/364442 | 1985 // ended. See http://crbug.com/364442 |
| 1953 if (endedPlayback(LoopCondition::Ignored)) | 1986 if (endedPlayback(LoopCondition::Ignored)) |
| 1954 seek(0); | 1987 seek(0); |
| 1955 | 1988 |
| 1956 if (m_mediaController) | 1989 if (m_mediaController) |
| 1957 m_mediaController->bringElementUpToSpeed(this); | 1990 m_mediaController->bringElementUpToSpeed(this); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1997 double progress = playedTime / duration(); | 2030 double progress = playedTime / duration(); |
| 1998 if (progress < 0.5) | 2031 if (progress < 0.5) |
| 1999 recordAutoplayMetric(AutoplayBailout); | 2032 recordAutoplayMetric(AutoplayBailout); |
| 2000 } | 2033 } |
| 2001 } | 2034 } |
| 2002 | 2035 |
| 2003 void HTMLMediaElement::pause() | 2036 void HTMLMediaElement::pause() |
| 2004 { | 2037 { |
| 2005 WTF_LOG(Media, "HTMLMediaElement::pause(%p)", this); | 2038 WTF_LOG(Media, "HTMLMediaElement::pause(%p)", this); |
| 2006 | 2039 |
| 2007 if (!m_player || m_networkState == NETWORK_EMPTY) | 2040 if (m_networkState == NETWORK_EMPTY) |
| 2008 scheduleDelayedAction(LoadMediaResource); | 2041 scheduleDelayedAction(LoadMediaResource); |
| 2009 | 2042 |
| 2010 m_autoplaying = false; | 2043 m_autoplaying = false; |
| 2011 | 2044 |
| 2012 if (!m_paused) { | 2045 if (!m_paused) { |
| 2013 if (m_initialPlayWithoutUserGestures) | 2046 if (m_initialPlayWithoutUserGestures) |
| 2014 gesturelessInitialPlayHalted(); | 2047 gesturelessInitialPlayHalted(); |
| 2015 | 2048 |
| 2016 m_paused = true; | 2049 m_paused = true; |
| 2017 scheduleTimeupdateEvent(false); | 2050 scheduleTimeupdateEvent(false); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2142 { | 2175 { |
| 2143 if (m_playbackProgressTimer.isActive()) | 2176 if (m_playbackProgressTimer.isActive()) |
| 2144 return; | 2177 return; |
| 2145 | 2178 |
| 2146 m_previousProgressTime = WTF::currentTime(); | 2179 m_previousProgressTime = WTF::currentTime(); |
| 2147 m_playbackProgressTimer.startRepeating(maxTimeupdateEventFrequency, FROM_HER E); | 2180 m_playbackProgressTimer.startRepeating(maxTimeupdateEventFrequency, FROM_HER E); |
| 2148 } | 2181 } |
| 2149 | 2182 |
| 2150 void HTMLMediaElement::playbackProgressTimerFired(Timer<HTMLMediaElement>*) | 2183 void HTMLMediaElement::playbackProgressTimerFired(Timer<HTMLMediaElement>*) |
| 2151 { | 2184 { |
| 2152 ASSERT(m_player); | |
| 2153 | |
| 2154 if (!std::isnan(m_fragmentEndTime) && currentTime() >= m_fragmentEndTime && directionOfPlayback() == Forward) { | 2185 if (!std::isnan(m_fragmentEndTime) && currentTime() >= m_fragmentEndTime && directionOfPlayback() == Forward) { |
| 2155 m_fragmentEndTime = std::numeric_limits<double>::quiet_NaN(); | 2186 m_fragmentEndTime = std::numeric_limits<double>::quiet_NaN(); |
| 2156 if (!m_mediaController && !m_paused) { | 2187 if (!m_mediaController && !m_paused) { |
| 2157 UseCounter::count(document(), UseCounter::HTMLMediaElementPauseAtFra gmentEnd); | 2188 UseCounter::count(document(), UseCounter::HTMLMediaElementPauseAtFra gmentEnd); |
| 2158 // changes paused to true and fires a simple event named pause at th e media element. | 2189 // changes paused to true and fires a simple event named pause at th e media element. |
| 2159 pause(); | 2190 pause(); |
| 2160 } | 2191 } |
| 2161 } | 2192 } |
| 2162 | 2193 |
| 2163 if (!m_seeking) | 2194 if (!m_seeking) |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2238 Vector<WebMediaPlayer::TrackId> enabledTrackIds; | 2269 Vector<WebMediaPlayer::TrackId> enabledTrackIds; |
| 2239 for (unsigned i = 0; i < audioTracks().length(); ++i) { | 2270 for (unsigned i = 0; i < audioTracks().length(); ++i) { |
| 2240 AudioTrack* track = audioTracks().anonymousIndexedGetter(i); | 2271 AudioTrack* track = audioTracks().anonymousIndexedGetter(i); |
| 2241 if (track->enabled()) | 2272 if (track->enabled()) |
| 2242 enabledTrackIds.append(track->trackId()); | 2273 enabledTrackIds.append(track->trackId()); |
| 2243 } | 2274 } |
| 2244 | 2275 |
| 2245 webMediaPlayer()->enabledAudioTracksChanged(enabledTrackIds); | 2276 webMediaPlayer()->enabledAudioTracksChanged(enabledTrackIds); |
| 2246 } | 2277 } |
| 2247 | 2278 |
| 2248 WebMediaPlayer::TrackId HTMLMediaElement::addAudioTrack(const String& id, WebMed iaPlayerClient::AudioTrackKind kind, const AtomicString& label, const AtomicStri ng& language, bool enabled) | 2279 WebMediaPlayer::TrackId HTMLMediaElement::addAudioTrack(const WebString& id, bli nk::WebMediaPlayerClient::AudioTrackKind kind, const WebString& label, const Web String& language, bool enabled) |
| 2249 { | 2280 { |
| 2250 AtomicString kindString = AudioKindToString(kind); | 2281 AtomicString kindString = AudioKindToString(kind); |
| 2251 WTF_LOG(Media, "HTMLMediaElement::addAudioTrack(%p, '%s', '%s', '%s', '%s', %d)", | 2282 WTF_LOG(Media, "HTMLMediaElement::addAudioTrack(%p, '%s', '%s', '%s', '%s', %d)", |
| 2252 this, id.ascii().data(), kindString.ascii().data(), label.ascii().data() , language.ascii().data(), enabled); | 2283 this, id.utf8().data(), kindString.ascii().data(), label.utf8().data(), language.utf8().data(), enabled); |
| 2253 | 2284 |
| 2254 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | 2285 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) |
| 2255 return 0; | 2286 return 0; |
| 2256 | 2287 |
| 2257 RefPtrWillBeRawPtr<AudioTrack> audioTrack = AudioTrack::create(id, kindStrin g, label, language, enabled); | 2288 RefPtrWillBeRawPtr<AudioTrack> audioTrack = AudioTrack::create(id, kindStrin g, label, language, enabled); |
| 2258 audioTracks().add(audioTrack); | 2289 audioTracks().add(audioTrack); |
| 2259 | 2290 |
| 2260 return audioTrack->trackId(); | 2291 return audioTrack->trackId(); |
| 2261 } | 2292 } |
| 2262 | 2293 |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 2282 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | 2313 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); |
| 2283 | 2314 |
| 2284 if (selectedTrackId) | 2315 if (selectedTrackId) |
| 2285 videoTracks().trackSelected(*selectedTrackId); | 2316 videoTracks().trackSelected(*selectedTrackId); |
| 2286 | 2317 |
| 2287 // FIXME: Add call on m_mediaSource to notify it of track changes once the S ourceBuffer.videoTracks attribute is added. | 2318 // FIXME: Add call on m_mediaSource to notify it of track changes once the S ourceBuffer.videoTracks attribute is added. |
| 2288 | 2319 |
| 2289 webMediaPlayer()->selectedVideoTrackChanged(selectedTrackId); | 2320 webMediaPlayer()->selectedVideoTrackChanged(selectedTrackId); |
| 2290 } | 2321 } |
| 2291 | 2322 |
| 2292 WebMediaPlayer::TrackId HTMLMediaElement::addVideoTrack(const String& id, WebMed iaPlayerClient::VideoTrackKind kind, const AtomicString& label, const AtomicStri ng& language, bool selected) | 2323 WebMediaPlayer::TrackId HTMLMediaElement::addVideoTrack(const WebString& id, bli nk::WebMediaPlayerClient::VideoTrackKind kind, const WebString& label, const Web String& language, bool selected) |
| 2293 { | 2324 { |
| 2294 AtomicString kindString = VideoKindToString(kind); | 2325 AtomicString kindString = VideoKindToString(kind); |
| 2295 WTF_LOG(Media, "HTMLMediaElement::addVideoTrack(%p, '%s', '%s', '%s', '%s', %d)", | 2326 WTF_LOG(Media, "HTMLMediaElement::addVideoTrack(%p, '%s', '%s', '%s', '%s', %d)", |
| 2296 this, id.ascii().data(), kindString.ascii().data(), label.ascii().data() , language.ascii().data(), selected); | 2327 this, id.utf8().data(), kindString.ascii().data(), label.utf8().data(), language.utf8().data(), selected); |
| 2297 | 2328 |
| 2298 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | 2329 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) |
| 2299 return 0; | 2330 return 0; |
| 2300 | 2331 |
| 2301 // If another track was selected (potentially by the user), leave it selecte d. | 2332 // If another track was selected (potentially by the user), leave it selecte d. |
| 2302 if (selected && videoTracks().selectedIndex() != -1) | 2333 if (selected && videoTracks().selectedIndex() != -1) |
| 2303 selected = false; | 2334 selected = false; |
| 2304 | 2335 |
| 2305 RefPtrWillBeRawPtr<VideoTrack> videoTrack = VideoTrack::create(id, kindStrin g, label, language, selected); | 2336 RefPtrWillBeRawPtr<VideoTrack> videoTrack = VideoTrack::create(id, kindStrin g, label, language, selected); |
| 2306 videoTracks().add(videoTrack); | 2337 videoTracks().add(videoTrack); |
| 2307 | 2338 |
| 2308 return videoTrack->trackId(); | 2339 return videoTrack->trackId(); |
| 2309 } | 2340 } |
| 2310 | 2341 |
| 2311 void HTMLMediaElement::removeVideoTrack(WebMediaPlayer::TrackId trackId) | 2342 void HTMLMediaElement::removeVideoTrack(WebMediaPlayer::TrackId trackId) |
| 2312 { | 2343 { |
| 2313 WTF_LOG(Media, "HTMLMediaElement::removeVideoTrack(%p)", this); | 2344 WTF_LOG(Media, "HTMLMediaElement::removeVideoTrack(%p)", this); |
| 2314 | 2345 |
| 2315 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | 2346 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) |
| 2316 return; | 2347 return; |
| 2317 | 2348 |
| 2318 videoTracks().remove(trackId); | 2349 videoTracks().remove(trackId); |
| 2319 } | 2350 } |
| 2320 | 2351 |
| 2321 void HTMLMediaElement::mediaPlayerDidAddTextTrack(WebInbandTextTrack* webTrack) | 2352 void HTMLMediaElement::addTextTrack(WebInbandTextTrack* webTrack) |
| 2322 { | 2353 { |
| 2323 // 4.8.10.12.2 Sourcing in-band text tracks | 2354 // 4.8.10.12.2 Sourcing in-band text tracks |
| 2324 // 1. Associate the relevant data with a new text track and its correspondin g new TextTrack object. | 2355 // 1. Associate the relevant data with a new text track and its correspondin g new TextTrack object. |
| 2325 RefPtrWillBeRawPtr<InbandTextTrack> textTrack = InbandTextTrack::create(webT rack); | 2356 RefPtrWillBeRawPtr<InbandTextTrack> textTrack = InbandTextTrack::create(webT rack); |
| 2326 | 2357 |
| 2327 // 2. Set the new text track's kind, label, and language based on the semant ics of the relevant data, | 2358 // 2. Set the new text track's kind, label, and language based on the semant ics of the relevant data, |
| 2328 // as defined by the relevant specification. If there is no label in that da ta, then the label must | 2359 // as defined by the relevant specification. If there is no label in that da ta, then the label must |
| 2329 // be set to the empty string. | 2360 // be set to the empty string. |
| 2330 // 3. Associate the text track list of cues with the rules for updating the text track rendering appropriate | 2361 // 3. Associate the text track list of cues with the rules for updating the text track rendering appropriate |
| 2331 // for the format in question. | 2362 // for the format in question. |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 2343 // - This will happen in honorUserPreferencesForAutomaticTextTrackSelection () | 2374 // - This will happen in honorUserPreferencesForAutomaticTextTrackSelection () |
| 2344 scheduleDelayedAction(LoadTextTrackResource); | 2375 scheduleDelayedAction(LoadTextTrackResource); |
| 2345 | 2376 |
| 2346 // 8. Add the new text track to the media element's list of text tracks. | 2377 // 8. Add the new text track to the media element's list of text tracks. |
| 2347 // 9. Fire an event with the name addtrack, that does not bubble and is not cancelable, and that uses the TrackEvent | 2378 // 9. Fire an event with the name addtrack, that does not bubble and is not cancelable, and that uses the TrackEvent |
| 2348 // interface, with the track attribute initialized to the text track's TextT rack object, at the media element's | 2379 // interface, with the track attribute initialized to the text track's TextT rack object, at the media element's |
| 2349 // textTracks attribute's TextTrackList object. | 2380 // textTracks attribute's TextTrackList object. |
| 2350 addTextTrack(textTrack.get()); | 2381 addTextTrack(textTrack.get()); |
| 2351 } | 2382 } |
| 2352 | 2383 |
| 2353 void HTMLMediaElement::mediaPlayerDidRemoveTextTrack(WebInbandTextTrack* webTrac k) | 2384 void HTMLMediaElement::removeTextTrack(WebInbandTextTrack* webTrack) |
| 2354 { | 2385 { |
| 2355 if (!m_textTracks) | 2386 if (!m_textTracks) |
| 2356 return; | 2387 return; |
| 2357 | 2388 |
| 2358 // This cast is safe because we created the InbandTextTrack with the WebInba ndTextTrack | 2389 // This cast is safe because we created the InbandTextTrack with the WebInba ndTextTrack |
| 2359 // passed to mediaPlayerDidAddTextTrack. | 2390 // passed to mediaPlayerDidAddTextTrack. |
| 2360 RefPtrWillBeRawPtr<InbandTextTrack> textTrack = static_cast<InbandTextTrack* >(webTrack->client()); | 2391 RefPtrWillBeRawPtr<InbandTextTrack> textTrack = static_cast<InbandTextTrack* >(webTrack->client()); |
| 2361 if (!textTrack) | 2392 if (!textTrack) |
| 2362 return; | 2393 return; |
| 2363 | 2394 |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2684 WTF_LOG(Media, "HTMLMediaElement::sourceRemoved(%p) - m_nextChildNodeToC onsider set to %p", this, m_nextChildNodeToConsider.get()); | 2715 WTF_LOG(Media, "HTMLMediaElement::sourceRemoved(%p) - m_nextChildNodeToC onsider set to %p", this, m_nextChildNodeToConsider.get()); |
| 2685 } else if (source == m_currentSourceNode) { | 2716 } else if (source == m_currentSourceNode) { |
| 2686 // Clear the current source node pointer, but don't change the movie as the spec says: | 2717 // Clear the current source node pointer, but don't change the movie as the spec says: |
| 2687 // 4.8.8 - Dynamically modifying a source element and its attribute when the element is already | 2718 // 4.8.8 - Dynamically modifying a source element and its attribute when the element is already |
| 2688 // inserted in a video or audio element will have no effect. | 2719 // inserted in a video or audio element will have no effect. |
| 2689 m_currentSourceNode = nullptr; | 2720 m_currentSourceNode = nullptr; |
| 2690 WTF_LOG(Media, "HTMLMediaElement::sourceRemoved(%p) - m_currentSourceNod e set to 0", this); | 2721 WTF_LOG(Media, "HTMLMediaElement::sourceRemoved(%p) - m_currentSourceNod e set to 0", this); |
| 2691 } | 2722 } |
| 2692 } | 2723 } |
| 2693 | 2724 |
| 2694 void HTMLMediaElement::mediaPlayerTimeChanged() | 2725 void HTMLMediaElement::timeChanged() |
| 2695 { | 2726 { |
| 2696 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerTimeChanged(%p)", this); | 2727 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerTimeChanged(%p)", this); |
| 2697 | 2728 |
| 2698 cueTimeline().updateActiveCues(currentTime()); | 2729 cueTimeline().updateActiveCues(currentTime()); |
| 2699 | 2730 |
| 2700 invalidateCachedTime(); | 2731 invalidateCachedTime(); |
| 2701 | 2732 |
| 2702 // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with t he seek. | 2733 // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with t he seek. |
| 2703 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !webMediaPlayer()->see king()) | 2734 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !webMediaPlayer()->see king()) |
| 2704 finishSeek(); | 2735 finishSeek(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2737 // for the media element's current media controller. | 2768 // for the media element's current media controller. |
| 2738 updateMediaController(); | 2769 updateMediaController(); |
| 2739 } | 2770 } |
| 2740 } else { | 2771 } else { |
| 2741 m_sentEndEvent = false; | 2772 m_sentEndEvent = false; |
| 2742 } | 2773 } |
| 2743 | 2774 |
| 2744 updatePlayState(); | 2775 updatePlayState(); |
| 2745 } | 2776 } |
| 2746 | 2777 |
| 2747 void HTMLMediaElement::mediaPlayerDurationChanged() | 2778 void HTMLMediaElement::durationChanged() |
| 2748 { | 2779 { |
| 2749 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerDurationChanged(%p)", this); | 2780 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p)", this); |
| 2750 // FIXME: Change MediaPlayerClient & WebMediaPlayer to convey | 2781 // FIXME: Change WebMediaPlayer to convey the currentTime |
| 2751 // the currentTime when the duration change occured. The current | 2782 // when the duration change occured. The current WebMediaPlayer |
| 2752 // WebMediaPlayer implementations always clamp currentTime() to | 2783 // implementations always clamp currentTime() to duration() |
| 2753 // duration() so the requestSeek condition here is always false. | 2784 // so the requestSeek condition here is always false. |
| 2754 durationChanged(duration(), currentTime() > duration()); | 2785 durationChanged(duration(), currentTime() > duration()); |
| 2755 } | 2786 } |
| 2756 | 2787 |
| 2757 void HTMLMediaElement::durationChanged(double duration, bool requestSeek) | 2788 void HTMLMediaElement::durationChanged(double duration, bool requestSeek) |
| 2758 { | 2789 { |
| 2759 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p, %f, %d)", this, durati on, requestSeek); | 2790 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p, %f, %d)", this, durati on, requestSeek); |
| 2760 | 2791 |
| 2761 // Abort if duration unchanged. | 2792 // Abort if duration unchanged. |
| 2762 if (m_duration == duration) | 2793 if (m_duration == duration) |
| 2763 return; | 2794 return; |
| 2764 | 2795 |
| 2765 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p) : %f -> %f", this, m_d uration, duration); | 2796 WTF_LOG(Media, "HTMLMediaElement::durationChanged(%p) : %f -> %f", this, m_d uration, duration); |
| 2766 m_duration = duration; | 2797 m_duration = duration; |
| 2767 scheduleEvent(EventTypeNames::durationchange); | 2798 scheduleEvent(EventTypeNames::durationchange); |
| 2768 | 2799 |
| 2769 if (mediaControls()) | 2800 if (mediaControls()) |
| 2770 mediaControls()->reset(); | 2801 mediaControls()->reset(); |
| 2771 if (layoutObject()) | 2802 if (layoutObject()) |
| 2772 layoutObject()->updateFromElement(); | 2803 layoutObject()->updateFromElement(); |
| 2773 | 2804 |
| 2774 if (requestSeek) | 2805 if (requestSeek) |
| 2775 seek(duration); | 2806 seek(duration); |
| 2776 } | 2807 } |
| 2777 | 2808 |
| 2778 void HTMLMediaElement::mediaPlayerPlaybackStateChanged() | 2809 void HTMLMediaElement::playbackStateChanged() |
| 2779 { | 2810 { |
| 2780 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerPlaybackStateChanged(%p)", this ); | 2811 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerPlaybackStateChanged(%p)", this ); |
| 2781 | 2812 |
| 2782 if (!webMediaPlayer()) | 2813 if (!webMediaPlayer()) |
| 2783 return; | 2814 return; |
| 2784 | 2815 |
| 2785 if (webMediaPlayer()->paused()) | 2816 if (webMediaPlayer()->paused()) |
| 2786 pause(); | 2817 pause(); |
| 2787 else | 2818 else |
| 2788 playInternal(); | 2819 playInternal(); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 2813 } | 2844 } |
| 2814 | 2845 |
| 2815 void HTMLMediaElement::disconnectedFromRemoteDevice() | 2846 void HTMLMediaElement::disconnectedFromRemoteDevice() |
| 2816 { | 2847 { |
| 2817 m_playingRemotely = false; | 2848 m_playingRemotely = false; |
| 2818 if (mediaControls()) | 2849 if (mediaControls()) |
| 2819 mediaControls()->stoppedCasting(); | 2850 mediaControls()->stoppedCasting(); |
| 2820 } | 2851 } |
| 2821 | 2852 |
| 2822 // MediaPlayerPresentation methods | 2853 // MediaPlayerPresentation methods |
| 2823 void HTMLMediaElement::mediaPlayerRepaint() | 2854 void HTMLMediaElement::repaint() |
| 2824 { | 2855 { |
| 2825 if (m_webLayer) | 2856 if (m_webLayer) |
| 2826 m_webLayer->invalidate(); | 2857 m_webLayer->invalidate(); |
| 2827 | 2858 |
| 2828 updateDisplayState(); | 2859 updateDisplayState(); |
| 2829 if (layoutObject()) | 2860 if (layoutObject()) |
| 2830 layoutObject()->setShouldDoFullPaintInvalidation(); | 2861 layoutObject()->setShouldDoFullPaintInvalidation(); |
| 2831 } | 2862 } |
| 2832 | 2863 |
| 2833 void HTMLMediaElement::mediaPlayerSizeChanged() | 2864 void HTMLMediaElement::sizeChanged() |
| 2834 { | 2865 { |
| 2835 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerSizeChanged(%p)", this); | 2866 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerSizeChanged(%p)", this); |
| 2836 | 2867 |
| 2837 ASSERT(hasVideo()); // "resize" makes no sense absent video. | 2868 ASSERT(hasVideo()); // "resize" makes no sense absent video. |
| 2838 if (m_readyState > HAVE_NOTHING && isHTMLVideoElement()) | 2869 if (m_readyState > HAVE_NOTHING && isHTMLVideoElement()) |
| 2839 scheduleEvent(EventTypeNames::resize); | 2870 scheduleEvent(EventTypeNames::resize); |
| 2840 | 2871 |
| 2841 if (layoutObject()) | 2872 if (layoutObject()) |
| 2842 layoutObject()->updateFromElement(); | 2873 layoutObject()->updateFromElement(); |
| 2843 } | 2874 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2888 } | 2919 } |
| 2889 | 2920 |
| 2890 bool HTMLMediaElement::couldPlayIfEnoughData() const | 2921 bool HTMLMediaElement::couldPlayIfEnoughData() const |
| 2891 { | 2922 { |
| 2892 return !paused() && !endedPlayback() && !stoppedDueToErrors(); | 2923 return !paused() && !endedPlayback() && !stoppedDueToErrors(); |
| 2893 } | 2924 } |
| 2894 | 2925 |
| 2895 bool HTMLMediaElement::endedPlayback(LoopCondition loopCondition) const | 2926 bool HTMLMediaElement::endedPlayback(LoopCondition loopCondition) const |
| 2896 { | 2927 { |
| 2897 double dur = duration(); | 2928 double dur = duration(); |
| 2898 if (!m_player || std::isnan(dur)) | 2929 if (std::isnan(dur)) |
| 2899 return false; | 2930 return false; |
| 2900 | 2931 |
| 2901 // 4.8.10.8 Playing the media resource | 2932 // 4.8.10.8 Playing the media resource |
| 2902 | 2933 |
| 2903 // A media element is said to have ended playback when the element's | 2934 // A media element is said to have ended playback when the element's |
| 2904 // readyState attribute is HAVE_METADATA or greater, | 2935 // readyState attribute is HAVE_METADATA or greater, |
| 2905 if (m_readyState < HAVE_METADATA) | 2936 if (m_readyState < HAVE_METADATA) |
| 2906 return false; | 2937 return false; |
| 2907 | 2938 |
| 2908 // and the current playback position is the end of the media resource and th e direction | 2939 // and the current playback position is the end of the media resource and th e direction |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 2924 RefPtrWillBeRawPtr<TimeRanges> seekableRanges = seekable(); | 2955 RefPtrWillBeRawPtr<TimeRanges> seekableRanges = seekable(); |
| 2925 if (!seekableRanges->contain(currentTime())) | 2956 if (!seekableRanges->contain(currentTime())) |
| 2926 return true; | 2957 return true; |
| 2927 } | 2958 } |
| 2928 | 2959 |
| 2929 return false; | 2960 return false; |
| 2930 } | 2961 } |
| 2931 | 2962 |
| 2932 void HTMLMediaElement::updatePlayState() | 2963 void HTMLMediaElement::updatePlayState() |
| 2933 { | 2964 { |
| 2934 if (!m_player) | |
| 2935 return; | |
| 2936 | |
| 2937 bool isPlaying = webMediaPlayer() && !webMediaPlayer()->paused(); | 2965 bool isPlaying = webMediaPlayer() && !webMediaPlayer()->paused(); |
| 2938 bool shouldBePlaying = potentiallyPlaying(); | 2966 bool shouldBePlaying = potentiallyPlaying(); |
| 2939 | 2967 |
| 2940 WTF_LOG(Media, "HTMLMediaElement::updatePlayState(%p) - shouldBePlaying = %s , isPlaying = %s", | 2968 WTF_LOG(Media, "HTMLMediaElement::updatePlayState(%p) - shouldBePlaying = %s , isPlaying = %s", |
| 2941 this, boolString(shouldBePlaying), boolString(isPlaying)); | 2969 this, boolString(shouldBePlaying), boolString(isPlaying)); |
| 2942 | 2970 |
| 2943 if (shouldBePlaying) { | 2971 if (shouldBePlaying) { |
| 2944 setDisplayMode(Video); | 2972 setDisplayMode(Video); |
| 2945 invalidateCachedTime(); | 2973 invalidateCachedTime(); |
| 2946 | 2974 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3017 } else { | 3045 } else { |
| 3018 m_networkState = NETWORK_IDLE; | 3046 m_networkState = NETWORK_IDLE; |
| 3019 } | 3047 } |
| 3020 | 3048 |
| 3021 // 5 - Set the element's delaying-the-load-event flag to false. This stops d elaying the load event. | 3049 // 5 - Set the element's delaying-the-load-event flag to false. This stops d elaying the load event. |
| 3022 setShouldDelayLoadEvent(false); | 3050 setShouldDelayLoadEvent(false); |
| 3023 | 3051 |
| 3024 // 6 - Abort the overall resource selection algorithm. | 3052 // 6 - Abort the overall resource selection algorithm. |
| 3025 m_currentSourceNode = nullptr; | 3053 m_currentSourceNode = nullptr; |
| 3026 | 3054 |
| 3027 // Reset m_readyState since m_player is gone. | 3055 // Reset m_readyState since m_webMediaPlayer is gone. |
| 3028 m_readyState = HAVE_NOTHING; | 3056 m_readyState = HAVE_NOTHING; |
| 3029 invalidateCachedTime(); | 3057 invalidateCachedTime(); |
| 3030 updateMediaController(); | 3058 updateMediaController(); |
| 3031 cueTimeline().updateActiveCues(0); | 3059 cueTimeline().updateActiveCues(0); |
| 3032 } | 3060 } |
| 3033 | 3061 |
| 3034 void HTMLMediaElement::clearMediaPlayerAndAudioSourceProviderClientWithoutLockin g() | 3062 void HTMLMediaElement::clearMediaPlayerAndAudioSourceProviderClientWithoutLockin g() |
| 3035 { | 3063 { |
| 3036 #if ENABLE(WEB_AUDIO) | 3064 #if ENABLE(WEB_AUDIO) |
| 3037 if (audioSourceProvider()) | 3065 if (audioSourceProvider()) |
| 3038 audioSourceProvider()->setClient(0); | 3066 audioSourceProvider()->setClient(nullptr); |
| 3039 #endif | 3067 #endif |
| 3040 m_player.clear(); | 3068 if (m_webMediaPlayer) { |
| 3069 m_audioSourceProvider.wrap(nullptr); | |
| 3070 m_webMediaPlayer.clear(); | |
| 3071 } | |
| 3041 } | 3072 } |
| 3042 | 3073 |
| 3043 void HTMLMediaElement::clearMediaPlayer(int flags) | 3074 void HTMLMediaElement::clearMediaPlayer(int flags) |
| 3044 { | 3075 { |
| 3045 forgetResourceSpecificTracks(); | 3076 forgetResourceSpecificTracks(); |
| 3046 | 3077 |
| 3047 closeMediaSource(); | 3078 closeMediaSource(); |
| 3048 | 3079 |
| 3049 cancelDeferredLoad(); | 3080 cancelDeferredLoad(); |
| 3050 | 3081 |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3255 // the user agent should run the rules for updating the text track rendering | 3286 // the user agent should run the rules for updating the text track rendering |
| 3256 // of each of the text tracks in the video element's list of text tracks ... | 3287 // of each of the text tracks in the video element's list of text tracks ... |
| 3257 if (isHTMLVideoElement() && closedCaptionsVisible()) | 3288 if (isHTMLVideoElement() && closedCaptionsVisible()) |
| 3258 ensureTextTrackContainer().updateDisplay(*this, TextTrackContainer::DidS tartExposingControls); | 3289 ensureTextTrackContainer().updateDisplay(*this, TextTrackContainer::DidS tartExposingControls); |
| 3259 } | 3290 } |
| 3260 | 3291 |
| 3261 void HTMLMediaElement::setClosedCaptionsVisible(bool closedCaptionVisible) | 3292 void HTMLMediaElement::setClosedCaptionsVisible(bool closedCaptionVisible) |
| 3262 { | 3293 { |
| 3263 WTF_LOG(Media, "HTMLMediaElement::setClosedCaptionsVisible(%p, %s)", this, b oolString(closedCaptionVisible)); | 3294 WTF_LOG(Media, "HTMLMediaElement::setClosedCaptionsVisible(%p, %s)", this, b oolString(closedCaptionVisible)); |
| 3264 | 3295 |
| 3265 if (!m_player || !hasClosedCaptions()) | 3296 if (!hasClosedCaptions()) |
| 3266 return; | 3297 return; |
| 3267 | 3298 |
| 3268 m_closedCaptionsVisible = closedCaptionVisible; | 3299 m_closedCaptionsVisible = closedCaptionVisible; |
| 3269 | 3300 |
| 3270 markCaptionAndSubtitleTracksAsUnconfigured(); | 3301 markCaptionAndSubtitleTracksAsUnconfigured(); |
| 3271 m_processingPreferenceChange = true; | 3302 m_processingPreferenceChange = true; |
| 3272 honorUserPreferencesForAutomaticTextTrackSelection(); | 3303 honorUserPreferencesForAutomaticTextTrackSelection(); |
| 3273 m_processingPreferenceChange = false; | 3304 m_processingPreferenceChange = false; |
| 3274 | 3305 |
| 3275 // As track visibility changed while m_processingPreferenceChange was set, | 3306 // As track visibility changed while m_processingPreferenceChange was set, |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3437 | 3468 |
| 3438 return nullptr; | 3469 return nullptr; |
| 3439 } | 3470 } |
| 3440 | 3471 |
| 3441 void HTMLMediaElement::createMediaPlayer() | 3472 void HTMLMediaElement::createMediaPlayer() |
| 3442 { | 3473 { |
| 3443 AudioSourceProviderClientLockScope scope(*this); | 3474 AudioSourceProviderClientLockScope scope(*this); |
| 3444 | 3475 |
| 3445 closeMediaSource(); | 3476 closeMediaSource(); |
| 3446 | 3477 |
| 3447 m_player = MediaPlayer::create(this); | 3478 if (m_webMediaPlayer) { |
| 3479 m_audioSourceProvider.wrap(nullptr); | |
| 3480 m_webMediaPlayer.clear(); | |
| 3481 } | |
| 3448 | 3482 |
| 3449 // We haven't yet found out if any remote routes are available. | 3483 // We haven't yet found out if any remote routes are available. |
| 3450 m_remoteRoutesAvailable = false; | 3484 m_remoteRoutesAvailable = false; |
| 3451 m_playingRemotely = false; | 3485 m_playingRemotely = false; |
| 3452 | 3486 |
| 3453 #if ENABLE(WEB_AUDIO) | 3487 #if ENABLE(WEB_AUDIO) |
| 3454 if (m_audioSourceNode && audioSourceProvider()) { | 3488 if (m_audioSourceNode && audioSourceProvider()) { |
| 3455 // When creating the player, make sure its AudioSourceProvider knows abo ut the client. | 3489 // When creating the player, make sure its AudioSourceProvider knows abo ut the client. |
| 3456 audioSourceProvider()->setClient(m_audioSourceNode); | 3490 audioSourceProvider()->setClient(m_audioSourceNode); |
| 3457 } | 3491 } |
| 3458 #endif | 3492 #endif |
| 3459 } | 3493 } |
| 3460 | 3494 |
| 3461 #if ENABLE(WEB_AUDIO) | 3495 #if ENABLE(WEB_AUDIO) |
| 3462 void HTMLMediaElement::setAudioSourceNode(AudioSourceProviderClient* sourceNode) | 3496 void HTMLMediaElement::setAudioSourceNode(AudioSourceProviderClient* sourceNode) |
| 3463 { | 3497 { |
| 3464 ASSERT(isMainThread()); | 3498 ASSERT(isMainThread()); |
| 3465 m_audioSourceNode = sourceNode; | 3499 m_audioSourceNode = sourceNode; |
| 3466 | 3500 |
| 3467 AudioSourceProviderClientLockScope scope(*this); | 3501 AudioSourceProviderClientLockScope scope(*this); |
| 3468 if (audioSourceProvider()) | 3502 if (audioSourceProvider()) |
| 3469 audioSourceProvider()->setClient(m_audioSourceNode); | 3503 audioSourceProvider()->setClient(m_audioSourceNode); |
| 3470 } | 3504 } |
| 3471 | |
| 3472 AudioSourceProvider* HTMLMediaElement::audioSourceProvider() | |
| 3473 { | |
| 3474 if (m_player) | |
| 3475 return m_player->audioSourceProvider(); | |
| 3476 | |
| 3477 return nullptr; | |
| 3478 } | |
| 3479 #endif | 3505 #endif |
| 3480 | 3506 |
| 3481 const AtomicString& HTMLMediaElement::mediaGroup() const | 3507 const AtomicString& HTMLMediaElement::mediaGroup() const |
| 3482 { | 3508 { |
| 3483 return fastGetAttribute(mediagroupAttr); | 3509 return fastGetAttribute(mediagroupAttr); |
| 3484 } | 3510 } |
| 3485 | 3511 |
| 3486 void HTMLMediaElement::setMediaGroup(const AtomicString& group) | 3512 void HTMLMediaElement::setMediaGroup(const AtomicString& group) |
| 3487 { | 3513 { |
| 3488 // When a media element is created with a mediagroup attribute, and when a m edia element's mediagroup | 3514 // When a media element is created with a mediagroup attribute, and when a m edia element's mediagroup |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3580 WebMediaPlayer::CORSMode HTMLMediaElement::corsMode() const | 3606 WebMediaPlayer::CORSMode HTMLMediaElement::corsMode() const |
| 3581 { | 3607 { |
| 3582 const AtomicString& crossOriginMode = fastGetAttribute(crossoriginAttr); | 3608 const AtomicString& crossOriginMode = fastGetAttribute(crossoriginAttr); |
| 3583 if (crossOriginMode.isNull()) | 3609 if (crossOriginMode.isNull()) |
| 3584 return WebMediaPlayer::CORSModeUnspecified; | 3610 return WebMediaPlayer::CORSModeUnspecified; |
| 3585 if (equalIgnoringCase(crossOriginMode, "use-credentials")) | 3611 if (equalIgnoringCase(crossOriginMode, "use-credentials")) |
| 3586 return WebMediaPlayer::CORSModeUseCredentials; | 3612 return WebMediaPlayer::CORSModeUseCredentials; |
| 3587 return WebMediaPlayer::CORSModeAnonymous; | 3613 return WebMediaPlayer::CORSModeAnonymous; |
| 3588 } | 3614 } |
| 3589 | 3615 |
| 3590 void HTMLMediaElement::mediaPlayerSetWebLayer(WebLayer* webLayer) | 3616 void HTMLMediaElement::setWebLayer(blink::WebLayer* webLayer) |
| 3591 { | 3617 { |
| 3592 if (webLayer == m_webLayer) | 3618 if (webLayer == m_webLayer) |
| 3593 return; | 3619 return; |
| 3594 | 3620 |
| 3595 // If either of the layers is null we need to enable or disable compositing. This is done by triggering a style recalc. | 3621 // If either of the layers is null we need to enable or disable compositing. This is done by triggering a style recalc. |
| 3596 if ((!m_webLayer || !webLayer) | 3622 if ((!m_webLayer || !webLayer) |
| 3597 #if ENABLE(OILPAN) | 3623 #if ENABLE(OILPAN) |
| 3598 && !m_isFinalizing | 3624 && !m_isFinalizing |
| 3599 #endif | 3625 #endif |
| 3600 ) | 3626 ) |
| 3601 setNeedsCompositingUpdate(); | 3627 setNeedsCompositingUpdate(); |
| 3602 | 3628 |
| 3603 if (m_webLayer) | 3629 if (m_webLayer) |
| 3604 GraphicsLayer::unregisterContentsLayer(m_webLayer); | 3630 GraphicsLayer::unregisterContentsLayer(m_webLayer); |
| 3605 m_webLayer = webLayer; | 3631 m_webLayer = webLayer; |
| 3606 if (m_webLayer) | 3632 if (m_webLayer) |
| 3607 GraphicsLayer::registerContentsLayer(m_webLayer); | 3633 GraphicsLayer::registerContentsLayer(m_webLayer); |
| 3608 } | 3634 } |
| 3609 | 3635 |
| 3610 void HTMLMediaElement::mediaPlayerMediaSourceOpened(WebMediaSource* webMediaSour ce) | 3636 void HTMLMediaElement::mediaSourceOpened(WebMediaSource* webMediaSource) |
| 3611 { | 3637 { |
| 3612 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource)); | 3638 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource)); |
| 3613 } | 3639 } |
| 3614 | 3640 |
| 3615 bool HTMLMediaElement::isInteractiveContent() const | 3641 bool HTMLMediaElement::isInteractiveContent() const |
| 3616 { | 3642 { |
| 3617 return fastHasAttribute(controlsAttr); | 3643 return fastHasAttribute(controlsAttr); |
| 3618 } | 3644 } |
| 3619 | 3645 |
| 3620 void HTMLMediaElement::defaultEventHandler(Event* event) | 3646 void HTMLMediaElement::defaultEventHandler(Event* event) |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3677 if (videoTracks().length() > 0 && videoTracks().selectedIndex() == -1) | 3703 if (videoTracks().length() > 0 && videoTracks().selectedIndex() == -1) |
| 3678 videoTracks().anonymousIndexedGetter(0)->setSelected(true); | 3704 videoTracks().anonymousIndexedGetter(0)->setSelected(true); |
| 3679 } | 3705 } |
| 3680 | 3706 |
| 3681 #if ENABLE(WEB_AUDIO) | 3707 #if ENABLE(WEB_AUDIO) |
| 3682 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) | 3708 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) |
| 3683 { | 3709 { |
| 3684 if (!Heap::isHeapObjectAlive(m_audioSourceNode) && audioSourceProvider()) | 3710 if (!Heap::isHeapObjectAlive(m_audioSourceNode) && audioSourceProvider()) |
| 3685 audioSourceProvider()->setClient(nullptr); | 3711 audioSourceProvider()->setClient(nullptr); |
| 3686 } | 3712 } |
| 3713 | |
| 3714 void HTMLMediaElement::AudioSourceProviderImpl::wrap(WebAudioSourceProvider* pro vider) | |
| 3715 { | |
| 3716 MutexLocker locker(provideInputLock); | |
| 3717 | |
| 3718 if (m_webAudioSourceProvider && provider != m_webAudioSourceProvider) | |
| 3719 m_webAudioSourceProvider->setClient(nullptr); | |
| 3720 | |
| 3721 m_webAudioSourceProvider = provider; | |
| 3722 if (m_webAudioSourceProvider) | |
| 3723 m_webAudioSourceProvider->setClient(m_client.get()); | |
| 3724 } | |
| 3725 | |
| 3726 void HTMLMediaElement::AudioSourceProviderImpl::setClient(AudioSourceProviderCli ent* client) | |
| 3727 { | |
| 3728 MutexLocker locker(provideInputLock); | |
| 3729 | |
| 3730 if (client) | |
| 3731 m_client = new HTMLMediaElement::AudioClientImpl(client); | |
| 3732 else | |
| 3733 m_client.clear(); | |
| 3734 | |
| 3735 if (m_webAudioSourceProvider) | |
| 3736 m_webAudioSourceProvider->setClient(m_client.get()); | |
| 3737 } | |
| 3738 | |
| 3739 void HTMLMediaElement::AudioSourceProviderImpl::provideInput(AudioBus* bus, size _t framesToProcess) | |
| 3740 { | |
| 3741 if (!bus) | |
| 3742 return; | |
| 3743 | |
| 3744 MutexTryLocker tryLocker(provideInputLock); | |
| 3745 if (!tryLocker.locked() || !m_webAudioSourceProvider || !m_client.get()) { | |
| 3746 bus->zero(); | |
| 3747 return; | |
| 3748 } | |
| 3749 | |
| 3750 // Wrap the AudioBus channel data using WebVector. | |
| 3751 size_t n = bus->numberOfChannels(); | |
| 3752 WebVector<float*> webAudioData(n); | |
| 3753 for (size_t i = 0; i < n; ++i) | |
| 3754 webAudioData[i] = bus->channel(i)->mutableData(); | |
| 3755 | |
| 3756 m_webAudioSourceProvider->provideInput(webAudioData, framesToProcess); | |
| 3757 } | |
| 3758 | |
| 3759 void HTMLMediaElement::AudioClientImpl::setFormat(size_t numberOfChannels, float sampleRate) | |
| 3760 { | |
| 3761 if (m_client) | |
| 3762 m_client->setFormat(numberOfChannels, sampleRate); | |
| 3763 } | |
| 3764 | |
| 3765 DEFINE_TRACE(HTMLMediaElement::AudioClientImpl) | |
| 3766 { | |
| 3767 visitor->trace(m_client); | |
| 3768 } | |
| 3687 #endif | 3769 #endif |
| 3688 | 3770 |
| 3689 } | 3771 } |
| OLD | NEW |