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 14 matching lines...) Expand all Loading... | |
310 | 364 |
311 m_asyncEventQueue->close(); | 365 m_asyncEventQueue->close(); |
312 | 366 |
313 setShouldDelayLoadEvent(false); | 367 setShouldDelayLoadEvent(false); |
314 | 368 |
315 #if !ENABLE(OILPAN) | 369 #if !ENABLE(OILPAN) |
316 if (m_textTracks) | 370 if (m_textTracks) |
317 m_textTracks->clearOwner(); | 371 m_textTracks->clearOwner(); |
318 #endif | 372 #endif |
319 | 373 |
374 m_audioTracks->shutdown(); | |
375 m_videoTracks->shutdown(); | |
376 | |
320 if (m_mediaController) { | 377 if (m_mediaController) { |
321 m_mediaController->removeMediaElement(this); | 378 m_mediaController->removeMediaElement(this); |
322 m_mediaController = nullptr; | 379 m_mediaController = nullptr; |
323 } | 380 } |
324 | 381 |
325 closeMediaSource(); | 382 closeMediaSource(); |
326 | 383 |
327 #if !ENABLE(OILPAN) | 384 #if !ENABLE(OILPAN) |
328 removeElementFromDocumentMap(this, &document()); | 385 removeElementFromDocumentMap(this, &document()); |
329 #endif | 386 #endif |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
612 | 669 |
613 void HTMLMediaElement::prepareForLoad() | 670 void HTMLMediaElement::prepareForLoad() |
614 { | 671 { |
615 WTF_LOG(Media, "HTMLMediaElement::prepareForLoad"); | 672 WTF_LOG(Media, "HTMLMediaElement::prepareForLoad"); |
616 | 673 |
617 // Perform the cleanup required for the resource load algorithm to run. | 674 // Perform the cleanup required for the resource load algorithm to run. |
618 stopPeriodicTimers(); | 675 stopPeriodicTimers(); |
619 m_loadTimer.stop(); | 676 m_loadTimer.stop(); |
620 // FIXME: Figure out appropriate place to reset LoadTextTrackResource if nec essary and set m_pendingActionFlags to 0 here. | 677 // FIXME: Figure out appropriate place to reset LoadTextTrackResource if nec essary and set m_pendingActionFlags to 0 here. |
621 m_pendingActionFlags &= ~LoadMediaResource; | 678 m_pendingActionFlags &= ~LoadMediaResource; |
679 m_audioTracksTimer.stop(); | |
622 m_sentEndEvent = false; | 680 m_sentEndEvent = false; |
623 m_sentStalledEvent = false; | 681 m_sentStalledEvent = false; |
624 m_haveFiredLoadedData = false; | 682 m_haveFiredLoadedData = false; |
625 m_completelyLoaded = false; | 683 m_completelyLoaded = false; |
626 m_havePreparedToPlay = false; | 684 m_havePreparedToPlay = false; |
627 m_displayMode = Unknown; | 685 m_displayMode = Unknown; |
628 | 686 |
629 // 1 - Abort any already-running instance of the resource selection algorith m for this element. | 687 // 1 - Abort any already-running instance of the resource selection algorith m for this element. |
630 m_loadState = WaitingForSource; | 688 m_loadState = WaitingForSource; |
631 m_currentSourceNode = nullptr; | 689 m_currentSourceNode = nullptr; |
(...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1595 finishSeek(); | 1653 finishSeek(); |
1596 } else { | 1654 } else { |
1597 if (wasPotentiallyPlaying && m_readyState < HAVE_FUTURE_DATA) { | 1655 if (wasPotentiallyPlaying && m_readyState < HAVE_FUTURE_DATA) { |
1598 // 4.8.10.8 | 1656 // 4.8.10.8 |
1599 scheduleTimeupdateEvent(false); | 1657 scheduleTimeupdateEvent(false); |
1600 scheduleEvent(EventTypeNames::waiting); | 1658 scheduleEvent(EventTypeNames::waiting); |
1601 } | 1659 } |
1602 } | 1660 } |
1603 | 1661 |
1604 if (m_readyState >= HAVE_METADATA && oldState < HAVE_METADATA) { | 1662 if (m_readyState >= HAVE_METADATA && oldState < HAVE_METADATA) { |
1663 createPlaceholderTracksIfNecessary(); | |
1664 | |
1605 prepareMediaFragmentURI(); | 1665 prepareMediaFragmentURI(); |
1666 | |
1667 selectInitialTracksIfNecessary(); | |
1668 | |
1606 scheduleEvent(EventTypeNames::durationchange); | 1669 scheduleEvent(EventTypeNames::durationchange); |
1607 if (isHTMLVideoElement(*this)) | 1670 if (isHTMLVideoElement(*this)) |
1608 scheduleEvent(EventTypeNames::resize); | 1671 scheduleEvent(EventTypeNames::resize); |
1609 scheduleEvent(EventTypeNames::loadedmetadata); | 1672 scheduleEvent(EventTypeNames::loadedmetadata); |
1610 if (hasMediaControls()) | 1673 if (hasMediaControls()) |
1611 mediaControls()->reset(); | 1674 mediaControls()->reset(); |
1612 if (renderer()) | 1675 if (renderer()) |
1613 renderer()->updateFromElement(); | 1676 renderer()->updateFromElement(); |
1614 } | 1677 } |
1615 | 1678 |
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2212 else | 2275 else |
2213 m_mediaController->pause(); | 2276 m_mediaController->pause(); |
2214 } else { | 2277 } else { |
2215 if (paused()) | 2278 if (paused()) |
2216 play(); | 2279 play(); |
2217 else | 2280 else |
2218 pause(); | 2281 pause(); |
2219 } | 2282 } |
2220 } | 2283 } |
2221 | 2284 |
2285 AudioTrackList& HTMLMediaElement::audioTracks() | |
2286 { | |
2287 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | |
2288 return *m_audioTracks; | |
2289 } | |
2290 | |
2291 void HTMLMediaElement::audioTrackChanged(const String& audioTrackID) | |
2292 { | |
2293 WTF_LOG(Media, "HTMLMediaElement::audioTrackChanged('%s')", audioTrackID.asc ii().data()); | |
2294 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | |
2295 ASSERT(!audioTrackID.isEmpty()); | |
2296 | |
2297 audioTracks().scheduleChangeEvent(); | |
2298 | |
2299 // FIXME: Add call on m_mediaSource to notify it of track changes once the S ourceBuffer.audioTracks attribute is added. | |
2300 | |
2301 if (!m_audioTracksTimer.isActive()) | |
2302 m_audioTracksTimer.startOneShot(0, FROM_HERE); | |
2303 } | |
2304 | |
2305 void HTMLMediaElement::addAudioTrack(const String& id, blink::WebMediaPlayerClie nt::AudioTrackKind kind, const AtomicString& label, const AtomicString& language , bool enabled) | |
2306 { | |
2307 AtomicString kindString = AudioKindToString(kind); | |
2308 WTF_LOG(Media, "HTMLMediaElement::addAudioTrack('%s', '%s', '%s', '%s', %d)" , | |
2309 id.ascii().data(), kindString.ascii().data(), label.ascii().data(), lang uage.ascii().data(), enabled); | |
2310 ASSERT(!id.isEmpty()); | |
2311 | |
2312 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | |
2313 return; | |
2314 | |
2315 RefPtr<AudioTrack> audioTrack = AudioTrack::create(this, id, kindString, lab el, language); | |
2316 audioTracks().add(audioTrack.get()); | |
2317 | |
2318 if (enabled) | |
2319 audioTrack->setEnabled(true); | |
2320 } | |
2321 | |
2322 void HTMLMediaElement::removeAudioTrack(const String& id) | |
2323 { | |
2324 WTF_LOG(Media, "HTMLMediaElement::removeAudioTrack('%s')", id.ascii().data() ); | |
2325 ASSERT(!id.isEmpty()); | |
2326 | |
2327 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | |
2328 return; | |
2329 | |
2330 audioTracks().remove(id); | |
2331 } | |
2332 | |
2333 VideoTrackList& HTMLMediaElement::videoTracks() | |
2334 { | |
2335 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | |
2336 return *m_videoTracks; | |
2337 } | |
2338 | |
2339 void HTMLMediaElement::selectedVideoTrackChanged(const String& selectedTrackID) | |
2340 { | |
2341 WTF_LOG(Media, "HTMLMediaElement::selectedVideoTrackChanged('%s')", selected TrackID.ascii().data()); | |
2342 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | |
2343 | |
2344 String unselectedTrackID; | |
2345 | |
2346 int oldSelectedIndex = videoTracks().selectedIndex(); | |
2347 if (oldSelectedIndex != -1) | |
2348 unselectedTrackID = videoTracks().anonymousIndexedGetter(oldSelectedInde x)->id(); | |
2349 | |
2350 ASSERT(unselectedTrackID != selectedTrackID); | |
2351 ASSERT(!unselectedTrackID.isEmpty() || !selectedTrackID.isEmpty()); | |
2352 | |
2353 videoTracks().trackSelected(selectedTrackID); | |
2354 | |
2355 // FIXME: Add call on m_mediaSource to notify it of track changes once the S ourceBuffer.videoTracks attribute is added. | |
2356 | |
2357 if (webMediaPlayer()) | |
2358 webMediaPlayer()->selectedVideoTrackChanged(selectedTrackID); | |
2359 } | |
2360 | |
2361 void HTMLMediaElement::addVideoTrack(const String& id, blink::WebMediaPlayerClie nt::VideoTrackKind kind, const AtomicString& label, const AtomicString& language , bool selected) | |
2362 { | |
2363 AtomicString kindString = VideoKindToString(kind); | |
2364 WTF_LOG(Media, "HTMLMediaElement::addVideoTrack('%s', '%s', '%s', '%s', %d)" , | |
2365 id.ascii().data(), kindString.ascii().data(), label.ascii().data(), lang uage.ascii().data(), selected); | |
2366 ASSERT(!id.isEmpty()); | |
2367 | |
2368 RefPtr<VideoTrack> videoTrack = VideoTrack::create(this, id, kindString, lab el, language); | |
2369 videoTracks().add(videoTrack.get()); | |
2370 | |
2371 if (selected) | |
2372 videoTrack->setSelected(true); | |
2373 } | |
2374 | |
2375 void HTMLMediaElement::removeVideoTrack(const String& id) | |
2376 { | |
2377 WTF_LOG(Media, "HTMLMediaElement::removeVideoTrack('%s')", id.ascii().data() ); | |
2378 ASSERT(!id.isEmpty()); | |
2379 | |
2380 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | |
2381 return; | |
2382 | |
2383 videoTracks().remove(id); | |
acolwell GONE FROM CHROMIUM
2014/05/12 18:23:11
I think you either need to make remove() virtual a
| |
2384 } | |
2385 | |
2222 void HTMLMediaElement::mediaPlayerDidAddTextTrack(WebInbandTextTrack* webTrack) | 2386 void HTMLMediaElement::mediaPlayerDidAddTextTrack(WebInbandTextTrack* webTrack) |
2223 { | 2387 { |
2224 // 4.8.10.12.2 Sourcing in-band text tracks | 2388 // 4.8.10.12.2 Sourcing in-band text tracks |
2225 // 1. Associate the relevant data with a new text track and its correspondin g new TextTrack object. | 2389 // 1. Associate the relevant data with a new text track and its correspondin g new TextTrack object. |
2226 RefPtrWillBeRawPtr<InbandTextTrack> textTrack = InbandTextTrack::create(docu ment(), webTrack); | 2390 RefPtrWillBeRawPtr<InbandTextTrack> textTrack = InbandTextTrack::create(docu ment(), webTrack); |
2227 | 2391 |
2228 // 2. Set the new text track's kind, label, and language based on the semant ics of the relevant data, | 2392 // 2. Set the new text track's kind, label, and language based on the semant ics of the relevant data, |
2229 // as defined by the relevant specification. If there is no label in that da ta, then the label must | 2393 // as defined by the relevant specification. If there is no label in that da ta, then the label must |
2230 // be set to the empty string. | 2394 // be set to the empty string. |
2231 // 3. Associate the text track list of cues with the rules for updating the text track rendering appropriate | 2395 // 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... | |
2281 void HTMLMediaElement::removeTextTrack(TextTrack* track) | 2445 void HTMLMediaElement::removeTextTrack(TextTrack* track) |
2282 { | 2446 { |
2283 TrackDisplayUpdateScope scope(this); | 2447 TrackDisplayUpdateScope scope(this); |
2284 m_textTracks->remove(track); | 2448 m_textTracks->remove(track); |
2285 | 2449 |
2286 closeCaptionTracksChanged(); | 2450 closeCaptionTracksChanged(); |
2287 } | 2451 } |
2288 | 2452 |
2289 void HTMLMediaElement::forgetResourceSpecificTracks() | 2453 void HTMLMediaElement::forgetResourceSpecificTracks() |
2290 { | 2454 { |
2455 // Implements the "forget the media element's media-resource-specific tracks " algorithm. | |
2456 // The order is explicitly specified as text, then audio, and finally video. Also | |
2457 // 'removetrack' events should not be fired. | |
2291 if (m_textTracks) { | 2458 if (m_textTracks) { |
2292 TrackDisplayUpdateScope scope(this); | 2459 TrackDisplayUpdateScope scope(this); |
2293 m_textTracks->removeAllInbandTracks(); | 2460 m_textTracks->removeAllInbandTracks(); |
2294 closeCaptionTracksChanged(); | 2461 closeCaptionTracksChanged(); |
2295 } | 2462 } |
2463 | |
2464 m_audioTracks->removeAll(); | |
2465 m_videoTracks->removeAll(); | |
2296 } | 2466 } |
2297 | 2467 |
2298 PassRefPtrWillBeRawPtr<TextTrack> HTMLMediaElement::addTextTrack(const AtomicStr ing& kind, const AtomicString& label, const AtomicString& language, ExceptionSta te& exceptionState) | 2468 PassRefPtrWillBeRawPtr<TextTrack> HTMLMediaElement::addTextTrack(const AtomicStr ing& kind, const AtomicString& label, const AtomicString& language, ExceptionSta te& exceptionState) |
2299 { | 2469 { |
2300 // 4.8.10.12.4 Text track API | 2470 // 4.8.10.12.4 Text track API |
2301 // The addTextTrack(kind, label, language) method of media elements, when in voked, must run the following steps: | 2471 // The addTextTrack(kind, label, language) method of media elements, when in voked, must run the following steps: |
2302 | 2472 |
2303 // 1. If kind is not one of the following strings, then throw a SyntaxError exception and abort these steps | 2473 // 1. If kind is not one of the following strings, then throw a SyntaxError exception and abort these steps |
2304 if (!TextTrack::isValidKindKeyword(kind)) { | 2474 if (!TextTrack::isValidKindKeyword(kind)) { |
2305 exceptionState.throwDOMException(SyntaxError, "The 'kind' provided ('" + kind + "') is invalid."); | 2475 exceptionState.throwDOMException(SyntaxError, "The 'kind' provided ('" + kind + "') is invalid."); |
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3111 forgetResourceSpecificTracks(); | 3281 forgetResourceSpecificTracks(); |
3112 | 3282 |
3113 closeMediaSource(); | 3283 closeMediaSource(); |
3114 | 3284 |
3115 m_delayingLoadForPreloadNone = false; | 3285 m_delayingLoadForPreloadNone = false; |
3116 | 3286 |
3117 clearMediaPlayerAndAudioSourceProviderClient(); | 3287 clearMediaPlayerAndAudioSourceProviderClient(); |
3118 | 3288 |
3119 stopPeriodicTimers(); | 3289 stopPeriodicTimers(); |
3120 m_loadTimer.stop(); | 3290 m_loadTimer.stop(); |
3291 m_audioTracksTimer.stop(); | |
3121 | 3292 |
3122 m_pendingActionFlags &= ~flags; | 3293 m_pendingActionFlags &= ~flags; |
3123 m_loadState = WaitingForSource; | 3294 m_loadState = WaitingForSource; |
3124 | 3295 |
3125 if (m_textTracks) | 3296 if (m_textTracks) |
3126 configureTextTrackDisplay(AssumeNoVisibleChange); | 3297 configureTextTrackDisplay(AssumeNoVisibleChange); |
3127 } | 3298 } |
3128 | 3299 |
3129 void HTMLMediaElement::stop() | 3300 void HTMLMediaElement::stop() |
3130 { | 3301 { |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3553 m_fragmentStartTime = MediaPlayer::invalidTime(); | 3724 m_fragmentStartTime = MediaPlayer::invalidTime(); |
3554 | 3725 |
3555 double end = fragmentParser.endTime(); | 3726 double end = fragmentParser.endTime(); |
3556 if (end != MediaFragmentURIParser::invalidTimeValue() && end > 0 && end > m_ fragmentStartTime) { | 3727 if (end != MediaFragmentURIParser::invalidTimeValue() && end > 0 && end > m_ fragmentStartTime) { |
3557 m_fragmentEndTime = end; | 3728 m_fragmentEndTime = end; |
3558 if (m_fragmentEndTime > dur) | 3729 if (m_fragmentEndTime > dur) |
3559 m_fragmentEndTime = dur; | 3730 m_fragmentEndTime = dur; |
3560 } else | 3731 } else |
3561 m_fragmentEndTime = MediaPlayer::invalidTime(); | 3732 m_fragmentEndTime = MediaPlayer::invalidTime(); |
3562 | 3733 |
3734 // FIXME: Add support for selecting tracks by ID with the Media Fragments tr ack dimension. | |
3735 | |
3563 if (m_fragmentStartTime != MediaPlayer::invalidTime() && m_readyState < HAVE _FUTURE_DATA) | 3736 if (m_fragmentStartTime != MediaPlayer::invalidTime() && m_readyState < HAVE _FUTURE_DATA) |
3564 prepareToPlay(); | 3737 prepareToPlay(); |
3565 } | 3738 } |
3566 | 3739 |
3567 void HTMLMediaElement::applyMediaFragmentURI() | 3740 void HTMLMediaElement::applyMediaFragmentURI() |
3568 { | 3741 { |
3569 if (m_fragmentStartTime != MediaPlayer::invalidTime()) { | 3742 if (m_fragmentStartTime != MediaPlayer::invalidTime()) { |
3570 m_sentEndEvent = false; | 3743 m_sentEndEvent = false; |
3571 UseCounter::count(document(), UseCounter::HTMLMediaElementSeekToFragment Start); | 3744 UseCounter::count(document(), UseCounter::HTMLMediaElementSeekToFragment Start); |
3572 seek(m_fragmentStartTime, IGNORE_EXCEPTION); | 3745 seek(m_fragmentStartTime, IGNORE_EXCEPTION); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3613 void HTMLMediaElement::trace(Visitor* visitor) | 3786 void HTMLMediaElement::trace(Visitor* visitor) |
3614 { | 3787 { |
3615 visitor->trace(m_currentSourceNode); | 3788 visitor->trace(m_currentSourceNode); |
3616 visitor->trace(m_nextChildNodeToConsider); | 3789 visitor->trace(m_nextChildNodeToConsider); |
3617 visitor->trace(m_textTracks); | 3790 visitor->trace(m_textTracks); |
3618 visitor->trace(m_textTracksWhenResourceSelectionBegan); | 3791 visitor->trace(m_textTracksWhenResourceSelectionBegan); |
3619 WillBeHeapSupplementable<HTMLMediaElement>::trace(visitor); | 3792 WillBeHeapSupplementable<HTMLMediaElement>::trace(visitor); |
3620 HTMLElement::trace(visitor); | 3793 HTMLElement::trace(visitor); |
3621 } | 3794 } |
3622 | 3795 |
3796 void HTMLMediaElement::createPlaceholderTracksIfNecessary() | |
3797 { | |
3798 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | |
3799 return; | |
3800 | |
3801 // Create a placeholder audio track if |m_player| says it has audio but it d idn't explicitly announce the tracks. | |
3802 if (m_player->hasAudio() && !audioTracks().length()) | |
3803 addAudioTrack("audio", WebMediaPlayerClient::AudioTrackKindMain, "Audio Track", "", true); | |
3804 | |
3805 // Create a placeholder video track if |m_player| says it has video but it d idn't explicitly announce the tracks. | |
3806 if (m_player->hasVideo() && !videoTracks().length()) | |
3807 addVideoTrack("video", WebMediaPlayerClient::VideoTrackKindMain, "Video Track", "", true); | |
3623 } | 3808 } |
3809 | |
3810 void HTMLMediaElement::selectInitialTracksIfNecessary() | |
3811 { | |
3812 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | |
3813 return; | |
3814 | |
3815 // Enable the first audio track if an audio track hasn't been enabled yet. | |
3816 if (audioTracks().length() > 0 && !audioTracks().hasEnabledTrack()) | |
3817 audioTracks().anonymousIndexedGetter(0)->setEnabled(true); | |
3818 | |
3819 // Select the first video track if a video track hasn't been selected yet. | |
3820 if (videoTracks().length() > 0 && videoTracks().selectedIndex() == -1) | |
3821 videoTracks().anonymousIndexedGetter(0)->setSelected(true); | |
3822 } | |
3823 | |
3824 void HTMLMediaElement::audioTracksTimerFired(Timer<HTMLMediaElement>*) | |
3825 { | |
3826 if (!webMediaPlayer()) | |
3827 return; | |
3828 | |
3829 Vector<String> enabledTrackIDs; | |
3830 for (unsigned i = 0; i < audioTracks().length(); ++i) { | |
3831 RefPtr<AudioTrack> track = audioTracks().anonymousIndexedGetter(i); | |
3832 if (track->enabled()) | |
3833 enabledTrackIDs.append(track->id()); | |
3834 } | |
3835 | |
3836 webMediaPlayer()->enabledAudioTracksChanged(enabledTrackIDs); | |
3837 } | |
3838 | |
3839 } | |
OLD | NEW |