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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
324 , m_duration(std::numeric_limits<double>::quiet_NaN()) | 324 , m_duration(std::numeric_limits<double>::quiet_NaN()) |
325 , m_lastTimeUpdateEventWallTime(0) | 325 , m_lastTimeUpdateEventWallTime(0) |
326 , m_lastTimeUpdateEventMovieTime(std::numeric_limits<double>::max()) | 326 , m_lastTimeUpdateEventMovieTime(std::numeric_limits<double>::max()) |
327 , m_loadState(WaitingForSource) | 327 , m_loadState(WaitingForSource) |
328 , m_deferredLoadState(NotDeferred) | 328 , m_deferredLoadState(NotDeferred) |
329 , m_deferredLoadTimer(this, &HTMLMediaElement::deferredLoadTimerFired) | 329 , m_deferredLoadTimer(this, &HTMLMediaElement::deferredLoadTimerFired) |
330 , m_webLayer(0) | 330 , m_webLayer(0) |
331 , m_preload(MediaPlayer::Auto) | 331 , m_preload(MediaPlayer::Auto) |
332 , m_displayMode(Unknown) | 332 , m_displayMode(Unknown) |
333 , m_cachedTime(MediaPlayer::invalidTime()) | 333 , m_cachedTime(MediaPlayer::invalidTime()) |
334 , m_cachedTimeWallClockUpdateTime(0) | |
335 , m_minimumWallClockTimeToCacheMediaTime(0) | |
336 , m_fragmentStartTime(MediaPlayer::invalidTime()) | 334 , m_fragmentStartTime(MediaPlayer::invalidTime()) |
337 , m_fragmentEndTime(MediaPlayer::invalidTime()) | 335 , m_fragmentEndTime(MediaPlayer::invalidTime()) |
338 , m_pendingActionFlags(0) | 336 , m_pendingActionFlags(0) |
339 , m_userGestureRequiredForPlay(false) | 337 , m_userGestureRequiredForPlay(false) |
340 , m_playing(false) | 338 , m_playing(false) |
341 , m_shouldDelayLoadEvent(false) | 339 , m_shouldDelayLoadEvent(false) |
342 , m_haveFiredLoadedData(false) | 340 , m_haveFiredLoadedData(false) |
343 , m_active(true) | 341 , m_active(true) |
344 , m_autoplaying(true) | 342 , m_autoplaying(true) |
345 , m_muted(false) | 343 , m_muted(false) |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
783 | 781 |
784 // 4.6 - If seeking is true, set it to false. | 782 // 4.6 - If seeking is true, set it to false. |
785 m_seeking = false; | 783 m_seeking = false; |
786 | 784 |
787 // 4.7 - Set the current playback position to 0. | 785 // 4.7 - Set the current playback position to 0. |
788 // Set the official playback position to 0. | 786 // Set the official playback position to 0. |
789 // If this changed the official playback position, then queue a ta sk to fire a simple event named timeupdate at the media element. | 787 // If this changed the official playback position, then queue a ta sk to fire a simple event named timeupdate at the media element. |
790 // FIXME: Add support for firing this event. | 788 // FIXME: Add support for firing this event. |
791 | 789 |
792 // 4.8 - Set the initial playback position to 0. | 790 // 4.8 - Set the initial playback position to 0. |
793 // FIXME: Make this less subtle. The position only becomes 0 because of the createMediaPlayer() call | 791 // FIXME: Make this less subtle. The position only becomes 0 because the ready state is HAVE_NOTHING. |
794 // above. | |
795 refreshCachedTime(); | |
796 invalidateCachedTime(); | 792 invalidateCachedTime(); |
797 | 793 |
798 // 4.9 - Set the timeline offset to Not-a-Number (NaN). | 794 // 4.9 - Set the timeline offset to Not-a-Number (NaN). |
799 // 4.10 - Update the duration attribute to Not-a-Number (NaN). | 795 // 4.10 - Update the duration attribute to Not-a-Number (NaN). |
800 | 796 |
801 | 797 |
802 updateMediaController(); | 798 updateMediaController(); |
803 updateActiveTextTrackCues(0); | 799 updateActiveTextTrackCues(0); |
804 } | 800 } |
805 | 801 |
(...skipping 1234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2040 return webMediaPlayer() && webMediaPlayer()->hasAudio(); | 2036 return webMediaPlayer() && webMediaPlayer()->hasAudio(); |
2041 } | 2037 } |
2042 | 2038 |
2043 bool HTMLMediaElement::seeking() const | 2039 bool HTMLMediaElement::seeking() const |
2044 { | 2040 { |
2045 return m_seeking; | 2041 return m_seeking; |
2046 } | 2042 } |
2047 | 2043 |
2048 void HTMLMediaElement::refreshCachedTime() const | 2044 void HTMLMediaElement::refreshCachedTime() const |
2049 { | 2045 { |
2050 if (!webMediaPlayer()) | 2046 if (!webMediaPlayer() || m_readyState < HAVE_METADATA) |
philipj_slow
2014/09/03 09:11:00
This reminds me of http://crbug.com/382721 which w
scherkus (not reviewing)
2014/09/03 17:03:45
While m_readyState >= HAVE_METADATA certainly impl
| |
2051 return; | 2047 return; |
2052 | 2048 |
2053 m_cachedTime = webMediaPlayer()->currentTime(); | 2049 m_cachedTime = webMediaPlayer()->currentTime(); |
2054 m_cachedTimeWallClockUpdateTime = WTF::currentTime(); | |
2055 } | 2050 } |
2056 | 2051 |
2057 void HTMLMediaElement::invalidateCachedTime() | 2052 void HTMLMediaElement::invalidateCachedTime() |
2058 { | 2053 { |
2059 WTF_LOG(Media, "HTMLMediaElement::invalidateCachedTime"); | 2054 WTF_LOG(Media, "HTMLMediaElement::invalidateCachedTime"); |
2060 | |
2061 // Don't try to cache movie time when playback first starts as the time repo rted by the engine | |
2062 // sometimes fluctuates for a short amount of time, so the cached time will be off if we take it | |
2063 // too early. | |
2064 static const double minimumTimePlayingBeforeCacheSnapshot = 0.5; | |
2065 | |
2066 m_minimumWallClockTimeToCacheMediaTime = WTF::currentTime() + minimumTimePla yingBeforeCacheSnapshot; | |
2067 m_cachedTime = MediaPlayer::invalidTime(); | 2055 m_cachedTime = MediaPlayer::invalidTime(); |
2068 } | 2056 } |
2069 | 2057 |
2070 // playback state | 2058 // playback state |
2071 double HTMLMediaElement::currentTime() const | 2059 double HTMLMediaElement::currentTime() const |
2072 { | 2060 { |
2073 #if LOG_CACHED_TIME_WARNINGS | |
2074 static const double minCachedDeltaForWarning = 0.01; | |
2075 #endif | |
2076 | |
2077 if (m_readyState == HAVE_NOTHING) | 2061 if (m_readyState == HAVE_NOTHING) |
2078 return 0; | 2062 return 0; |
2079 | 2063 |
2080 if (m_seeking) { | 2064 if (m_seeking) { |
2081 WTF_LOG(Media, "HTMLMediaElement::currentTime - seeking, returning %f", m_lastSeekTime); | 2065 WTF_LOG(Media, "HTMLMediaElement::currentTime - seeking, returning %f", m_lastSeekTime); |
2082 return m_lastSeekTime; | 2066 return m_lastSeekTime; |
2083 } | 2067 } |
2084 | 2068 |
2085 if (m_cachedTime != MediaPlayer::invalidTime() && m_paused) { | 2069 if (m_cachedTime != MediaPlayer::invalidTime() && m_paused) { |
2086 #if LOG_CACHED_TIME_WARNINGS | 2070 #if LOG_CACHED_TIME_WARNINGS |
2071 static const double minCachedDeltaForWarning = 0.01; | |
2087 double delta = m_cachedTime - webMediaPlayer()->currentTime(); | 2072 double delta = m_cachedTime - webMediaPlayer()->currentTime(); |
2088 if (delta > minCachedDeltaForWarning) | 2073 if (delta > minCachedDeltaForWarning) |
2089 WTF_LOG(Media, "HTMLMediaElement::currentTime - WARNING, cached time is %f seconds off of media time when paused", delta); | 2074 WTF_LOG(Media, "HTMLMediaElement::currentTime - WARNING, cached time is %f seconds off of media time when paused", delta); |
2090 #endif | 2075 #endif |
2091 return m_cachedTime; | 2076 return m_cachedTime; |
2092 } | 2077 } |
2093 | 2078 |
2094 refreshCachedTime(); | 2079 refreshCachedTime(); |
2095 | 2080 |
2096 return m_cachedTime; | 2081 return m_cachedTime; |
(...skipping 1312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3409 m_networkState = NETWORK_IDLE; | 3394 m_networkState = NETWORK_IDLE; |
3410 | 3395 |
3411 // 5 - Set the element's delaying-the-load-event flag to false. This stops d elaying the load event. | 3396 // 5 - Set the element's delaying-the-load-event flag to false. This stops d elaying the load event. |
3412 setShouldDelayLoadEvent(false); | 3397 setShouldDelayLoadEvent(false); |
3413 | 3398 |
3414 // 6 - Abort the overall resource selection algorithm. | 3399 // 6 - Abort the overall resource selection algorithm. |
3415 m_currentSourceNode = nullptr; | 3400 m_currentSourceNode = nullptr; |
3416 | 3401 |
3417 // Reset m_readyState since m_player is gone. | 3402 // Reset m_readyState since m_player is gone. |
3418 m_readyState = HAVE_NOTHING; | 3403 m_readyState = HAVE_NOTHING; |
3404 invalidateCachedTime(); | |
3419 updateMediaController(); | 3405 updateMediaController(); |
3420 updateActiveTextTrackCues(0); | 3406 updateActiveTextTrackCues(0); |
3421 } | 3407 } |
3422 | 3408 |
3423 void HTMLMediaElement::clearMediaPlayerAndAudioSourceProviderClientWithoutLockin g() | 3409 void HTMLMediaElement::clearMediaPlayerAndAudioSourceProviderClientWithoutLockin g() |
3424 { | 3410 { |
3425 #if ENABLE(WEB_AUDIO) | 3411 #if ENABLE(WEB_AUDIO) |
3426 if (audioSourceProvider()) | 3412 if (audioSourceProvider()) |
3427 audioSourceProvider()->setClient(0); | 3413 audioSourceProvider()->setClient(0); |
3428 #endif | 3414 #endif |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3989 | 3975 |
3990 #if ENABLE(WEB_AUDIO) | 3976 #if ENABLE(WEB_AUDIO) |
3991 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) | 3977 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) |
3992 { | 3978 { |
3993 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) | 3979 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) |
3994 audioSourceProvider()->setClient(0); | 3980 audioSourceProvider()->setClient(0); |
3995 } | 3981 } |
3996 #endif | 3982 #endif |
3997 | 3983 |
3998 } | 3984 } |
OLD | NEW |