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

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

Issue 320053003: Revert 175683 "Eliminate MediaPlayer & MediaPlayerClient abstrac..." (Closed) Base URL: svn://svn.chromium.org/blink/
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 | Annotate | Revision Log
« no previous file with comments | « no previous file | trunk/Source/platform/graphics/media/MediaPlayer.h » ('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 1694 matching lines...) Expand 10 before | Expand all | Expand 10 after
1705 1705
1706 void HTMLMediaElement::progressEventTimerFired(Timer<HTMLMediaElement>*) 1706 void HTMLMediaElement::progressEventTimerFired(Timer<HTMLMediaElement>*)
1707 { 1707 {
1708 ASSERT(m_player); 1708 ASSERT(m_player);
1709 if (m_networkState != NETWORK_LOADING) 1709 if (m_networkState != NETWORK_LOADING)
1710 return; 1710 return;
1711 1711
1712 double time = WTF::currentTime(); 1712 double time = WTF::currentTime();
1713 double timedelta = time - m_previousProgressTime; 1713 double timedelta = time - m_previousProgressTime;
1714 1714
1715 if (webMediaPlayer() && webMediaPlayer()->didLoadingProgress()) { 1715 if (m_player->didLoadingProgress()) {
1716 scheduleEvent(EventTypeNames::progress); 1716 scheduleEvent(EventTypeNames::progress);
1717 m_previousProgressTime = time; 1717 m_previousProgressTime = time;
1718 m_sentStalledEvent = false; 1718 m_sentStalledEvent = false;
1719 if (renderer()) 1719 if (renderer())
1720 renderer()->updateFromElement(); 1720 renderer()->updateFromElement();
1721 } else if (timedelta > 3.0 && !m_sentStalledEvent) { 1721 } else if (timedelta > 3.0 && !m_sentStalledEvent) {
1722 scheduleEvent(EventTypeNames::stalled); 1722 scheduleEvent(EventTypeNames::stalled);
1723 m_sentStalledEvent = true; 1723 m_sentStalledEvent = true;
1724 setShouldDelayLoadEvent(false); 1724 setShouldDelayLoadEvent(false);
1725 } 1725 }
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
1982 void HTMLMediaElement::setPlaybackRate(double rate) 1982 void HTMLMediaElement::setPlaybackRate(double rate)
1983 { 1983 {
1984 WTF_LOG(Media, "HTMLMediaElement::setPlaybackRate(%f)", rate); 1984 WTF_LOG(Media, "HTMLMediaElement::setPlaybackRate(%f)", rate);
1985 1985
1986 if (m_playbackRate != rate) { 1986 if (m_playbackRate != rate) {
1987 m_playbackRate = rate; 1987 m_playbackRate = rate;
1988 invalidateCachedTime(); 1988 invalidateCachedTime();
1989 scheduleEvent(EventTypeNames::ratechange); 1989 scheduleEvent(EventTypeNames::ratechange);
1990 } 1990 }
1991 1991
1992 if (m_player && potentiallyPlaying() && !m_mediaController) 1992 if (m_player && potentiallyPlaying() && m_player->rate() != rate && !m_media Controller)
1993 webMediaPlayer()->setRate(rate); 1993 m_player->setRate(rate);
1994 } 1994 }
1995 1995
1996 void HTMLMediaElement::updatePlaybackRate() 1996 void HTMLMediaElement::updatePlaybackRate()
1997 { 1997 {
1998 double effectiveRate = m_mediaController ? m_mediaController->playbackRate() : m_playbackRate; 1998 double effectiveRate = m_mediaController ? m_mediaController->playbackRate() : m_playbackRate;
1999 if (m_player && potentiallyPlaying()) 1999 if (m_player && potentiallyPlaying() && m_player->rate() != effectiveRate)
2000 webMediaPlayer()->setRate(effectiveRate); 2000 m_player->setRate(effectiveRate);
2001 } 2001 }
2002 2002
2003 bool HTMLMediaElement::ended() const 2003 bool HTMLMediaElement::ended() const
2004 { 2004 {
2005 // 4.8.10.8 Playing the media resource 2005 // 4.8.10.8 Playing the media resource
2006 // The ended attribute must return true if the media element has ended 2006 // The ended attribute must return true if the media element has ended
2007 // playback and the direction of playback is forwards, and false otherwise. 2007 // playback and the direction of playback is forwards, and false otherwise.
2008 return endedPlayback() && m_playbackRate > 0; 2008 return endedPlayback() && m_playbackRate > 0;
2009 } 2009 }
2010 2010
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after
2890 ASSERT(hasVideo()); // "resize" makes no sense absent video. 2890 ASSERT(hasVideo()); // "resize" makes no sense absent video.
2891 if (m_readyState > HAVE_NOTHING && isHTMLVideoElement(*this)) 2891 if (m_readyState > HAVE_NOTHING && isHTMLVideoElement(*this))
2892 scheduleEvent(EventTypeNames::resize); 2892 scheduleEvent(EventTypeNames::resize);
2893 2893
2894 if (renderer()) 2894 if (renderer())
2895 renderer()->updateFromElement(); 2895 renderer()->updateFromElement();
2896 } 2896 }
2897 2897
2898 PassRefPtr<TimeRanges> HTMLMediaElement::buffered() const 2898 PassRefPtr<TimeRanges> HTMLMediaElement::buffered() const
2899 { 2899 {
2900 if (!m_player)
2901 return TimeRanges::create();
2902
2900 if (m_mediaSource) 2903 if (m_mediaSource)
2901 return m_mediaSource->buffered(); 2904 return m_mediaSource->buffered();
2902 2905
2903 if (!webMediaPlayer()) 2906 return m_player->buffered();
2904 return TimeRanges::create();
2905
2906 return TimeRanges::create(webMediaPlayer()->buffered());
2907 } 2907 }
2908 2908
2909 PassRefPtr<TimeRanges> HTMLMediaElement::played() 2909 PassRefPtr<TimeRanges> HTMLMediaElement::played()
2910 { 2910 {
2911 if (m_playing) { 2911 if (m_playing) {
2912 double time = currentTime(); 2912 double time = currentTime();
2913 if (time > m_lastSeekTime) 2913 if (time > m_lastSeekTime)
2914 addPlayedRange(m_lastSeekTime, time); 2914 addPlayedRange(m_lastSeekTime, time);
2915 } 2915 }
2916 2916
2917 if (!m_playedTimeRanges) 2917 if (!m_playedTimeRanges)
2918 m_playedTimeRanges = TimeRanges::create(); 2918 m_playedTimeRanges = TimeRanges::create();
2919 2919
2920 return m_playedTimeRanges->copy(); 2920 return m_playedTimeRanges->copy();
2921 } 2921 }
2922 2922
2923 PassRefPtr<TimeRanges> HTMLMediaElement::seekable() const 2923 PassRefPtr<TimeRanges> HTMLMediaElement::seekable() const
2924 { 2924 {
2925 if (webMediaPlayer()) { 2925 if (m_player) {
2926 double maxTimeSeekable = webMediaPlayer()->maxTimeSeekable(); 2926 double maxTimeSeekable = m_player->maxTimeSeekable();
2927 if (maxTimeSeekable) 2927 if (maxTimeSeekable)
2928 return TimeRanges::create(0, maxTimeSeekable); 2928 return TimeRanges::create(0, maxTimeSeekable);
2929 } 2929 }
2930 return TimeRanges::create(); 2930 return TimeRanges::create();
2931 } 2931 }
2932 2932
2933 bool HTMLMediaElement::potentiallyPlaying() const 2933 bool HTMLMediaElement::potentiallyPlaying() const
2934 { 2934 {
2935 // "pausedToBuffer" means the media engine's rate is 0, but only because it had to stop playing 2935 // "pausedToBuffer" means the media engine's rate is 0, but only because it had to stop playing
2936 // when it ran out of buffered data. A movie is this state is "potentially p laying", modulo the 2936 // when it ran out of buffered data. A movie is this state is "potentially p laying", modulo the
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
3026 WTF_LOG(Media, "HTMLMediaElement::updatePlayState - shouldBePlaying = %s, pl ayerPaused = %s", 3026 WTF_LOG(Media, "HTMLMediaElement::updatePlayState - shouldBePlaying = %s, pl ayerPaused = %s",
3027 boolString(shouldBePlaying), boolString(playerPaused)); 3027 boolString(shouldBePlaying), boolString(playerPaused));
3028 3028
3029 if (shouldBePlaying) { 3029 if (shouldBePlaying) {
3030 setDisplayMode(Video); 3030 setDisplayMode(Video);
3031 invalidateCachedTime(); 3031 invalidateCachedTime();
3032 3032
3033 if (playerPaused) { 3033 if (playerPaused) {
3034 // Set rate, muted before calling play in case they were set before the media engine was setup. 3034 // Set rate, muted before calling play in case they were set before the media engine was setup.
3035 // The media engine should just stash the rate and muted values sinc e it isn't already playing. 3035 // The media engine should just stash the rate and muted values sinc e it isn't already playing.
3036 webMediaPlayer()->setRate(m_playbackRate); 3036 m_player->setRate(m_playbackRate);
3037 updateVolume(); 3037 updateVolume();
3038 webMediaPlayer()->play(); 3038 webMediaPlayer()->play();
3039 } 3039 }
3040 3040
3041 if (hasMediaControls()) 3041 if (hasMediaControls())
3042 mediaControls()->playbackStarted(); 3042 mediaControls()->playbackStarted();
3043 startPlaybackProgressTimer(); 3043 startPlaybackProgressTimer();
3044 m_playing = true; 3044 m_playing = true;
3045 3045
3046 } else { // Should not be playing right now 3046 } else { // Should not be playing right now
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
3657 visitor->trace(m_error); 3657 visitor->trace(m_error);
3658 visitor->trace(m_currentSourceNode); 3658 visitor->trace(m_currentSourceNode);
3659 visitor->trace(m_nextChildNodeToConsider); 3659 visitor->trace(m_nextChildNodeToConsider);
3660 visitor->trace(m_textTracks); 3660 visitor->trace(m_textTracks);
3661 visitor->trace(m_textTracksWhenResourceSelectionBegan); 3661 visitor->trace(m_textTracksWhenResourceSelectionBegan);
3662 WillBeHeapSupplementable<HTMLMediaElement>::trace(visitor); 3662 WillBeHeapSupplementable<HTMLMediaElement>::trace(visitor);
3663 HTMLElement::trace(visitor); 3663 HTMLElement::trace(visitor);
3664 } 3664 }
3665 3665
3666 } 3666 }
OLDNEW
« no previous file with comments | « no previous file | trunk/Source/platform/graphics/media/MediaPlayer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698