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

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

Issue 298093004: Eliminate MediaPlayer & MediaPlayerClient abstractions(play/pause, other 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 | « Source/core/html/HTMLMediaElement.h ('k') | 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 1706 matching lines...) Expand 10 before | Expand all | Expand 10 after
1717 void HTMLMediaElement::addPlayedRange(double start, double end) 1717 void HTMLMediaElement::addPlayedRange(double start, double end)
1718 { 1718 {
1719 WTF_LOG(Media, "HTMLMediaElement::addPlayedRange(%f, %f)", start, end); 1719 WTF_LOG(Media, "HTMLMediaElement::addPlayedRange(%f, %f)", start, end);
1720 if (!m_playedTimeRanges) 1720 if (!m_playedTimeRanges)
1721 m_playedTimeRanges = TimeRanges::create(); 1721 m_playedTimeRanges = TimeRanges::create();
1722 m_playedTimeRanges->add(start, end); 1722 m_playedTimeRanges->add(start, end);
1723 } 1723 }
1724 1724
1725 bool HTMLMediaElement::supportsSave() const 1725 bool HTMLMediaElement::supportsSave() const
1726 { 1726 {
1727 return m_player ? m_player->supportsSave() : false; 1727 return webMediaPlayer() && webMediaPlayer()->supportsSave();
1728 } 1728 }
1729 1729
1730 void HTMLMediaElement::prepareToPlay() 1730 void HTMLMediaElement::prepareToPlay()
1731 { 1731 {
1732 WTF_LOG(Media, "HTMLMediaElement::prepareToPlay(%p)", this); 1732 WTF_LOG(Media, "HTMLMediaElement::prepareToPlay(%p)", this);
1733 if (m_havePreparedToPlay) 1733 if (m_havePreparedToPlay)
1734 return; 1734 return;
1735 m_havePreparedToPlay = true; 1735 m_havePreparedToPlay = true;
1736 1736
1737 if (m_delayingLoadForPreloadNone) 1737 if (m_delayingLoadForPreloadNone)
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1773 time = min(time, duration()); 1773 time = min(time, duration());
1774 1774
1775 // 6 - If the new playback position is less than the earliest possible posit ion, let it be that position instead. 1775 // 6 - If the new playback position is less than the earliest possible posit ion, let it be that position instead.
1776 time = max(time, 0.0); 1776 time = max(time, 0.0);
1777 1777
1778 // Ask the media engine for the time value in the movie's time scale before comparing with current time. This 1778 // Ask the media engine for the time value in the movie's time scale before comparing with current time. This
1779 // is necessary because if the seek time is not equal to currentTime but the delta is less than the movie's 1779 // is necessary because if the seek time is not equal to currentTime but the delta is less than the movie's
1780 // time scale, we will ask the media engine to "seek" to the current movie t ime, which may be a noop and 1780 // time scale, we will ask the media engine to "seek" to the current movie t ime, which may be a noop and
1781 // not generate a timechanged callback. This means m_seeking will never be c leared and we will never 1781 // not generate a timechanged callback. This means m_seeking will never be c leared and we will never
1782 // fire a 'seeked' event. 1782 // fire a 'seeked' event.
1783 if (webMediaPlayer()) {
acolwell GONE FROM CHROMIUM 2014/06/02 22:24:26 Do you really need this? I don't believe it is pos
Srirama 2014/06/03 05:48:01 Done.
1784 double mediaTime = webMediaPlayer()->mediaTimeForTimeValue(time);
1785 if (time != mediaTime) {
1783 #if !LOG_DISABLED 1786 #if !LOG_DISABLED
1784 double mediaTime = m_player->mediaTimeForTimeValue(time); 1787 WTF_LOG(Media, "HTMLMediaElement::seek(%f) - media timeline equivale nt is %f", time, mediaTime);
1785 if (time != mediaTime)
1786 WTF_LOG(Media, "HTMLMediaElement::seek(%f) - media timeline equivalent i s %f", time, mediaTime);
1787 #endif 1788 #endif
1788 time = m_player->mediaTimeForTimeValue(time); 1789 time = mediaTime;
1790 }
1791 }
1789 1792
1790 // 7 - If the (possibly now changed) new playback position is not in one of the ranges given in the 1793 // 7 - If the (possibly now changed) new playback position is not in one of the ranges given in the
1791 // seekable attribute, then let it be the position in one of the ranges give n in the seekable attribute 1794 // seekable attribute, then let it be the position in one of the ranges give n in the seekable attribute
1792 // that is the nearest to the new playback position. ... If there are no ran ges given in the seekable 1795 // that is the nearest to the new playback position. ... If there are no ran ges given in the seekable
1793 // attribute then set the seeking IDL attribute to false and abort these ste ps. 1796 // attribute then set the seeking IDL attribute to false and abort these ste ps.
1794 RefPtr<TimeRanges> seekableRanges = seekable(); 1797 RefPtr<TimeRanges> seekableRanges = seekable();
1795 1798
1796 // Short circuit seeking to the current time by just firing the events if no seek is required. 1799 // Short circuit seeking to the current time by just firing the events if no seek is required.
1797 // Don't skip calling the media engine if we are in poster mode because a se ek should always 1800 // Don't skip calling the media engine if we are in poster mode because a se ek should always
1798 // cancel poster display. 1801 // cancel poster display.
(...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after
2823 seek(duration, IGNORE_EXCEPTION); 2826 seek(duration, IGNORE_EXCEPTION);
2824 } 2827 }
2825 2828
2826 void HTMLMediaElement::mediaPlayerPlaybackStateChanged() 2829 void HTMLMediaElement::mediaPlayerPlaybackStateChanged()
2827 { 2830 {
2828 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerPlaybackStateChanged"); 2831 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerPlaybackStateChanged");
2829 2832
2830 if (!m_player || m_pausedInternal) 2833 if (!m_player || m_pausedInternal)
2831 return; 2834 return;
2832 2835
2833 if (m_player->paused()) 2836 if (webMediaPlayer() && webMediaPlayer()->paused())
acolwell GONE FROM CHROMIUM 2014/06/02 22:24:26 Remove pointer check. The call to this method come
Srirama 2014/06/03 05:48:01 Done.
2834 pause(); 2837 pause();
2835 else 2838 else
2836 playInternal(); 2839 playInternal();
2837 } 2840 }
2838 2841
2839 void HTMLMediaElement::mediaPlayerRequestFullscreen() 2842 void HTMLMediaElement::mediaPlayerRequestFullscreen()
2840 { 2843 {
2841 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerRequestFullscreen"); 2844 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerRequestFullscreen");
2842 2845
2843 // The player is responsible for only invoking this callback in response to 2846 // The player is responsible for only invoking this callback in response to
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
2995 2998
2996 return shouldMute ? 0 : m_volume * volumeMultiplier; 2999 return shouldMute ? 0 : m_volume * volumeMultiplier;
2997 } 3000 }
2998 3001
2999 void HTMLMediaElement::updatePlayState() 3002 void HTMLMediaElement::updatePlayState()
3000 { 3003 {
3001 if (!m_player) 3004 if (!m_player)
3002 return; 3005 return;
3003 3006
3004 if (m_pausedInternal) { 3007 if (m_pausedInternal) {
3005 if (!m_player->paused()) 3008 if (webMediaPlayer() && !webMediaPlayer()->paused())
3006 m_player->pause(); 3009 webMediaPlayer()->pause();
3007 refreshCachedTime(); 3010 refreshCachedTime();
3008 m_playbackProgressTimer.stop(); 3011 m_playbackProgressTimer.stop();
3009 if (hasMediaControls()) 3012 if (hasMediaControls())
3010 mediaControls()->playbackStopped(); 3013 mediaControls()->playbackStopped();
3011 return; 3014 return;
3012 } 3015 }
3013 3016
3014 bool shouldBePlaying = potentiallyPlaying(); 3017 bool shouldBePlaying = potentiallyPlaying();
3015 bool playerPaused = m_player->paused(); 3018 bool playerPaused = webMediaPlayer() && webMediaPlayer()->paused();
3016 3019
3017 WTF_LOG(Media, "HTMLMediaElement::updatePlayState - shouldBePlaying = %s, pl ayerPaused = %s", 3020 WTF_LOG(Media, "HTMLMediaElement::updatePlayState - shouldBePlaying = %s, pl ayerPaused = %s",
3018 boolString(shouldBePlaying), boolString(playerPaused)); 3021 boolString(shouldBePlaying), boolString(playerPaused));
3019 3022
3020 if (shouldBePlaying) { 3023 if (shouldBePlaying) {
3021 setDisplayMode(Video); 3024 setDisplayMode(Video);
3022 invalidateCachedTime(); 3025 invalidateCachedTime();
3023 3026
3024 if (playerPaused) { 3027 if (playerPaused) {
3025 // Set rate, muted before calling play in case they were set before the media engine was setup. 3028 // Set rate, muted before calling play in case they were set before the media engine was setup.
3026 // The media engine should just stash the rate and muted values sinc e it isn't already playing. 3029 // The media engine should just stash the rate and muted values sinc e it isn't already playing.
3027 m_player->setRate(m_playbackRate); 3030 m_player->setRate(m_playbackRate);
3028 updateVolume(); 3031 updateVolume();
3029 3032
3030 m_player->play(); 3033 if (webMediaPlayer())
acolwell GONE FROM CHROMIUM 2014/06/02 22:24:26 Is this really necessary? I believe the conditions
Srirama 2014/06/03 05:48:01 Done.
3034 webMediaPlayer()->play();
3031 } 3035 }
3032 3036
3033 if (hasMediaControls()) 3037 if (hasMediaControls())
3034 mediaControls()->playbackStarted(); 3038 mediaControls()->playbackStarted();
3035 startPlaybackProgressTimer(); 3039 startPlaybackProgressTimer();
3036 m_playing = true; 3040 m_playing = true;
3037 3041
3038 } else { // Should not be playing right now 3042 } else { // Should not be playing right now
3039 if (!playerPaused) 3043 if (!playerPaused && webMediaPlayer())
3040 m_player->pause(); 3044 webMediaPlayer()->pause();
3041 refreshCachedTime(); 3045 refreshCachedTime();
3042 3046
3043 m_playbackProgressTimer.stop(); 3047 m_playbackProgressTimer.stop();
3044 m_playing = false; 3048 m_playing = false;
3045 double time = currentTime(); 3049 double time = currentTime();
3046 if (time > m_lastSeekTime) 3050 if (time > m_lastSeekTime)
3047 addPlayedRange(m_lastSeekTime, time); 3051 addPlayedRange(m_lastSeekTime, time);
3048 3052
3049 if (couldPlayIfEnoughData()) 3053 if (couldPlayIfEnoughData())
3050 prepareToPlay(); 3054 prepareToPlay();
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
3649 visitor->trace(m_error); 3653 visitor->trace(m_error);
3650 visitor->trace(m_currentSourceNode); 3654 visitor->trace(m_currentSourceNode);
3651 visitor->trace(m_nextChildNodeToConsider); 3655 visitor->trace(m_nextChildNodeToConsider);
3652 visitor->trace(m_textTracks); 3656 visitor->trace(m_textTracks);
3653 visitor->trace(m_textTracksWhenResourceSelectionBegan); 3657 visitor->trace(m_textTracksWhenResourceSelectionBegan);
3654 WillBeHeapSupplementable<HTMLMediaElement>::trace(visitor); 3658 WillBeHeapSupplementable<HTMLMediaElement>::trace(visitor);
3655 HTMLElement::trace(visitor); 3659 HTMLElement::trace(visitor);
3656 } 3660 }
3657 3661
3658 } 3662 }
OLDNEW
« no previous file with comments | « Source/core/html/HTMLMediaElement.h ('k') | Source/platform/graphics/media/MediaPlayer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698