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

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

Issue 306123003: Eliminate MediaPlayer & MediaPlayerClient abstractions(seek, duration, poster APIs) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed review comments Created 6 years, 6 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 1823 matching lines...) Expand 10 before | Expand all | Expand 10 after
1834 if (m_lastSeekTime < now) 1834 if (m_lastSeekTime < now)
1835 addPlayedRange(m_lastSeekTime, now); 1835 addPlayedRange(m_lastSeekTime, now);
1836 } 1836 }
1837 m_lastSeekTime = time; 1837 m_lastSeekTime = time;
1838 m_sentEndEvent = false; 1838 m_sentEndEvent = false;
1839 1839
1840 // 8 - Queue a task to fire a simple event named seeking at the element. 1840 // 8 - Queue a task to fire a simple event named seeking at the element.
1841 scheduleEvent(EventTypeNames::seeking); 1841 scheduleEvent(EventTypeNames::seeking);
1842 1842
1843 // 9 - Set the current playback position to the given new playback position 1843 // 9 - Set the current playback position to the given new playback position
1844 m_player->seek(time); 1844 webMediaPlayer()->seek(time);
1845 1845
1846 // 10-14 are handled, if necessary, when the engine signals a readystate cha nge or otherwise 1846 // 10-14 are handled, if necessary, when the engine signals a readystate cha nge or otherwise
1847 // satisfies seek completion and signals a time change. 1847 // satisfies seek completion and signals a time change.
1848 } 1848 }
1849 1849
1850 void HTMLMediaElement::finishSeek() 1850 void HTMLMediaElement::finishSeek()
1851 { 1851 {
1852 WTF_LOG(Media, "HTMLMediaElement::finishSeek"); 1852 WTF_LOG(Media, "HTMLMediaElement::finishSeek");
1853 1853
1854 // 4.8.10.9 Seeking completion 1854 // 4.8.10.9 Seeking completion
(...skipping 19 matching lines...) Expand all
1874 return webMediaPlayer() && webMediaPlayer()->hasAudio(); 1874 return webMediaPlayer() && webMediaPlayer()->hasAudio();
1875 } 1875 }
1876 1876
1877 bool HTMLMediaElement::seeking() const 1877 bool HTMLMediaElement::seeking() const
1878 { 1878 {
1879 return m_seeking; 1879 return m_seeking;
1880 } 1880 }
1881 1881
1882 void HTMLMediaElement::refreshCachedTime() const 1882 void HTMLMediaElement::refreshCachedTime() const
1883 { 1883 {
1884 m_cachedTime = m_player->currentTime(); 1884 m_cachedTime = webMediaPlayer() ? webMediaPlayer()->currentTime() : 0.0;
acolwell GONE FROM CHROMIUM 2014/06/03 17:02:38 Just return early w/o modifying m_cachedTime or m_
Srirama 2014/06/04 06:01:12 Done.
1885 m_cachedTimeWallClockUpdateTime = WTF::currentTime(); 1885 m_cachedTimeWallClockUpdateTime = WTF::currentTime();
1886 } 1886 }
1887 1887
1888 void HTMLMediaElement::invalidateCachedTime() 1888 void HTMLMediaElement::invalidateCachedTime()
1889 { 1889 {
1890 WTF_LOG(Media, "HTMLMediaElement::invalidateCachedTime"); 1890 WTF_LOG(Media, "HTMLMediaElement::invalidateCachedTime");
1891 1891
1892 // Don't try to cache movie time when playback first starts as the time repo rted by the engine 1892 // Don't try to cache movie time when playback first starts as the time repo rted by the engine
1893 // sometimes fluctuates for a short amount of time, so the cached time will be off if we take it 1893 // sometimes fluctuates for a short amount of time, so the cached time will be off if we take it
1894 // too early. 1894 // too early.
1895 static const double minimumTimePlayingBeforeCacheSnapshot = 0.5; 1895 static const double minimumTimePlayingBeforeCacheSnapshot = 0.5;
1896 1896
1897 m_minimumWallClockTimeToCacheMediaTime = WTF::currentTime() + minimumTimePla yingBeforeCacheSnapshot; 1897 m_minimumWallClockTimeToCacheMediaTime = WTF::currentTime() + minimumTimePla yingBeforeCacheSnapshot;
1898 m_cachedTime = MediaPlayer::invalidTime(); 1898 m_cachedTime = MediaPlayer::invalidTime();
1899 } 1899 }
1900 1900
1901 // playback state 1901 // playback state
1902 double HTMLMediaElement::currentTime() const 1902 double HTMLMediaElement::currentTime() const
1903 { 1903 {
1904 #if LOG_CACHED_TIME_WARNINGS 1904 #if LOG_CACHED_TIME_WARNINGS
1905 static const double minCachedDeltaForWarning = 0.01; 1905 static const double minCachedDeltaForWarning = 0.01;
1906 #endif 1906 #endif
1907 1907
1908 if (!m_player) 1908 if (!m_player || !webMediaPlayer())
1909 return 0; 1909 return 0;
1910 1910
1911 if (m_seeking) { 1911 if (m_seeking) {
1912 WTF_LOG(Media, "HTMLMediaElement::currentTime - seeking, returning %f", m_lastSeekTime); 1912 WTF_LOG(Media, "HTMLMediaElement::currentTime - seeking, returning %f", m_lastSeekTime);
1913 return m_lastSeekTime; 1913 return m_lastSeekTime;
1914 } 1914 }
1915 1915
1916 if (m_cachedTime != MediaPlayer::invalidTime() && m_paused) { 1916 if (m_cachedTime != MediaPlayer::invalidTime() && m_paused) {
1917 #if LOG_CACHED_TIME_WARNINGS 1917 #if LOG_CACHED_TIME_WARNINGS
1918 double delta = m_cachedTime - m_player->currentTime(); 1918 double delta = m_cachedTime - webMediaPlayer()->currentTime();
1919 if (delta > minCachedDeltaForWarning) 1919 if (delta > minCachedDeltaForWarning)
1920 WTF_LOG(Media, "HTMLMediaElement::currentTime - WARNING, cached time is %f seconds off of media time when paused", delta); 1920 WTF_LOG(Media, "HTMLMediaElement::currentTime - WARNING, cached time is %f seconds off of media time when paused", delta);
1921 #endif 1921 #endif
1922 return m_cachedTime; 1922 return m_cachedTime;
1923 } 1923 }
1924 1924
1925 refreshCachedTime(); 1925 refreshCachedTime();
1926 1926
1927 return m_cachedTime; 1927 return m_cachedTime;
1928 } 1928 }
(...skipping 18 matching lines...) Expand all
1947 // case because MediaSourceBase and SourceBuffer do not notify the element 1947 // case because MediaSourceBase and SourceBuffer do not notify the element
1948 // directly upon duration changes caused by endOfStream, remove, or append 1948 // directly upon duration changes caused by endOfStream, remove, or append
1949 // operations; rather the notification is triggered by the WebMediaPlayer 1949 // operations; rather the notification is triggered by the WebMediaPlayer
1950 // implementation observing that the underlying engine has updated duration 1950 // implementation observing that the underlying engine has updated duration
1951 // and notifying the element to consult its MediaSource for current 1951 // and notifying the element to consult its MediaSource for current
1952 // duration. See http://crbug.com/266644 1952 // duration. See http://crbug.com/266644
1953 1953
1954 if (m_mediaSource) 1954 if (m_mediaSource)
1955 return m_mediaSource->duration(); 1955 return m_mediaSource->duration();
1956 1956
1957 return m_player->duration(); 1957 return webMediaPlayer()->duration();
1958 } 1958 }
1959 1959
1960 bool HTMLMediaElement::paused() const 1960 bool HTMLMediaElement::paused() const
1961 { 1961 {
1962 return m_paused; 1962 return m_paused;
1963 } 1963 }
1964 1964
1965 double HTMLMediaElement::defaultPlaybackRate() const 1965 double HTMLMediaElement::defaultPlaybackRate() const
1966 { 1966 {
1967 return m_defaultPlaybackRate; 1967 return m_defaultPlaybackRate;
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after
2763 2763
2764 void HTMLMediaElement::mediaPlayerTimeChanged() 2764 void HTMLMediaElement::mediaPlayerTimeChanged()
2765 { 2765 {
2766 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerTimeChanged"); 2766 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerTimeChanged");
2767 2767
2768 updateActiveTextTrackCues(currentTime()); 2768 updateActiveTextTrackCues(currentTime());
2769 2769
2770 invalidateCachedTime(); 2770 invalidateCachedTime();
2771 2771
2772 // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with t he seek. 2772 // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with t he seek.
2773 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !m_player->seeking()) 2773 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !webMediaPlayer()->see king())
2774 finishSeek(); 2774 finishSeek();
2775 2775
2776 // Always call scheduleTimeupdateEvent when the media engine reports a time discontinuity, 2776 // Always call scheduleTimeupdateEvent when the media engine reports a time discontinuity,
2777 // it will only queue a 'timeupdate' event if we haven't already posted one at the current 2777 // it will only queue a 'timeupdate' event if we haven't already posted one at the current
2778 // movie time. 2778 // movie time.
2779 scheduleTimeupdateEvent(false); 2779 scheduleTimeupdateEvent(false);
2780 2780
2781 double now = currentTime(); 2781 double now = currentTime();
2782 double dur = duration(); 2782 double dur = duration();
2783 2783
(...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after
3666 visitor->trace(m_error); 3666 visitor->trace(m_error);
3667 visitor->trace(m_currentSourceNode); 3667 visitor->trace(m_currentSourceNode);
3668 visitor->trace(m_nextChildNodeToConsider); 3668 visitor->trace(m_nextChildNodeToConsider);
3669 visitor->trace(m_textTracks); 3669 visitor->trace(m_textTracks);
3670 visitor->trace(m_textTracksWhenResourceSelectionBegan); 3670 visitor->trace(m_textTracksWhenResourceSelectionBegan);
3671 WillBeHeapSupplementable<HTMLMediaElement>::trace(visitor); 3671 WillBeHeapSupplementable<HTMLMediaElement>::trace(visitor);
3672 HTMLElement::trace(visitor); 3672 HTMLElement::trace(visitor);
3673 } 3673 }
3674 3674
3675 } 3675 }
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