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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 , m_lastSeekTime(0) | 325 , m_lastSeekTime(0) |
326 , m_previousProgressTime(std::numeric_limits<double>::max()) | 326 , m_previousProgressTime(std::numeric_limits<double>::max()) |
327 , m_duration(std::numeric_limits<double>::quiet_NaN()) | 327 , m_duration(std::numeric_limits<double>::quiet_NaN()) |
328 , m_lastTimeUpdateEventWallTime(0) | 328 , m_lastTimeUpdateEventWallTime(0) |
329 , m_lastTimeUpdateEventMovieTime(0) | 329 , m_lastTimeUpdateEventMovieTime(0) |
330 , m_defaultPlaybackStartPosition(0) | 330 , m_defaultPlaybackStartPosition(0) |
331 , m_loadState(WaitingForSource) | 331 , m_loadState(WaitingForSource) |
332 , m_deferredLoadState(NotDeferred) | 332 , m_deferredLoadState(NotDeferred) |
333 , m_deferredLoadTimer(this, &HTMLMediaElement::deferredLoadTimerFired) | 333 , m_deferredLoadTimer(this, &HTMLMediaElement::deferredLoadTimerFired) |
334 , m_webLayer(nullptr) | 334 , m_webLayer(nullptr) |
335 , m_displayMode(Unknown) | |
336 , m_cachedTime(std::numeric_limits<double>::quiet_NaN()) | 335 , m_cachedTime(std::numeric_limits<double>::quiet_NaN()) |
337 , m_fragmentEndTime(std::numeric_limits<double>::quiet_NaN()) | 336 , m_fragmentEndTime(std::numeric_limits<double>::quiet_NaN()) |
338 , m_pendingActionFlags(0) | 337 , m_pendingActionFlags(0) |
339 , m_userGestureRequiredForPlay(false) | 338 , m_userGestureRequiredForPlay(false) |
340 , m_playing(false) | 339 , m_playing(false) |
341 , m_shouldDelayLoadEvent(false) | 340 , m_shouldDelayLoadEvent(false) |
342 , m_haveFiredLoadedData(false) | 341 , m_haveFiredLoadedData(false) |
343 , m_autoplaying(true) | 342 , m_autoplaying(true) |
344 , m_muted(false) | 343 , m_muted(false) |
345 , m_paused(true) | 344 , m_paused(true) |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 stopPeriodicTimers(); | 719 stopPeriodicTimers(); |
721 m_loadTimer.stop(); | 720 m_loadTimer.stop(); |
722 cancelDeferredLoad(); | 721 cancelDeferredLoad(); |
723 // FIXME: Figure out appropriate place to reset LoadTextTrackResource if nec
essary and set m_pendingActionFlags to 0 here. | 722 // FIXME: Figure out appropriate place to reset LoadTextTrackResource if nec
essary and set m_pendingActionFlags to 0 here. |
724 m_pendingActionFlags &= ~LoadMediaResource; | 723 m_pendingActionFlags &= ~LoadMediaResource; |
725 m_sentEndEvent = false; | 724 m_sentEndEvent = false; |
726 m_sentStalledEvent = false; | 725 m_sentStalledEvent = false; |
727 m_haveFiredLoadedData = false; | 726 m_haveFiredLoadedData = false; |
728 m_completelyLoaded = false; | 727 m_completelyLoaded = false; |
729 m_havePreparedToPlay = false; | 728 m_havePreparedToPlay = false; |
730 m_displayMode = Unknown; | 729 setShowPoster(true); |
731 | 730 |
732 // 1 - Abort any already-running instance of the resource selection algorith
m for this element. | 731 // 1 - Abort any already-running instance of the resource selection algorith
m for this element. |
733 m_loadState = WaitingForSource; | 732 m_loadState = WaitingForSource; |
734 m_currentSourceNode = nullptr; | 733 m_currentSourceNode = nullptr; |
735 | 734 |
736 // 2 - If there are any tasks from the media element's media element event t
ask source in | 735 // 2 - If there are any tasks from the media element's media element event t
ask source in |
737 // one of the task queues, then remove those tasks. | 736 // one of the task queues, then remove those tasks. |
738 cancelPendingEventsAndCallbacks(); | 737 cancelPendingEventsAndCallbacks(); |
739 | 738 |
740 // 3 - If the media element's networkState is set to NETWORK_LOADING or NETW
ORK_IDLE, queue | 739 // 3 - If the media element's networkState is set to NETWORK_LOADING or NETW
ORK_IDLE, queue |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
846 mode = children; | 845 mode = children; |
847 m_nextChildNodeToConsider = element; | 846 m_nextChildNodeToConsider = element; |
848 m_currentSourceNode = nullptr; | 847 m_currentSourceNode = nullptr; |
849 } else { | 848 } else { |
850 // Otherwise the media element has neither a src attribute nor a sou
rce element | 849 // Otherwise the media element has neither a src attribute nor a sou
rce element |
851 // child: set the networkState to NETWORK_EMPTY, and abort these ste
ps; the | 850 // child: set the networkState to NETWORK_EMPTY, and abort these ste
ps; the |
852 // synchronous section ends. | 851 // synchronous section ends. |
853 m_loadState = WaitingForSource; | 852 m_loadState = WaitingForSource; |
854 setShouldDelayLoadEvent(false); | 853 setShouldDelayLoadEvent(false); |
855 m_networkState = NETWORK_EMPTY; | 854 m_networkState = NETWORK_EMPTY; |
856 updateDisplayState(); | 855 updateDisplayState(false); |
857 | 856 |
858 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p), nothing t
o load", this); | 857 WTF_LOG(Media, "HTMLMediaElement::selectMediaResource(%p), nothing t
o load", this); |
859 return; | 858 return; |
860 } | 859 } |
861 } | 860 } |
862 | 861 |
863 // 4 - Set the media element's delaying-the-load-event flag to true (this de
lays the load event), | 862 // 4 - Set the media element's delaying-the-load-event flag to true (this de
lays the load event), |
864 // and set its networkState to NETWORK_LOADING. | 863 // and set its networkState to NETWORK_LOADING. |
865 setShouldDelayLoadEvent(true); | 864 setShouldDelayLoadEvent(true); |
866 m_networkState = NETWORK_LOADING; | 865 m_networkState = NETWORK_LOADING; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
937 | 936 |
938 #if ENABLE(WEB_AUDIO) | 937 #if ENABLE(WEB_AUDIO) |
939 if (m_audioSourceNode) | 938 if (m_audioSourceNode) |
940 m_audioSourceNode->onCurrentSrcChanged(m_currentSrc); | 939 m_audioSourceNode->onCurrentSrcChanged(m_currentSrc); |
941 #endif | 940 #endif |
942 | 941 |
943 WTF_LOG(Media, "HTMLMediaElement::loadResource(%p) - m_currentSrc -> %s", th
is, urlForLoggingMedia(m_currentSrc).utf8().data()); | 942 WTF_LOG(Media, "HTMLMediaElement::loadResource(%p) - m_currentSrc -> %s", th
is, urlForLoggingMedia(m_currentSrc).utf8().data()); |
944 | 943 |
945 startProgressEventTimer(); | 944 startProgressEventTimer(); |
946 | 945 |
947 // Reset display mode to force a recalculation of what to show because we ar
e resetting the player. | 946 setShowPoster(true); |
948 setDisplayMode(Unknown); | |
949 | 947 |
950 setPlayerPreload(); | 948 setPlayerPreload(); |
951 | 949 |
952 if (fastHasAttribute(mutedAttr)) | 950 if (fastHasAttribute(mutedAttr)) |
953 m_muted = true; | 951 m_muted = true; |
954 updateVolume(); | 952 updateVolume(); |
955 | 953 |
956 ASSERT(!m_mediaSource); | 954 ASSERT(!m_mediaSource); |
957 | 955 |
958 bool attemptLoad = true; | 956 bool attemptLoad = true; |
(...skipping 23 matching lines...) Expand all Loading... |
982 deferLoad(); | 980 deferLoad(); |
983 } else { | 981 } else { |
984 startPlayerLoad(); | 982 startPlayerLoad(); |
985 } | 983 } |
986 } else { | 984 } else { |
987 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); | 985 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); |
988 } | 986 } |
989 | 987 |
990 // If there is no poster to display, allow the media engine to render video
frames as soon as | 988 // If there is no poster to display, allow the media engine to render video
frames as soon as |
991 // they are available. | 989 // they are available. |
992 updateDisplayState(); | 990 updateDisplayState(false); |
993 | 991 |
994 if (layoutObject()) | 992 if (layoutObject()) |
995 layoutObject()->updateFromElement(); | 993 layoutObject()->updateFromElement(); |
996 } | 994 } |
997 | 995 |
998 void HTMLMediaElement::startPlayerLoad() | 996 void HTMLMediaElement::startPlayerLoad() |
999 { | 997 { |
1000 ASSERT(!m_webMediaPlayer); | 998 ASSERT(!m_webMediaPlayer); |
1001 // Filter out user:pass as those two URL components aren't | 999 // Filter out user:pass as those two URL components aren't |
1002 // considered for media resource fetches (including for the CORS | 1000 // considered for media resource fetches (including for the CORS |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1234 | 1232 |
1235 stopPeriodicTimers(); | 1233 stopPeriodicTimers(); |
1236 m_loadState = WaitingForSource; | 1234 m_loadState = WaitingForSource; |
1237 | 1235 |
1238 // 6.17 - Waiting: Set the element's networkState attribute to the NETWORK_N
O_SOURCE value | 1236 // 6.17 - Waiting: Set the element's networkState attribute to the NETWORK_N
O_SOURCE value |
1239 m_networkState = NETWORK_NO_SOURCE; | 1237 m_networkState = NETWORK_NO_SOURCE; |
1240 | 1238 |
1241 // 6.18 - Set the element's delaying-the-load-event flag to false. This stop
s delaying the load event. | 1239 // 6.18 - Set the element's delaying-the-load-event flag to false. This stop
s delaying the load event. |
1242 setShouldDelayLoadEvent(false); | 1240 setShouldDelayLoadEvent(false); |
1243 | 1241 |
1244 updateDisplayState(); | 1242 updateDisplayState(false); |
1245 | 1243 |
1246 if (layoutObject()) | 1244 if (layoutObject()) |
1247 layoutObject()->updateFromElement(); | 1245 layoutObject()->updateFromElement(); |
1248 } | 1246 } |
1249 | 1247 |
1250 void HTMLMediaElement::noneSupported() | 1248 void HTMLMediaElement::noneSupported() |
1251 { | 1249 { |
1252 WTF_LOG(Media, "HTMLMediaElement::noneSupported(%p)", this); | 1250 WTF_LOG(Media, "HTMLMediaElement::noneSupported(%p)", this); |
1253 | 1251 |
1254 stopPeriodicTimers(); | 1252 stopPeriodicTimers(); |
(...skipping 18 matching lines...) Expand all Loading... |
1273 scheduleEvent(EventTypeNames::error); | 1271 scheduleEvent(EventTypeNames::error); |
1274 | 1272 |
1275 closeMediaSource(); | 1273 closeMediaSource(); |
1276 | 1274 |
1277 // 8 - Set the element's delaying-the-load-event flag to false. This stops d
elaying the load event. | 1275 // 8 - Set the element's delaying-the-load-event flag to false. This stops d
elaying the load event. |
1278 setShouldDelayLoadEvent(false); | 1276 setShouldDelayLoadEvent(false); |
1279 | 1277 |
1280 // 9 - Abort these steps. Until the load() method is invoked or the src attr
ibute is changed, | 1278 // 9 - Abort these steps. Until the load() method is invoked or the src attr
ibute is changed, |
1281 // the element won't attempt to load another resource. | 1279 // the element won't attempt to load another resource. |
1282 | 1280 |
1283 updateDisplayState(); | 1281 updateDisplayState(false); |
1284 | 1282 |
1285 if (layoutObject()) | 1283 if (layoutObject()) |
1286 layoutObject()->updateFromElement(); | 1284 layoutObject()->updateFromElement(); |
1287 } | 1285 } |
1288 | 1286 |
1289 void HTMLMediaElement::mediaEngineError(MediaError* err) | 1287 void HTMLMediaElement::mediaEngineError(MediaError* err) |
1290 { | 1288 { |
1291 ASSERT(m_readyState >= HAVE_METADATA); | 1289 ASSERT(m_readyState >= HAVE_METADATA); |
1292 WTF_LOG(Media, "HTMLMediaElement::mediaEngineError(%p, %d)", this, static_ca
st<int>(err->code())); | 1290 WTF_LOG(Media, "HTMLMediaElement::mediaEngineError(%p, %d)", this, static_ca
st<int>(err->code())); |
1293 | 1291 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1359 | 1357 |
1360 if (error == WebMediaPlayer::NetworkStateNetworkError && m_readyState >= HAV
E_METADATA) | 1358 if (error == WebMediaPlayer::NetworkStateNetworkError && m_readyState >= HAV
E_METADATA) |
1361 mediaEngineError(MediaError::create(MediaError::MEDIA_ERR_NETWORK)); | 1359 mediaEngineError(MediaError::create(MediaError::MEDIA_ERR_NETWORK)); |
1362 else if (error == WebMediaPlayer::NetworkStateDecodeError) | 1360 else if (error == WebMediaPlayer::NetworkStateDecodeError) |
1363 mediaEngineError(MediaError::create(MediaError::MEDIA_ERR_DECODE)); | 1361 mediaEngineError(MediaError::create(MediaError::MEDIA_ERR_DECODE)); |
1364 else if ((error == WebMediaPlayer::NetworkStateFormatError | 1362 else if ((error == WebMediaPlayer::NetworkStateFormatError |
1365 || error == WebMediaPlayer::NetworkStateNetworkError) | 1363 || error == WebMediaPlayer::NetworkStateNetworkError) |
1366 && m_loadState == LoadingFromSrcAttr) | 1364 && m_loadState == LoadingFromSrcAttr) |
1367 noneSupported(); | 1365 noneSupported(); |
1368 | 1366 |
1369 updateDisplayState(); | 1367 updateDisplayState(false); |
1370 if (mediaControls()) | 1368 if (mediaControls()) |
1371 mediaControls()->reset(); | 1369 mediaControls()->reset(); |
1372 } | 1370 } |
1373 | 1371 |
1374 void HTMLMediaElement::setNetworkState(WebMediaPlayer::NetworkState state) | 1372 void HTMLMediaElement::setNetworkState(WebMediaPlayer::NetworkState state) |
1375 { | 1373 { |
1376 WTF_LOG(Media, "HTMLMediaElement::setNetworkState(%p, %d) - current state is
%d", this, static_cast<int>(state), static_cast<int>(m_networkState)); | 1374 WTF_LOG(Media, "HTMLMediaElement::setNetworkState(%p, %d) - current state is
%d", this, static_cast<int>(state), static_cast<int>(m_networkState)); |
1377 | 1375 |
1378 if (state == WebMediaPlayer::NetworkStateEmpty) { | 1376 if (state == WebMediaPlayer::NetworkStateEmpty) { |
1379 // Just update the cached state and leave, we can't do anything. | 1377 // Just update the cached state and leave, we can't do anything. |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1562 scheduleEvent(EventTypeNames::playing); | 1560 scheduleEvent(EventTypeNames::playing); |
1563 } | 1561 } |
1564 } | 1562 } |
1565 | 1563 |
1566 scheduleEvent(EventTypeNames::canplaythrough); | 1564 scheduleEvent(EventTypeNames::canplaythrough); |
1567 | 1565 |
1568 shouldUpdateDisplayState = true; | 1566 shouldUpdateDisplayState = true; |
1569 } | 1567 } |
1570 | 1568 |
1571 if (shouldUpdateDisplayState) { | 1569 if (shouldUpdateDisplayState) { |
1572 updateDisplayState(); | 1570 updateDisplayState(false); |
1573 if (mediaControls()) | 1571 if (mediaControls()) |
1574 mediaControls()->refreshClosedCaptionsButtonVisibility(); | 1572 mediaControls()->refreshClosedCaptionsButtonVisibility(); |
1575 } | 1573 } |
1576 | 1574 |
1577 updatePlayState(); | 1575 updatePlayState(); |
1578 updateMediaController(); | 1576 updateMediaController(); |
1579 cueTimeline().updateActiveCues(currentTime()); | 1577 cueTimeline().updateActiveCues(currentTime()); |
1580 } | 1578 } |
1581 | 1579 |
1582 void HTMLMediaElement::progressEventTimerFired(Timer<HTMLMediaElement>*) | 1580 void HTMLMediaElement::progressEventTimerFired(Timer<HTMLMediaElement>*) |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1704 | 1702 |
1705 // 14 - Set the seeking IDL attribute to false. | 1703 // 14 - Set the seeking IDL attribute to false. |
1706 m_seeking = false; | 1704 m_seeking = false; |
1707 | 1705 |
1708 // 16 - Queue a task to fire a simple event named timeupdate at the element. | 1706 // 16 - Queue a task to fire a simple event named timeupdate at the element. |
1709 scheduleTimeupdateEvent(false); | 1707 scheduleTimeupdateEvent(false); |
1710 | 1708 |
1711 // 17 - Queue a task to fire a simple event named seeked at the element. | 1709 // 17 - Queue a task to fire a simple event named seeked at the element. |
1712 scheduleEvent(EventTypeNames::seeked); | 1710 scheduleEvent(EventTypeNames::seeked); |
1713 | 1711 |
1714 setDisplayMode(Video); | 1712 setShowPoster(false); |
1715 } | 1713 } |
1716 | 1714 |
1717 HTMLMediaElement::ReadyState HTMLMediaElement::readyState() const | 1715 HTMLMediaElement::ReadyState HTMLMediaElement::readyState() const |
1718 { | 1716 { |
1719 return m_readyState; | 1717 return m_readyState; |
1720 } | 1718 } |
1721 | 1719 |
1722 bool HTMLMediaElement::hasAudio() const | 1720 bool HTMLMediaElement::hasAudio() const |
1723 { | 1721 { |
1724 return webMediaPlayer() && webMediaPlayer()->hasAudio(); | 1722 return webMediaPlayer() && webMediaPlayer()->hasAudio(); |
(...skipping 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2839 if (mediaControls()) | 2837 if (mediaControls()) |
2840 mediaControls()->stoppedCasting(); | 2838 mediaControls()->stoppedCasting(); |
2841 } | 2839 } |
2842 | 2840 |
2843 // MediaPlayerPresentation methods | 2841 // MediaPlayerPresentation methods |
2844 void HTMLMediaElement::repaint() | 2842 void HTMLMediaElement::repaint() |
2845 { | 2843 { |
2846 if (m_webLayer) | 2844 if (m_webLayer) |
2847 m_webLayer->invalidate(); | 2845 m_webLayer->invalidate(); |
2848 | 2846 |
2849 updateDisplayState(); | 2847 updateDisplayState(false); |
2850 if (layoutObject()) | 2848 if (layoutObject()) |
2851 layoutObject()->setShouldDoFullPaintInvalidation(); | 2849 layoutObject()->setShouldDoFullPaintInvalidation(); |
2852 } | 2850 } |
2853 | 2851 |
2854 void HTMLMediaElement::sizeChanged() | 2852 void HTMLMediaElement::sizeChanged() |
2855 { | 2853 { |
2856 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerSizeChanged(%p)", this); | 2854 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerSizeChanged(%p)", this); |
2857 | 2855 |
2858 ASSERT(hasVideo()); // "resize" makes no sense absent video. | 2856 ASSERT(hasVideo()); // "resize" makes no sense absent video. |
2859 if (m_readyState > HAVE_NOTHING && isHTMLVideoElement()) | 2857 if (m_readyState > HAVE_NOTHING && isHTMLVideoElement()) |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2952 | 2950 |
2953 void HTMLMediaElement::updatePlayState() | 2951 void HTMLMediaElement::updatePlayState() |
2954 { | 2952 { |
2955 bool isPlaying = webMediaPlayer() && !webMediaPlayer()->paused(); | 2953 bool isPlaying = webMediaPlayer() && !webMediaPlayer()->paused(); |
2956 bool shouldBePlaying = potentiallyPlaying(); | 2954 bool shouldBePlaying = potentiallyPlaying(); |
2957 | 2955 |
2958 WTF_LOG(Media, "HTMLMediaElement::updatePlayState(%p) - shouldBePlaying = %s
, isPlaying = %s", | 2956 WTF_LOG(Media, "HTMLMediaElement::updatePlayState(%p) - shouldBePlaying = %s
, isPlaying = %s", |
2959 this, boolString(shouldBePlaying), boolString(isPlaying)); | 2957 this, boolString(shouldBePlaying), boolString(isPlaying)); |
2960 | 2958 |
2961 if (shouldBePlaying) { | 2959 if (shouldBePlaying) { |
2962 setDisplayMode(Video); | 2960 setShowPoster(false); |
2963 invalidateCachedTime(); | 2961 invalidateCachedTime(); |
2964 | 2962 |
2965 if (!isPlaying) { | 2963 if (!isPlaying) { |
2966 // Set rate, muted before calling play in case they were set before
the media engine was setup. | 2964 // Set rate, muted before calling play in case they were set before
the media engine was setup. |
2967 // The media engine should just stash the rate and muted values sinc
e it isn't already playing. | 2965 // The media engine should just stash the rate and muted values sinc
e it isn't already playing. |
2968 webMediaPlayer()->setRate(effectivePlaybackRate()); | 2966 webMediaPlayer()->setRate(effectivePlaybackRate()); |
2969 updateVolume(); | 2967 updateVolume(); |
2970 webMediaPlayer()->play(); | 2968 webMediaPlayer()->play(); |
2971 } | 2969 } |
2972 | 2970 |
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3770 visitor->trace(m_client); | 3768 visitor->trace(m_client); |
3771 } | 3769 } |
3772 | 3770 |
3773 DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl) | 3771 DEFINE_TRACE(HTMLMediaElement::AudioSourceProviderImpl) |
3774 { | 3772 { |
3775 visitor->trace(m_client); | 3773 visitor->trace(m_client); |
3776 } | 3774 } |
3777 #endif | 3775 #endif |
3778 | 3776 |
3779 } | 3777 } |
OLD | NEW |