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 AtomicString VideoKindToString(WebMediaPlayerClient::VideoTrackKind kind) | |
Inactive
2014/03/08 03:05:59
Looks like this could return a const AtomicString&
acolwell GONE FROM CHROMIUM
2014/03/08 19:56:42
Done.
| |
172 { | |
173 switch (kind) { | |
174 case WebMediaPlayerClient::VideoTrackKindNone: | |
175 return AtomicString(); | |
Inactive
2014/03/08 03:05:59
nullAtom? (same below)
acolwell GONE FROM CHROMIUM
2014/03/08 19:56:42
Done.
| |
176 break; | |
Inactive
2014/03/08 03:05:59
Why the breaks after the return statements? (Sorry
acolwell GONE FROM CHROMIUM
2014/03/08 19:56:42
Removed. I think an earlier version of this functi
| |
177 case WebMediaPlayerClient::VideoTrackKindAlternative: | |
178 return VideoTrack::alternativeKeyword(); | |
179 break; | |
180 case WebMediaPlayerClient::VideoTrackKindCaptions: | |
181 return VideoTrack::captionsKeyword(); | |
182 break; | |
183 case WebMediaPlayerClient::VideoTrackKindMain: | |
184 return VideoTrack::mainKeyword(); | |
185 break; | |
186 case WebMediaPlayerClient::VideoTrackKindSign: | |
187 return VideoTrack::signKeyword(); | |
188 break; | |
189 case WebMediaPlayerClient::VideoTrackKindSubtitles: | |
190 return VideoTrack::subtitlesKeyword(); | |
191 break; | |
192 case WebMediaPlayerClient::VideoTrackKindCommentary: | |
193 return VideoTrack::commentaryKeyword(); | |
194 break; | |
195 } | |
196 | |
197 ASSERT_NOT_REACHED(); | |
198 return AtomicString(); | |
199 } | |
200 | |
201 static AtomicString AudioKindToString(WebMediaPlayerClient::AudioTrackKind kind) | |
Inactive
2014/03/08 03:05:59
Looks like this could return a const AtomicString&
acolwell GONE FROM CHROMIUM
2014/03/08 19:56:42
Done.
| |
202 { | |
203 switch (kind) { | |
204 case WebMediaPlayerClient::AudioTrackKindNone: | |
205 return AtomicString(); | |
206 break; | |
207 case WebMediaPlayerClient::AudioTrackKindAlternative: | |
208 return AudioTrack::alternativeKeyword(); | |
209 break; | |
210 case WebMediaPlayerClient::AudioTrackKindDescriptions: | |
211 return AudioTrack::descriptionsKeyword(); | |
212 break; | |
213 case WebMediaPlayerClient::AudioTrackKindMain: | |
214 return AudioTrack::mainKeyword(); | |
215 break; | |
216 case WebMediaPlayerClient::AudioTrackKindMainDescriptions: | |
217 return AudioTrack::mainDescriptionsKeyword(); | |
218 break; | |
219 case WebMediaPlayerClient::AudioTrackKindTranslation: | |
220 return AudioTrack::translationKeyword(); | |
221 break; | |
222 case WebMediaPlayerClient::AudioTrackKindCommentary: | |
223 return AudioTrack::commentaryKeyword(); | |
224 break; | |
225 } | |
226 | |
227 ASSERT_NOT_REACHED(); | |
228 return AtomicString(); | |
229 } | |
230 | |
166 static bool canLoadURL(const KURL& url, const ContentType& contentType, const St ring& keySystem) | 231 static bool canLoadURL(const KURL& url, const ContentType& contentType, const St ring& keySystem) |
167 { | 232 { |
168 DEFINE_STATIC_LOCAL(const String, codecs, ("codecs")); | 233 DEFINE_STATIC_LOCAL(const String, codecs, ("codecs")); |
169 | 234 |
170 String contentMIMEType = contentType.type().lower(); | 235 String contentMIMEType = contentType.type().lower(); |
171 String contentTypeCodecs = contentType.parameter(codecs); | 236 String contentTypeCodecs = contentType.parameter(codecs); |
172 | 237 |
173 // If the MIME type is missing or is not meaningful, try to figure it out fr om the URL. | 238 // 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") { | 239 if (contentMIMEType.isEmpty() || contentMIMEType == "application/octet-strea m" || contentMIMEType == "text/plain") { |
175 if (url.protocolIsData()) | 240 if (url.protocolIsData()) |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
270 , m_sentStalledEvent(false) | 335 , m_sentStalledEvent(false) |
271 , m_sentEndEvent(false) | 336 , m_sentEndEvent(false) |
272 , m_pausedInternal(false) | 337 , m_pausedInternal(false) |
273 , m_closedCaptionsVisible(false) | 338 , m_closedCaptionsVisible(false) |
274 , m_completelyLoaded(false) | 339 , m_completelyLoaded(false) |
275 , m_havePreparedToPlay(false) | 340 , m_havePreparedToPlay(false) |
276 , m_tracksAreReady(true) | 341 , m_tracksAreReady(true) |
277 , m_haveVisibleTextTrack(false) | 342 , m_haveVisibleTextTrack(false) |
278 , m_processingPreferenceChange(false) | 343 , m_processingPreferenceChange(false) |
279 , m_lastTextTrackUpdateTime(-1) | 344 , m_lastTextTrackUpdateTime(-1) |
345 , m_audioTracks(nullptr) | |
Inactive
2014/03/08 03:05:59
Those are RefPtrs, not raw pointers. No need to ex
acolwell GONE FROM CHROMIUM
2014/03/08 19:56:42
Done.
| |
346 , m_videoTracks(nullptr) | |
280 , m_textTracks(nullptr) | 347 , m_textTracks(nullptr) |
281 , m_ignoreTrackDisplayUpdate(0) | 348 , m_ignoreTrackDisplayUpdate(0) |
282 #if ENABLE(WEB_AUDIO) | 349 #if ENABLE(WEB_AUDIO) |
283 , m_audioSourceNode(0) | 350 , m_audioSourceNode(0) |
284 #endif | 351 #endif |
285 { | 352 { |
286 ASSERT(RuntimeEnabledFeatures::mediaEnabled()); | 353 ASSERT(RuntimeEnabledFeatures::mediaEnabled()); |
287 | 354 |
288 WTF_LOG(Media, "HTMLMediaElement::HTMLMediaElement"); | 355 WTF_LOG(Media, "HTMLMediaElement::HTMLMediaElement"); |
289 ScriptWrappable::init(this); | 356 ScriptWrappable::init(this); |
(...skipping 12 matching lines...) Expand all Loading... | |
302 { | 369 { |
303 WTF_LOG(Media, "HTMLMediaElement::~HTMLMediaElement"); | 370 WTF_LOG(Media, "HTMLMediaElement::~HTMLMediaElement"); |
304 | 371 |
305 m_asyncEventQueue->close(); | 372 m_asyncEventQueue->close(); |
306 | 373 |
307 setShouldDelayLoadEvent(false); | 374 setShouldDelayLoadEvent(false); |
308 | 375 |
309 if (m_textTracks) | 376 if (m_textTracks) |
310 m_textTracks->clearOwner(); | 377 m_textTracks->clearOwner(); |
311 | 378 |
379 if (m_audioTracks) | |
380 m_audioTracks->shutdown(); | |
381 | |
382 if (m_videoTracks) | |
383 m_videoTracks->shutdown(); | |
384 | |
312 if (m_mediaController) { | 385 if (m_mediaController) { |
313 m_mediaController->removeMediaElement(this); | 386 m_mediaController->removeMediaElement(this); |
314 m_mediaController = nullptr; | 387 m_mediaController = nullptr; |
315 } | 388 } |
316 | 389 |
317 closeMediaSource(); | 390 closeMediaSource(); |
318 | 391 |
319 removeElementFromDocumentMap(this, &document()); | 392 removeElementFromDocumentMap(this, &document()); |
320 | 393 |
321 // Destroying the player may cause a resource load to be canceled, | 394 // 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 | 434 // previous document. A proper fix would provide a mechanism to allow this |
362 // object to refresh the MediaPlayer's LocalFrame and FrameLoader references on | 435 // object to refresh the MediaPlayer's LocalFrame and FrameLoader references on |
363 // document changes so that playback can be resumed properly. | 436 // document changes so that playback can be resumed properly. |
364 userCancelledLoad(); | 437 userCancelledLoad(); |
365 | 438 |
366 // Decrement the load event delay count on oldDocument now that m_player has been destroyed | 439 // 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. | 440 // and there is no risk of dispatching a load event from within the destruct or. |
368 oldDocument.decrementLoadEventDelayCount(); | 441 oldDocument.decrementLoadEventDelayCount(); |
369 | 442 |
370 ActiveDOMObject::didMoveToNewExecutionContext(&document()); | 443 ActiveDOMObject::didMoveToNewExecutionContext(&document()); |
444 | |
445 // Notify track lists so they don't stop firing events when moved to a new d ocument | |
446 // and the original document gets destroyed. | |
447 if (m_audioTracks) | |
448 m_audioTracks->didMoveToNewExecutionContext(&document()); | |
449 | |
450 if (m_videoTracks) | |
451 m_videoTracks->didMoveToNewExecutionContext(&document()); | |
452 | |
371 HTMLElement::didMoveToNewDocument(oldDocument); | 453 HTMLElement::didMoveToNewDocument(oldDocument); |
372 } | 454 } |
373 | 455 |
374 bool HTMLMediaElement::hasCustomFocusLogic() const | 456 bool HTMLMediaElement::hasCustomFocusLogic() const |
375 { | 457 { |
376 return true; | 458 return true; |
377 } | 459 } |
378 | 460 |
379 bool HTMLMediaElement::supportsFocus() const | 461 bool HTMLMediaElement::supportsFocus() const |
380 { | 462 { |
(...skipping 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1573 finishSeek(); | 1655 finishSeek(); |
1574 } else { | 1656 } else { |
1575 if (wasPotentiallyPlaying && m_readyState < HAVE_FUTURE_DATA) { | 1657 if (wasPotentiallyPlaying && m_readyState < HAVE_FUTURE_DATA) { |
1576 // 4.8.10.8 | 1658 // 4.8.10.8 |
1577 scheduleTimeupdateEvent(false); | 1659 scheduleTimeupdateEvent(false); |
1578 scheduleEvent(EventTypeNames::waiting); | 1660 scheduleEvent(EventTypeNames::waiting); |
1579 } | 1661 } |
1580 } | 1662 } |
1581 | 1663 |
1582 if (m_readyState >= HAVE_METADATA && oldState < HAVE_METADATA) { | 1664 if (m_readyState >= HAVE_METADATA && oldState < HAVE_METADATA) { |
1665 createPlaceholderTracksIfNecessary(); | |
1666 | |
1583 prepareMediaFragmentURI(); | 1667 prepareMediaFragmentURI(); |
1668 | |
1669 selectInitialTracksIfNecessary(); | |
1670 | |
1584 scheduleEvent(EventTypeNames::durationchange); | 1671 scheduleEvent(EventTypeNames::durationchange); |
1585 if (isVideo()) | 1672 if (isVideo()) |
1586 scheduleEvent(EventTypeNames::resize); | 1673 scheduleEvent(EventTypeNames::resize); |
1587 scheduleEvent(EventTypeNames::loadedmetadata); | 1674 scheduleEvent(EventTypeNames::loadedmetadata); |
1588 if (hasMediaControls()) | 1675 if (hasMediaControls()) |
1589 mediaControls()->reset(); | 1676 mediaControls()->reset(); |
1590 if (renderer()) | 1677 if (renderer()) |
1591 renderer()->updateFromElement(); | 1678 renderer()->updateFromElement(); |
1592 } | 1679 } |
1593 | 1680 |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2194 m_lastTimeUpdateEventWallTime = now; | 2281 m_lastTimeUpdateEventWallTime = now; |
2195 m_lastTimeUpdateEventMovieTime = movieTime; | 2282 m_lastTimeUpdateEventMovieTime = movieTime; |
2196 } | 2283 } |
2197 } | 2284 } |
2198 | 2285 |
2199 bool HTMLMediaElement::canPlay() const | 2286 bool HTMLMediaElement::canPlay() const |
2200 { | 2287 { |
2201 return paused() || ended() || m_readyState < HAVE_METADATA; | 2288 return paused() || ended() || m_readyState < HAVE_METADATA; |
2202 } | 2289 } |
2203 | 2290 |
2291 AudioTrackList* HTMLMediaElement::audioTracks() | |
Inactive
2014/03/08 03:05:59
Could return a reference as it never returns null.
acolwell GONE FROM CHROMIUM
2014/03/08 19:56:42
Done.
| |
2292 { | |
2293 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | |
2294 | |
2295 if (!m_audioTracks) | |
2296 m_audioTracks = AudioTrackList::create(this); | |
2297 | |
2298 return m_audioTracks.get(); | |
2299 } | |
2300 | |
2301 void HTMLMediaElement::audioTrackChanged(const AtomicString& audioTrackID, bool enabled) | |
2302 { | |
2303 WTF_LOG(Media, "HTMLMediaElement::audioTrackChanged('%s', %d)", audioTrackID .ascii().data(), enabled); | |
2304 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | |
2305 ASSERT(!audioTrackID.isEmpty()); | |
2306 | |
2307 audioTracks()->scheduleChangeEvent(); | |
2308 | |
2309 // FIXME: Add call on m_mediaSource to notify it of track changes once the S ourceBuffer.audioTracks attribute is added. | |
2310 | |
2311 if (webMediaPlayer()) | |
2312 webMediaPlayer()->enabledAudioTrackChange(audioTrackID, enabled); | |
2313 } | |
2314 | |
2315 VideoTrackList* HTMLMediaElement::videoTracks() | |
Inactive
2014/03/08 03:05:59
Could return a reference as it never returns null.
acolwell GONE FROM CHROMIUM
2014/03/08 19:56:42
Done.
| |
2316 { | |
2317 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | |
2318 | |
2319 if (!m_videoTracks) | |
2320 m_videoTracks = VideoTrackList::create(this); | |
2321 | |
2322 return m_videoTracks.get(); | |
2323 } | |
2324 | |
2325 void HTMLMediaElement::selectedVideoTrackChanged(const AtomicString& selectedTra ckID) | |
2326 { | |
2327 WTF_LOG(Media, "HTMLMediaElement::selectedVideoTrackChanged('%s')", selected TrackID.ascii().data()); | |
2328 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | |
2329 | |
2330 AtomicString unselectedTrackID; | |
2331 | |
2332 int oldSelectedIndex = videoTracks()->selectedIndex(); | |
2333 if (oldSelectedIndex != -1) | |
2334 unselectedTrackID = videoTracks()->anonymousIndexedGetter(oldSelectedInd ex)->id(); | |
2335 | |
2336 ASSERT(unselectedTrackID != selectedTrackID); | |
2337 | |
2338 videoTracks()->trackSelected(selectedTrackID); | |
2339 | |
2340 // FIXME: Add call on m_mediaSource to notify it of track changes once the S ourceBuffer.videoTracks attribute is added. | |
2341 | |
2342 ASSERT(!unselectedTrackID.isEmpty() || !selectedTrackID.isEmpty()); | |
2343 | |
2344 if (webMediaPlayer()) | |
2345 webMediaPlayer()->selectedVideoTrackChange(unselectedTrackID, selectedTr ackID); | |
2346 } | |
2347 | |
2348 void HTMLMediaElement::addVideoTrack(const AtomicString& id, blink::WebMediaPlay erClient::VideoTrackKind kind, const AtomicString& label, const AtomicString& la nguage, bool selected) | |
2349 { | |
2350 AtomicString kindString = VideoKindToString(kind); | |
2351 WTF_LOG(Media, "HTMLMediaElement::addVideoTrack('%s', '%s', '%s', '%s', %d)" , | |
2352 id.ascii().data(), kindString.ascii().data(), label.ascii().data(), lang uage.ascii().data(), selected); | |
2353 ASSERT(!id.isEmpty()); | |
2354 | |
2355 RefPtr<VideoTrack> videoTrack = VideoTrack::create(this, id, kindString, lab el, language); | |
2356 videoTracks()->add(videoTrack.get()); | |
2357 | |
2358 if (selected) | |
2359 videoTrack->setSelected(true); | |
2360 } | |
2361 | |
2362 void HTMLMediaElement::removeVideoTrack(const AtomicString& id) | |
2363 { | |
2364 WTF_LOG(Media, "HTMLMediaElement::removeVideoTrack('%s')", id.ascii().data() ); | |
2365 ASSERT(!id.isEmpty()); | |
2366 | |
2367 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | |
2368 return; | |
2369 | |
2370 videoTracks()->remove(id); | |
2371 } | |
2372 | |
2373 void HTMLMediaElement::addAudioTrack(const AtomicString& id, blink::WebMediaPlay erClient::AudioTrackKind kind, const AtomicString& label, const AtomicString& la nguage, bool enabled) | |
2374 { | |
2375 AtomicString kindString = AudioKindToString(kind); | |
2376 WTF_LOG(Media, "HTMLMediaElement::addAudioTrack('%s', '%s', '%s', '%s', %d)" , | |
2377 id.ascii().data(), kindString.ascii().data(), label.ascii().data(), lang uage.ascii().data(), enabled); | |
2378 ASSERT(!id.isEmpty()); | |
2379 | |
2380 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | |
2381 return; | |
2382 | |
2383 RefPtr<AudioTrack> audioTrack = AudioTrack::create(this, id, kindString, lab el, language); | |
2384 audioTracks()->add(audioTrack.get()); | |
2385 | |
2386 if (enabled) | |
2387 audioTrack->setEnabled(true); | |
2388 } | |
2389 | |
2390 void HTMLMediaElement::removeAudioTrack(const AtomicString& id) | |
2391 { | |
2392 WTF_LOG(Media, "HTMLMediaElement::removeAudioTrack('%s')", id.ascii().data() ); | |
2393 ASSERT(!id.isEmpty()); | |
2394 | |
2395 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | |
2396 return; | |
2397 | |
2398 audioTracks()->remove(id); | |
2399 } | |
2400 | |
2204 void HTMLMediaElement::mediaPlayerDidAddTextTrack(WebInbandTextTrack* webTrack) | 2401 void HTMLMediaElement::mediaPlayerDidAddTextTrack(WebInbandTextTrack* webTrack) |
2205 { | 2402 { |
2206 if (!RuntimeEnabledFeatures::videoTrackEnabled()) | 2403 if (!RuntimeEnabledFeatures::videoTrackEnabled()) |
2207 return; | 2404 return; |
2208 | 2405 |
2209 // 4.8.10.12.2 Sourcing in-band text tracks | 2406 // 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. | 2407 // 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); | 2408 RefPtr<InbandTextTrack> textTrack = InbandTextTrack::create(document(), webT rack); |
2212 | 2409 |
2213 // 2. Set the new text track's kind, label, and language based on the semant ics of the relevant data, | 2410 // 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) | 2466 void HTMLMediaElement::removeTextTrack(TextTrack* track) |
2270 { | 2467 { |
2271 TrackDisplayUpdateScope scope(this); | 2468 TrackDisplayUpdateScope scope(this); |
2272 m_textTracks->remove(track); | 2469 m_textTracks->remove(track); |
2273 | 2470 |
2274 closeCaptionTracksChanged(); | 2471 closeCaptionTracksChanged(); |
2275 } | 2472 } |
2276 | 2473 |
2277 void HTMLMediaElement::forgetResourceSpecificTracks() | 2474 void HTMLMediaElement::forgetResourceSpecificTracks() |
2278 { | 2475 { |
2476 // Implements the "forget the media element's media-resource-specific tracks " algorithm. | |
2477 // The order is explicitly specified as text, then audio, and finally video. Also | |
2478 // 'removetrack' events should not be fired. | |
2279 if (m_textTracks) { | 2479 if (m_textTracks) { |
2280 TrackDisplayUpdateScope scope(this); | 2480 TrackDisplayUpdateScope scope(this); |
2281 m_textTracks->removeAllInbandTracks(); | 2481 m_textTracks->removeAllInbandTracks(); |
2282 closeCaptionTracksChanged(); | 2482 closeCaptionTracksChanged(); |
2283 } | 2483 } |
2484 | |
2485 if (m_audioTracks) | |
2486 m_audioTracks->removeAll(); | |
2487 | |
2488 if (m_videoTracks) | |
2489 m_videoTracks->removeAll(); | |
2284 } | 2490 } |
2285 | 2491 |
2286 PassRefPtr<TextTrack> HTMLMediaElement::addTextTrack(const AtomicString& kind, c onst AtomicString& label, const AtomicString& language, ExceptionState& exceptio nState) | 2492 PassRefPtr<TextTrack> HTMLMediaElement::addTextTrack(const AtomicString& kind, c onst AtomicString& label, const AtomicString& language, ExceptionState& exceptio nState) |
2287 { | 2493 { |
2288 ASSERT(RuntimeEnabledFeatures::videoTrackEnabled()); | 2494 ASSERT(RuntimeEnabledFeatures::videoTrackEnabled()); |
2289 | 2495 |
2290 // 4.8.10.12.4 Text track API | 2496 // 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: | 2497 // The addTextTrack(kind, label, language) method of media elements, when in voked, must run the following steps: |
2292 | 2498 |
2293 // 1. If kind is not one of the following strings, then throw a SyntaxError exception and abort these steps | 2499 // 1. If kind is not one of the following strings, then throw a SyntaxError exception and abort these steps |
(...skipping 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3582 m_fragmentStartTime = MediaPlayer::invalidTime(); | 3788 m_fragmentStartTime = MediaPlayer::invalidTime(); |
3583 | 3789 |
3584 double end = fragmentParser.endTime(); | 3790 double end = fragmentParser.endTime(); |
3585 if (end != MediaFragmentURIParser::invalidTimeValue() && end > 0 && end > m_ fragmentStartTime) { | 3791 if (end != MediaFragmentURIParser::invalidTimeValue() && end > 0 && end > m_ fragmentStartTime) { |
3586 m_fragmentEndTime = end; | 3792 m_fragmentEndTime = end; |
3587 if (m_fragmentEndTime > dur) | 3793 if (m_fragmentEndTime > dur) |
3588 m_fragmentEndTime = dur; | 3794 m_fragmentEndTime = dur; |
3589 } else | 3795 } else |
3590 m_fragmentEndTime = MediaPlayer::invalidTime(); | 3796 m_fragmentEndTime = MediaPlayer::invalidTime(); |
3591 | 3797 |
3798 // FIXME: Add support for selecting tracks by ID with the Media Fragments tr ack dimension. | |
3799 | |
3592 if (m_fragmentStartTime != MediaPlayer::invalidTime() && m_readyState < HAVE _FUTURE_DATA) | 3800 if (m_fragmentStartTime != MediaPlayer::invalidTime() && m_readyState < HAVE _FUTURE_DATA) |
3593 prepareToPlay(); | 3801 prepareToPlay(); |
3594 } | 3802 } |
3595 | 3803 |
3596 void HTMLMediaElement::applyMediaFragmentURI() | 3804 void HTMLMediaElement::applyMediaFragmentURI() |
3597 { | 3805 { |
3598 if (m_fragmentStartTime != MediaPlayer::invalidTime()) { | 3806 if (m_fragmentStartTime != MediaPlayer::invalidTime()) { |
3599 m_sentEndEvent = false; | 3807 m_sentEndEvent = false; |
3600 UseCounter::count(document(), UseCounter::HTMLMediaElementSeekToFragment Start); | 3808 UseCounter::count(document(), UseCounter::HTMLMediaElementSeekToFragment Start); |
3601 seek(m_fragmentStartTime, IGNORE_EXCEPTION); | 3809 seek(m_fragmentStartTime, IGNORE_EXCEPTION); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3640 void HTMLMediaElement::mediaPlayerMediaSourceOpened(blink::WebMediaSource* webMe diaSource) | 3848 void HTMLMediaElement::mediaPlayerMediaSourceOpened(blink::WebMediaSource* webMe diaSource) |
3641 { | 3849 { |
3642 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource)); | 3850 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource)); |
3643 } | 3851 } |
3644 | 3852 |
3645 bool HTMLMediaElement::isInteractiveContent() const | 3853 bool HTMLMediaElement::isInteractiveContent() const |
3646 { | 3854 { |
3647 return fastHasAttribute(controlsAttr); | 3855 return fastHasAttribute(controlsAttr); |
3648 } | 3856 } |
3649 | 3857 |
3858 void HTMLMediaElement::createPlaceholderTracksIfNecessary() | |
3859 { | |
3860 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | |
3861 return; | |
3862 | |
3863 // Create a placeholder audio track if |m_player| says it has audio but it d idn't explicitly announce the tracks. | |
3864 if (m_player->hasAudio() && !audioTracks()->length()) | |
3865 addAudioTrack("audio", WebMediaPlayerClient::AudioTrackKindMain, "Audio Track", "", true); | |
3866 | |
3867 // Create a placeholder video track if |m_player| says it has video but it d idn't explicitly announce the tracks. | |
3868 if (m_player->hasVideo() && !videoTracks()->length()) | |
3869 addVideoTrack("video", WebMediaPlayerClient::VideoTrackKindMain, "Video Track", "", true); | |
3650 } | 3870 } |
3871 | |
3872 void HTMLMediaElement::selectInitialTracksIfNecessary() | |
3873 { | |
3874 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | |
3875 return; | |
3876 | |
3877 // Enable the first audio track if an audio track hasn't been enabled yet. | |
3878 if (audioTracks()->length() > 0 && !audioTracks()->hasEnabledTrack()) | |
3879 audioTracks()->anonymousIndexedGetter(0)->setEnabled(true); | |
3880 | |
3881 // Select the first video track if a video track hasn't been selected yet. | |
3882 if (videoTracks()->length() > 0 && videoTracks()->selectedIndex() == -1) | |
3883 videoTracks()->anonymousIndexedGetter(0)->setSelected(true); | |
3884 } | |
3885 | |
3886 } | |
OLD | NEW |