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

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: 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 if (webMediaPlayer())
acolwell GONE FROM CHROMIUM 2014/06/02 22:34:17 You should not need this check. You shouldn't be a
Srirama 2014/06/03 07:06:02 Done.
1845 webMediaPlayer()->seek(time);
1845 1846
1846 // 10-14 are handled, if necessary, when the engine signals a readystate cha nge or otherwise 1847 // 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. 1848 // satisfies seek completion and signals a time change.
1848 } 1849 }
1849 1850
1850 void HTMLMediaElement::finishSeek() 1851 void HTMLMediaElement::finishSeek()
1851 { 1852 {
1852 WTF_LOG(Media, "HTMLMediaElement::finishSeek"); 1853 WTF_LOG(Media, "HTMLMediaElement::finishSeek");
1853 1854
1854 // 4.8.10.9 Seeking completion 1855 // 4.8.10.9 Seeking completion
(...skipping 19 matching lines...) Expand all
1874 return webMediaPlayer() && webMediaPlayer()->hasAudio(); 1875 return webMediaPlayer() && webMediaPlayer()->hasAudio();
1875 } 1876 }
1876 1877
1877 bool HTMLMediaElement::seeking() const 1878 bool HTMLMediaElement::seeking() const
1878 { 1879 {
1879 return m_seeking; 1880 return m_seeking;
1880 } 1881 }
1881 1882
1882 void HTMLMediaElement::refreshCachedTime() const 1883 void HTMLMediaElement::refreshCachedTime() const
1883 { 1884 {
1884 m_cachedTime = m_player->currentTime(); 1885 m_cachedTime = webMediaPlayer() ? webMediaPlayer()->currentTime() : 0.0;
acolwell GONE FROM CHROMIUM 2014/06/02 22:34:17 You shouldn't need this check. This method shouldn
Srirama 2014/06/03 07:06:02 It is null for preload:none case, when it is calle
1885 m_cachedTimeWallClockUpdateTime = WTF::currentTime(); 1886 m_cachedTimeWallClockUpdateTime = WTF::currentTime();
1886 } 1887 }
1887 1888
1888 void HTMLMediaElement::invalidateCachedTime() 1889 void HTMLMediaElement::invalidateCachedTime()
1889 { 1890 {
1890 WTF_LOG(Media, "HTMLMediaElement::invalidateCachedTime"); 1891 WTF_LOG(Media, "HTMLMediaElement::invalidateCachedTime");
1891 1892
1892 // Don't try to cache movie time when playback first starts as the time repo rted by the engine 1893 // 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 1894 // sometimes fluctuates for a short amount of time, so the cached time will be off if we take it
1894 // too early. 1895 // too early.
(...skipping 13 matching lines...) Expand all
1908 if (!m_player) 1909 if (!m_player)
1909 return 0; 1910 return 0;
1910 1911
1911 if (m_seeking) { 1912 if (m_seeking) {
1912 WTF_LOG(Media, "HTMLMediaElement::currentTime - seeking, returning %f", m_lastSeekTime); 1913 WTF_LOG(Media, "HTMLMediaElement::currentTime - seeking, returning %f", m_lastSeekTime);
1913 return m_lastSeekTime; 1914 return m_lastSeekTime;
1914 } 1915 }
1915 1916
1916 if (m_cachedTime != MediaPlayer::invalidTime() && m_paused) { 1917 if (m_cachedTime != MediaPlayer::invalidTime() && m_paused) {
1917 #if LOG_CACHED_TIME_WARNINGS 1918 #if LOG_CACHED_TIME_WARNINGS
1918 double delta = m_cachedTime - m_player->currentTime(); 1919 double playerCurrentTime = webMediaPlayer() ? webMediaPlayer()->currentT ime() : 0.0;
acolwell GONE FROM CHROMIUM 2014/06/02 22:34:17 This check should be moved to the top with the !m_
Srirama 2014/06/03 07:06:02 Done.
1920 double delta = m_cachedTime - playerCurrentTime;
1919 if (delta > minCachedDeltaForWarning) 1921 if (delta > minCachedDeltaForWarning)
1920 WTF_LOG(Media, "HTMLMediaElement::currentTime - WARNING, cached time is %f seconds off of media time when paused", delta); 1922 WTF_LOG(Media, "HTMLMediaElement::currentTime - WARNING, cached time is %f seconds off of media time when paused", delta);
1921 #endif 1923 #endif
1922 return m_cachedTime; 1924 return m_cachedTime;
1923 } 1925 }
1924 1926
1925 refreshCachedTime(); 1927 refreshCachedTime();
1926 1928
1927 return m_cachedTime; 1929 return m_cachedTime;
1928 } 1930 }
(...skipping 18 matching lines...) Expand all
1947 // case because MediaSourceBase and SourceBuffer do not notify the element 1949 // case because MediaSourceBase and SourceBuffer do not notify the element
1948 // directly upon duration changes caused by endOfStream, remove, or append 1950 // directly upon duration changes caused by endOfStream, remove, or append
1949 // operations; rather the notification is triggered by the WebMediaPlayer 1951 // operations; rather the notification is triggered by the WebMediaPlayer
1950 // implementation observing that the underlying engine has updated duration 1952 // implementation observing that the underlying engine has updated duration
1951 // and notifying the element to consult its MediaSource for current 1953 // and notifying the element to consult its MediaSource for current
1952 // duration. See http://crbug.com/266644 1954 // duration. See http://crbug.com/266644
1953 1955
1954 if (m_mediaSource) 1956 if (m_mediaSource)
1955 return m_mediaSource->duration(); 1957 return m_mediaSource->duration();
1956 1958
1957 return m_player->duration(); 1959 return webMediaPlayer() ? webMediaPlayer()->duration() : 0.0;
acolwell GONE FROM CHROMIUM 2014/06/02 22:34:17 This check should not be needed. webMediaPlayer()
Srirama 2014/06/03 07:06:02 Done.
1958 } 1960 }
1959 1961
1960 bool HTMLMediaElement::paused() const 1962 bool HTMLMediaElement::paused() const
1961 { 1963 {
1962 return m_paused; 1964 return m_paused;
1963 } 1965 }
1964 1966
1965 double HTMLMediaElement::defaultPlaybackRate() const 1967 double HTMLMediaElement::defaultPlaybackRate() const
1966 { 1968 {
1967 return m_defaultPlaybackRate; 1969 return m_defaultPlaybackRate;
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after
2763 2765
2764 void HTMLMediaElement::mediaPlayerTimeChanged() 2766 void HTMLMediaElement::mediaPlayerTimeChanged()
2765 { 2767 {
2766 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerTimeChanged"); 2768 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerTimeChanged");
2767 2769
2768 updateActiveTextTrackCues(currentTime()); 2770 updateActiveTextTrackCues(currentTime());
2769 2771
2770 invalidateCachedTime(); 2772 invalidateCachedTime();
2771 2773
2772 // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with t he seek. 2774 // 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()) 2775 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA
2776 && !(webMediaPlayer() && webMediaPlayer()->seeking()))
acolwell GONE FROM CHROMIUM 2014/06/02 22:34:17 the pointer check should not be necessary since we
Srirama 2014/06/03 07:06:02 Done.
2774 finishSeek(); 2777 finishSeek();
2775 2778
2776 // Always call scheduleTimeupdateEvent when the media engine reports a time discontinuity, 2779 // 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 2780 // it will only queue a 'timeupdate' event if we haven't already posted one at the current
2778 // movie time. 2781 // movie time.
2779 scheduleTimeupdateEvent(false); 2782 scheduleTimeupdateEvent(false);
2780 2783
2781 double now = currentTime(); 2784 double now = currentTime();
2782 double dur = duration(); 2785 double dur = duration();
2783 2786
(...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after
3666 visitor->trace(m_error); 3669 visitor->trace(m_error);
3667 visitor->trace(m_currentSourceNode); 3670 visitor->trace(m_currentSourceNode);
3668 visitor->trace(m_nextChildNodeToConsider); 3671 visitor->trace(m_nextChildNodeToConsider);
3669 visitor->trace(m_textTracks); 3672 visitor->trace(m_textTracks);
3670 visitor->trace(m_textTracksWhenResourceSelectionBegan); 3673 visitor->trace(m_textTracksWhenResourceSelectionBegan);
3671 WillBeHeapSupplementable<HTMLMediaElement>::trace(visitor); 3674 WillBeHeapSupplementable<HTMLMediaElement>::trace(visitor);
3672 HTMLElement::trace(visitor); 3675 HTMLElement::trace(visitor);
3673 } 3676 }
3674 3677
3675 } 3678 }
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