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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 } | 234 } |
235 | 235 |
236 // If no MIME type is specified, always attempt to load. | 236 // If no MIME type is specified, always attempt to load. |
237 if (contentMIMEType.isEmpty()) | 237 if (contentMIMEType.isEmpty()) |
238 return true; | 238 return true; |
239 | 239 |
240 // 4.8.10.3 MIME types - In the absence of a specification to the contrary,
the MIME type "application/octet-stream" | 240 // 4.8.10.3 MIME types - In the absence of a specification to the contrary,
the MIME type "application/octet-stream" |
241 // when used with parameters, e.g. "application/octet-stream;codecs=theora",
is a type that the user agent knows | 241 // when used with parameters, e.g. "application/octet-stream;codecs=theora",
is a type that the user agent knows |
242 // it cannot render. | 242 // it cannot render. |
243 if (contentMIMEType != "application/octet-stream" || contentTypeCodecs.isEmp
ty()) { | 243 if (contentMIMEType != "application/octet-stream" || contentTypeCodecs.isEmp
ty()) { |
244 WebMimeRegistry::SupportsType supported = blink::Platform::current()->mi
meRegistry()->supportsMediaMIMEType(contentMIMEType, contentTypeCodecs, keySyste
m.lower()); | 244 WebMimeRegistry::SupportsType supported = Platform::current()->mimeRegis
try()->supportsMediaMIMEType(contentMIMEType, contentTypeCodecs, keySystem.lower
()); |
245 return supported > WebMimeRegistry::IsNotSupported; | 245 return supported > WebMimeRegistry::IsNotSupported; |
246 } | 246 } |
247 | 247 |
248 return false; | 248 return false; |
249 } | 249 } |
250 | 250 |
251 // These values are used for a histogram. Do not reorder. | 251 // These values are used for a histogram. Do not reorder. |
252 enum AutoplayMetrics { | 252 enum AutoplayMetrics { |
253 // Media element with autoplay seen. | 253 // Media element with autoplay seen. |
254 AutoplayMediaFound = 0, | 254 AutoplayMediaFound = 0, |
255 // Autoplay enabled and user stopped media play at any point. | 255 // Autoplay enabled and user stopped media play at any point. |
256 AutoplayStopped = 1, | 256 AutoplayStopped = 1, |
257 // Autoplay enabled but user bailed out on media play early. | 257 // Autoplay enabled but user bailed out on media play early. |
258 AutoplayBailout = 2, | 258 AutoplayBailout = 2, |
259 // Autoplay disabled but user manually started media. | 259 // Autoplay disabled but user manually started media. |
260 AutoplayManualStart = 3, | 260 AutoplayManualStart = 3, |
261 // Autoplay was (re)enabled through a user-gesture triggered load() | 261 // Autoplay was (re)enabled through a user-gesture triggered load() |
262 AutoplayEnabledThroughLoad = 4, | 262 AutoplayEnabledThroughLoad = 4, |
263 // This enum value must be last. | 263 // This enum value must be last. |
264 NumberOfAutoplayMetrics, | 264 NumberOfAutoplayMetrics, |
265 }; | 265 }; |
266 | 266 |
267 static void recordAutoplayMetric(AutoplayMetrics metric) | 267 static void recordAutoplayMetric(AutoplayMetrics metric) |
268 { | 268 { |
269 blink::Platform::current()->histogramEnumeration("Blink.MediaElement.Autopla
y", metric, NumberOfAutoplayMetrics); | 269 Platform::current()->histogramEnumeration("Blink.MediaElement.Autoplay", met
ric, NumberOfAutoplayMetrics); |
270 } | 270 } |
271 | 271 |
272 WebMimeRegistry::SupportsType HTMLMediaElement::supportsType(const ContentType&
contentType, const String& keySystem) | 272 WebMimeRegistry::SupportsType HTMLMediaElement::supportsType(const ContentType&
contentType, const String& keySystem) |
273 { | 273 { |
274 DEFINE_STATIC_LOCAL(const String, codecs, ("codecs")); | 274 DEFINE_STATIC_LOCAL(const String, codecs, ("codecs")); |
275 | 275 |
276 if (!RuntimeEnabledFeatures::mediaEnabled()) | 276 if (!RuntimeEnabledFeatures::mediaEnabled()) |
277 return WebMimeRegistry::IsNotSupported; | 277 return WebMimeRegistry::IsNotSupported; |
278 | 278 |
279 String type = contentType.type().lower(); | 279 String type = contentType.type().lower(); |
280 // The codecs string is not lower-cased because MP4 values are case sensitiv
e | 280 // The codecs string is not lower-cased because MP4 values are case sensitiv
e |
281 // per http://tools.ietf.org/html/rfc4281#page-7. | 281 // per http://tools.ietf.org/html/rfc4281#page-7. |
282 String typeCodecs = contentType.parameter(codecs); | 282 String typeCodecs = contentType.parameter(codecs); |
283 String system = keySystem.lower(); | 283 String system = keySystem.lower(); |
284 | 284 |
285 if (type.isEmpty()) | 285 if (type.isEmpty()) |
286 return WebMimeRegistry::IsNotSupported; | 286 return WebMimeRegistry::IsNotSupported; |
287 | 287 |
288 // 4.8.10.3 MIME types - The canPlayType(type) method must return the empty
string if type is a type that the | 288 // 4.8.10.3 MIME types - The canPlayType(type) method must return the empty
string if type is a type that the |
289 // user agent knows it cannot render or is the type "application/octet-strea
m" | 289 // user agent knows it cannot render or is the type "application/octet-strea
m" |
290 if (type == "application/octet-stream") | 290 if (type == "application/octet-stream") |
291 return WebMimeRegistry::IsNotSupported; | 291 return WebMimeRegistry::IsNotSupported; |
292 | 292 |
293 return blink::Platform::current()->mimeRegistry()->supportsMediaMIMEType(typ
e, typeCodecs, system); | 293 return Platform::current()->mimeRegistry()->supportsMediaMIMEType(type, type
Codecs, system); |
294 } | 294 } |
295 | 295 |
296 URLRegistry* HTMLMediaElement::s_mediaStreamRegistry = 0; | 296 URLRegistry* HTMLMediaElement::s_mediaStreamRegistry = 0; |
297 | 297 |
298 void HTMLMediaElement::setMediaStreamRegistry(URLRegistry* registry) | 298 void HTMLMediaElement::setMediaStreamRegistry(URLRegistry* registry) |
299 { | 299 { |
300 ASSERT(!s_mediaStreamRegistry); | 300 ASSERT(!s_mediaStreamRegistry); |
301 s_mediaStreamRegistry = registry; | 301 s_mediaStreamRegistry = registry; |
302 } | 302 } |
303 | 303 |
(...skipping 1919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2223 Vector<WebMediaPlayer::TrackId> enabledTrackIds; | 2223 Vector<WebMediaPlayer::TrackId> enabledTrackIds; |
2224 for (unsigned i = 0; i < audioTracks().length(); ++i) { | 2224 for (unsigned i = 0; i < audioTracks().length(); ++i) { |
2225 AudioTrack* track = audioTracks().anonymousIndexedGetter(i); | 2225 AudioTrack* track = audioTracks().anonymousIndexedGetter(i); |
2226 if (track->enabled()) | 2226 if (track->enabled()) |
2227 enabledTrackIds.append(track->trackId()); | 2227 enabledTrackIds.append(track->trackId()); |
2228 } | 2228 } |
2229 | 2229 |
2230 webMediaPlayer()->enabledAudioTracksChanged(enabledTrackIds); | 2230 webMediaPlayer()->enabledAudioTracksChanged(enabledTrackIds); |
2231 } | 2231 } |
2232 | 2232 |
2233 WebMediaPlayer::TrackId HTMLMediaElement::addAudioTrack(const String& id, blink:
:WebMediaPlayerClient::AudioTrackKind kind, const AtomicString& label, const Ato
micString& language, bool enabled) | 2233 WebMediaPlayer::TrackId HTMLMediaElement::addAudioTrack(const String& id, WebMed
iaPlayerClient::AudioTrackKind kind, const AtomicString& label, const AtomicStri
ng& language, bool enabled) |
2234 { | 2234 { |
2235 AtomicString kindString = AudioKindToString(kind); | 2235 AtomicString kindString = AudioKindToString(kind); |
2236 WTF_LOG(Media, "HTMLMediaElement::addAudioTrack(%p, '%s', '%s', '%s', '%s',
%d)", | 2236 WTF_LOG(Media, "HTMLMediaElement::addAudioTrack(%p, '%s', '%s', '%s', '%s',
%d)", |
2237 this, id.ascii().data(), kindString.ascii().data(), label.ascii().data()
, language.ascii().data(), enabled); | 2237 this, id.ascii().data(), kindString.ascii().data(), label.ascii().data()
, language.ascii().data(), enabled); |
2238 | 2238 |
2239 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | 2239 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) |
2240 return 0; | 2240 return 0; |
2241 | 2241 |
2242 RefPtrWillBeRawPtr<AudioTrack> audioTrack = AudioTrack::create(id, kindStrin
g, label, language, enabled); | 2242 RefPtrWillBeRawPtr<AudioTrack> audioTrack = AudioTrack::create(id, kindStrin
g, label, language, enabled); |
2243 audioTracks().add(audioTrack); | 2243 audioTracks().add(audioTrack); |
(...skipping 23 matching lines...) Expand all Loading... |
2267 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | 2267 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); |
2268 | 2268 |
2269 if (selectedTrackId) | 2269 if (selectedTrackId) |
2270 videoTracks().trackSelected(*selectedTrackId); | 2270 videoTracks().trackSelected(*selectedTrackId); |
2271 | 2271 |
2272 // FIXME: Add call on m_mediaSource to notify it of track changes once the S
ourceBuffer.videoTracks attribute is added. | 2272 // FIXME: Add call on m_mediaSource to notify it of track changes once the S
ourceBuffer.videoTracks attribute is added. |
2273 | 2273 |
2274 webMediaPlayer()->selectedVideoTrackChanged(selectedTrackId); | 2274 webMediaPlayer()->selectedVideoTrackChanged(selectedTrackId); |
2275 } | 2275 } |
2276 | 2276 |
2277 WebMediaPlayer::TrackId HTMLMediaElement::addVideoTrack(const String& id, blink:
:WebMediaPlayerClient::VideoTrackKind kind, const AtomicString& label, const Ato
micString& language, bool selected) | 2277 WebMediaPlayer::TrackId HTMLMediaElement::addVideoTrack(const String& id, WebMed
iaPlayerClient::VideoTrackKind kind, const AtomicString& label, const AtomicStri
ng& language, bool selected) |
2278 { | 2278 { |
2279 AtomicString kindString = VideoKindToString(kind); | 2279 AtomicString kindString = VideoKindToString(kind); |
2280 WTF_LOG(Media, "HTMLMediaElement::addVideoTrack(%p, '%s', '%s', '%s', '%s',
%d)", | 2280 WTF_LOG(Media, "HTMLMediaElement::addVideoTrack(%p, '%s', '%s', '%s', '%s',
%d)", |
2281 this, id.ascii().data(), kindString.ascii().data(), label.ascii().data()
, language.ascii().data(), selected); | 2281 this, id.ascii().data(), kindString.ascii().data(), label.ascii().data()
, language.ascii().data(), selected); |
2282 | 2282 |
2283 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | 2283 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) |
2284 return 0; | 2284 return 0; |
2285 | 2285 |
2286 // If another track was selected (potentially by the user), leave it selecte
d. | 2286 // If another track was selected (potentially by the user), leave it selecte
d. |
2287 if (selected && videoTracks().selectedIndex() != -1) | 2287 if (selected && videoTracks().selectedIndex() != -1) |
(...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3148 } | 3148 } |
3149 | 3149 |
3150 void HTMLMediaElement::willStopBeingFullscreenElement() | 3150 void HTMLMediaElement::willStopBeingFullscreenElement() |
3151 { | 3151 { |
3152 if (mediaControls()) | 3152 if (mediaControls()) |
3153 mediaControls()->exitedFullscreen(); | 3153 mediaControls()->exitedFullscreen(); |
3154 if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled() && isHTMLVideoEl
ement()) | 3154 if (RuntimeEnabledFeatures::overlayFullscreenVideoEnabled() && isHTMLVideoEl
ement()) |
3155 document().layoutView()->compositor()->setNeedsCompositingUpdate(Composi
tingUpdateRebuildTree); | 3155 document().layoutView()->compositor()->setNeedsCompositingUpdate(Composi
tingUpdateRebuildTree); |
3156 } | 3156 } |
3157 | 3157 |
3158 blink::WebLayer* HTMLMediaElement::platformLayer() const | 3158 WebLayer* HTMLMediaElement::platformLayer() const |
3159 { | 3159 { |
3160 return m_webLayer; | 3160 return m_webLayer; |
3161 } | 3161 } |
3162 | 3162 |
3163 bool HTMLMediaElement::hasClosedCaptions() const | 3163 bool HTMLMediaElement::hasClosedCaptions() const |
3164 { | 3164 { |
3165 if (m_textTracks) { | 3165 if (m_textTracks) { |
3166 for (unsigned i = 0; i < m_textTracks->length(); ++i) { | 3166 for (unsigned i = 0; i < m_textTracks->length(); ++i) { |
3167 if (m_textTracks->item(i)->readinessState() == TextTrack::FailedToLo
ad) | 3167 if (m_textTracks->item(i)->readinessState() == TextTrack::FailedToLo
ad) |
3168 continue; | 3168 continue; |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3559 WebMediaPlayer::CORSMode HTMLMediaElement::corsMode() const | 3559 WebMediaPlayer::CORSMode HTMLMediaElement::corsMode() const |
3560 { | 3560 { |
3561 const AtomicString& crossOriginMode = fastGetAttribute(crossoriginAttr); | 3561 const AtomicString& crossOriginMode = fastGetAttribute(crossoriginAttr); |
3562 if (crossOriginMode.isNull()) | 3562 if (crossOriginMode.isNull()) |
3563 return WebMediaPlayer::CORSModeUnspecified; | 3563 return WebMediaPlayer::CORSModeUnspecified; |
3564 if (equalIgnoringCase(crossOriginMode, "use-credentials")) | 3564 if (equalIgnoringCase(crossOriginMode, "use-credentials")) |
3565 return WebMediaPlayer::CORSModeUseCredentials; | 3565 return WebMediaPlayer::CORSModeUseCredentials; |
3566 return WebMediaPlayer::CORSModeAnonymous; | 3566 return WebMediaPlayer::CORSModeAnonymous; |
3567 } | 3567 } |
3568 | 3568 |
3569 void HTMLMediaElement::mediaPlayerSetWebLayer(blink::WebLayer* webLayer) | 3569 void HTMLMediaElement::mediaPlayerSetWebLayer(WebLayer* webLayer) |
3570 { | 3570 { |
3571 if (webLayer == m_webLayer) | 3571 if (webLayer == m_webLayer) |
3572 return; | 3572 return; |
3573 | 3573 |
3574 // If either of the layers is null we need to enable or disable compositing.
This is done by triggering a style recalc. | 3574 // If either of the layers is null we need to enable or disable compositing.
This is done by triggering a style recalc. |
3575 if ((!m_webLayer || !webLayer) | 3575 if ((!m_webLayer || !webLayer) |
3576 #if ENABLE(OILPAN) | 3576 #if ENABLE(OILPAN) |
3577 && !m_isFinalizing | 3577 && !m_isFinalizing |
3578 #endif | 3578 #endif |
3579 ) | 3579 ) |
3580 setNeedsCompositingUpdate(); | 3580 setNeedsCompositingUpdate(); |
3581 | 3581 |
3582 if (m_webLayer) | 3582 if (m_webLayer) |
3583 GraphicsLayer::unregisterContentsLayer(m_webLayer); | 3583 GraphicsLayer::unregisterContentsLayer(m_webLayer); |
3584 m_webLayer = webLayer; | 3584 m_webLayer = webLayer; |
3585 if (m_webLayer) | 3585 if (m_webLayer) |
3586 GraphicsLayer::registerContentsLayer(m_webLayer); | 3586 GraphicsLayer::registerContentsLayer(m_webLayer); |
3587 } | 3587 } |
3588 | 3588 |
3589 void HTMLMediaElement::mediaPlayerMediaSourceOpened(blink::WebMediaSource* webMe
diaSource) | 3589 void HTMLMediaElement::mediaPlayerMediaSourceOpened(WebMediaSource* webMediaSour
ce) |
3590 { | 3590 { |
3591 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource)); | 3591 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource)); |
3592 } | 3592 } |
3593 | 3593 |
3594 bool HTMLMediaElement::isInteractiveContent() const | 3594 bool HTMLMediaElement::isInteractiveContent() const |
3595 { | 3595 { |
3596 return fastHasAttribute(controlsAttr); | 3596 return fastHasAttribute(controlsAttr); |
3597 } | 3597 } |
3598 | 3598 |
3599 void HTMLMediaElement::defaultEventHandler(Event* event) | 3599 void HTMLMediaElement::defaultEventHandler(Event* event) |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3659 | 3659 |
3660 #if ENABLE(WEB_AUDIO) | 3660 #if ENABLE(WEB_AUDIO) |
3661 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) | 3661 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) |
3662 { | 3662 { |
3663 if (!visitor->isHeapObjectAlive(m_audioSourceNode) && audioSourceProvider()) | 3663 if (!visitor->isHeapObjectAlive(m_audioSourceNode) && audioSourceProvider()) |
3664 audioSourceProvider()->setClient(nullptr); | 3664 audioSourceProvider()->setClient(nullptr); |
3665 } | 3665 } |
3666 #endif | 3666 #endif |
3667 | 3667 |
3668 } | 3668 } |
OLD | NEW |