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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #include "core/frame/UseCounter.h" | 44 #include "core/frame/UseCounter.h" |
45 #include "core/frame/csp/ContentSecurityPolicy.h" | 45 #include "core/frame/csp/ContentSecurityPolicy.h" |
46 #include "core/html/HTMLMediaSource.h" | 46 #include "core/html/HTMLMediaSource.h" |
47 #include "core/html/HTMLSourceElement.h" | 47 #include "core/html/HTMLSourceElement.h" |
48 #include "core/html/HTMLTrackElement.h" | 48 #include "core/html/HTMLTrackElement.h" |
49 #include "core/html/MediaController.h" | 49 #include "core/html/MediaController.h" |
50 #include "core/html/MediaError.h" | 50 #include "core/html/MediaError.h" |
51 #include "core/html/MediaFragmentURIParser.h" | 51 #include "core/html/MediaFragmentURIParser.h" |
52 #include "core/html/TimeRanges.h" | 52 #include "core/html/TimeRanges.h" |
53 #include "core/html/shadow/MediaControls.h" | 53 #include "core/html/shadow/MediaControls.h" |
| 54 #include "core/html/track/AudioTrack.h" |
| 55 #include "core/html/track/AudioTrackList.h" |
54 #include "core/html/track/InbandTextTrack.h" | 56 #include "core/html/track/InbandTextTrack.h" |
55 #include "core/html/track/TextTrackCueList.h" | 57 #include "core/html/track/TextTrackCueList.h" |
56 #include "core/html/track/TextTrackList.h" | 58 #include "core/html/track/TextTrackList.h" |
| 59 #include "core/html/track/VideoTrack.h" |
| 60 #include "core/html/track/VideoTrackList.h" |
57 #include "core/loader/FrameLoader.h" | 61 #include "core/loader/FrameLoader.h" |
58 #include "core/rendering/RenderVideo.h" | 62 #include "core/rendering/RenderVideo.h" |
59 #include "core/rendering/RenderView.h" | 63 #include "core/rendering/RenderView.h" |
60 #include "core/rendering/compositing/RenderLayerCompositor.h" | 64 #include "core/rendering/compositing/RenderLayerCompositor.h" |
61 #include "platform/ContentType.h" | 65 #include "platform/ContentType.h" |
62 #include "platform/Language.h" | 66 #include "platform/Language.h" |
63 #include "platform/Logging.h" | 67 #include "platform/Logging.h" |
64 #include "platform/MIMETypeFromURL.h" | 68 #include "platform/MIMETypeFromURL.h" |
65 #include "platform/MIMETypeRegistry.h" | 69 #include "platform/MIMETypeRegistry.h" |
66 #include "platform/NotImplemented.h" | 70 #include "platform/NotImplemented.h" |
(...skipping 11 matching lines...) Expand all Loading... |
78 | 82 |
79 #if ENABLE(WEB_AUDIO) | 83 #if ENABLE(WEB_AUDIO) |
80 #include "platform/audio/AudioSourceProvider.h" | 84 #include "platform/audio/AudioSourceProvider.h" |
81 #include "platform/audio/AudioSourceProviderClient.h" | 85 #include "platform/audio/AudioSourceProviderClient.h" |
82 #endif | 86 #endif |
83 | 87 |
84 using namespace std; | 88 using namespace std; |
85 using blink::WebInbandTextTrack; | 89 using blink::WebInbandTextTrack; |
86 using blink::WebMediaPlayer; | 90 using blink::WebMediaPlayer; |
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 ~TrackDisplayUpdateScope() | 167 ~TrackDisplayUpdateScope() |
163 { | 168 { |
164 ASSERT(m_mediaElement); | 169 ASSERT(m_mediaElement); |
165 m_mediaElement->endIgnoringTrackDisplayUpdateRequests(); | 170 m_mediaElement->endIgnoringTrackDisplayUpdateRequests(); |
166 } | 171 } |
167 | 172 |
168 private: | 173 private: |
169 HTMLMediaElement* m_mediaElement; | 174 HTMLMediaElement* m_mediaElement; |
170 }; | 175 }; |
171 | 176 |
| 177 static const AtomicString& AudioKindToString(WebMediaPlayerClient::AudioTrackKin
d kind) |
| 178 { |
| 179 switch (kind) { |
| 180 case WebMediaPlayerClient::AudioTrackKindNone: |
| 181 return emptyAtom; |
| 182 case WebMediaPlayerClient::AudioTrackKindAlternative: |
| 183 return AudioTrack::alternativeKeyword(); |
| 184 case WebMediaPlayerClient::AudioTrackKindDescriptions: |
| 185 return AudioTrack::descriptionsKeyword(); |
| 186 case WebMediaPlayerClient::AudioTrackKindMain: |
| 187 return AudioTrack::mainKeyword(); |
| 188 case WebMediaPlayerClient::AudioTrackKindMainDescriptions: |
| 189 return AudioTrack::mainDescriptionsKeyword(); |
| 190 case WebMediaPlayerClient::AudioTrackKindTranslation: |
| 191 return AudioTrack::translationKeyword(); |
| 192 case WebMediaPlayerClient::AudioTrackKindCommentary: |
| 193 return AudioTrack::commentaryKeyword(); |
| 194 } |
| 195 |
| 196 ASSERT_NOT_REACHED(); |
| 197 return emptyAtom; |
| 198 } |
| 199 |
| 200 static const AtomicString& VideoKindToString(WebMediaPlayerClient::VideoTrackKin
d kind) |
| 201 { |
| 202 switch (kind) { |
| 203 case WebMediaPlayerClient::VideoTrackKindNone: |
| 204 return emptyAtom; |
| 205 case WebMediaPlayerClient::VideoTrackKindAlternative: |
| 206 return VideoTrack::alternativeKeyword(); |
| 207 case WebMediaPlayerClient::VideoTrackKindCaptions: |
| 208 return VideoTrack::captionsKeyword(); |
| 209 case WebMediaPlayerClient::VideoTrackKindMain: |
| 210 return VideoTrack::mainKeyword(); |
| 211 case WebMediaPlayerClient::VideoTrackKindSign: |
| 212 return VideoTrack::signKeyword(); |
| 213 case WebMediaPlayerClient::VideoTrackKindSubtitles: |
| 214 return VideoTrack::subtitlesKeyword(); |
| 215 case WebMediaPlayerClient::VideoTrackKindCommentary: |
| 216 return VideoTrack::commentaryKeyword(); |
| 217 } |
| 218 |
| 219 ASSERT_NOT_REACHED(); |
| 220 return emptyAtom; |
| 221 } |
| 222 |
172 static bool canLoadURL(const KURL& url, const ContentType& contentType, const St
ring& keySystem) | 223 static bool canLoadURL(const KURL& url, const ContentType& contentType, const St
ring& keySystem) |
173 { | 224 { |
174 DEFINE_STATIC_LOCAL(const String, codecs, ("codecs")); | 225 DEFINE_STATIC_LOCAL(const String, codecs, ("codecs")); |
175 | 226 |
176 String contentMIMEType = contentType.type().lower(); | 227 String contentMIMEType = contentType.type().lower(); |
177 String contentTypeCodecs = contentType.parameter(codecs); | 228 String contentTypeCodecs = contentType.parameter(codecs); |
178 | 229 |
179 // If the MIME type is missing or is not meaningful, try to figure it out fr
om the URL. | 230 // If the MIME type is missing or is not meaningful, try to figure it out fr
om the URL. |
180 if (contentMIMEType.isEmpty() || contentMIMEType == "application/octet-strea
m" || contentMIMEType == "text/plain") { | 231 if (contentMIMEType.isEmpty() || contentMIMEType == "application/octet-strea
m" || contentMIMEType == "text/plain") { |
181 if (url.protocolIsData()) | 232 if (url.protocolIsData()) |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 { | 284 { |
234 return s_mediaStreamRegistry ? s_mediaStreamRegistry->contains(url) : false; | 285 return s_mediaStreamRegistry ? s_mediaStreamRegistry->contains(url) : false; |
235 } | 286 } |
236 | 287 |
237 HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document& docum
ent) | 288 HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document& docum
ent) |
238 : HTMLElement(tagName, document) | 289 : HTMLElement(tagName, document) |
239 , ActiveDOMObject(&document) | 290 , ActiveDOMObject(&document) |
240 , m_loadTimer(this, &HTMLMediaElement::loadTimerFired) | 291 , m_loadTimer(this, &HTMLMediaElement::loadTimerFired) |
241 , m_progressEventTimer(this, &HTMLMediaElement::progressEventTimerFired) | 292 , m_progressEventTimer(this, &HTMLMediaElement::progressEventTimerFired) |
242 , m_playbackProgressTimer(this, &HTMLMediaElement::playbackProgressTimerFire
d) | 293 , m_playbackProgressTimer(this, &HTMLMediaElement::playbackProgressTimerFire
d) |
| 294 , m_audioTracksTimer(this, &HTMLMediaElement::audioTracksTimerFired) |
243 , m_playedTimeRanges() | 295 , m_playedTimeRanges() |
244 , m_asyncEventQueue(GenericEventQueue::create(this)) | 296 , m_asyncEventQueue(GenericEventQueue::create(this)) |
245 , m_playbackRate(1.0f) | 297 , m_playbackRate(1.0f) |
246 , m_defaultPlaybackRate(1.0f) | 298 , m_defaultPlaybackRate(1.0f) |
247 , m_networkState(NETWORK_EMPTY) | 299 , m_networkState(NETWORK_EMPTY) |
248 , m_readyState(HAVE_NOTHING) | 300 , m_readyState(HAVE_NOTHING) |
249 , m_readyStateMaximum(HAVE_NOTHING) | 301 , m_readyStateMaximum(HAVE_NOTHING) |
250 , m_volume(1.0f) | 302 , m_volume(1.0f) |
251 , m_lastSeekTime(0) | 303 , m_lastSeekTime(0) |
252 , m_previousProgressTime(numeric_limits<double>::max()) | 304 , m_previousProgressTime(numeric_limits<double>::max()) |
(...skipping 23 matching lines...) Expand all Loading... |
276 , m_sentEndEvent(false) | 328 , m_sentEndEvent(false) |
277 , m_pausedInternal(false) | 329 , m_pausedInternal(false) |
278 , m_closedCaptionsVisible(false) | 330 , m_closedCaptionsVisible(false) |
279 , m_completelyLoaded(false) | 331 , m_completelyLoaded(false) |
280 , m_havePreparedToPlay(false) | 332 , m_havePreparedToPlay(false) |
281 , m_delayingLoadForPreloadNone(false) | 333 , m_delayingLoadForPreloadNone(false) |
282 , m_tracksAreReady(true) | 334 , m_tracksAreReady(true) |
283 , m_haveVisibleTextTrack(false) | 335 , m_haveVisibleTextTrack(false) |
284 , m_processingPreferenceChange(false) | 336 , m_processingPreferenceChange(false) |
285 , m_lastTextTrackUpdateTime(-1) | 337 , m_lastTextTrackUpdateTime(-1) |
| 338 , m_audioTracks(AudioTrackList::create(*this)) |
| 339 , m_videoTracks(VideoTrackList::create(*this)) |
286 , m_textTracks(nullptr) | 340 , m_textTracks(nullptr) |
287 , m_ignoreTrackDisplayUpdate(0) | 341 , m_ignoreTrackDisplayUpdate(0) |
288 #if ENABLE(WEB_AUDIO) | 342 #if ENABLE(WEB_AUDIO) |
289 , m_audioSourceNode(0) | 343 , m_audioSourceNode(0) |
290 #endif | 344 #endif |
291 { | 345 { |
292 ASSERT(RuntimeEnabledFeatures::mediaEnabled()); | 346 ASSERT(RuntimeEnabledFeatures::mediaEnabled()); |
293 | 347 |
294 WTF_LOG(Media, "HTMLMediaElement::HTMLMediaElement"); | 348 WTF_LOG(Media, "HTMLMediaElement::HTMLMediaElement"); |
295 ScriptWrappable::init(this); | 349 ScriptWrappable::init(this); |
(...skipping 27 matching lines...) Expand all Loading... |
323 // removed from the map during weak processing. | 377 // removed from the map during weak processing. |
324 if (documentToElementSetMap().contains(&document())) | 378 if (documentToElementSetMap().contains(&document())) |
325 setShouldDelayLoadEvent(false); | 379 setShouldDelayLoadEvent(false); |
326 #else | 380 #else |
327 setShouldDelayLoadEvent(false); | 381 setShouldDelayLoadEvent(false); |
328 #endif | 382 #endif |
329 | 383 |
330 #if !ENABLE(OILPAN) | 384 #if !ENABLE(OILPAN) |
331 if (m_textTracks) | 385 if (m_textTracks) |
332 m_textTracks->clearOwner(); | 386 m_textTracks->clearOwner(); |
| 387 m_audioTracks->shutdown(); |
| 388 m_videoTracks->shutdown(); |
333 #endif | 389 #endif |
334 | 390 |
335 if (m_mediaController) { | 391 if (m_mediaController) { |
336 m_mediaController->removeMediaElement(this); | 392 m_mediaController->removeMediaElement(this); |
337 m_mediaController = nullptr; | 393 m_mediaController = nullptr; |
338 } | 394 } |
339 | 395 |
340 closeMediaSource(); | 396 closeMediaSource(); |
341 | 397 |
342 #if !ENABLE(OILPAN) | 398 #if !ENABLE(OILPAN) |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 | 683 |
628 void HTMLMediaElement::prepareForLoad() | 684 void HTMLMediaElement::prepareForLoad() |
629 { | 685 { |
630 WTF_LOG(Media, "HTMLMediaElement::prepareForLoad"); | 686 WTF_LOG(Media, "HTMLMediaElement::prepareForLoad"); |
631 | 687 |
632 // Perform the cleanup required for the resource load algorithm to run. | 688 // Perform the cleanup required for the resource load algorithm to run. |
633 stopPeriodicTimers(); | 689 stopPeriodicTimers(); |
634 m_loadTimer.stop(); | 690 m_loadTimer.stop(); |
635 // FIXME: Figure out appropriate place to reset LoadTextTrackResource if nec
essary and set m_pendingActionFlags to 0 here. | 691 // FIXME: Figure out appropriate place to reset LoadTextTrackResource if nec
essary and set m_pendingActionFlags to 0 here. |
636 m_pendingActionFlags &= ~LoadMediaResource; | 692 m_pendingActionFlags &= ~LoadMediaResource; |
| 693 m_audioTracksTimer.stop(); |
637 m_sentEndEvent = false; | 694 m_sentEndEvent = false; |
638 m_sentStalledEvent = false; | 695 m_sentStalledEvent = false; |
639 m_haveFiredLoadedData = false; | 696 m_haveFiredLoadedData = false; |
640 m_completelyLoaded = false; | 697 m_completelyLoaded = false; |
641 m_havePreparedToPlay = false; | 698 m_havePreparedToPlay = false; |
642 m_displayMode = Unknown; | 699 m_displayMode = Unknown; |
643 | 700 |
644 // 1 - Abort any already-running instance of the resource selection algorith
m for this element. | 701 // 1 - Abort any already-running instance of the resource selection algorith
m for this element. |
645 m_loadState = WaitingForSource; | 702 m_loadState = WaitingForSource; |
646 m_currentSourceNode = nullptr; | 703 m_currentSourceNode = nullptr; |
(...skipping 984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1631 finishSeek(); | 1688 finishSeek(); |
1632 } else { | 1689 } else { |
1633 if (wasPotentiallyPlaying && m_readyState < HAVE_FUTURE_DATA) { | 1690 if (wasPotentiallyPlaying && m_readyState < HAVE_FUTURE_DATA) { |
1634 // 4.8.10.8 | 1691 // 4.8.10.8 |
1635 scheduleTimeupdateEvent(false); | 1692 scheduleTimeupdateEvent(false); |
1636 scheduleEvent(EventTypeNames::waiting); | 1693 scheduleEvent(EventTypeNames::waiting); |
1637 } | 1694 } |
1638 } | 1695 } |
1639 | 1696 |
1640 if (m_readyState >= HAVE_METADATA && oldState < HAVE_METADATA) { | 1697 if (m_readyState >= HAVE_METADATA && oldState < HAVE_METADATA) { |
| 1698 createPlaceholderTracksIfNecessary(); |
| 1699 |
1641 prepareMediaFragmentURI(); | 1700 prepareMediaFragmentURI(); |
| 1701 |
| 1702 selectInitialTracksIfNecessary(); |
| 1703 |
1642 scheduleEvent(EventTypeNames::durationchange); | 1704 scheduleEvent(EventTypeNames::durationchange); |
1643 if (isHTMLVideoElement(*this)) | 1705 if (isHTMLVideoElement(*this)) |
1644 scheduleEvent(EventTypeNames::resize); | 1706 scheduleEvent(EventTypeNames::resize); |
1645 scheduleEvent(EventTypeNames::loadedmetadata); | 1707 scheduleEvent(EventTypeNames::loadedmetadata); |
1646 if (hasMediaControls()) | 1708 if (hasMediaControls()) |
1647 mediaControls()->reset(); | 1709 mediaControls()->reset(); |
1648 if (renderer()) | 1710 if (renderer()) |
1649 renderer()->updateFromElement(); | 1711 renderer()->updateFromElement(); |
1650 } | 1712 } |
1651 | 1713 |
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2248 else | 2310 else |
2249 m_mediaController->pause(); | 2311 m_mediaController->pause(); |
2250 } else { | 2312 } else { |
2251 if (paused()) | 2313 if (paused()) |
2252 play(); | 2314 play(); |
2253 else | 2315 else |
2254 pause(); | 2316 pause(); |
2255 } | 2317 } |
2256 } | 2318 } |
2257 | 2319 |
| 2320 AudioTrackList& HTMLMediaElement::audioTracks() |
| 2321 { |
| 2322 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); |
| 2323 return *m_audioTracks; |
| 2324 } |
| 2325 |
| 2326 void HTMLMediaElement::audioTrackChanged() |
| 2327 { |
| 2328 WTF_LOG(Media, "HTMLMediaElement::audioTrackChanged()"); |
| 2329 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); |
| 2330 |
| 2331 audioTracks().scheduleChangeEvent(); |
| 2332 |
| 2333 // FIXME: Add call on m_mediaSource to notify it of track changes once the S
ourceBuffer.audioTracks attribute is added. |
| 2334 |
| 2335 if (!m_audioTracksTimer.isActive()) |
| 2336 m_audioTracksTimer.startOneShot(0, FROM_HERE); |
| 2337 } |
| 2338 |
| 2339 void HTMLMediaElement::audioTracksTimerFired(Timer<HTMLMediaElement>*) |
| 2340 { |
| 2341 if (!webMediaPlayer()) |
| 2342 return; |
| 2343 |
| 2344 Vector<WebMediaPlayer::TrackId> enabledTrackIds; |
| 2345 for (unsigned i = 0; i < audioTracks().length(); ++i) { |
| 2346 AudioTrack* track = audioTracks().anonymousIndexedGetter(i); |
| 2347 if (track->enabled()) |
| 2348 enabledTrackIds.append(track->trackId()); |
| 2349 } |
| 2350 |
| 2351 webMediaPlayer()->enabledAudioTracksChanged(enabledTrackIds); |
| 2352 } |
| 2353 |
| 2354 WebMediaPlayer::TrackId HTMLMediaElement::addAudioTrack(const String& id, blink:
:WebMediaPlayerClient::AudioTrackKind kind, const AtomicString& label, const Ato
micString& language, bool enabled) |
| 2355 { |
| 2356 AtomicString kindString = AudioKindToString(kind); |
| 2357 WTF_LOG(Media, "HTMLMediaElement::addAudioTrack('%s', '%s', '%s', '%s', %d)"
, |
| 2358 id.ascii().data(), kindString.ascii().data(), label.ascii().data(), lang
uage.ascii().data(), enabled); |
| 2359 |
| 2360 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) |
| 2361 return 0; |
| 2362 |
| 2363 RefPtrWillBeRawPtr<AudioTrack> audioTrack = AudioTrack::create(id, kindStrin
g, label, language); |
| 2364 audioTracks().add(audioTrack); |
| 2365 |
| 2366 if (enabled) |
| 2367 audioTrack->setEnabled(true); |
| 2368 |
| 2369 return audioTrack->trackId(); |
| 2370 } |
| 2371 |
| 2372 void HTMLMediaElement::removeAudioTrack(WebMediaPlayer::TrackId trackId) |
| 2373 { |
| 2374 WTF_LOG(Media, "HTMLMediaElement::removeAudioTrack()"); |
| 2375 |
| 2376 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) |
| 2377 return; |
| 2378 |
| 2379 audioTracks().remove(trackId); |
| 2380 } |
| 2381 |
| 2382 VideoTrackList& HTMLMediaElement::videoTracks() |
| 2383 { |
| 2384 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); |
| 2385 return *m_videoTracks; |
| 2386 } |
| 2387 |
| 2388 void HTMLMediaElement::selectedVideoTrackChanged(WebMediaPlayer::TrackId* select
edTrackId) |
| 2389 { |
| 2390 WTF_LOG(Media, "HTMLMediaElement::selectedVideoTrackChanged()"); |
| 2391 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); |
| 2392 |
| 2393 videoTracks().trackSelected(selectedTrackId); |
| 2394 |
| 2395 // FIXME: Add call on m_mediaSource to notify it of track changes once the S
ourceBuffer.videoTracks attribute is added. |
| 2396 |
| 2397 if (webMediaPlayer()) |
| 2398 webMediaPlayer()->selectedVideoTrackChanged(selectedTrackId); |
| 2399 } |
| 2400 |
| 2401 WebMediaPlayer::TrackId HTMLMediaElement::addVideoTrack(const String& id, blink:
:WebMediaPlayerClient::VideoTrackKind kind, const AtomicString& label, const Ato
micString& language, bool selected) |
| 2402 { |
| 2403 AtomicString kindString = VideoKindToString(kind); |
| 2404 WTF_LOG(Media, "HTMLMediaElement::addVideoTrack('%s', '%s', '%s', '%s', %d)"
, |
| 2405 id.ascii().data(), kindString.ascii().data(), label.ascii().data(), lang
uage.ascii().data(), selected); |
| 2406 |
| 2407 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) |
| 2408 return 0; |
| 2409 |
| 2410 RefPtrWillBeRawPtr<VideoTrack> videoTrack = VideoTrack::create(id, kindStrin
g, label, language); |
| 2411 videoTracks().add(videoTrack); |
| 2412 |
| 2413 if (selected) |
| 2414 videoTrack->setSelected(true); |
| 2415 |
| 2416 return videoTrack->trackId(); |
| 2417 } |
| 2418 |
| 2419 void HTMLMediaElement::removeVideoTrack(WebMediaPlayer::TrackId trackId) |
| 2420 { |
| 2421 WTF_LOG(Media, "HTMLMediaElement::removeVideoTrack()"); |
| 2422 |
| 2423 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) |
| 2424 return; |
| 2425 |
| 2426 videoTracks().remove(trackId); |
| 2427 } |
| 2428 |
2258 void HTMLMediaElement::mediaPlayerDidAddTextTrack(WebInbandTextTrack* webTrack) | 2429 void HTMLMediaElement::mediaPlayerDidAddTextTrack(WebInbandTextTrack* webTrack) |
2259 { | 2430 { |
2260 // 4.8.10.12.2 Sourcing in-band text tracks | 2431 // 4.8.10.12.2 Sourcing in-band text tracks |
2261 // 1. Associate the relevant data with a new text track and its correspondin
g new TextTrack object. | 2432 // 1. Associate the relevant data with a new text track and its correspondin
g new TextTrack object. |
2262 RefPtrWillBeRawPtr<InbandTextTrack> textTrack = InbandTextTrack::create(docu
ment(), webTrack); | 2433 RefPtrWillBeRawPtr<InbandTextTrack> textTrack = InbandTextTrack::create(docu
ment(), webTrack); |
2263 | 2434 |
2264 // 2. Set the new text track's kind, label, and language based on the semant
ics of the relevant data, | 2435 // 2. Set the new text track's kind, label, and language based on the semant
ics of the relevant data, |
2265 // as defined by the relevant specification. If there is no label in that da
ta, then the label must | 2436 // as defined by the relevant specification. If there is no label in that da
ta, then the label must |
2266 // be set to the empty string. | 2437 // be set to the empty string. |
2267 // 3. Associate the text track list of cues with the rules for updating the
text track rendering appropriate | 2438 // 3. Associate the text track list of cues with the rules for updating the
text track rendering appropriate |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2317 void HTMLMediaElement::removeTextTrack(TextTrack* track) | 2488 void HTMLMediaElement::removeTextTrack(TextTrack* track) |
2318 { | 2489 { |
2319 TrackDisplayUpdateScope scope(this); | 2490 TrackDisplayUpdateScope scope(this); |
2320 m_textTracks->remove(track); | 2491 m_textTracks->remove(track); |
2321 | 2492 |
2322 closeCaptionTracksChanged(); | 2493 closeCaptionTracksChanged(); |
2323 } | 2494 } |
2324 | 2495 |
2325 void HTMLMediaElement::forgetResourceSpecificTracks() | 2496 void HTMLMediaElement::forgetResourceSpecificTracks() |
2326 { | 2497 { |
| 2498 // Implements the "forget the media element's media-resource-specific tracks
" algorithm. |
| 2499 // The order is explicitly specified as text, then audio, and finally video.
Also |
| 2500 // 'removetrack' events should not be fired. |
2327 if (m_textTracks) { | 2501 if (m_textTracks) { |
2328 TrackDisplayUpdateScope scope(this); | 2502 TrackDisplayUpdateScope scope(this); |
2329 m_textTracks->removeAllInbandTracks(); | 2503 m_textTracks->removeAllInbandTracks(); |
2330 closeCaptionTracksChanged(); | 2504 closeCaptionTracksChanged(); |
2331 } | 2505 } |
| 2506 |
| 2507 m_audioTracks->removeAll(); |
| 2508 m_videoTracks->removeAll(); |
2332 } | 2509 } |
2333 | 2510 |
2334 PassRefPtrWillBeRawPtr<TextTrack> HTMLMediaElement::addTextTrack(const AtomicStr
ing& kind, const AtomicString& label, const AtomicString& language, ExceptionSta
te& exceptionState) | 2511 PassRefPtrWillBeRawPtr<TextTrack> HTMLMediaElement::addTextTrack(const AtomicStr
ing& kind, const AtomicString& label, const AtomicString& language, ExceptionSta
te& exceptionState) |
2335 { | 2512 { |
2336 // 4.8.10.12.4 Text track API | 2513 // 4.8.10.12.4 Text track API |
2337 // The addTextTrack(kind, label, language) method of media elements, when in
voked, must run the following steps: | 2514 // The addTextTrack(kind, label, language) method of media elements, when in
voked, must run the following steps: |
2338 | 2515 |
2339 // 1. If kind is not one of the following strings, then throw a SyntaxError
exception and abort these steps | 2516 // 1. If kind is not one of the following strings, then throw a SyntaxError
exception and abort these steps |
2340 if (!TextTrack::isValidKindKeyword(kind)) { | 2517 if (!TextTrack::isValidKindKeyword(kind)) { |
2341 exceptionState.throwDOMException(SyntaxError, "The 'kind' provided ('" +
kind + "') is invalid."); | 2518 exceptionState.throwDOMException(SyntaxError, "The 'kind' provided ('" +
kind + "') is invalid."); |
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3147 forgetResourceSpecificTracks(); | 3324 forgetResourceSpecificTracks(); |
3148 | 3325 |
3149 closeMediaSource(); | 3326 closeMediaSource(); |
3150 | 3327 |
3151 m_delayingLoadForPreloadNone = false; | 3328 m_delayingLoadForPreloadNone = false; |
3152 | 3329 |
3153 clearMediaPlayerAndAudioSourceProviderClient(); | 3330 clearMediaPlayerAndAudioSourceProviderClient(); |
3154 | 3331 |
3155 stopPeriodicTimers(); | 3332 stopPeriodicTimers(); |
3156 m_loadTimer.stop(); | 3333 m_loadTimer.stop(); |
| 3334 m_audioTracksTimer.stop(); |
3157 | 3335 |
3158 m_pendingActionFlags &= ~flags; | 3336 m_pendingActionFlags &= ~flags; |
3159 m_loadState = WaitingForSource; | 3337 m_loadState = WaitingForSource; |
3160 | 3338 |
3161 if (m_textTracks) | 3339 if (m_textTracks) |
3162 configureTextTrackDisplay(AssumeNoVisibleChange); | 3340 configureTextTrackDisplay(AssumeNoVisibleChange); |
3163 } | 3341 } |
3164 | 3342 |
3165 void HTMLMediaElement::stop() | 3343 void HTMLMediaElement::stop() |
3166 { | 3344 { |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3588 m_fragmentStartTime = MediaPlayer::invalidTime(); | 3766 m_fragmentStartTime = MediaPlayer::invalidTime(); |
3589 | 3767 |
3590 double end = fragmentParser.endTime(); | 3768 double end = fragmentParser.endTime(); |
3591 if (end != MediaFragmentURIParser::invalidTimeValue() && end > 0 && end > m_
fragmentStartTime) { | 3769 if (end != MediaFragmentURIParser::invalidTimeValue() && end > 0 && end > m_
fragmentStartTime) { |
3592 m_fragmentEndTime = end; | 3770 m_fragmentEndTime = end; |
3593 if (m_fragmentEndTime > dur) | 3771 if (m_fragmentEndTime > dur) |
3594 m_fragmentEndTime = dur; | 3772 m_fragmentEndTime = dur; |
3595 } else | 3773 } else |
3596 m_fragmentEndTime = MediaPlayer::invalidTime(); | 3774 m_fragmentEndTime = MediaPlayer::invalidTime(); |
3597 | 3775 |
| 3776 // FIXME: Add support for selecting tracks by ID with the Media Fragments tr
ack dimension. |
| 3777 |
3598 if (m_fragmentStartTime != MediaPlayer::invalidTime() && m_readyState < HAVE
_FUTURE_DATA) | 3778 if (m_fragmentStartTime != MediaPlayer::invalidTime() && m_readyState < HAVE
_FUTURE_DATA) |
3599 prepareToPlay(); | 3779 prepareToPlay(); |
3600 } | 3780 } |
3601 | 3781 |
3602 void HTMLMediaElement::applyMediaFragmentURI() | 3782 void HTMLMediaElement::applyMediaFragmentURI() |
3603 { | 3783 { |
3604 if (m_fragmentStartTime != MediaPlayer::invalidTime()) { | 3784 if (m_fragmentStartTime != MediaPlayer::invalidTime()) { |
3605 m_sentEndEvent = false; | 3785 m_sentEndEvent = false; |
3606 UseCounter::count(document(), UseCounter::HTMLMediaElementSeekToFragment
Start); | 3786 UseCounter::count(document(), UseCounter::HTMLMediaElementSeekToFragment
Start); |
3607 seek(m_fragmentStartTime, IGNORE_EXCEPTION); | 3787 seek(m_fragmentStartTime, IGNORE_EXCEPTION); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3643 bool HTMLMediaElement::isInteractiveContent() const | 3823 bool HTMLMediaElement::isInteractiveContent() const |
3644 { | 3824 { |
3645 return fastHasAttribute(controlsAttr); | 3825 return fastHasAttribute(controlsAttr); |
3646 } | 3826 } |
3647 | 3827 |
3648 void HTMLMediaElement::trace(Visitor* visitor) | 3828 void HTMLMediaElement::trace(Visitor* visitor) |
3649 { | 3829 { |
3650 visitor->trace(m_error); | 3830 visitor->trace(m_error); |
3651 visitor->trace(m_currentSourceNode); | 3831 visitor->trace(m_currentSourceNode); |
3652 visitor->trace(m_nextChildNodeToConsider); | 3832 visitor->trace(m_nextChildNodeToConsider); |
| 3833 visitor->trace(m_audioTracks); |
| 3834 visitor->trace(m_videoTracks); |
3653 visitor->trace(m_textTracks); | 3835 visitor->trace(m_textTracks); |
3654 visitor->trace(m_textTracksWhenResourceSelectionBegan); | 3836 visitor->trace(m_textTracksWhenResourceSelectionBegan); |
3655 WillBeHeapSupplementable<HTMLMediaElement>::trace(visitor); | 3837 WillBeHeapSupplementable<HTMLMediaElement>::trace(visitor); |
3656 HTMLElement::trace(visitor); | 3838 HTMLElement::trace(visitor); |
3657 } | 3839 } |
3658 | 3840 |
| 3841 void HTMLMediaElement::createPlaceholderTracksIfNecessary() |
| 3842 { |
| 3843 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) |
| 3844 return; |
| 3845 |
| 3846 // Create a placeholder audio track if |m_player| says it has audio but it d
idn't explicitly announce the tracks. |
| 3847 if (m_player->hasAudio() && !audioTracks().length()) |
| 3848 addAudioTrack("audio", WebMediaPlayerClient::AudioTrackKindMain, "Audio
Track", "", true); |
| 3849 |
| 3850 // Create a placeholder video track if |m_player| says it has video but it d
idn't explicitly announce the tracks. |
| 3851 if (m_player->hasVideo() && !videoTracks().length()) |
| 3852 addVideoTrack("video", WebMediaPlayerClient::VideoTrackKindMain, "Video
Track", "", true); |
3659 } | 3853 } |
| 3854 |
| 3855 void HTMLMediaElement::selectInitialTracksIfNecessary() |
| 3856 { |
| 3857 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) |
| 3858 return; |
| 3859 |
| 3860 // Enable the first audio track if an audio track hasn't been enabled yet. |
| 3861 if (audioTracks().length() > 0 && !audioTracks().hasEnabledTrack()) |
| 3862 audioTracks().anonymousIndexedGetter(0)->setEnabled(true); |
| 3863 |
| 3864 // Select the first video track if a video track hasn't been selected yet. |
| 3865 if (videoTracks().length() > 0 && videoTracks().selectedIndex() == -1) |
| 3866 videoTracks().anonymousIndexedGetter(0)->setSelected(true); |
| 3867 } |
| 3868 |
| 3869 } |
OLD | NEW |