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 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() | |
| 2292 { | |
| 2293 WTF_LOG(Media, "HTMLMediaElement::audioTrackChanged()"); | |
| 2294 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | |
| 2295 | |
| 2296 audioTracks().scheduleChangeEvent(); | |
| 2297 | |
| 2298 // FIXME: Add call on m_mediaSource to notify it of track changes once the S ourceBuffer.audioTracks attribute is added. | |
| 2299 | |
| 2300 if (!m_audioTracksTimer.isActive()) | |
| 2301 m_audioTracksTimer.startOneShot(0, FROM_HERE); | |
| 2302 } | |
| 2303 | |
| 2304 void HTMLMediaElement::audioTracksTimerFired(Timer<HTMLMediaElement>*) | |
| 2305 { | |
| 2306 if (!webMediaPlayer()) | |
| 2307 return; | |
| 2308 | |
| 2309 Vector<blink::WebTrackId> enabledTrackIds; | |
| 2310 for (unsigned i = 0; i < audioTracks().length(); ++i) { | |
| 2311 RefPtr<AudioTrack> track = audioTracks().anonymousIndexedGetter(i); | |
| 2312 if (track->enabled()) | |
| 2313 enabledTrackIds.append(track->webId()); | |
| 2314 } | |
| 2315 | |
| 2316 webMediaPlayer()->enabledAudioTracksChanged(enabledTrackIds); | |
| 2317 } | |
| 2318 | |
| 2319 blink::WebTrackId HTMLMediaElement::addAudioTrack(const String& id, blink::WebMe diaPlayerClient::AudioTrackKind kind, const AtomicString& label, const AtomicStr ing& language, bool enabled) | |
| 2320 { | |
| 2321 AtomicString kindString = AudioKindToString(kind); | |
| 2322 WTF_LOG(Media, "HTMLMediaElement::addAudioTrack('%s', '%s', '%s', '%s', %d)" , | |
| 2323 id.ascii().data(), kindString.ascii().data(), label.ascii().data(), lang uage.ascii().data(), enabled); | |
| 2324 | |
| 2325 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | |
| 2326 return 0; | |
| 2327 | |
| 2328 RefPtr<AudioTrack> audioTrack = AudioTrack::create(id, kindString, label, la nguage); | |
| 2329 audioTracks().add(audioTrack.get()); | |
| 2330 | |
| 2331 if (enabled) | |
| 2332 audioTrack->setEnabled(true); | |
| 2333 | |
| 2334 return audioTrack->webId(); | |
| 2335 } | |
| 2336 | |
| 2337 void HTMLMediaElement::removeAudioTrack(blink::WebTrackId webId) | |
| 2338 { | |
| 2339 WTF_LOG(Media, "HTMLMediaElement::removeAudioTrack()"); | |
| 2340 | |
| 2341 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | |
| 2342 return; | |
| 2343 | |
| 2344 audioTracks().remove(webId); | |
| 2345 } | |
| 2346 | |
| 2347 VideoTrackList& HTMLMediaElement::videoTracks() | |
| 2348 { | |
| 2349 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | |
| 2350 return *m_videoTracks; | |
| 2351 } | |
| 2352 | |
| 2353 void HTMLMediaElement::selectedVideoTrackChanged(blink::WebTrackId* selectedTrac kId) | |
| 2354 { | |
| 2355 WTF_LOG(Media, "HTMLMediaElement::selectedVideoTrackChanged()"); | |
| 2356 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled()); | |
| 2357 | |
| 2358 videoTracks().trackSelected(selectedTrackId); | |
| 2359 | |
| 2360 // FIXME: Add call on m_mediaSource to notify it of track changes once the S ourceBuffer.videoTracks attribute is added. | |
| 2361 | |
| 2362 if (webMediaPlayer()) | |
| 2363 webMediaPlayer()->selectedVideoTrackChanged(selectedTrackId); | |
| 2364 } | |
| 2365 | |
| 2366 blink::WebTrackId HTMLMediaElement::addVideoTrack(const String& id, blink::WebMe diaPlayerClient::VideoTrackKind kind, const AtomicString& label, const AtomicStr ing& language, bool selected) | |
| 2367 { | |
| 2368 AtomicString kindString = VideoKindToString(kind); | |
| 2369 WTF_LOG(Media, "HTMLMediaElement::addVideoTrack('%s', '%s', '%s', '%s', %d)" , | |
| 2370 id.ascii().data(), kindString.ascii().data(), label.ascii().data(), lang uage.ascii().data(), selected); | |
| 2371 | |
| 2372 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | |
| 2373 return 0; | |
| 2374 | |
| 2375 RefPtr<VideoTrack> videoTrack = VideoTrack::create(id, kindString, label, la nguage); | |
| 2376 videoTracks().add(videoTrack.get()); | |
| 2377 | |
| 2378 if (selected) | |
| 2379 videoTrack->setSelected(true); | |
|
landell
2014/05/17 06:15:28
I see one potential problem here. Seems as this ca
philipj_slow
2014/05/20 09:05:13
Good catch, that's a pretty terrible API.
I can s
| |
| 2380 | |
| 2381 return videoTrack->webId(); | |
| 2382 } | |
| 2383 | |
| 2384 void HTMLMediaElement::removeVideoTrack(blink::WebTrackId webId) | |
| 2385 { | |
| 2386 WTF_LOG(Media, "HTMLMediaElement::removeVideoTrack()"); | |
| 2387 | |
| 2388 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | |
| 2389 return; | |
| 2390 | |
| 2391 videoTracks().remove(webId); | |
|
acolwell GONE FROM CHROMIUM
2014/05/16 19:47:56
Still need to check for removing the selected trac
| |
| 2392 } | |
| 2393 | |
| 2222 void HTMLMediaElement::mediaPlayerDidAddTextTrack(WebInbandTextTrack* webTrack) | 2394 void HTMLMediaElement::mediaPlayerDidAddTextTrack(WebInbandTextTrack* webTrack) |
| 2223 { | 2395 { |
| 2224 // 4.8.10.12.2 Sourcing in-band text tracks | 2396 // 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. | 2397 // 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); | 2398 RefPtrWillBeRawPtr<InbandTextTrack> textTrack = InbandTextTrack::create(docu ment(), webTrack); |
| 2227 | 2399 |
| 2228 // 2. Set the new text track's kind, label, and language based on the semant ics of the relevant data, | 2400 // 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 | 2401 // 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. | 2402 // 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 | 2403 // 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) | 2453 void HTMLMediaElement::removeTextTrack(TextTrack* track) |
| 2282 { | 2454 { |
| 2283 TrackDisplayUpdateScope scope(this); | 2455 TrackDisplayUpdateScope scope(this); |
| 2284 m_textTracks->remove(track); | 2456 m_textTracks->remove(track); |
| 2285 | 2457 |
| 2286 closeCaptionTracksChanged(); | 2458 closeCaptionTracksChanged(); |
| 2287 } | 2459 } |
| 2288 | 2460 |
| 2289 void HTMLMediaElement::forgetResourceSpecificTracks() | 2461 void HTMLMediaElement::forgetResourceSpecificTracks() |
| 2290 { | 2462 { |
| 2463 // Implements the "forget the media element's media-resource-specific tracks " algorithm. | |
| 2464 // The order is explicitly specified as text, then audio, and finally video. Also | |
| 2465 // 'removetrack' events should not be fired. | |
| 2291 if (m_textTracks) { | 2466 if (m_textTracks) { |
| 2292 TrackDisplayUpdateScope scope(this); | 2467 TrackDisplayUpdateScope scope(this); |
| 2293 m_textTracks->removeAllInbandTracks(); | 2468 m_textTracks->removeAllInbandTracks(); |
| 2294 closeCaptionTracksChanged(); | 2469 closeCaptionTracksChanged(); |
| 2295 } | 2470 } |
| 2471 | |
| 2472 m_audioTracks->removeAll(); | |
| 2473 m_videoTracks->removeAll(); | |
| 2296 } | 2474 } |
| 2297 | 2475 |
| 2298 PassRefPtrWillBeRawPtr<TextTrack> HTMLMediaElement::addTextTrack(const AtomicStr ing& kind, const AtomicString& label, const AtomicString& language, ExceptionSta te& exceptionState) | 2476 PassRefPtrWillBeRawPtr<TextTrack> HTMLMediaElement::addTextTrack(const AtomicStr ing& kind, const AtomicString& label, const AtomicString& language, ExceptionSta te& exceptionState) |
| 2299 { | 2477 { |
| 2300 // 4.8.10.12.4 Text track API | 2478 // 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: | 2479 // The addTextTrack(kind, label, language) method of media elements, when in voked, must run the following steps: |
| 2302 | 2480 |
| 2303 // 1. If kind is not one of the following strings, then throw a SyntaxError exception and abort these steps | 2481 // 1. If kind is not one of the following strings, then throw a SyntaxError exception and abort these steps |
| 2304 if (!TextTrack::isValidKindKeyword(kind)) { | 2482 if (!TextTrack::isValidKindKeyword(kind)) { |
| 2305 exceptionState.throwDOMException(SyntaxError, "The 'kind' provided ('" + kind + "') is invalid."); | 2483 exceptionState.throwDOMException(SyntaxError, "The 'kind' provided ('" + kind + "') is invalid."); |
| (...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3111 forgetResourceSpecificTracks(); | 3289 forgetResourceSpecificTracks(); |
| 3112 | 3290 |
| 3113 closeMediaSource(); | 3291 closeMediaSource(); |
| 3114 | 3292 |
| 3115 m_delayingLoadForPreloadNone = false; | 3293 m_delayingLoadForPreloadNone = false; |
| 3116 | 3294 |
| 3117 clearMediaPlayerAndAudioSourceProviderClient(); | 3295 clearMediaPlayerAndAudioSourceProviderClient(); |
| 3118 | 3296 |
| 3119 stopPeriodicTimers(); | 3297 stopPeriodicTimers(); |
| 3120 m_loadTimer.stop(); | 3298 m_loadTimer.stop(); |
| 3299 m_audioTracksTimer.stop(); | |
| 3121 | 3300 |
| 3122 m_pendingActionFlags &= ~flags; | 3301 m_pendingActionFlags &= ~flags; |
| 3123 m_loadState = WaitingForSource; | 3302 m_loadState = WaitingForSource; |
| 3124 | 3303 |
| 3125 if (m_textTracks) | 3304 if (m_textTracks) |
| 3126 configureTextTrackDisplay(AssumeNoVisibleChange); | 3305 configureTextTrackDisplay(AssumeNoVisibleChange); |
| 3127 } | 3306 } |
| 3128 | 3307 |
| 3129 void HTMLMediaElement::stop() | 3308 void HTMLMediaElement::stop() |
| 3130 { | 3309 { |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3553 m_fragmentStartTime = MediaPlayer::invalidTime(); | 3732 m_fragmentStartTime = MediaPlayer::invalidTime(); |
| 3554 | 3733 |
| 3555 double end = fragmentParser.endTime(); | 3734 double end = fragmentParser.endTime(); |
| 3556 if (end != MediaFragmentURIParser::invalidTimeValue() && end > 0 && end > m_ fragmentStartTime) { | 3735 if (end != MediaFragmentURIParser::invalidTimeValue() && end > 0 && end > m_ fragmentStartTime) { |
| 3557 m_fragmentEndTime = end; | 3736 m_fragmentEndTime = end; |
| 3558 if (m_fragmentEndTime > dur) | 3737 if (m_fragmentEndTime > dur) |
| 3559 m_fragmentEndTime = dur; | 3738 m_fragmentEndTime = dur; |
| 3560 } else | 3739 } else |
| 3561 m_fragmentEndTime = MediaPlayer::invalidTime(); | 3740 m_fragmentEndTime = MediaPlayer::invalidTime(); |
| 3562 | 3741 |
| 3742 // FIXME: Add support for selecting tracks by ID with the Media Fragments tr ack dimension. | |
| 3743 | |
| 3563 if (m_fragmentStartTime != MediaPlayer::invalidTime() && m_readyState < HAVE _FUTURE_DATA) | 3744 if (m_fragmentStartTime != MediaPlayer::invalidTime() && m_readyState < HAVE _FUTURE_DATA) |
| 3564 prepareToPlay(); | 3745 prepareToPlay(); |
| 3565 } | 3746 } |
| 3566 | 3747 |
| 3567 void HTMLMediaElement::applyMediaFragmentURI() | 3748 void HTMLMediaElement::applyMediaFragmentURI() |
| 3568 { | 3749 { |
| 3569 if (m_fragmentStartTime != MediaPlayer::invalidTime()) { | 3750 if (m_fragmentStartTime != MediaPlayer::invalidTime()) { |
| 3570 m_sentEndEvent = false; | 3751 m_sentEndEvent = false; |
| 3571 UseCounter::count(document(), UseCounter::HTMLMediaElementSeekToFragment Start); | 3752 UseCounter::count(document(), UseCounter::HTMLMediaElementSeekToFragment Start); |
| 3572 seek(m_fragmentStartTime, IGNORE_EXCEPTION); | 3753 seek(m_fragmentStartTime, IGNORE_EXCEPTION); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3613 void HTMLMediaElement::trace(Visitor* visitor) | 3794 void HTMLMediaElement::trace(Visitor* visitor) |
| 3614 { | 3795 { |
| 3615 visitor->trace(m_currentSourceNode); | 3796 visitor->trace(m_currentSourceNode); |
| 3616 visitor->trace(m_nextChildNodeToConsider); | 3797 visitor->trace(m_nextChildNodeToConsider); |
| 3617 visitor->trace(m_textTracks); | 3798 visitor->trace(m_textTracks); |
| 3618 visitor->trace(m_textTracksWhenResourceSelectionBegan); | 3799 visitor->trace(m_textTracksWhenResourceSelectionBegan); |
| 3619 WillBeHeapSupplementable<HTMLMediaElement>::trace(visitor); | 3800 WillBeHeapSupplementable<HTMLMediaElement>::trace(visitor); |
| 3620 HTMLElement::trace(visitor); | 3801 HTMLElement::trace(visitor); |
| 3621 } | 3802 } |
| 3622 | 3803 |
| 3804 void HTMLMediaElement::createPlaceholderTracksIfNecessary() | |
| 3805 { | |
| 3806 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | |
| 3807 return; | |
| 3808 | |
| 3809 // Create a placeholder audio track if |m_player| says it has audio but it d idn't explicitly announce the tracks. | |
| 3810 if (m_player->hasAudio() && !audioTracks().length()) | |
| 3811 addAudioTrack("audio", WebMediaPlayerClient::AudioTrackKindMain, "Audio Track", "", true); | |
| 3812 | |
| 3813 // Create a placeholder video track if |m_player| says it has video but it d idn't explicitly announce the tracks. | |
| 3814 if (m_player->hasVideo() && !videoTracks().length()) | |
| 3815 addVideoTrack("video", WebMediaPlayerClient::VideoTrackKindMain, "Video Track", "", true); | |
| 3623 } | 3816 } |
| 3817 | |
| 3818 void HTMLMediaElement::selectInitialTracksIfNecessary() | |
| 3819 { | |
| 3820 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled()) | |
| 3821 return; | |
| 3822 | |
| 3823 // Enable the first audio track if an audio track hasn't been enabled yet. | |
| 3824 if (audioTracks().length() > 0 && !audioTracks().hasEnabledTrack()) | |
| 3825 audioTracks().anonymousIndexedGetter(0)->setEnabled(true); | |
| 3826 | |
| 3827 // Select the first video track if a video track hasn't been selected yet. | |
| 3828 if (videoTracks().length() > 0 && videoTracks().selectedIndex() == -1) | |
| 3829 videoTracks().anonymousIndexedGetter(0)->setSelected(true); | |
| 3830 } | |
| 3831 | |
| 3832 } | |
| OLD | NEW |