Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: Source/core/html/HTMLMediaElement.cpp

Issue 170233009: Initial implementation of AudioTrack, AudioTrackList, VideoTrack, and VideoTrackList. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@blink-master
Patch Set: Rebase Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
156 ~TrackDisplayUpdateScope() 161 ~TrackDisplayUpdateScope()
157 { 162 {
158 ASSERT(m_mediaElement); 163 ASSERT(m_mediaElement);
159 m_mediaElement->endIgnoringTrackDisplayUpdateRequests(); 164 m_mediaElement->endIgnoringTrackDisplayUpdateRequests();
160 } 165 }
161 166
162 private: 167 private:
163 HTMLMediaElement* m_mediaElement; 168 HTMLMediaElement* m_mediaElement;
164 }; 169 };
165 170
171 static const AtomicString& VideoKindToString(WebMediaPlayerClient::VideoTrackKin d kind)
172 {
173 switch (kind) {
174 case WebMediaPlayerClient::VideoTrackKindNone:
175 return emptyAtom;
176 case WebMediaPlayerClient::VideoTrackKindAlternative:
177 return VideoTrack::alternativeKeyword();
178 case WebMediaPlayerClient::VideoTrackKindCaptions:
179 return VideoTrack::captionsKeyword();
180 case WebMediaPlayerClient::VideoTrackKindMain:
181 return VideoTrack::mainKeyword();
182 case WebMediaPlayerClient::VideoTrackKindSign:
183 return VideoTrack::signKeyword();
184 case WebMediaPlayerClient::VideoTrackKindSubtitles:
185 return VideoTrack::subtitlesKeyword();
186 case WebMediaPlayerClient::VideoTrackKindCommentary:
187 return VideoTrack::commentaryKeyword();
188 }
189
190 ASSERT_NOT_REACHED();
191 return emptyAtom;
192 }
193
194 static const AtomicString& AudioKindToString(WebMediaPlayerClient::AudioTrackKin d kind)
195 {
196 switch (kind) {
197 case WebMediaPlayerClient::AudioTrackKindNone:
198 return emptyAtom;
199 case WebMediaPlayerClient::AudioTrackKindAlternative:
200 return AudioTrack::alternativeKeyword();
201 case WebMediaPlayerClient::AudioTrackKindDescriptions:
202 return AudioTrack::descriptionsKeyword();
203 case WebMediaPlayerClient::AudioTrackKindMain:
204 return AudioTrack::mainKeyword();
205 case WebMediaPlayerClient::AudioTrackKindMainDescriptions:
206 return AudioTrack::mainDescriptionsKeyword();
207 case WebMediaPlayerClient::AudioTrackKindTranslation:
208 return AudioTrack::translationKeyword();
209 case WebMediaPlayerClient::AudioTrackKindCommentary:
210 return AudioTrack::commentaryKeyword();
211 }
212
213 ASSERT_NOT_REACHED();
214 return emptyAtom;
215 }
216
166 static bool canLoadURL(const KURL& url, const ContentType& contentType, const St ring& keySystem) 217 static bool canLoadURL(const KURL& url, const ContentType& contentType, const St ring& keySystem)
167 { 218 {
168 DEFINE_STATIC_LOCAL(const String, codecs, ("codecs")); 219 DEFINE_STATIC_LOCAL(const String, codecs, ("codecs"));
169 220
170 String contentMIMEType = contentType.type().lower(); 221 String contentMIMEType = contentType.type().lower();
171 String contentTypeCodecs = contentType.parameter(codecs); 222 String contentTypeCodecs = contentType.parameter(codecs);
172 223
173 // If the MIME type is missing or is not meaningful, try to figure it out fr om the URL. 224 // If the MIME type is missing or is not meaningful, try to figure it out fr om the URL.
174 if (contentMIMEType.isEmpty() || contentMIMEType == "application/octet-strea m" || contentMIMEType == "text/plain") { 225 if (contentMIMEType.isEmpty() || contentMIMEType == "application/octet-strea m" || contentMIMEType == "text/plain") {
175 if (url.protocolIsData()) 226 if (url.protocolIsData())
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 { 353 {
303 WTF_LOG(Media, "HTMLMediaElement::~HTMLMediaElement"); 354 WTF_LOG(Media, "HTMLMediaElement::~HTMLMediaElement");
304 355
305 m_asyncEventQueue->close(); 356 m_asyncEventQueue->close();
306 357
307 setShouldDelayLoadEvent(false); 358 setShouldDelayLoadEvent(false);
308 359
309 if (m_textTracks) 360 if (m_textTracks)
310 m_textTracks->clearOwner(); 361 m_textTracks->clearOwner();
311 362
363 if (m_audioTracks)
364 m_audioTracks->shutdown();
365
366 if (m_videoTracks)
367 m_videoTracks->shutdown();
368
312 if (m_mediaController) { 369 if (m_mediaController) {
313 m_mediaController->removeMediaElement(this); 370 m_mediaController->removeMediaElement(this);
314 m_mediaController = nullptr; 371 m_mediaController = nullptr;
315 } 372 }
316 373
317 closeMediaSource(); 374 closeMediaSource();
318 375
319 removeElementFromDocumentMap(this, &document()); 376 removeElementFromDocumentMap(this, &document());
320 377
321 // Destroying the player may cause a resource load to be canceled, 378 // Destroying the player may cause a resource load to be canceled,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 // previous document. A proper fix would provide a mechanism to allow this 418 // previous document. A proper fix would provide a mechanism to allow this
362 // object to refresh the MediaPlayer's LocalFrame and FrameLoader references on 419 // object to refresh the MediaPlayer's LocalFrame and FrameLoader references on
363 // document changes so that playback can be resumed properly. 420 // document changes so that playback can be resumed properly.
364 userCancelledLoad(); 421 userCancelledLoad();
365 422
366 // Decrement the load event delay count on oldDocument now that m_player has been destroyed 423 // Decrement the load event delay count on oldDocument now that m_player has been destroyed
367 // and there is no risk of dispatching a load event from within the destruct or. 424 // and there is no risk of dispatching a load event from within the destruct or.
368 oldDocument.decrementLoadEventDelayCount(); 425 oldDocument.decrementLoadEventDelayCount();
369 426
370 ActiveDOMObject::didMoveToNewExecutionContext(&document()); 427 ActiveDOMObject::didMoveToNewExecutionContext(&document());
428
429 // Notify track lists so they don't stop firing events when moved to a new d ocument
430 // and the original document gets destroyed.
431 if (m_audioTracks)
432 m_audioTracks->didMoveToNewExecutionContext(&document());
433
434 if (m_videoTracks)
435 m_videoTracks->didMoveToNewExecutionContext(&document());
436
371 HTMLElement::didMoveToNewDocument(oldDocument); 437 HTMLElement::didMoveToNewDocument(oldDocument);
372 } 438 }
373 439
374 bool HTMLMediaElement::hasCustomFocusLogic() const 440 bool HTMLMediaElement::hasCustomFocusLogic() const
375 { 441 {
376 return true; 442 return true;
377 } 443 }
378 444
379 bool HTMLMediaElement::supportsFocus() const 445 bool HTMLMediaElement::supportsFocus() const
380 { 446 {
(...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1559 finishSeek(); 1625 finishSeek();
1560 } else { 1626 } else {
1561 if (wasPotentiallyPlaying && m_readyState < HAVE_FUTURE_DATA) { 1627 if (wasPotentiallyPlaying && m_readyState < HAVE_FUTURE_DATA) {
1562 // 4.8.10.8 1628 // 4.8.10.8
1563 scheduleTimeupdateEvent(false); 1629 scheduleTimeupdateEvent(false);
1564 scheduleEvent(EventTypeNames::waiting); 1630 scheduleEvent(EventTypeNames::waiting);
1565 } 1631 }
1566 } 1632 }
1567 1633
1568 if (m_readyState >= HAVE_METADATA && oldState < HAVE_METADATA) { 1634 if (m_readyState >= HAVE_METADATA && oldState < HAVE_METADATA) {
1635 createPlaceholderTracksIfNecessary();
1636
1569 prepareMediaFragmentURI(); 1637 prepareMediaFragmentURI();
1638
1639 selectInitialTracksIfNecessary();
1640
1570 scheduleEvent(EventTypeNames::durationchange); 1641 scheduleEvent(EventTypeNames::durationchange);
1571 if (isVideo()) 1642 if (isVideo())
1572 scheduleEvent(EventTypeNames::resize); 1643 scheduleEvent(EventTypeNames::resize);
1573 scheduleEvent(EventTypeNames::loadedmetadata); 1644 scheduleEvent(EventTypeNames::loadedmetadata);
1574 if (hasMediaControls()) 1645 if (hasMediaControls())
1575 mediaControls()->reset(); 1646 mediaControls()->reset();
1576 if (renderer()) 1647 if (renderer())
1577 renderer()->updateFromElement(); 1648 renderer()->updateFromElement();
1578 } 1649 }
1579 1650
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
2182 m_lastTimeUpdateEventWallTime = now; 2253 m_lastTimeUpdateEventWallTime = now;
2183 m_lastTimeUpdateEventMovieTime = movieTime; 2254 m_lastTimeUpdateEventMovieTime = movieTime;
2184 } 2255 }
2185 } 2256 }
2186 2257
2187 bool HTMLMediaElement::canPlay() const 2258 bool HTMLMediaElement::canPlay() const
2188 { 2259 {
2189 return paused() || ended() || m_readyState < HAVE_METADATA; 2260 return paused() || ended() || m_readyState < HAVE_METADATA;
2190 } 2261 }
2191 2262
2263 AudioTrackList& HTMLMediaElement::audioTracks()
2264 {
2265 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled());
2266
2267 if (!m_audioTracks)
2268 m_audioTracks = AudioTrackList::create(this);
2269
2270 return *m_audioTracks;
2271 }
2272
2273 void HTMLMediaElement::audioTrackChanged(const AtomicString& audioTrackID, bool enabled)
2274 {
2275 WTF_LOG(Media, "HTMLMediaElement::audioTrackChanged('%s', %d)", audioTrackID .ascii().data(), enabled);
2276 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled());
2277 ASSERT(!audioTrackID.isEmpty());
2278
2279 audioTracks().scheduleChangeEvent();
2280
2281 // FIXME: Add call on m_mediaSource to notify it of track changes once the S ourceBuffer.audioTracks attribute is added.
2282
2283 if (webMediaPlayer())
2284 webMediaPlayer()->enabledAudioTrackChange(audioTrackID, enabled);
2285 }
2286
2287 VideoTrackList& HTMLMediaElement::videoTracks()
2288 {
2289 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled());
2290
2291 if (!m_videoTracks)
2292 m_videoTracks = VideoTrackList::create(this);
2293
2294 return *m_videoTracks;
2295 }
2296
2297 void HTMLMediaElement::selectedVideoTrackChanged(const AtomicString& selectedTra ckID)
2298 {
2299 WTF_LOG(Media, "HTMLMediaElement::selectedVideoTrackChanged('%s')", selected TrackID.ascii().data());
2300 ASSERT(RuntimeEnabledFeatures::audioVideoTracksEnabled());
2301
2302 AtomicString unselectedTrackID;
2303
2304 int oldSelectedIndex = videoTracks().selectedIndex();
2305 if (oldSelectedIndex != -1)
2306 unselectedTrackID = videoTracks().anonymousIndexedGetter(oldSelectedInde x)->id();
2307
2308 ASSERT(unselectedTrackID != selectedTrackID);
2309
2310 videoTracks().trackSelected(selectedTrackID);
2311
2312 // FIXME: Add call on m_mediaSource to notify it of track changes once the S ourceBuffer.videoTracks attribute is added.
2313
2314 ASSERT(!unselectedTrackID.isEmpty() || !selectedTrackID.isEmpty());
2315
2316 if (webMediaPlayer())
2317 webMediaPlayer()->selectedVideoTrackChange(unselectedTrackID, selectedTr ackID);
2318 }
2319
2320 void HTMLMediaElement::addVideoTrack(const AtomicString& id, blink::WebMediaPlay erClient::VideoTrackKind kind, const AtomicString& label, const AtomicString& la nguage, bool selected)
2321 {
2322 AtomicString kindString = VideoKindToString(kind);
2323 WTF_LOG(Media, "HTMLMediaElement::addVideoTrack('%s', '%s', '%s', '%s', %d)" ,
2324 id.ascii().data(), kindString.ascii().data(), label.ascii().data(), lang uage.ascii().data(), selected);
2325 ASSERT(!id.isEmpty());
2326
2327 RefPtr<VideoTrack> videoTrack = VideoTrack::create(this, id, kindString, lab el, language);
2328 videoTracks().add(videoTrack.get());
2329
2330 if (selected)
2331 videoTrack->setSelected(true);
2332 }
2333
2334 void HTMLMediaElement::removeVideoTrack(const AtomicString& id)
2335 {
2336 WTF_LOG(Media, "HTMLMediaElement::removeVideoTrack('%s')", id.ascii().data() );
2337 ASSERT(!id.isEmpty());
2338
2339 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled())
2340 return;
2341
2342 videoTracks().remove(id);
2343 }
2344
2345 void HTMLMediaElement::addAudioTrack(const AtomicString& id, blink::WebMediaPlay erClient::AudioTrackKind kind, const AtomicString& label, const AtomicString& la nguage, bool enabled)
2346 {
2347 AtomicString kindString = AudioKindToString(kind);
2348 WTF_LOG(Media, "HTMLMediaElement::addAudioTrack('%s', '%s', '%s', '%s', %d)" ,
2349 id.ascii().data(), kindString.ascii().data(), label.ascii().data(), lang uage.ascii().data(), enabled);
2350 ASSERT(!id.isEmpty());
2351
2352 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled())
2353 return;
2354
2355 RefPtr<AudioTrack> audioTrack = AudioTrack::create(this, id, kindString, lab el, language);
2356 audioTracks().add(audioTrack.get());
2357
2358 if (enabled)
2359 audioTrack->setEnabled(true);
2360 }
2361
2362 void HTMLMediaElement::removeAudioTrack(const AtomicString& id)
2363 {
2364 WTF_LOG(Media, "HTMLMediaElement::removeAudioTrack('%s')", id.ascii().data() );
2365 ASSERT(!id.isEmpty());
2366
2367 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled())
2368 return;
2369
2370 audioTracks().remove(id);
2371 }
2372
2192 void HTMLMediaElement::mediaPlayerDidAddTextTrack(WebInbandTextTrack* webTrack) 2373 void HTMLMediaElement::mediaPlayerDidAddTextTrack(WebInbandTextTrack* webTrack)
2193 { 2374 {
2194 if (!RuntimeEnabledFeatures::videoTrackEnabled()) 2375 if (!RuntimeEnabledFeatures::videoTrackEnabled())
2195 return; 2376 return;
2196 2377
2197 // 4.8.10.12.2 Sourcing in-band text tracks 2378 // 4.8.10.12.2 Sourcing in-band text tracks
2198 // 1. Associate the relevant data with a new text track and its correspondin g new TextTrack object. 2379 // 1. Associate the relevant data with a new text track and its correspondin g new TextTrack object.
2199 RefPtr<InbandTextTrack> textTrack = InbandTextTrack::create(document(), webT rack); 2380 RefPtr<InbandTextTrack> textTrack = InbandTextTrack::create(document(), webT rack);
2200 2381
2201 // 2. Set the new text track's kind, label, and language based on the semant ics of the relevant data, 2382 // 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
2257 void HTMLMediaElement::removeTextTrack(TextTrack* track) 2438 void HTMLMediaElement::removeTextTrack(TextTrack* track)
2258 { 2439 {
2259 TrackDisplayUpdateScope scope(this); 2440 TrackDisplayUpdateScope scope(this);
2260 m_textTracks->remove(track); 2441 m_textTracks->remove(track);
2261 2442
2262 closeCaptionTracksChanged(); 2443 closeCaptionTracksChanged();
2263 } 2444 }
2264 2445
2265 void HTMLMediaElement::forgetResourceSpecificTracks() 2446 void HTMLMediaElement::forgetResourceSpecificTracks()
2266 { 2447 {
2448 // Implements the "forget the media element's media-resource-specific tracks " algorithm.
2449 // The order is explicitly specified as text, then audio, and finally video. Also
2450 // 'removetrack' events should not be fired.
2267 if (m_textTracks) { 2451 if (m_textTracks) {
2268 TrackDisplayUpdateScope scope(this); 2452 TrackDisplayUpdateScope scope(this);
2269 m_textTracks->removeAllInbandTracks(); 2453 m_textTracks->removeAllInbandTracks();
2270 closeCaptionTracksChanged(); 2454 closeCaptionTracksChanged();
2271 } 2455 }
2456
2457 if (m_audioTracks)
2458 m_audioTracks->removeAll();
2459
2460 if (m_videoTracks)
2461 m_videoTracks->removeAll();
2272 } 2462 }
2273 2463
2274 PassRefPtr<TextTrack> HTMLMediaElement::addTextTrack(const AtomicString& kind, c onst AtomicString& label, const AtomicString& language, ExceptionState& exceptio nState) 2464 PassRefPtr<TextTrack> HTMLMediaElement::addTextTrack(const AtomicString& kind, c onst AtomicString& label, const AtomicString& language, ExceptionState& exceptio nState)
2275 { 2465 {
2276 ASSERT(RuntimeEnabledFeatures::videoTrackEnabled()); 2466 ASSERT(RuntimeEnabledFeatures::videoTrackEnabled());
2277 2467
2278 // 4.8.10.12.4 Text track API 2468 // 4.8.10.12.4 Text track API
2279 // The addTextTrack(kind, label, language) method of media elements, when in voked, must run the following steps: 2469 // The addTextTrack(kind, label, language) method of media elements, when in voked, must run the following steps:
2280 2470
2281 // 1. If kind is not one of the following strings, then throw a SyntaxError exception and abort these steps 2471 // 1. If kind is not one of the following strings, then throw a SyntaxError exception and abort these steps
(...skipping 1291 matching lines...) Expand 10 before | Expand all | Expand 10 after
3573 m_fragmentStartTime = MediaPlayer::invalidTime(); 3763 m_fragmentStartTime = MediaPlayer::invalidTime();
3574 3764
3575 double end = fragmentParser.endTime(); 3765 double end = fragmentParser.endTime();
3576 if (end != MediaFragmentURIParser::invalidTimeValue() && end > 0 && end > m_ fragmentStartTime) { 3766 if (end != MediaFragmentURIParser::invalidTimeValue() && end > 0 && end > m_ fragmentStartTime) {
3577 m_fragmentEndTime = end; 3767 m_fragmentEndTime = end;
3578 if (m_fragmentEndTime > dur) 3768 if (m_fragmentEndTime > dur)
3579 m_fragmentEndTime = dur; 3769 m_fragmentEndTime = dur;
3580 } else 3770 } else
3581 m_fragmentEndTime = MediaPlayer::invalidTime(); 3771 m_fragmentEndTime = MediaPlayer::invalidTime();
3582 3772
3773 // FIXME: Add support for selecting tracks by ID with the Media Fragments tr ack dimension.
3774
3583 if (m_fragmentStartTime != MediaPlayer::invalidTime() && m_readyState < HAVE _FUTURE_DATA) 3775 if (m_fragmentStartTime != MediaPlayer::invalidTime() && m_readyState < HAVE _FUTURE_DATA)
3584 prepareToPlay(); 3776 prepareToPlay();
3585 } 3777 }
3586 3778
3587 void HTMLMediaElement::applyMediaFragmentURI() 3779 void HTMLMediaElement::applyMediaFragmentURI()
3588 { 3780 {
3589 if (m_fragmentStartTime != MediaPlayer::invalidTime()) { 3781 if (m_fragmentStartTime != MediaPlayer::invalidTime()) {
3590 m_sentEndEvent = false; 3782 m_sentEndEvent = false;
3591 UseCounter::count(document(), UseCounter::HTMLMediaElementSeekToFragment Start); 3783 UseCounter::count(document(), UseCounter::HTMLMediaElementSeekToFragment Start);
3592 seek(m_fragmentStartTime, IGNORE_EXCEPTION); 3784 seek(m_fragmentStartTime, IGNORE_EXCEPTION);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
3631 void HTMLMediaElement::mediaPlayerMediaSourceOpened(blink::WebMediaSource* webMe diaSource) 3823 void HTMLMediaElement::mediaPlayerMediaSourceOpened(blink::WebMediaSource* webMe diaSource)
3632 { 3824 {
3633 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource)); 3825 m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource));
3634 } 3826 }
3635 3827
3636 bool HTMLMediaElement::isInteractiveContent() const 3828 bool HTMLMediaElement::isInteractiveContent() const
3637 { 3829 {
3638 return fastHasAttribute(controlsAttr); 3830 return fastHasAttribute(controlsAttr);
3639 } 3831 }
3640 3832
3833 void HTMLMediaElement::createPlaceholderTracksIfNecessary()
3834 {
3835 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled())
3836 return;
3837
3838 // Create a placeholder audio track if |m_player| says it has audio but it d idn't explicitly announce the tracks.
3839 if (m_player->hasAudio() && !audioTracks().length())
3840 addAudioTrack("audio", WebMediaPlayerClient::AudioTrackKindMain, "Audio Track", "", true);
3841
3842 // Create a placeholder video track if |m_player| says it has video but it d idn't explicitly announce the tracks.
3843 if (m_player->hasVideo() && !videoTracks().length())
philipj_slow 2014/03/14 03:51:59 hasVideo() can only be true for HTMLVideoElement,
acolwell GONE FROM CHROMIUM 2014/03/18 22:02:15 This is m_player->hasVideo() not hasVideo(). It re
philipj_slow 2014/03/20 16:17:40 You're right.
3844 addVideoTrack("video", WebMediaPlayerClient::VideoTrackKindMain, "Video Track", "", true);
3641 } 3845 }
3846
3847 void HTMLMediaElement::selectInitialTracksIfNecessary()
3848 {
3849 if (!RuntimeEnabledFeatures::audioVideoTracksEnabled())
3850 return;
3851
3852 // Enable the first audio track if an audio track hasn't been enabled yet.
3853 if (audioTracks().length() > 0 && !audioTracks().hasEnabledTrack())
3854 audioTracks().anonymousIndexedGetter(0)->setEnabled(true);
3855
3856 // Select the first video track if a video track hasn't been selected yet.
3857 if (videoTracks().length() > 0 && videoTracks().selectedIndex() == -1)
3858 videoTracks().anonymousIndexedGetter(0)->setSelected(true);
3859 }
3860
3861 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698