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

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

Issue 325513002: Revert 175508 "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
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 1717 matching lines...) Expand 10 before | Expand all | Expand 10 after
1728 void HTMLMediaElement::addPlayedRange(double start, double end) 1728 void HTMLMediaElement::addPlayedRange(double start, double end)
1729 { 1729 {
1730 WTF_LOG(Media, "HTMLMediaElement::addPlayedRange(%f, %f)", start, end); 1730 WTF_LOG(Media, "HTMLMediaElement::addPlayedRange(%f, %f)", start, end);
1731 if (!m_playedTimeRanges) 1731 if (!m_playedTimeRanges)
1732 m_playedTimeRanges = TimeRanges::create(); 1732 m_playedTimeRanges = TimeRanges::create();
1733 m_playedTimeRanges->add(start, end); 1733 m_playedTimeRanges->add(start, end);
1734 } 1734 }
1735 1735
1736 bool HTMLMediaElement::supportsSave() const 1736 bool HTMLMediaElement::supportsSave() const
1737 { 1737 {
1738 return webMediaPlayer() && webMediaPlayer()->supportsSave(); 1738 return m_player ? m_player->supportsSave() : false;
1739 } 1739 }
1740 1740
1741 void HTMLMediaElement::prepareToPlay() 1741 void HTMLMediaElement::prepareToPlay()
1742 { 1742 {
1743 WTF_LOG(Media, "HTMLMediaElement::prepareToPlay(%p)", this); 1743 WTF_LOG(Media, "HTMLMediaElement::prepareToPlay(%p)", this);
1744 if (m_havePreparedToPlay) 1744 if (m_havePreparedToPlay)
1745 return; 1745 return;
1746 m_havePreparedToPlay = true; 1746 m_havePreparedToPlay = true;
1747 1747
1748 if (m_delayingLoadForPreloadNone) 1748 if (m_delayingLoadForPreloadNone)
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1784 time = min(time, duration()); 1784 time = min(time, duration());
1785 1785
1786 // 6 - If the new playback position is less than the earliest possible posit ion, let it be that position instead. 1786 // 6 - If the new playback position is less than the earliest possible posit ion, let it be that position instead.
1787 time = max(time, 0.0); 1787 time = max(time, 0.0);
1788 1788
1789 // Ask the media engine for the time value in the movie's time scale before comparing with current time. This 1789 // Ask the media engine for the time value in the movie's time scale before comparing with current time. This
1790 // is necessary because if the seek time is not equal to currentTime but the delta is less than the movie's 1790 // is necessary because if the seek time is not equal to currentTime but the delta is less than the movie's
1791 // time scale, we will ask the media engine to "seek" to the current movie t ime, which may be a noop and 1791 // time scale, we will ask the media engine to "seek" to the current movie t ime, which may be a noop and
1792 // not generate a timechanged callback. This means m_seeking will never be c leared and we will never 1792 // not generate a timechanged callback. This means m_seeking will never be c leared and we will never
1793 // fire a 'seeked' event. 1793 // fire a 'seeked' event.
1794 double mediaTime = webMediaPlayer()->mediaTimeForTimeValue(time);
1795 if (time != mediaTime) {
1796 #if !LOG_DISABLED 1794 #if !LOG_DISABLED
1795 double mediaTime = m_player->mediaTimeForTimeValue(time);
1796 if (time != mediaTime)
1797 WTF_LOG(Media, "HTMLMediaElement::seek(%f) - media timeline equivalent i s %f", time, mediaTime); 1797 WTF_LOG(Media, "HTMLMediaElement::seek(%f) - media timeline equivalent i s %f", time, mediaTime);
1798 #endif 1798 #endif
1799 time = mediaTime; 1799 time = m_player->mediaTimeForTimeValue(time);
1800 }
1801 1800
1802 // 7 - If the (possibly now changed) new playback position is not in one of the ranges given in the 1801 // 7 - If the (possibly now changed) new playback position is not in one of the ranges given in the
1803 // seekable attribute, then let it be the position in one of the ranges give n in the seekable attribute 1802 // seekable attribute, then let it be the position in one of the ranges give n in the seekable attribute
1804 // that is the nearest to the new playback position. ... If there are no ran ges given in the seekable 1803 // that is the nearest to the new playback position. ... If there are no ran ges given in the seekable
1805 // attribute then set the seeking IDL attribute to false and abort these ste ps. 1804 // attribute then set the seeking IDL attribute to false and abort these ste ps.
1806 RefPtr<TimeRanges> seekableRanges = seekable(); 1805 RefPtr<TimeRanges> seekableRanges = seekable();
1807 1806
1808 // Short circuit seeking to the current time by just firing the events if no seek is required. 1807 // Short circuit seeking to the current time by just firing the events if no seek is required.
1809 // Don't skip calling the media engine if we are in poster mode because a se ek should always 1808 // Don't skip calling the media engine if we are in poster mode because a se ek should always
1810 // cancel poster display. 1809 // cancel poster display.
(...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after
2835 seek(duration, IGNORE_EXCEPTION); 2834 seek(duration, IGNORE_EXCEPTION);
2836 } 2835 }
2837 2836
2838 void HTMLMediaElement::mediaPlayerPlaybackStateChanged() 2837 void HTMLMediaElement::mediaPlayerPlaybackStateChanged()
2839 { 2838 {
2840 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerPlaybackStateChanged"); 2839 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerPlaybackStateChanged");
2841 2840
2842 if (!m_player || m_pausedInternal) 2841 if (!m_player || m_pausedInternal)
2843 return; 2842 return;
2844 2843
2845 if (webMediaPlayer()->paused()) 2844 if (m_player->paused())
2846 pause(); 2845 pause();
2847 else 2846 else
2848 playInternal(); 2847 playInternal();
2849 } 2848 }
2850 2849
2851 void HTMLMediaElement::mediaPlayerRequestFullscreen() 2850 void HTMLMediaElement::mediaPlayerRequestFullscreen()
2852 { 2851 {
2853 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerRequestFullscreen"); 2852 WTF_LOG(Media, "HTMLMediaElement::mediaPlayerRequestFullscreen");
2854 2853
2855 // The player is responsible for only invoking this callback in response to 2854 // The player is responsible for only invoking this callback in response to
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
3001 3000
3002 return shouldMute ? 0 : m_volume * volumeMultiplier; 3001 return shouldMute ? 0 : m_volume * volumeMultiplier;
3003 } 3002 }
3004 3003
3005 void HTMLMediaElement::updatePlayState() 3004 void HTMLMediaElement::updatePlayState()
3006 { 3005 {
3007 if (!m_player) 3006 if (!m_player)
3008 return; 3007 return;
3009 3008
3010 if (m_pausedInternal) { 3009 if (m_pausedInternal) {
3011 if (webMediaPlayer() && !webMediaPlayer()->paused()) 3010 if (!m_player->paused())
3012 webMediaPlayer()->pause(); 3011 m_player->pause();
3013 refreshCachedTime(); 3012 refreshCachedTime();
3014 m_playbackProgressTimer.stop(); 3013 m_playbackProgressTimer.stop();
3015 if (hasMediaControls()) 3014 if (hasMediaControls())
3016 mediaControls()->playbackStopped(); 3015 mediaControls()->playbackStopped();
3017 return; 3016 return;
3018 } 3017 }
3019 3018
3020 bool shouldBePlaying = potentiallyPlaying(); 3019 bool shouldBePlaying = potentiallyPlaying();
3021 bool playerPaused = webMediaPlayer() && webMediaPlayer()->paused(); 3020 bool playerPaused = m_player->paused();
3022 3021
3023 WTF_LOG(Media, "HTMLMediaElement::updatePlayState - shouldBePlaying = %s, pl ayerPaused = %s", 3022 WTF_LOG(Media, "HTMLMediaElement::updatePlayState - shouldBePlaying = %s, pl ayerPaused = %s",
3024 boolString(shouldBePlaying), boolString(playerPaused)); 3023 boolString(shouldBePlaying), boolString(playerPaused));
3025 3024
3026 if (shouldBePlaying) { 3025 if (shouldBePlaying) {
3027 setDisplayMode(Video); 3026 setDisplayMode(Video);
3028 invalidateCachedTime(); 3027 invalidateCachedTime();
3029 3028
3030 if (playerPaused) { 3029 if (playerPaused) {
3031 // Set rate, muted before calling play in case they were set before the media engine was setup. 3030 // Set rate, muted before calling play in case they were set before the media engine was setup.
3032 // The media engine should just stash the rate and muted values sinc e it isn't already playing. 3031 // The media engine should just stash the rate and muted values sinc e it isn't already playing.
3033 m_player->setRate(m_playbackRate); 3032 m_player->setRate(m_playbackRate);
3034 updateVolume(); 3033 updateVolume();
3035 webMediaPlayer()->play(); 3034
3035 m_player->play();
3036 } 3036 }
3037 3037
3038 if (hasMediaControls()) 3038 if (hasMediaControls())
3039 mediaControls()->playbackStarted(); 3039 mediaControls()->playbackStarted();
3040 startPlaybackProgressTimer(); 3040 startPlaybackProgressTimer();
3041 m_playing = true; 3041 m_playing = true;
3042 3042
3043 } else { // Should not be playing right now 3043 } else { // Should not be playing right now
3044 if (!playerPaused && webMediaPlayer()) 3044 if (!playerPaused)
3045 webMediaPlayer()->pause(); 3045 m_player->pause();
3046 refreshCachedTime(); 3046 refreshCachedTime();
3047 3047
3048 m_playbackProgressTimer.stop(); 3048 m_playbackProgressTimer.stop();
3049 m_playing = false; 3049 m_playing = false;
3050 double time = currentTime(); 3050 double time = currentTime();
3051 if (time > m_lastSeekTime) 3051 if (time > m_lastSeekTime)
3052 addPlayedRange(m_lastSeekTime, time); 3052 addPlayedRange(m_lastSeekTime, time);
3053 3053
3054 if (couldPlayIfEnoughData()) 3054 if (couldPlayIfEnoughData())
3055 prepareToPlay(); 3055 prepareToPlay();
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
3654 visitor->trace(m_error); 3654 visitor->trace(m_error);
3655 visitor->trace(m_currentSourceNode); 3655 visitor->trace(m_currentSourceNode);
3656 visitor->trace(m_nextChildNodeToConsider); 3656 visitor->trace(m_nextChildNodeToConsider);
3657 visitor->trace(m_textTracks); 3657 visitor->trace(m_textTracks);
3658 visitor->trace(m_textTracksWhenResourceSelectionBegan); 3658 visitor->trace(m_textTracksWhenResourceSelectionBegan);
3659 WillBeHeapSupplementable<HTMLMediaElement>::trace(visitor); 3659 WillBeHeapSupplementable<HTMLMediaElement>::trace(visitor);
3660 HTMLElement::trace(visitor); 3660 HTMLElement::trace(visitor);
3661 } 3661 }
3662 3662
3663 } 3663 }
OLDNEW
« no previous file with comments | « trunk/Source/core/html/HTMLMediaElement.h ('k') | trunk/Source/platform/graphics/media/MediaPlayer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698