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

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

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

Powered by Google App Engine
This is Rietveld 408576698