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

Side by Side Diff: Source/core/html/HTMLMediaElement.cpp

Issue 388803005: Eliminate MediaPlayer abstraction(seek, duration, poster APIs) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Source/core/html/HTMLVideoElement.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 1961 matching lines...) Expand 10 before | Expand all | Expand 10 after
1972 if (m_lastSeekTime < now) 1972 if (m_lastSeekTime < now)
1973 addPlayedRange(m_lastSeekTime, now); 1973 addPlayedRange(m_lastSeekTime, now);
1974 } 1974 }
1975 m_lastSeekTime = time; 1975 m_lastSeekTime = time;
1976 m_sentEndEvent = false; 1976 m_sentEndEvent = false;
1977 1977
1978 // 8 - Queue a task to fire a simple event named seeking at the element. 1978 // 8 - Queue a task to fire a simple event named seeking at the element.
1979 scheduleEvent(EventTypeNames::seeking); 1979 scheduleEvent(EventTypeNames::seeking);
1980 1980
1981 // 9 - Set the current playback position to the given new playback position 1981 // 9 - Set the current playback position to the given new playback position
1982 m_player->seek(time); 1982 webMediaPlayer()->seek(time);
philipj_slow 2014/07/13 22:12:49 I missed in this in the previous review, but the m
Srirama 2014/07/14 07:50:54 The check at the top if (m_readyState == HAVE_NOTH
philipj_slow 2014/07/14 10:54:57 OK. So since m_readyState >= HAVE_METADATA now imp
Srirama 2014/07/14 12:18:21 Done.
1983 1983
1984 // 10-14 are handled, if necessary, when the engine signals a readystate cha nge or otherwise 1984 // 10-14 are handled, if necessary, when the engine signals a readystate cha nge or otherwise
1985 // satisfies seek completion and signals a time change. 1985 // satisfies seek completion and signals a time change.
1986 } 1986 }
1987 1987
1988 void HTMLMediaElement::finishSeek() 1988 void HTMLMediaElement::finishSeek()
1989 { 1989 {
1990 WTF_LOG(Media, "HTMLMediaElement::finishSeek"); 1990 WTF_LOG(Media, "HTMLMediaElement::finishSeek");
1991 1991
1992 // 4.8.10.9 Seeking completion 1992 // 4.8.10.9 Seeking completion
(...skipping 19 matching lines...) Expand all
2012 return webMediaPlayer() && webMediaPlayer()->hasAudio(); 2012 return webMediaPlayer() && webMediaPlayer()->hasAudio();
2013 } 2013 }
2014 2014
2015 bool HTMLMediaElement::seeking() const 2015 bool HTMLMediaElement::seeking() const
2016 { 2016 {
2017 return m_seeking; 2017 return m_seeking;
2018 } 2018 }
2019 2019
2020 void HTMLMediaElement::refreshCachedTime() const 2020 void HTMLMediaElement::refreshCachedTime() const
2021 { 2021 {
2022 m_cachedTime = m_player->currentTime(); 2022 if (!webMediaPlayer())
2023 return;
2024
2025 m_cachedTime = webMediaPlayer()->currentTime();
2023 m_cachedTimeWallClockUpdateTime = WTF::currentTime(); 2026 m_cachedTimeWallClockUpdateTime = WTF::currentTime();
2024 } 2027 }
2025 2028
2026 void HTMLMediaElement::invalidateCachedTime() 2029 void HTMLMediaElement::invalidateCachedTime()
2027 { 2030 {
2028 WTF_LOG(Media, "HTMLMediaElement::invalidateCachedTime"); 2031 WTF_LOG(Media, "HTMLMediaElement::invalidateCachedTime");
2029 2032
2030 // Don't try to cache movie time when playback first starts as the time repo rted by the engine 2033 // Don't try to cache movie time when playback first starts as the time repo rted by the engine
2031 // sometimes fluctuates for a short amount of time, so the cached time will be off if we take it 2034 // sometimes fluctuates for a short amount of time, so the cached time will be off if we take it
2032 // too early. 2035 // too early.
2033 static const double minimumTimePlayingBeforeCacheSnapshot = 0.5; 2036 static const double minimumTimePlayingBeforeCacheSnapshot = 0.5;
2034 2037
2035 m_minimumWallClockTimeToCacheMediaTime = WTF::currentTime() + minimumTimePla yingBeforeCacheSnapshot; 2038 m_minimumWallClockTimeToCacheMediaTime = WTF::currentTime() + minimumTimePla yingBeforeCacheSnapshot;
2036 m_cachedTime = MediaPlayer::invalidTime(); 2039 m_cachedTime = MediaPlayer::invalidTime();
2037 } 2040 }
2038 2041
2039 // playback state 2042 // playback state
2040 double HTMLMediaElement::currentTime() const 2043 double HTMLMediaElement::currentTime() const
2041 { 2044 {
2042 #if LOG_CACHED_TIME_WARNINGS 2045 #if LOG_CACHED_TIME_WARNINGS
2043 static const double minCachedDeltaForWarning = 0.01; 2046 static const double minCachedDeltaForWarning = 0.01;
2044 #endif 2047 #endif
2045 2048
2046 if (!m_player) 2049 if (!m_player || !webMediaPlayer())
philipj_slow 2014/07/13 22:12:48 !m_player implies !webMediaPlayer(), so just the l
Srirama 2014/07/14 07:50:54 Done.
2047 return 0; 2050 return 0;
2048 2051
2049 if (m_seeking) { 2052 if (m_seeking) {
2050 WTF_LOG(Media, "HTMLMediaElement::currentTime - seeking, returning %f", m_lastSeekTime); 2053 WTF_LOG(Media, "HTMLMediaElement::currentTime - seeking, returning %f", m_lastSeekTime);
2051 return m_lastSeekTime; 2054 return m_lastSeekTime;
2052 } 2055 }
2053 2056
2054 if (m_cachedTime != MediaPlayer::invalidTime() && m_paused) { 2057 if (m_cachedTime != MediaPlayer::invalidTime() && m_paused) {
2055 #if LOG_CACHED_TIME_WARNINGS 2058 #if LOG_CACHED_TIME_WARNINGS
2056 double delta = m_cachedTime - m_player->currentTime(); 2059 double delta = m_cachedTime - webMediaPlayer()->currentTime();
2057 if (delta > minCachedDeltaForWarning) 2060 if (delta > minCachedDeltaForWarning)
2058 WTF_LOG(Media, "HTMLMediaElement::currentTime - WARNING, cached time is %f seconds off of media time when paused", delta); 2061 WTF_LOG(Media, "HTMLMediaElement::currentTime - WARNING, cached time is %f seconds off of media time when paused", delta);
2059 #endif 2062 #endif
2060 return m_cachedTime; 2063 return m_cachedTime;
2061 } 2064 }
2062 2065
2063 refreshCachedTime(); 2066 refreshCachedTime();
2064 2067
2065 return m_cachedTime; 2068 return m_cachedTime;
2066 } 2069 }
(...skipping 18 matching lines...) Expand all
2085 // case because MediaSource and SourceBuffer do not notify the element 2088 // case because MediaSource and SourceBuffer do not notify the element
2086 // directly upon duration changes caused by endOfStream, remove, or append 2089 // directly upon duration changes caused by endOfStream, remove, or append
2087 // operations; rather the notification is triggered by the WebMediaPlayer 2090 // operations; rather the notification is triggered by the WebMediaPlayer
2088 // implementation observing that the underlying engine has updated duration 2091 // implementation observing that the underlying engine has updated duration
2089 // and notifying the element to consult its MediaSource for current 2092 // and notifying the element to consult its MediaSource for current
2090 // duration. See http://crbug.com/266644 2093 // duration. See http://crbug.com/266644
2091 2094
2092 if (m_mediaSource) 2095 if (m_mediaSource)
2093 return m_mediaSource->duration(); 2096 return m_mediaSource->duration();
2094 2097
2095 return m_player->duration(); 2098 return webMediaPlayer()->duration();
philipj_slow 2014/07/13 22:12:48 Change the !m_player check at the top to match?
Srirama 2014/07/14 07:50:54 Removed !m_player check but !webmediaplayer() chec
philipj_slow 2014/07/14 10:54:57 The check at the top is equivalent to the one in s
philipj_slow 2014/07/14 11:06:56 My bad, you already fixed this one.
2096 } 2099 }
2097 2100
2098 bool HTMLMediaElement::paused() const 2101 bool HTMLMediaElement::paused() const
2099 { 2102 {
2100 return m_paused; 2103 return m_paused;
2101 } 2104 }
2102 2105
2103 double HTMLMediaElement::defaultPlaybackRate() const 2106 double HTMLMediaElement::defaultPlaybackRate() const
2104 { 2107 {
2105 return m_defaultPlaybackRate; 2108 return m_defaultPlaybackRate;
(...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after
3019 3022
3020 void HTMLMediaElement::mediaPlayerTimeChanged() 3023 void HTMLMediaElement::mediaPlayerTimeChanged()
3021 { 3024 {
3022 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerTimeChanged"); 3025 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerTimeChanged");
3023 3026
3024 updateActiveTextTrackCues(currentTime()); 3027 updateActiveTextTrackCues(currentTime());
3025 3028
3026 invalidateCachedTime(); 3029 invalidateCachedTime();
3027 3030
3028 // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with t he seek. 3031 // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with t he seek.
3029 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !m_player->seeking()) 3032 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !webMediaPlayer()->see king())
3030 finishSeek(); 3033 finishSeek();
3031 3034
3032 // Always call scheduleTimeupdateEvent when the media engine reports a time discontinuity, 3035 // Always call scheduleTimeupdateEvent when the media engine reports a time discontinuity,
3033 // it will only queue a 'timeupdate' event if we haven't already posted one at the current 3036 // it will only queue a 'timeupdate' event if we haven't already posted one at the current
3034 // movie time. 3037 // movie time.
3035 scheduleTimeupdateEvent(false); 3038 scheduleTimeupdateEvent(false);
3036 3039
3037 double now = currentTime(); 3040 double now = currentTime();
3038 double dur = duration(); 3041 double dur = duration();
3039 3042
(...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after
3969 3972
3970 #if ENABLE(WEB_AUDIO) 3973 #if ENABLE(WEB_AUDIO)
3971 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) 3974 void HTMLMediaElement::clearWeakMembers(Visitor* visitor)
3972 { 3975 {
3973 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) 3976 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider())
3974 audioSourceProvider()->setClient(0); 3977 audioSourceProvider()->setClient(0);
3975 } 3978 }
3976 #endif 3979 #endif
3977 3980
3978 } 3981 }
OLDNEW
« no previous file with comments | « no previous file | Source/core/html/HTMLVideoElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698