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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 #include "core/frame/UseCounter.h" | 45 #include "core/frame/UseCounter.h" |
| 46 #include "core/frame/csp/ContentSecurityPolicy.h" | 46 #include "core/frame/csp/ContentSecurityPolicy.h" |
| 47 #include "core/html/HTMLMediaSource.h" | 47 #include "core/html/HTMLMediaSource.h" |
| 48 #include "core/html/HTMLSourceElement.h" | 48 #include "core/html/HTMLSourceElement.h" |
| 49 #include "core/html/HTMLTrackElement.h" | 49 #include "core/html/HTMLTrackElement.h" |
| 50 #include "core/html/MediaController.h" | 50 #include "core/html/MediaController.h" |
| 51 #include "core/html/MediaError.h" | 51 #include "core/html/MediaError.h" |
| 52 #include "core/html/MediaFragmentURIParser.h" | 52 #include "core/html/MediaFragmentURIParser.h" |
| 53 #include "core/html/TimeRanges.h" | 53 #include "core/html/TimeRanges.h" |
| 54 #include "core/html/shadow/MediaControls.h" | 54 #include "core/html/shadow/MediaControls.h" |
| 55 #include "core/html/track/AudioTrack.h" | |
| 56 #include "core/html/track/AudioTrackList.h" | |
| 55 #include "core/html/track/InbandTextTrack.h" | 57 #include "core/html/track/InbandTextTrack.h" |
| 56 #include "core/html/track/TextTrackCueList.h" | 58 #include "core/html/track/TextTrackCueList.h" |
| 57 #include "core/html/track/TextTrackList.h" | 59 #include "core/html/track/TextTrackList.h" |
| 60 #include "core/html/track/VideoTrack.h" | |
| 61 #include "core/html/track/VideoTrackList.h" | |
| 58 #include "core/loader/FrameLoader.h" | 62 #include "core/loader/FrameLoader.h" |
| 59 #include "core/rendering/RenderVideo.h" | 63 #include "core/rendering/RenderVideo.h" |
| 60 #include "core/rendering/RenderView.h" | 64 #include "core/rendering/RenderView.h" |
| 61 #include "core/rendering/compositing/RenderLayerCompositor.h" | 65 #include "core/rendering/compositing/RenderLayerCompositor.h" |
| 62 #include "platform/ContentType.h" | 66 #include "platform/ContentType.h" |
| 63 #include "platform/Language.h" | 67 #include "platform/Language.h" |
| 64 #include "platform/Logging.h" | 68 #include "platform/Logging.h" |
| 65 #include "platform/MIMETypeFromURL.h" | 69 #include "platform/MIMETypeFromURL.h" |
| 66 #include "platform/MIMETypeRegistry.h" | 70 #include "platform/MIMETypeRegistry.h" |
| 67 #include "platform/NotImplemented.h" | 71 #include "platform/NotImplemented.h" |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 78 #include "wtf/text/CString.h" | 82 #include "wtf/text/CString.h" |
| 79 | 83 |
| 80 #if ENABLE(WEB_AUDIO) | 84 #if ENABLE(WEB_AUDIO) |
| 81 #include "platform/audio/AudioSourceProvider.h" | 85 #include "platform/audio/AudioSourceProvider.h" |
| 82 #include "modules/webaudio/MediaElementAudioSourceNode.h" | 86 #include "modules/webaudio/MediaElementAudioSourceNode.h" |
| 83 #endif | 87 #endif |
| 84 | 88 |
| 85 using namespace std; | 89 using namespace std; |
| 86 using blink::WebInbandTextTrack; | 90 using blink::WebInbandTextTrack; |
| 87 using blink::WebMimeRegistry; | 91 using blink::WebMimeRegistry; |
| 92 using blink::WebMediaPlayerClient; | |
| 88 | 93 |
| 89 namespace WebCore { | 94 namespace WebCore { |
| 90 | 95 |
| 91 #if !LOG_DISABLED | 96 #if !LOG_DISABLED |
| 92 static String urlForLoggingMedia(const KURL& url) | 97 static String urlForLoggingMedia(const KURL& url) |
| 93 { | 98 { |
| 94 static const unsigned maximumURLLengthForLogging = 128; | 99 static const unsigned maximumURLLengthForLogging = 128; |
| 95 | 100 |
| 96 if (url.string().length() < maximumURLLengthForLogging) | 101 if (url.string().length() < maximumURLLengthForLogging) |
| 97 return url.string(); | 102 return url.string(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 156 ~TrackDisplayUpdateScope() | 161 ~TrackDisplayUpdateScope() |
| 157 { | 162 { |
| 158 ASSERT(m_mediaElement); | 163 ASSERT(m_mediaElement); |
| 159 m_mediaElement->endIgnoringTrackDisplayUpdateRequests(); | 164 m_mediaElement->endIgnoringTrackDisplayUpdateRequests(); |
| 160 } | 165 } |
| 161 | 166 |
| 162 private: | 167 private: |
| 163 HTMLMediaElement* m_mediaElement; | 168 HTMLMediaElement* m_mediaElement; |
| 164 }; | 169 }; |
| 165 | 170 |
| 171 static const AtomicString& VideoKindToString(WebMediaPlayerClient::VideoTrackKin d kind) | |
|
philipj_slow
2014/03/09 09:04:14
Switch the order of this and the AudioKindToString
acolwell GONE FROM CHROMIUM
2014/03/18 22:02:15
Done.
| |
| 172 { | |
| 173 switch (kind) { | |
| 174 case WebMediaPlayerClient::VideoTrackKindNone: | |
| 175 return emptyAtom; | |
| 176 case WebMediaPlayerClient::VideoTrackKindAlternative: | |
| 177 return VideoTrack::alternativeKeyword(); | |
| 178 case WebMediaPlayerClient::VideoTrackKindCaptions: | |
| 179 return VideoTrack::captionsKeyword(); | |
| 180 case WebMediaPlayerClient::VideoTrackKindMain: | |
| 181 return VideoTrack::mainKeyword(); | |
| 182 case WebMediaPlayerClient::VideoTrackKindSign: | |
| 183 return VideoTrack::signKeyword(); | |
| 184 case WebMediaPlayerClient::VideoTrackKindSubtitles: | |
| 185 return VideoTrack::subtitlesKeyword(); | |
| 186 case WebMediaPlayerClient::VideoTrackKindCommentary: | |
| 187 return VideoTrack::commentaryKeyword(); | |
| 188 } | |
| 189 | |
| 190 ASSERT_NOT_REACHED(); | |
| 191 return emptyAtom; | |
| 192 } | |
| 193 | |
| 194 static const AtomicString& AudioKindToString(WebMediaPlayerClient::AudioTrackKin d kind) | |
| 195 { | |
| 196 switch (kind) { | |
| 197 case WebMediaPlayerClient::AudioTrackKindNone: | |
| 198 return emptyAtom; | |
| 199 case WebMediaPlayerClient::AudioTrackKindAlternative: | |
| 200 return AudioTrack::alternativeKeyword(); | |
| 201 case WebMediaPlayerClient::AudioTrackKindDescriptions: | |
| 202 return AudioTrack::descriptionsKeyword(); | |
| 203 case WebMediaPlayerClient::AudioTrackKindMain: | |
| 204 return AudioTrack::mainKeyword(); | |
| 205 case WebMediaPlayerClient::AudioTrackKindMainDescriptions: | |
| 206 return AudioTrack::mainDescriptionsKeyword(); | |
| 207 case WebMediaPlayerClient::AudioTrackKindTranslation: | |
| 208 return AudioTrack::translationKeyword(); | |
| 209 case WebMediaPlayerClient::AudioTrackKindCommentary: | |
| 210 return AudioTrack::commentaryKeyword(); | |
| 211 } | |
| 212 | |
| 213 ASSERT_NOT_REACHED(); | |
| 214 return emptyAtom; | |
| 215 } | |
| 216 | |
| 166 static bool canLoadURL(const KURL& url, const ContentType& contentType, const St ring& keySystem) | 217 static bool canLoadURL(const KURL& url, const ContentType& contentType, const St ring& keySystem) |
| 167 { | 218 { |
| 168 DEFINE_STATIC_LOCAL(const String, codecs, ("codecs")); | 219 DEFINE_STATIC_LOCAL(const String, codecs, ("codecs")); |
| 169 | 220 |
| 170 String contentMIMEType = contentType.type().lower(); | 221 String contentMIMEType = contentType.type().lower(); |
| 171 String contentTypeCodecs = contentType.parameter(codecs); | 222 String contentTypeCodecs = contentType.parameter(codecs); |
| 172 | 223 |
| 173 // If the MIME type is missing or is not meaningful, try to figure it out fr om the URL. | 224 // If the MIME type is missing or is not meaningful, try to figure it out fr om the URL. |
| 174 if (contentMIMEType.isEmpty() || contentMIMEType == "application/octet-strea m" || contentMIMEType == "text/plain") { | 225 if (contentMIMEType.isEmpty() || contentMIMEType == "application/octet-strea m" || contentMIMEType == "text/plain") { |
| 175 if (url.protocolIsData()) | 226 if (url.protocolIsData()) |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 302 { | 353 { |
| 303 WTF_LOG(Media, "HTMLMediaElement::~HTMLMediaElement"); | 354 WTF_LOG(Media, "HTMLMediaElement::~HTMLMediaElement"); |
| 304 | 355 |
| 305 m_asyncEventQueue->close(); | 356 m_asyncEventQueue->close(); |
| 306 | 357 |
| 307 setShouldDelayLoadEvent(false); | 358 setShouldDelayLoadEvent(false); |
| 308 | 359 |
| 309 if (m_textTracks) | 360 if (m_textTracks) |
| 310 m_textTracks->clearOwner(); | 361 m_textTracks->clearOwner(); |
| 311 | 362 |
| 363 if (m_audioTracks) | |
| 364 m_audioTracks->shutdown(); | |
|
philipj_slow
2014/03/09 09:04:14
This will cancel pending events, and I think it's
acolwell GONE FROM CHROMIUM
2014/03/18 22:02:15
I've removed the m_asyncEventQueue->close() from s
philipj_slow
2014/03/20 16:17:39
Bug for TextTrackList: https://code.google.com/p/c
| |
| 365 | |
| 366 if (m_videoTracks) | |
| 367 m_videoTracks->shutdown(); | |
| 368 | |
| 312 if (m_mediaController) { | 369 if (m_mediaController) { |
| 313 m_mediaController->removeMediaElement(this); | 370 m_mediaController->removeMediaElement(this); |
| 314 m_mediaController = nullptr; | 371 m_mediaController = nullptr; |
| 315 } | 372 } |
| 316 | 373 |
| 317 closeMediaSource(); | 374 closeMediaSource(); |
| 318 | 375 |
| 319 removeElementFromDocumentMap(this, &document()); | 376 removeElementFromDocumentMap(this, &document()); |
| 320 | 377 |
| 321 // Destroying the player may cause a resource load to be canceled, | 378 // Destroying the player may cause a resource load to be canceled, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 361 // previous document. A proper fix would provide a mechanism to allow this | 418 // previous document. A proper fix would provide a mechanism to allow this |
| 362 // object to refresh the MediaPlayer's LocalFrame and FrameLoader references on | 419 // object to refresh the MediaPlayer's LocalFrame and FrameLoader references on |
| 363 // document changes so that playback can be resumed properly. | 420 // document changes so that playback can be resumed properly. |
| 364 userCancelledLoad(); | 421 userCancelledLoad(); |
| 365 | 422 |
| 366 // Decrement the load event delay count on oldDocument now that m_player has been destroyed | 423 // Decrement the load event delay count on oldDocument now that m_player has been destroyed |
| 367 // and there is no risk of dispatching a load event from within the destruct or. | 424 // and there is no risk of dispatching a load event from within the destruct or. |
| 368 oldDocument.decrementLoadEventDelayCount(); | 425 oldDocument.decrementLoadEventDelayCount(); |
| 369 | 426 |
| 370 ActiveDOMObject::didMoveToNewExecutionContext(&document()); | 427 ActiveDOMObject::didMoveToNewExecutionContext(&document()); |
| 428 | |
| 429 // Notify track lists so they don't stop firing events when moved to a new d ocument | |
|
philipj_slow
2014/03/09 09:04:14
Can you add a test case for this? Seems like somet
| |
| 430 // and the original document gets destroyed. | |
| 431 if (m_audioTracks) | |
| 432 m_audioTracks->didMoveToNewExecutionContext(&document()); | |
| 433 | |
| 434 if (m_videoTracks) | |
| 435 m_videoTracks->didMoveToNewExecutionContext(&document()); | |
| 436 | |
| 371 HTMLElement::didMoveToNewDocument(oldDocument); | 437 HTMLElement::didMoveToNewDocument(oldDocument); |
| 372 } | 438 } |
| 373 | 439 |
| 374 bool HTMLMediaElement::hasCustomFocusLogic() const | 440 bool HTMLMediaElement::hasCustomFocusLogic() const |
| 375 { | 441 { |
| 376 return true; | 442 return true; |
| 377 } | 443 } |
| 378 | 444 |
| 379 bool HTMLMediaElement::supportsFocus() const | 445 bool HTMLMediaElement::supportsFocus() const |
| 380 { | 446 { |
| (...skipping 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1573 finishSeek(); | 1639 finishSeek(); |
| 1574 } else { | 1640 } else { |
| 1575 if (wasPotentiallyPlaying && m_readyState < HAVE_FUTURE_DATA) { | 1641 if (wasPotentiallyPlaying && m_readyState < HAVE_FUTURE_DATA) { |
| 1576 // 4.8.10.8 | 1642 // 4.8.10.8 |
| 1577 scheduleTimeupdateEvent(false); | 1643 scheduleTimeupdateEvent(false); |
| 1578 scheduleEvent(EventTypeNames::waiting); | 1644 scheduleEvent(EventTypeNames::waiting); |
| 1579 } | 1645 } |
| 1580 } | 1646 } |
| 1581 | 1647 |
| 1582 if (m_readyState >= HAVE_METADATA && oldState < HAVE_METADATA) { | 1648 if (m_readyState >= HAVE_METADATA && oldState < HAVE_METADATA) { |
| 1649 createPlaceholderTracksIfNecessary(); | |
| 1650 | |
| 1583 prepareMediaFragmentURI(); | 1651 prepareMediaFragmentURI(); |
| 1652 | |
| 1653 selectInitialTracksIfNecessary(); | |
| 1654 | |
| 1584 scheduleEvent(EventTypeNames::durationchange); | 1655 scheduleEvent(EventTypeNames::durationchange); |
| 1585 if (isVideo()) | 1656 if (isVideo()) |
| 1586 scheduleEvent(EventTypeNames::resize); | 1657 scheduleEvent(EventTypeNames::resize); |
| 1587 scheduleEvent(EventTypeNames::loadedmetadata); | 1658 scheduleEvent(EventTypeNames::loadedmetadata); |
| 1588 if (hasMediaControls()) | 1659 if (hasMediaControls()) |
| 1589 mediaControls()->reset(); | 1660 mediaControls()->reset(); |
| 1590 if (renderer()) | 1661 if (renderer()) |
| 1591 renderer()->updateFromElement(); | 1662 renderer()->updateFromElement(); |
| 1592 } | 1663 } |
| 1593 | 1664 |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2194 m_lastTimeUpdateEventWallTime = now; | 2265 m_lastTimeUpdateEventWallTime = now; |
| 2195 m_lastTimeUpdateEventMovieTime = movieTime; | 2266 m_lastTimeUpdateEventMovieTime = movieTime; |
| 2196 } | 2267 } |
| 2197 } | 2268 } |
| 2198 | 2269 |
| 2199 bool HTMLMediaElement::canPlay() const | 2270 bool HTMLMediaElement::canPlay() const |
| 2200 { | 2271 { |
| 2201 return paused() || ended() || m_readyState < HAVE_METADATA; | 2272 return paused() || ended() || m_readyState < HAVE_METADATA; |
| 2202 } | 2273 } |
| 2203 | 2274 |
| 2275 AudioTrackList& HTMLMediaElement::audioTracks() | |
| 2276 { | |
| 2277 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | |
| 2278 | |
| 2279 if (!m_audioTracks) | |
| 2280 m_audioTracks = AudioTrackList::create(this); | |
| 2281 | |
| 2282 return *m_audioTracks; | |
| 2283 } | |
| 2284 | |
| 2285 void HTMLMediaElement::audioTrackChanged(const AtomicString& audioTrackID, bool enabled) | |
| 2286 { | |
| 2287 WTF_LOG(Media, "HTMLMediaElement::audioTrackChanged('%s', %d)", audioTrackID .ascii().data(), enabled); | |
| 2288 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | |
| 2289 ASSERT(!audioTrackID.isEmpty()); | |
| 2290 | |
| 2291 audioTracks().scheduleChangeEvent(); | |
| 2292 | |
| 2293 // FIXME: Add call on m_mediaSource to notify it of track changes once the S ourceBuffer.audioTracks attribute is added. | |
| 2294 | |
| 2295 if (webMediaPlayer()) | |
| 2296 webMediaPlayer()->enabledAudioTrackChange(audioTrackID, enabled); | |
|
philipj_slow
2014/03/09 09:04:14
This API seems to make gapless track switching har
| |
| 2297 } | |
| 2298 | |
| 2299 VideoTrackList& HTMLMediaElement::videoTracks() | |
| 2300 { | |
| 2301 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | |
| 2302 | |
| 2303 if (!m_videoTracks) | |
| 2304 m_videoTracks = VideoTrackList::create(this); | |
| 2305 | |
| 2306 return *m_videoTracks; | |
| 2307 } | |
| 2308 | |
| 2309 void HTMLMediaElement::selectedVideoTrackChanged(const AtomicString& selectedTra ckID) | |
| 2310 { | |
| 2311 WTF_LOG(Media, "HTMLMediaElement::selectedVideoTrackChanged('%s')", selected TrackID.ascii().data()); | |
| 2312 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | |
| 2313 | |
| 2314 AtomicString unselectedTrackID; | |
| 2315 | |
| 2316 int oldSelectedIndex = videoTracks().selectedIndex(); | |
| 2317 if (oldSelectedIndex != -1) | |
| 2318 unselectedTrackID = videoTracks().anonymousIndexedGetter(oldSelectedInde x)->id(); | |
| 2319 | |
| 2320 ASSERT(unselectedTrackID != selectedTrackID); | |
| 2321 | |
| 2322 videoTracks().trackSelected(selectedTrackID); | |
| 2323 | |
| 2324 // FIXME: Add call on m_mediaSource to notify it of track changes once the S ourceBuffer.videoTracks attribute is added. | |
| 2325 | |
| 2326 ASSERT(!unselectedTrackID.isEmpty() || !selectedTrackID.isEmpty()); | |
| 2327 | |
| 2328 if (webMediaPlayer()) | |
| 2329 webMediaPlayer()->selectedVideoTrackChange(unselectedTrackID, selectedTr ackID); | |
| 2330 } | |
| 2331 | |
| 2332 void HTMLMediaElement::addVideoTrack(const AtomicString& id, blink::WebMediaPlay erClient::VideoTrackKind kind, const AtomicString& label, const AtomicString& la nguage, bool selected) | |
| 2333 { | |
| 2334 AtomicString kindString = VideoKindToString(kind); | |
| 2335 WTF_LOG(Media, "HTMLMediaElement::addVideoTrack('%s', '%s', '%s', '%s', %d)" , | |
| 2336 id.ascii().data(), kindString.ascii().data(), label.ascii().data(), lang uage.ascii().data(), selected); | |
| 2337 ASSERT(!id.isEmpty()); | |
|
philipj_slow
2014/03/09 09:04:14
Also assert that the id is unique? selectedVideoTr
| |
| 2338 | |
| 2339 RefPtr<VideoTrack> videoTrack = VideoTrack::create(this, id, kindString, lab el, language); | |
| 2340 videoTracks().add(videoTrack.get()); | |
| 2341 | |
| 2342 if (selected) | |
| 2343 videoTrack->setSelected(true); | |
|
philipj_slow
2014/03/09 09:04:14
This will fire a change event for any new track...
| |
| 2344 } | |
| 2345 | |
| 2346 void HTMLMediaElement::removeVideoTrack(const AtomicString& id) | |
| 2347 { | |
| 2348 WTF_LOG(Media, "HTMLMediaElement::removeVideoTrack('%s')", id.ascii().data() ); | |
| 2349 ASSERT(!id.isEmpty()); | |
| 2350 | |
| 2351 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | |
| 2352 return; | |
| 2353 | |
| 2354 videoTracks().remove(id); | |
| 2355 } | |
| 2356 | |
| 2357 void HTMLMediaElement::addAudioTrack(const AtomicString& id, blink::WebMediaPlay erClient::AudioTrackKind kind, const AtomicString& label, const AtomicString& la nguage, bool enabled) | |
|
philipj_slow
2014/03/09 09:04:14
Move these up together with the other *AudioTrack
acolwell GONE FROM CHROMIUM
2014/03/18 22:02:15
Done.
| |
| 2358 { | |
| 2359 AtomicString kindString = AudioKindToString(kind); | |
| 2360 WTF_LOG(Media, "HTMLMediaElement::addAudioTrack('%s', '%s', '%s', '%s', %d)" , | |
| 2361 id.ascii().data(), kindString.ascii().data(), label.ascii().data(), lang uage.ascii().data(), enabled); | |
| 2362 ASSERT(!id.isEmpty()); | |
| 2363 | |
| 2364 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | |
| 2365 return; | |
| 2366 | |
| 2367 RefPtr<AudioTrack> audioTrack = AudioTrack::create(this, id, kindString, lab el, language); | |
| 2368 audioTracks().add(audioTrack.get()); | |
| 2369 | |
| 2370 if (enabled) | |
| 2371 audioTrack->setEnabled(true); | |
| 2372 } | |
| 2373 | |
| 2374 void HTMLMediaElement::removeAudioTrack(const AtomicString& id) | |
| 2375 { | |
| 2376 WTF_LOG(Media, "HTMLMediaElement::removeAudioTrack('%s')", id.ascii().data() ); | |
| 2377 ASSERT(!id.isEmpty()); | |
| 2378 | |
| 2379 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | |
| 2380 return; | |
| 2381 | |
| 2382 audioTracks().remove(id); | |
| 2383 } | |
| 2384 | |
| 2204 void HTMLMediaElement::mediaPlayerDidAddTextTrack(WebInbandTextTrack* webTrack) | 2385 void HTMLMediaElement::mediaPlayerDidAddTextTrack(WebInbandTextTrack* webTrack) |
| 2205 { | 2386 { |
| 2206 if (!RuntimeEnabledFeatures::videoTrackEnabled()) | 2387 if (!RuntimeEnabledFeatures::videoTrackEnabled()) |
| 2207 return; | 2388 return; |
| 2208 | 2389 |
| 2209 // 4.8.10.12.2 Sourcing in-band text tracks | 2390 // 4.8.10.12.2 Sourcing in-band text tracks |
| 2210 // 1. Associate the relevant data with a new text track and its correspondin g new TextTrack object. | 2391 // 1. Associate the relevant data with a new text track and its correspondin g new TextTrack object. |
| 2211 RefPtr<InbandTextTrack> textTrack = InbandTextTrack::create(document(), webT rack); | 2392 RefPtr<InbandTextTrack> textTrack = InbandTextTrack::create(document(), webT rack); |
| 2212 | 2393 |
| 2213 // 2. Set the new text track's kind, label, and language based on the semant ics of the relevant data, | 2394 // 2. Set the new text track's kind, label, and language based on the semant ics of the relevant data, |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2269 void HTMLMediaElement::removeTextTrack(TextTrack* track) | 2450 void HTMLMediaElement::removeTextTrack(TextTrack* track) |
| 2270 { | 2451 { |
| 2271 TrackDisplayUpdateScope scope(this); | 2452 TrackDisplayUpdateScope scope(this); |
| 2272 m_textTracks->remove(track); | 2453 m_textTracks->remove(track); |
| 2273 | 2454 |
| 2274 closeCaptionTracksChanged(); | 2455 closeCaptionTracksChanged(); |
| 2275 } | 2456 } |
| 2276 | 2457 |
| 2277 void HTMLMediaElement::forgetResourceSpecificTracks() | 2458 void HTMLMediaElement::forgetResourceSpecificTracks() |
| 2278 { | 2459 { |
| 2460 // Implements the "forget the media element's media-resource-specific tracks " algorithm. | |
| 2461 // The order is explicitly specified as text, then audio, and finally video. Also | |
|
philipj_slow
2014/03/09 09:04:14
Hmm, are there any events that fire that make it p
acolwell GONE FROM CHROMIUM
2014/03/18 22:02:15
I don't believe so. I just put the comment here to
philipj_slow
2014/03/20 16:17:39
Great!
| |
| 2462 // 'removetrack' events should not be fired. | |
| 2279 if (m_textTracks) { | 2463 if (m_textTracks) { |
| 2280 TrackDisplayUpdateScope scope(this); | 2464 TrackDisplayUpdateScope scope(this); |
| 2281 m_textTracks->removeAllInbandTracks(); | 2465 m_textTracks->removeAllInbandTracks(); |
| 2282 closeCaptionTracksChanged(); | 2466 closeCaptionTracksChanged(); |
| 2283 } | 2467 } |
| 2468 | |
| 2469 if (m_audioTracks) | |
| 2470 m_audioTracks->removeAll(); | |
| 2471 | |
| 2472 if (m_videoTracks) | |
| 2473 m_videoTracks->removeAll(); | |
| 2284 } | 2474 } |
| 2285 | 2475 |
| 2286 PassRefPtr<TextTrack> HTMLMediaElement::addTextTrack(const AtomicString& kind, c onst AtomicString& label, const AtomicString& language, ExceptionState& exceptio nState) | 2476 PassRefPtr<TextTrack> HTMLMediaElement::addTextTrack(const AtomicString& kind, c onst AtomicString& label, const AtomicString& language, ExceptionState& exceptio nState) |
| 2287 { | 2477 { |
| 2288 ASSERT(RuntimeEnabledFeatures::videoTrackEnabled()); | 2478 ASSERT(RuntimeEnabledFeatures::videoTrackEnabled()); |
| 2289 | 2479 |
| 2290 // 4.8.10.12.4 Text track API | 2480 // 4.8.10.12.4 Text track API |
| 2291 // The addTextTrack(kind, label, language) method of media elements, when in voked, must run the following steps: | 2481 // The addTextTrack(kind, label, language) method of media elements, when in voked, must run the following steps: |
| 2292 | 2482 |
| 2293 // 1. If kind is not one of the following strings, then throw a SyntaxError exception and abort these steps | 2483 // 1. If kind is not one of the following strings, then throw a SyntaxError exception and abort these steps |
| (...skipping 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3583 m_fragmentStartTime = MediaPlayer::invalidTime(); | 3773 m_fragmentStartTime = MediaPlayer::invalidTime(); |
| 3584 | 3774 |
| 3585 double end = fragmentParser.endTime(); | 3775 double end = fragmentParser.endTime(); |
| 3586 if (end != MediaFragmentURIParser::invalidTimeValue() && end > 0 && end > m_ fragmentStartTime) { | 3776 if (end != MediaFragmentURIParser::invalidTimeValue() && end > 0 && end > m_ fragmentStartTime) { |
| 3587 m_fragmentEndTime = end; | 3777 m_fragmentEndTime = end; |
| 3588 if (m_fragmentEndTime > dur) | 3778 if (m_fragmentEndTime > dur) |
| 3589 m_fragmentEndTime = dur; | 3779 m_fragmentEndTime = dur; |
| 3590 } else | 3780 } else |
| 3591 m_fragmentEndTime = MediaPlayer::invalidTime(); | 3781 m_fragmentEndTime = MediaPlayer::invalidTime(); |
| 3592 | 3782 |
| 3783 // FIXME: Add support for selecting tracks by ID with the Media Fragments tr ack dimension. | |
| 3784 | |
| 3593 if (m_fragmentStartTime != MediaPlayer::invalidTime() && m_readyState < HAVE _FUTURE_DATA) | 3785 if (m_fragmentStartTime != MediaPlayer::invalidTime() && m_readyState < HAVE _FUTURE_DATA) |
| 3594 prepareToPlay(); | 3786 prepareToPlay(); |
| 3595 } | 3787 } |
| 3596 | 3788 |
| 3597 void HTMLMediaElement::applyMediaFragmentURI() | 3789 void HTMLMediaElement::applyMediaFragmentURI() |
| 3598 { | 3790 { |
| 3599 if (m_fragmentStartTime != MediaPlayer::invalidTime()) { | 3791 if (m_fragmentStartTime != MediaPlayer::invalidTime()) { |
| 3600 m_sentEndEvent = false; | 3792 m_sentEndEvent = false; |
| 3601 UseCounter::count(document(), UseCounter::HTMLMediaElementSeekToFragment Start); | 3793 UseCounter::count(document(), UseCounter::HTMLMediaElementSeekToFragment Start); |
| 3602 seek(m_fragmentStartTime, IGNORE_EXCEPTION); | 3794 seek(m_fragmentStartTime, IGNORE_EXCEPTION); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3641 void HTMLMediaElement::mediaPlayerMediaSourceOpened(blink::WebMediaSource* webMe diaSource) | 3833 void HTMLMediaElement::mediaPlayerMediaSourceOpened(blink::WebMediaSource* webMe diaSource) |
| 3642 { | 3834 { |
| 3643 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource)); | 3835 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource)); |
| 3644 } | 3836 } |
| 3645 | 3837 |
| 3646 bool HTMLMediaElement::isInteractiveContent() const | 3838 bool HTMLMediaElement::isInteractiveContent() const |
| 3647 { | 3839 { |
| 3648 return fastHasAttribute(controlsAttr); | 3840 return fastHasAttribute(controlsAttr); |
| 3649 } | 3841 } |
| 3650 | 3842 |
| 3843 void HTMLMediaElement::createPlaceholderTracksIfNecessary() | |
| 3844 { | |
| 3845 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | |
| 3846 return; | |
| 3847 | |
| 3848 // Create a placeholder audio track if |m_player| says it has audio but it d idn't explicitly announce the tracks. | |
| 3849 if (m_player->hasAudio() && !audioTracks().length()) | |
| 3850 addAudioTrack("audio", WebMediaPlayerClient::AudioTrackKindMain, "Audio Track", "", true); | |
| 3851 | |
| 3852 // Create a placeholder video track if |m_player| says it has video but it d idn't explicitly announce the tracks. | |
| 3853 if (m_player->hasVideo() && !videoTracks().length()) | |
| 3854 addVideoTrack("video", WebMediaPlayerClient::VideoTrackKindMain, "Video Track", "", true); | |
| 3651 } | 3855 } |
| 3856 | |
| 3857 void HTMLMediaElement::selectInitialTracksIfNecessary() | |
|
philipj_slow
2014/03/09 09:04:14
Why is this needed? We can assert that at least on
acolwell GONE FROM CHROMIUM
2014/03/18 22:02:15
This was initially intended to house the logic for
philipj_slow
2014/03/20 16:17:39
Ah, I didn't really consider what the low-level me
| |
| 3858 { | |
| 3859 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | |
| 3860 return; | |
| 3861 | |
| 3862 // Enable the first audio track if an audio track hasn't been enabled yet. | |
| 3863 if (audioTracks().length() > 0 && !audioTracks().hasEnabledTrack()) | |
| 3864 audioTracks().anonymousIndexedGetter(0)->setEnabled(true); | |
| 3865 | |
| 3866 // Select the first video track if a video track hasn't been selected yet. | |
| 3867 if (videoTracks().length() > 0 && videoTracks().selectedIndex() == -1) | |
| 3868 videoTracks().anonymousIndexedGetter(0)->setSelected(true); | |
| 3869 } | |
| 3870 | |
| 3871 } | |
| OLD | NEW |