| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 | 112 |
| 113 namespace blink { | 113 namespace blink { |
| 114 | 114 |
| 115 using namespace HTMLNames; | 115 using namespace HTMLNames; |
| 116 | 116 |
| 117 using WeakMediaElementSet = HeapHashSet<WeakMember<HTMLMediaElement>>; | 117 using WeakMediaElementSet = HeapHashSet<WeakMember<HTMLMediaElement>>; |
| 118 using DocumentElementSetMap = HeapHashMap<WeakMember<Document>, Member<WeakMedia
ElementSet>>; | 118 using DocumentElementSetMap = HeapHashMap<WeakMember<Document>, Member<WeakMedia
ElementSet>>; |
| 119 | 119 |
| 120 namespace { | 120 namespace { |
| 121 | 121 |
| 122 // URL protocol used to signal that the media source API is being used. | |
| 123 const char mediaSourceBlobProtocol[] = "blob"; | |
| 124 | |
| 125 enum MediaControlsShow { | 122 enum MediaControlsShow { |
| 126 MediaControlsShowAttribute = 0, | 123 MediaControlsShowAttribute = 0, |
| 127 MediaControlsShowFullscreen, | 124 MediaControlsShowFullscreen, |
| 128 MediaControlsShowNoScript, | 125 MediaControlsShowNoScript, |
| 129 MediaControlsShowNotShown, | 126 MediaControlsShowNotShown, |
| 130 MediaControlsShowMax | 127 MediaControlsShowMax |
| 131 }; | 128 }; |
| 132 | 129 |
| 133 String urlForLoggingMedia(const KURL& url) | 130 String urlForLoggingMedia(const KURL& url) |
| 134 { | 131 { |
| (...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1024 setPlayerPreload(); | 1021 setPlayerPreload(); |
| 1025 | 1022 |
| 1026 if (fastHasAttribute(mutedAttr)) | 1023 if (fastHasAttribute(mutedAttr)) |
| 1027 m_muted = true; | 1024 m_muted = true; |
| 1028 updateVolume(); | 1025 updateVolume(); |
| 1029 | 1026 |
| 1030 DCHECK(!m_mediaSource); | 1027 DCHECK(!m_mediaSource); |
| 1031 | 1028 |
| 1032 bool attemptLoad = true; | 1029 bool attemptLoad = true; |
| 1033 | 1030 |
| 1034 bool isStreamOrBlobUrl = source.isMediaStream() || url.protocolIs(mediaSourc
eBlobProtocol); | 1031 m_mediaSource = HTMLMediaSource::lookup(url.getString()); |
| 1035 if (isStreamOrBlobUrl) { | 1032 if (m_mediaSource && !m_mediaSource->attachToElement(this)) { |
| 1036 bool isMediaStream = source.isMediaStream() || (source.isURL() && isMedi
aStreamURL(url.getString())); | 1033 // Forget our reference to the MediaSource, so we leave it alone |
| 1037 if (isMediaStream) { | 1034 // while processing remainder of load failure. |
| 1038 m_autoplayHelper->unlockUserGesture(GesturelessPlaybackEnabledByStre
am); | 1035 m_mediaSource = nullptr; |
| 1039 } else { | 1036 attemptLoad = false; |
| 1040 m_mediaSource = HTMLMediaSource::lookup(url.getString()); | |
| 1041 | |
| 1042 if (m_mediaSource) { | |
| 1043 if (!m_mediaSource->attachToElement(this)) { | |
| 1044 // Forget our reference to the MediaSource, so we leave it a
lone | |
| 1045 // while processing remainder of load failure. | |
| 1046 m_mediaSource = nullptr; | |
| 1047 attemptLoad = false; | |
| 1048 } | |
| 1049 } | |
| 1050 } | |
| 1051 } | 1037 } |
| 1052 | 1038 |
| 1053 bool canLoadResource = source.isMediaStream() || canLoadURL(url, contentType
); | 1039 bool canLoadResource = source.isMediaStream() || canLoadURL(url, contentType
); |
| 1054 if (attemptLoad && canLoadResource) { | 1040 if (attemptLoad && canLoadResource) { |
| 1055 DCHECK(!webMediaPlayer()); | 1041 DCHECK(!webMediaPlayer()); |
| 1056 | 1042 |
| 1057 // Conditionally defer the load if effective preload is 'none'. | 1043 // Conditionally defer the load if effective preload is 'none'. |
| 1058 // Skip this optional deferral for MediaStream sources or any blob URL, | 1044 // Skip this optional deferral for MediaStream sources or any blob URL, |
| 1059 // including MediaSource blob URLs. | 1045 // including MediaSource blob URLs. |
| 1060 if (!isStreamOrBlobUrl && effectivePreloadType() == WebMediaPlayer::Prel
oadNone) { | 1046 if (!source.isMediaStream() && !url.protocolIs("blob") && effectivePrelo
adType() == WebMediaPlayer::PreloadNone) { |
| 1061 MEDIA_LOG << "loadResource(" << (void*)this << ") : Delaying load be
cause preload == 'none'"; | 1047 MEDIA_LOG << "loadResource(" << (void*)this << ") : Delaying load be
cause preload == 'none'"; |
| 1062 deferLoad(); | 1048 deferLoad(); |
| 1063 } else { | 1049 } else { |
| 1064 startPlayerLoad(); | 1050 startPlayerLoad(); |
| 1065 } | 1051 } |
| 1066 } else { | 1052 } else { |
| 1067 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); | 1053 mediaLoadingFailed(WebMediaPlayer::NetworkStateFormatError); |
| 1068 } | 1054 } |
| 1069 | 1055 |
| 1070 // If there is no poster to display, allow the media engine to render video
frames as soon as | 1056 // If there is no poster to display, allow the media engine to render video
frames as soon as |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1216 } | 1202 } |
| 1217 DCHECK_EQ(m_deferredLoadState, WaitingForStopDelayingLoadEventTask); | 1203 DCHECK_EQ(m_deferredLoadState, WaitingForStopDelayingLoadEventTask); |
| 1218 m_deferredLoadState = WaitingForTrigger; | 1204 m_deferredLoadState = WaitingForTrigger; |
| 1219 } | 1205 } |
| 1220 | 1206 |
| 1221 WebMediaPlayer::LoadType HTMLMediaElement::loadType() const | 1207 WebMediaPlayer::LoadType HTMLMediaElement::loadType() const |
| 1222 { | 1208 { |
| 1223 if (m_mediaSource) | 1209 if (m_mediaSource) |
| 1224 return WebMediaPlayer::LoadTypeMediaSource; | 1210 return WebMediaPlayer::LoadTypeMediaSource; |
| 1225 | 1211 |
| 1226 if (m_srcObject || isMediaStreamURL(m_currentSrc.getString())) | 1212 if (m_srcObject || (!m_currentSrc.isNull() && isMediaStreamURL(m_currentSrc.
getString()))) |
| 1227 return WebMediaPlayer::LoadTypeMediaStream; | 1213 return WebMediaPlayer::LoadTypeMediaStream; |
| 1228 | 1214 |
| 1229 return WebMediaPlayer::LoadTypeURL; | 1215 return WebMediaPlayer::LoadTypeURL; |
| 1230 } | 1216 } |
| 1231 | 1217 |
| 1232 bool HTMLMediaElement::textTracksAreReady() const | 1218 bool HTMLMediaElement::textTracksAreReady() const |
| 1233 { | 1219 { |
| 1234 // 4.8.10.12.1 Text track model | 1220 // 4.8.10.12.1 Text track model |
| 1235 // ... | 1221 // ... |
| 1236 // The text tracks of a media element are ready if all the text tracks whose
mode was not | 1222 // The text tracks of a media element are ready if all the text tracks whose
mode was not |
| (...skipping 2481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3718 void HTMLMediaElement::unlockUserGesture() | 3704 void HTMLMediaElement::unlockUserGesture() |
| 3719 { | 3705 { |
| 3720 m_lockedPendingUserGesture = false; | 3706 m_lockedPendingUserGesture = false; |
| 3721 } | 3707 } |
| 3722 | 3708 |
| 3723 bool HTMLMediaElement::isGestureNeededForPlayback() const | 3709 bool HTMLMediaElement::isGestureNeededForPlayback() const |
| 3724 { | 3710 { |
| 3725 if (!m_lockedPendingUserGesture) | 3711 if (!m_lockedPendingUserGesture) |
| 3726 return false; | 3712 return false; |
| 3727 | 3713 |
| 3714 if (loadType() == WebMediaPlayer::LoadTypeMediaStream) |
| 3715 return false; |
| 3716 |
| 3728 // We want to allow muted video to autoplay if: | 3717 // We want to allow muted video to autoplay if: |
| 3729 // - the flag is enabled; | 3718 // - the flag is enabled; |
| 3730 // - Data Saver is not enabled; | 3719 // - Data Saver is not enabled; |
| 3731 // - Autoplay is enabled in settings; | 3720 // - Autoplay is enabled in settings; |
| 3732 if (isHTMLVideoElement() | 3721 if (isHTMLVideoElement() |
| 3733 && muted() | 3722 && muted() |
| 3734 && RuntimeEnabledFeatures::autoplayMutedVideosEnabled() | 3723 && RuntimeEnabledFeatures::autoplayMutedVideosEnabled() |
| 3735 && !(document().settings() && document().settings()->dataSaverEnabled()) | 3724 && !(document().settings() && document().settings()->dataSaverEnabled()) |
| 3736 && isAutoplayAllowedPerSettings()) { | 3725 && isAutoplayAllowedPerSettings()) { |
| 3737 return false; | 3726 return false; |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4023 | 4012 |
| 4024 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co
nst | 4013 IntRect HTMLMediaElement::AutoplayHelperClientImpl::absoluteBoundingBoxRect() co
nst |
| 4025 { | 4014 { |
| 4026 IntRect result; | 4015 IntRect result; |
| 4027 if (LayoutObject* object = m_element->layoutObject()) | 4016 if (LayoutObject* object = m_element->layoutObject()) |
| 4028 result = object->absoluteBoundingBoxRect(); | 4017 result = object->absoluteBoundingBoxRect(); |
| 4029 return result; | 4018 return result; |
| 4030 } | 4019 } |
| 4031 | 4020 |
| 4032 } // namespace blink | 4021 } // namespace blink |
| OLD | NEW |