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 1818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1829 if (m_lastSeekTime < now) | 1829 if (m_lastSeekTime < now) |
1830 addPlayedRange(m_lastSeekTime, now); | 1830 addPlayedRange(m_lastSeekTime, now); |
1831 } | 1831 } |
1832 m_lastSeekTime = time; | 1832 m_lastSeekTime = time; |
1833 m_sentEndEvent = false; | 1833 m_sentEndEvent = false; |
1834 | 1834 |
1835 // 8 - Queue a task to fire a simple event named seeking at the element. | 1835 // 8 - Queue a task to fire a simple event named seeking at the element. |
1836 scheduleEvent(EventTypeNames::seeking); | 1836 scheduleEvent(EventTypeNames::seeking); |
1837 | 1837 |
1838 // 9 - Set the current playback position to the given new playback position | 1838 // 9 - Set the current playback position to the given new playback position |
1839 webMediaPlayer()->seek(time); | 1839 m_player->seek(time); |
1840 | 1840 |
1841 // 10-14 are handled, if necessary, when the engine signals a readystate cha
nge or otherwise | 1841 // 10-14 are handled, if necessary, when the engine signals a readystate cha
nge or otherwise |
1842 // satisfies seek completion and signals a time change. | 1842 // satisfies seek completion and signals a time change. |
1843 } | 1843 } |
1844 | 1844 |
1845 void HTMLMediaElement::finishSeek() | 1845 void HTMLMediaElement::finishSeek() |
1846 { | 1846 { |
1847 WTF_LOG(Media, "HTMLMediaElement::finishSeek"); | 1847 WTF_LOG(Media, "HTMLMediaElement::finishSeek"); |
1848 | 1848 |
1849 // 4.8.10.9 Seeking completion | 1849 // 4.8.10.9 Seeking completion |
(...skipping 19 matching lines...) Expand all Loading... |
1869 return webMediaPlayer() && webMediaPlayer()->hasAudio(); | 1869 return webMediaPlayer() && webMediaPlayer()->hasAudio(); |
1870 } | 1870 } |
1871 | 1871 |
1872 bool HTMLMediaElement::seeking() const | 1872 bool HTMLMediaElement::seeking() const |
1873 { | 1873 { |
1874 return m_seeking; | 1874 return m_seeking; |
1875 } | 1875 } |
1876 | 1876 |
1877 void HTMLMediaElement::refreshCachedTime() const | 1877 void HTMLMediaElement::refreshCachedTime() const |
1878 { | 1878 { |
1879 if (!webMediaPlayer()) | 1879 m_cachedTime = m_player->currentTime(); |
1880 return; | |
1881 | |
1882 m_cachedTime = webMediaPlayer()->currentTime(); | |
1883 m_cachedTimeWallClockUpdateTime = WTF::currentTime(); | 1880 m_cachedTimeWallClockUpdateTime = WTF::currentTime(); |
1884 } | 1881 } |
1885 | 1882 |
1886 void HTMLMediaElement::invalidateCachedTime() | 1883 void HTMLMediaElement::invalidateCachedTime() |
1887 { | 1884 { |
1888 WTF_LOG(Media, "HTMLMediaElement::invalidateCachedTime"); | 1885 WTF_LOG(Media, "HTMLMediaElement::invalidateCachedTime"); |
1889 | 1886 |
1890 // Don't try to cache movie time when playback first starts as the time repo
rted by the engine | 1887 // Don't try to cache movie time when playback first starts as the time repo
rted by the engine |
1891 // sometimes fluctuates for a short amount of time, so the cached time will
be off if we take it | 1888 // sometimes fluctuates for a short amount of time, so the cached time will
be off if we take it |
1892 // too early. | 1889 // too early. |
1893 static const double minimumTimePlayingBeforeCacheSnapshot = 0.5; | 1890 static const double minimumTimePlayingBeforeCacheSnapshot = 0.5; |
1894 | 1891 |
1895 m_minimumWallClockTimeToCacheMediaTime = WTF::currentTime() + minimumTimePla
yingBeforeCacheSnapshot; | 1892 m_minimumWallClockTimeToCacheMediaTime = WTF::currentTime() + minimumTimePla
yingBeforeCacheSnapshot; |
1896 m_cachedTime = MediaPlayer::invalidTime(); | 1893 m_cachedTime = MediaPlayer::invalidTime(); |
1897 } | 1894 } |
1898 | 1895 |
1899 // playback state | 1896 // playback state |
1900 double HTMLMediaElement::currentTime() const | 1897 double HTMLMediaElement::currentTime() const |
1901 { | 1898 { |
1902 #if LOG_CACHED_TIME_WARNINGS | 1899 #if LOG_CACHED_TIME_WARNINGS |
1903 static const double minCachedDeltaForWarning = 0.01; | 1900 static const double minCachedDeltaForWarning = 0.01; |
1904 #endif | 1901 #endif |
1905 | 1902 |
1906 if (!m_player || !webMediaPlayer()) | 1903 if (!m_player) |
1907 return 0; | 1904 return 0; |
1908 | 1905 |
1909 if (m_seeking) { | 1906 if (m_seeking) { |
1910 WTF_LOG(Media, "HTMLMediaElement::currentTime - seeking, returning %f",
m_lastSeekTime); | 1907 WTF_LOG(Media, "HTMLMediaElement::currentTime - seeking, returning %f",
m_lastSeekTime); |
1911 return m_lastSeekTime; | 1908 return m_lastSeekTime; |
1912 } | 1909 } |
1913 | 1910 |
1914 if (m_cachedTime != MediaPlayer::invalidTime() && m_paused) { | 1911 if (m_cachedTime != MediaPlayer::invalidTime() && m_paused) { |
1915 #if LOG_CACHED_TIME_WARNINGS | 1912 #if LOG_CACHED_TIME_WARNINGS |
1916 double delta = m_cachedTime - webMediaPlayer()->currentTime(); | 1913 double delta = m_cachedTime - m_player->currentTime(); |
1917 if (delta > minCachedDeltaForWarning) | 1914 if (delta > minCachedDeltaForWarning) |
1918 WTF_LOG(Media, "HTMLMediaElement::currentTime - WARNING, cached time
is %f seconds off of media time when paused", delta); | 1915 WTF_LOG(Media, "HTMLMediaElement::currentTime - WARNING, cached time
is %f seconds off of media time when paused", delta); |
1919 #endif | 1916 #endif |
1920 return m_cachedTime; | 1917 return m_cachedTime; |
1921 } | 1918 } |
1922 | 1919 |
1923 refreshCachedTime(); | 1920 refreshCachedTime(); |
1924 | 1921 |
1925 return m_cachedTime; | 1922 return m_cachedTime; |
1926 } | 1923 } |
(...skipping 18 matching lines...) Expand all Loading... |
1945 // case because MediaSource and SourceBuffer do not notify the element | 1942 // case because MediaSource and SourceBuffer do not notify the element |
1946 // directly upon duration changes caused by endOfStream, remove, or append | 1943 // directly upon duration changes caused by endOfStream, remove, or append |
1947 // operations; rather the notification is triggered by the WebMediaPlayer | 1944 // operations; rather the notification is triggered by the WebMediaPlayer |
1948 // implementation observing that the underlying engine has updated duration | 1945 // implementation observing that the underlying engine has updated duration |
1949 // and notifying the element to consult its MediaSource for current | 1946 // and notifying the element to consult its MediaSource for current |
1950 // duration. See http://crbug.com/266644 | 1947 // duration. See http://crbug.com/266644 |
1951 | 1948 |
1952 if (m_mediaSource) | 1949 if (m_mediaSource) |
1953 return m_mediaSource->duration(); | 1950 return m_mediaSource->duration(); |
1954 | 1951 |
1955 return webMediaPlayer()->duration(); | 1952 return m_player->duration(); |
1956 } | 1953 } |
1957 | 1954 |
1958 bool HTMLMediaElement::paused() const | 1955 bool HTMLMediaElement::paused() const |
1959 { | 1956 { |
1960 return m_paused; | 1957 return m_paused; |
1961 } | 1958 } |
1962 | 1959 |
1963 double HTMLMediaElement::defaultPlaybackRate() const | 1960 double HTMLMediaElement::defaultPlaybackRate() const |
1964 { | 1961 { |
1965 return m_defaultPlaybackRate; | 1962 return m_defaultPlaybackRate; |
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2761 | 2758 |
2762 void HTMLMediaElement::mediaPlayerTimeChanged() | 2759 void HTMLMediaElement::mediaPlayerTimeChanged() |
2763 { | 2760 { |
2764 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerTimeChanged"); | 2761 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerTimeChanged"); |
2765 | 2762 |
2766 updateActiveTextTrackCues(currentTime()); | 2763 updateActiveTextTrackCues(currentTime()); |
2767 | 2764 |
2768 invalidateCachedTime(); | 2765 invalidateCachedTime(); |
2769 | 2766 |
2770 // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with t
he seek. | 2767 // 4.8.10.9 steps 12-14. Needed if no ReadyState change is associated with t
he seek. |
2771 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !webMediaPlayer()->see
king()) | 2768 if (m_seeking && m_readyState >= HAVE_CURRENT_DATA && !m_player->seeking()) |
2772 finishSeek(); | 2769 finishSeek(); |
2773 | 2770 |
2774 // Always call scheduleTimeupdateEvent when the media engine reports a time
discontinuity, | 2771 // Always call scheduleTimeupdateEvent when the media engine reports a time
discontinuity, |
2775 // it will only queue a 'timeupdate' event if we haven't already posted one
at the current | 2772 // it will only queue a 'timeupdate' event if we haven't already posted one
at the current |
2776 // movie time. | 2773 // movie time. |
2777 scheduleTimeupdateEvent(false); | 2774 scheduleTimeupdateEvent(false); |
2778 | 2775 |
2779 double now = currentTime(); | 2776 double now = currentTime(); |
2780 double dur = duration(); | 2777 double dur = duration(); |
2781 | 2778 |
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3657 visitor->trace(m_error); | 3654 visitor->trace(m_error); |
3658 visitor->trace(m_currentSourceNode); | 3655 visitor->trace(m_currentSourceNode); |
3659 visitor->trace(m_nextChildNodeToConsider); | 3656 visitor->trace(m_nextChildNodeToConsider); |
3660 visitor->trace(m_textTracks); | 3657 visitor->trace(m_textTracks); |
3661 visitor->trace(m_textTracksWhenResourceSelectionBegan); | 3658 visitor->trace(m_textTracksWhenResourceSelectionBegan); |
3662 WillBeHeapSupplementable<HTMLMediaElement>::trace(visitor); | 3659 WillBeHeapSupplementable<HTMLMediaElement>::trace(visitor); |
3663 HTMLElement::trace(visitor); | 3660 HTMLElement::trace(visitor); |
3664 } | 3661 } |
3665 | 3662 |
3666 } | 3663 } |
OLD | NEW |