Chromium Code Reviews| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 #include "wtf/text/CString.h" | 78 #include "wtf/text/CString.h" |
| 79 | 79 |
| 80 #if ENABLE(WEB_AUDIO) | 80 #if ENABLE(WEB_AUDIO) |
| 81 #include "platform/audio/AudioSourceProvider.h" | 81 #include "platform/audio/AudioSourceProvider.h" |
| 82 #include "modules/webaudio/MediaElementAudioSourceNode.h" | 82 #include "modules/webaudio/MediaElementAudioSourceNode.h" |
| 83 #endif | 83 #endif |
| 84 | 84 |
| 85 using namespace std; | 85 using namespace std; |
| 86 using blink::WebInbandTextTrack; | 86 using blink::WebInbandTextTrack; |
| 87 using blink::WebMimeRegistry; | 87 using blink::WebMimeRegistry; |
| 88 using blink::WebMediaPlayer; | |
|
philipj_slow
2014/03/08 19:38:40
Move up one line to keep list sorted.
acolwell GONE FROM CHROMIUM
2014/03/10 21:53:31
Done.
| |
| 88 | 89 |
| 89 namespace WebCore { | 90 namespace WebCore { |
| 90 | 91 |
| 91 #if !LOG_DISABLED | 92 #if !LOG_DISABLED |
| 92 static String urlForLoggingMedia(const KURL& url) | 93 static String urlForLoggingMedia(const KURL& url) |
| 93 { | 94 { |
| 94 static const unsigned maximumURLLengthForLogging = 128; | 95 static const unsigned maximumURLLengthForLogging = 128; |
| 95 | 96 |
| 96 if (url.string().length() < maximumURLLengthForLogging) | 97 if (url.string().length() < maximumURLLengthForLogging) |
| 97 return url.string(); | 98 return url.string(); |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 272 , m_pausedInternal(false) | 273 , m_pausedInternal(false) |
| 273 , m_closedCaptionsVisible(false) | 274 , m_closedCaptionsVisible(false) |
| 274 , m_completelyLoaded(false) | 275 , m_completelyLoaded(false) |
| 275 , m_havePreparedToPlay(false) | 276 , m_havePreparedToPlay(false) |
| 276 , m_tracksAreReady(true) | 277 , m_tracksAreReady(true) |
| 277 , m_haveVisibleTextTrack(false) | 278 , m_haveVisibleTextTrack(false) |
| 278 , m_processingPreferenceChange(false) | 279 , m_processingPreferenceChange(false) |
| 279 , m_lastTextTrackUpdateTime(-1) | 280 , m_lastTextTrackUpdateTime(-1) |
| 280 , m_textTracks(nullptr) | 281 , m_textTracks(nullptr) |
| 281 , m_ignoreTrackDisplayUpdate(0) | 282 , m_ignoreTrackDisplayUpdate(0) |
| 283 , m_delayingLoad(false) | |
| 282 #if ENABLE(WEB_AUDIO) | 284 #if ENABLE(WEB_AUDIO) |
| 283 , m_audioSourceNode(0) | 285 , m_audioSourceNode(0) |
| 284 #endif | 286 #endif |
| 285 { | 287 { |
| 286 ASSERT(RuntimeEnabledFeatures::mediaEnabled()); | 288 ASSERT(RuntimeEnabledFeatures::mediaEnabled()); |
| 287 | 289 |
| 288 WTF_LOG(Media, "HTMLMediaElement::HTMLMediaElement"); | 290 WTF_LOG(Media, "HTMLMediaElement::HTMLMediaElement"); |
| 289 ScriptWrappable::init(this); | 291 ScriptWrappable::init(this); |
| 290 | 292 |
| 291 if (document.settings() && document.settings()->mediaPlaybackRequiresUserGes ture()) | 293 if (document.settings() && document.settings()->mediaPlaybackRequiresUserGes ture()) |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 406 else if (equalIgnoringCase(value, "metadata")) | 408 else if (equalIgnoringCase(value, "metadata")) |
| 407 m_preload = MediaPlayer::MetaData; | 409 m_preload = MediaPlayer::MetaData; |
| 408 else { | 410 else { |
| 409 // The spec does not define an "invalid value default" but "auto" is suggested as the | 411 // The spec does not define an "invalid value default" but "auto" is suggested as the |
| 410 // "missing value default", so use it for everything except "none" a nd "metadata" | 412 // "missing value default", so use it for everything except "none" a nd "metadata" |
| 411 m_preload = MediaPlayer::Auto; | 413 m_preload = MediaPlayer::Auto; |
| 412 } | 414 } |
| 413 | 415 |
| 414 // The attribute must be ignored if the autoplay attribute is present | 416 // The attribute must be ignored if the autoplay attribute is present |
| 415 if (!autoplay() && m_player) | 417 if (!autoplay() && m_player) |
| 416 m_player->setPreload(m_preload); | 418 setPlayerPreload(); |
| 417 | 419 |
| 418 } else if (name == mediagroupAttr) | 420 } else if (name == mediagroupAttr) |
| 419 setMediaGroup(value); | 421 setMediaGroup(value); |
| 420 else if (name == onbeforeloadAttr) | 422 else if (name == onbeforeloadAttr) |
| 421 setAttributeEventListener(EventTypeNames::beforeload, createAttributeEve ntListener(this, name, value)); | 423 setAttributeEventListener(EventTypeNames::beforeload, createAttributeEve ntListener(this, name, value)); |
| 422 else | 424 else |
| 423 HTMLElement::parseAttribute(name, value); | 425 HTMLElement::parseAttribute(name, value); |
| 424 } | 426 } |
| 425 | 427 |
| 426 void HTMLMediaElement::finishParsingChildren() | 428 void HTMLMediaElement::finishParsingChildren() |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 832 | 834 |
| 833 // The resource fetch algorithm | 835 // The resource fetch algorithm |
| 834 m_networkState = NETWORK_LOADING; | 836 m_networkState = NETWORK_LOADING; |
| 835 | 837 |
| 836 // Set m_currentSrc *before* changing to the cache url, the fact that we are loading from the app | 838 // Set m_currentSrc *before* changing to the cache url, the fact that we are loading from the app |
| 837 // cache is an internal detail not exposed through the media element API. | 839 // cache is an internal detail not exposed through the media element API. |
| 838 m_currentSrc = url; | 840 m_currentSrc = url; |
| 839 | 841 |
| 840 WTF_LOG(Media, "HTMLMediaElement::loadResource - m_currentSrc -> %s", urlFor LoggingMedia(m_currentSrc).utf8().data()); | 842 WTF_LOG(Media, "HTMLMediaElement::loadResource - m_currentSrc -> %s", urlFor LoggingMedia(m_currentSrc).utf8().data()); |
| 841 | 843 |
| 842 blink::WebMediaPlayer::LoadType loadType = blink::WebMediaPlayer::LoadTypeUR L; | |
| 843 | |
| 844 startProgressEventTimer(); | 844 startProgressEventTimer(); |
| 845 | 845 |
| 846 // Reset display mode to force a recalculation of what to show because we ar e resetting the player. | 846 // Reset display mode to force a recalculation of what to show because we ar e resetting the player. |
| 847 setDisplayMode(Unknown); | 847 setDisplayMode(Unknown); |
| 848 | 848 |
| 849 if (!autoplay()) | 849 if (!autoplay()) |
| 850 m_player->setPreload(m_preload); | 850 setPlayerPreload(); |
| 851 | 851 |
| 852 if (fastHasAttribute(mutedAttr)) | 852 if (fastHasAttribute(mutedAttr)) |
| 853 m_muted = true; | 853 m_muted = true; |
| 854 updateVolume(); | 854 updateVolume(); |
| 855 | 855 |
| 856 ASSERT(!m_mediaSource); | 856 ASSERT(!m_mediaSource); |
| 857 | 857 |
| 858 bool attemptLoad = true; | 858 bool attemptLoad = true; |
| 859 | 859 |
| 860 if (url.protocolIs(mediaSourceBlobProtocol)) { | 860 if (url.protocolIs(mediaSourceBlobProtocol)) { |
| 861 if (isMediaStreamURL(url.string())) { | 861 if (isMediaStreamURL(url.string())) { |
| 862 loadType = blink::WebMediaPlayer::LoadTypeMediaStream; | |
| 863 m_userGestureRequiredForPlay = false; | 862 m_userGestureRequiredForPlay = false; |
| 864 } else { | 863 } else { |
| 865 m_mediaSource = HTMLMediaSource::lookup(url.string()); | 864 m_mediaSource = HTMLMediaSource::lookup(url.string()); |
| 866 | 865 |
| 867 if (m_mediaSource) { | 866 if (m_mediaSource) { |
| 868 loadType = blink::WebMediaPlayer::LoadTypeMediaSource; | |
| 869 | |
| 870 if (!m_mediaSource->attachToElement(this)) { | 867 if (!m_mediaSource->attachToElement(this)) { |
| 871 // Forget our reference to the MediaSource, so we leave it a lone | 868 // Forget our reference to the MediaSource, so we leave it a lone |
| 872 // while processing remainder of load failure. | 869 // while processing remainder of load failure. |
| 873 m_mediaSource = nullptr; | 870 m_mediaSource = nullptr; |
| 874 attemptLoad = false; | 871 attemptLoad = false; |
| 875 } | 872 } |
| 876 } | 873 } |
| 877 } | 874 } |
| 878 } | 875 } |
| 879 | 876 |
| 880 if (attemptLoad && canLoadURL(url, contentType, keySystem)) { | 877 if (attemptLoad && canLoadURL(url, contentType, keySystem)) { |
| 881 m_player->load(loadType, url); | 878 ASSERT(!webMediaPlayer()); |
| 879 | |
| 880 if (m_preload == MediaPlayer::None) { | |
| 881 m_delayingLoad = true; | |
|
philipj_slow
2014/03/08 19:38:40
http://www.whatwg.org/specs/web-apps/current-work/
acolwell GONE FROM CHROMIUM
2014/03/10 21:53:31
I just want to keep this CL as a simple move of ex
philipj_slow
2014/03/12 05:21:01
Sounds great!
| |
| 882 } else { | |
| 883 m_player->load(loadType(), m_currentSrc, corsMode()); | |
| 884 } | |
| 882 } else { | 885 } else { |
| 883 mediaLoadingFailed(MediaPlayer::FormatError); | 886 mediaLoadingFailed(MediaPlayer::FormatError); |
| 884 } | 887 } |
| 885 | 888 |
| 886 // If there is no poster to display, allow the media engine to render video frames as soon as | 889 // If there is no poster to display, allow the media engine to render video frames as soon as |
| 887 // they are available. | 890 // they are available. |
| 888 updateDisplayState(); | 891 updateDisplayState(); |
| 889 | 892 |
| 890 if (renderer()) | 893 if (renderer()) |
| 891 renderer()->updateFromElement(); | 894 renderer()->updateFromElement(); |
| (...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1674 { | 1677 { |
| 1675 return m_player ? m_player->supportsSave() : false; | 1678 return m_player ? m_player->supportsSave() : false; |
| 1676 } | 1679 } |
| 1677 | 1680 |
| 1678 void HTMLMediaElement::prepareToPlay() | 1681 void HTMLMediaElement::prepareToPlay() |
| 1679 { | 1682 { |
| 1680 WTF_LOG(Media, "HTMLMediaElement::prepareToPlay(%p)", this); | 1683 WTF_LOG(Media, "HTMLMediaElement::prepareToPlay(%p)", this); |
| 1681 if (m_havePreparedToPlay) | 1684 if (m_havePreparedToPlay) |
| 1682 return; | 1685 return; |
| 1683 m_havePreparedToPlay = true; | 1686 m_havePreparedToPlay = true; |
| 1684 m_player->prepareToPlay(); | 1687 |
| 1688 if (m_delayingLoad) | |
| 1689 startDelayedLoad(); | |
| 1685 } | 1690 } |
| 1686 | 1691 |
| 1687 void HTMLMediaElement::seek(double time, ExceptionState& exceptionState) | 1692 void HTMLMediaElement::seek(double time, ExceptionState& exceptionState) |
| 1688 { | 1693 { |
| 1689 WTF_LOG(Media, "HTMLMediaElement::seek(%f)", time); | 1694 WTF_LOG(Media, "HTMLMediaElement::seek(%f)", time); |
| 1690 | 1695 |
| 1691 // 4.8.10.9 Seeking | 1696 // 4.8.10.9 Seeking |
| 1692 | 1697 |
| 1693 // 1 - If the media element's readyState is HAVE_NOTHING, then raise an Inva lidStateError exception. | 1698 // 1 - If the media element's readyState is HAVE_NOTHING, then raise an Inva lidStateError exception. |
| 1694 if (m_readyState == HAVE_NOTHING || !m_player) { | 1699 if (m_readyState == HAVE_NOTHING || !m_player) { |
| (...skipping 1437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3132 m_audioSourceNode->unlock(); | 3137 m_audioSourceNode->unlock(); |
| 3133 #endif | 3138 #endif |
| 3134 } | 3139 } |
| 3135 | 3140 |
| 3136 void HTMLMediaElement::clearMediaPlayer(int flags) | 3141 void HTMLMediaElement::clearMediaPlayer(int flags) |
| 3137 { | 3142 { |
| 3138 forgetResourceSpecificTracks(); | 3143 forgetResourceSpecificTracks(); |
| 3139 | 3144 |
| 3140 closeMediaSource(); | 3145 closeMediaSource(); |
| 3141 | 3146 |
| 3147 m_delayingLoad = false; | |
| 3148 | |
| 3142 clearMediaPlayerAndAudioSourceProviderClient(); | 3149 clearMediaPlayerAndAudioSourceProviderClient(); |
| 3143 | 3150 |
| 3144 stopPeriodicTimers(); | 3151 stopPeriodicTimers(); |
| 3145 m_loadTimer.stop(); | 3152 m_loadTimer.stop(); |
| 3146 | 3153 |
| 3147 m_pendingActionFlags &= ~flags; | 3154 m_pendingActionFlags &= ~flags; |
| 3148 m_loadState = WaitingForSource; | 3155 m_loadState = WaitingForSource; |
| 3149 | 3156 |
| 3150 if (m_textTracks) | 3157 if (m_textTracks) |
| 3151 configureTextTrackDisplay(AssumeNoVisibleChange); | 3158 configureTextTrackDisplay(AssumeNoVisibleChange); |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3595 | 3602 |
| 3596 void HTMLMediaElement::applyMediaFragmentURI() | 3603 void HTMLMediaElement::applyMediaFragmentURI() |
| 3597 { | 3604 { |
| 3598 if (m_fragmentStartTime != MediaPlayer::invalidTime()) { | 3605 if (m_fragmentStartTime != MediaPlayer::invalidTime()) { |
| 3599 m_sentEndEvent = false; | 3606 m_sentEndEvent = false; |
| 3600 UseCounter::count(document(), UseCounter::HTMLMediaElementSeekToFragment Start); | 3607 UseCounter::count(document(), UseCounter::HTMLMediaElementSeekToFragment Start); |
| 3601 seek(m_fragmentStartTime, IGNORE_EXCEPTION); | 3608 seek(m_fragmentStartTime, IGNORE_EXCEPTION); |
| 3602 } | 3609 } |
| 3603 } | 3610 } |
| 3604 | 3611 |
| 3605 MediaPlayerClient::CORSMode HTMLMediaElement::mediaPlayerCORSMode() const | 3612 WebMediaPlayer::CORSMode HTMLMediaElement::corsMode() const |
| 3606 { | 3613 { |
| 3607 const AtomicString& crossOriginMode = fastGetAttribute(crossoriginAttr); | 3614 const AtomicString& crossOriginMode = fastGetAttribute(crossoriginAttr); |
| 3608 if (crossOriginMode.isNull()) | 3615 if (crossOriginMode.isNull()) |
| 3609 return Unspecified; | 3616 return WebMediaPlayer::CORSModeUnspecified; |
| 3610 if (equalIgnoringCase(crossOriginMode, "use-credentials")) | 3617 if (equalIgnoringCase(crossOriginMode, "use-credentials")) |
| 3611 return UseCredentials; | 3618 return WebMediaPlayer::CORSModeUseCredentials; |
| 3612 return Anonymous; | 3619 return WebMediaPlayer::CORSModeAnonymous; |
| 3613 } | 3620 } |
| 3614 | 3621 |
| 3615 void HTMLMediaElement::mediaPlayerSetWebLayer(blink::WebLayer* webLayer) | 3622 void HTMLMediaElement::mediaPlayerSetWebLayer(blink::WebLayer* webLayer) |
| 3616 { | 3623 { |
| 3617 if (webLayer == m_webLayer) | 3624 if (webLayer == m_webLayer) |
| 3618 return; | 3625 return; |
| 3619 | 3626 |
| 3620 // If either of the layers is null we need to enable or disable compositing. This is done by triggering a style recalc. | 3627 // If either of the layers is null we need to enable or disable compositing. This is done by triggering a style recalc. |
| 3621 if (!m_webLayer || !webLayer) | 3628 if (!m_webLayer || !webLayer) |
| 3622 scheduleLayerUpdate(); | 3629 scheduleLayerUpdate(); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 3640 void HTMLMediaElement::mediaPlayerMediaSourceOpened(blink::WebMediaSource* webMe diaSource) | 3647 void HTMLMediaElement::mediaPlayerMediaSourceOpened(blink::WebMediaSource* webMe diaSource) |
| 3641 { | 3648 { |
| 3642 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource)); | 3649 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource)); |
| 3643 } | 3650 } |
| 3644 | 3651 |
| 3645 bool HTMLMediaElement::isInteractiveContent() const | 3652 bool HTMLMediaElement::isInteractiveContent() const |
| 3646 { | 3653 { |
| 3647 return fastHasAttribute(controlsAttr); | 3654 return fastHasAttribute(controlsAttr); |
| 3648 } | 3655 } |
| 3649 | 3656 |
| 3657 void HTMLMediaElement::setPlayerPreload() | |
| 3658 { | |
| 3659 m_player->setPreload(m_preload); | |
|
philipj_slow
2014/03/08 19:38:40
I had to look for a while before I understood why
acolwell GONE FROM CHROMIUM
2014/03/10 21:53:31
Agreed. I was surprised about this as well especia
| |
| 3660 | |
| 3661 if (m_delayingLoad && m_preload != MediaPlayer::None) | |
| 3662 startDelayedLoad(); | |
| 3650 } | 3663 } |
| 3664 | |
| 3665 void HTMLMediaElement::startDelayedLoad() | |
| 3666 { | |
| 3667 ASSERT(m_delayingLoad); | |
| 3668 | |
| 3669 m_delayingLoad = false; | |
| 3670 | |
| 3671 m_player->load(loadType(), m_currentSrc, corsMode()); | |
| 3672 } | |
| 3673 | |
| 3674 WebMediaPlayer::LoadType HTMLMediaElement::loadType() const | |
|
philipj_slow
2014/03/08 19:38:40
Maybe move these functions up together with their
acolwell GONE FROM CHROMIUM
2014/03/10 21:53:31
Done.
| |
| 3675 { | |
| 3676 if (m_mediaSource) | |
| 3677 return WebMediaPlayer::LoadTypeMediaSource; | |
| 3678 | |
| 3679 if (isMediaStreamURL(m_currentSrc.string())) | |
| 3680 return WebMediaPlayer::LoadTypeMediaStream; | |
| 3681 | |
| 3682 return WebMediaPlayer::LoadTypeURL; | |
| 3683 } | |
| 3684 | |
| 3685 } | |
| OLD | NEW |