| 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 12 matching lines...) Expand all Loading... |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #ifndef HTMLMediaElement_h | 26 #ifndef HTMLMediaElement_h |
| 27 #define HTMLMediaElement_h | 27 #define HTMLMediaElement_h |
| 28 | 28 |
| 29 #include "core/dom/ActiveDOMObject.h" | 29 #include "core/dom/ActiveDOMObject.h" |
| 30 #include "core/events/GenericEventQueue.h" | 30 #include "core/events/GenericEventQueue.h" |
| 31 #include "core/html/HTMLElement.h" | 31 #include "core/html/HTMLElement.h" |
| 32 #include "core/html/track/TextTrack.h" | 32 #include "core/html/track/TextTrack.h" |
| 33 #include "core/html/track/TextTrackCue.h" | |
| 34 #include "core/html/track/vtt/VTTCue.h" | |
| 35 #include "platform/PODIntervalTree.h" | |
| 36 #include "platform/Supplementable.h" | 33 #include "platform/Supplementable.h" |
| 37 #include "platform/graphics/media/MediaPlayer.h" | 34 #include "platform/graphics/media/MediaPlayer.h" |
| 38 #include "public/platform/WebMediaPlayerClient.h" | 35 #include "public/platform/WebMediaPlayerClient.h" |
| 39 #include "public/platform/WebMimeRegistry.h" | 36 #include "public/platform/WebMimeRegistry.h" |
| 40 | 37 |
| 41 namespace blink { | 38 namespace blink { |
| 42 class WebInbandTextTrack; | 39 class WebInbandTextTrack; |
| 43 class WebLayer; | 40 class WebLayer; |
| 44 } | 41 } |
| 45 | 42 |
| 46 namespace blink { | 43 namespace blink { |
| 47 | 44 |
| 48 #if ENABLE(WEB_AUDIO) | 45 #if ENABLE(WEB_AUDIO) |
| 49 class AudioSourceProvider; | 46 class AudioSourceProvider; |
| 50 class AudioSourceProviderClient; | 47 class AudioSourceProviderClient; |
| 51 #endif | 48 #endif |
| 52 class AudioTrackList; | 49 class AudioTrackList; |
| 53 class ContentType; | 50 class ContentType; |
| 51 class CueTimeline; |
| 54 class Event; | 52 class Event; |
| 55 class ExceptionState; | 53 class ExceptionState; |
| 56 class HTMLSourceElement; | 54 class HTMLSourceElement; |
| 57 class HTMLTrackElement; | 55 class HTMLTrackElement; |
| 58 class KURL; | 56 class KURL; |
| 59 class MediaController; | 57 class MediaController; |
| 60 class MediaControls; | 58 class MediaControls; |
| 61 class MediaError; | 59 class MediaError; |
| 62 class HTMLMediaSource; | 60 class HTMLMediaSource; |
| 63 class TextTrackList; | 61 class TextTrackList; |
| 64 class TimeRanges; | 62 class TimeRanges; |
| 65 class URLRegistry; | 63 class URLRegistry; |
| 66 class VideoTrackList; | 64 class VideoTrackList; |
| 67 | 65 |
| 68 typedef PODIntervalTree<double, TextTrackCue*> CueIntervalTree; | |
| 69 typedef CueIntervalTree::IntervalType CueInterval; | |
| 70 typedef Vector<CueInterval> CueList; | |
| 71 | |
| 72 // FIXME: The inheritance from MediaPlayerClient here should be private inherita
nce. | 66 // FIXME: The inheritance from MediaPlayerClient here should be private inherita
nce. |
| 73 // But it can't be until the Chromium WebMediaPlayerClientImpl class is fixed so
it | 67 // But it can't be until the Chromium WebMediaPlayerClientImpl class is fixed so
it |
| 74 // no longer depends on typecasting a MediaPlayerClient to an HTMLMediaElement. | 68 // no longer depends on typecasting a MediaPlayerClient to an HTMLMediaElement. |
| 75 | 69 |
| 76 class HTMLMediaElement : public HTMLElement, public WillBeHeapSupplementable<HTM
LMediaElement>, public MediaPlayerClient, public ActiveDOMObject { | 70 class HTMLMediaElement : public HTMLElement, public WillBeHeapSupplementable<HTM
LMediaElement>, public MediaPlayerClient, public ActiveDOMObject { |
| 77 DEFINE_WRAPPERTYPEINFO(); | 71 DEFINE_WRAPPERTYPEINFO(); |
| 78 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLMediaElement); | 72 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLMediaElement); |
| 79 public: | 73 public: |
| 80 static blink::WebMimeRegistry::SupportsType supportsType(const ContentType&,
const String& keySystem = String()); | 74 static blink::WebMimeRegistry::SupportsType supportsType(const ContentType&,
const String& keySystem = String()); |
| 81 | 75 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 | 165 |
| 172 AudioTrackList& audioTracks(); | 166 AudioTrackList& audioTracks(); |
| 173 void audioTrackChanged(); | 167 void audioTrackChanged(); |
| 174 | 168 |
| 175 VideoTrackList& videoTracks(); | 169 VideoTrackList& videoTracks(); |
| 176 void selectedVideoTrackChanged(blink::WebMediaPlayer::TrackId*); | 170 void selectedVideoTrackChanged(blink::WebMediaPlayer::TrackId*); |
| 177 | 171 |
| 178 PassRefPtrWillBeRawPtr<TextTrack> addTextTrack(const AtomicString& kind, con
st AtomicString& label, const AtomicString& language, ExceptionState&); | 172 PassRefPtrWillBeRawPtr<TextTrack> addTextTrack(const AtomicString& kind, con
st AtomicString& label, const AtomicString& language, ExceptionState&); |
| 179 | 173 |
| 180 TextTrackList* textTracks(); | 174 TextTrackList* textTracks(); |
| 181 CueList currentlyActiveCues() const { return m_currentlyActiveCues; } | 175 CueTimeline& cueTimeline(); |
| 182 | 176 |
| 183 void addTextTrack(TextTrack*); | 177 void addTextTrack(TextTrack*); |
| 184 void removeTextTrack(TextTrack*); | 178 void removeTextTrack(TextTrack*); |
| 185 void textTracksChanged(); | 179 void textTracksChanged(); |
| 186 void notifyMediaPlayerOfTextTrackChanges(); | 180 void notifyMediaPlayerOfTextTrackChanges(); |
| 187 | 181 |
| 188 // Implements the "forget the media element's media-resource-specific tracks
" algorithm in the HTML5 spec. | 182 // Implements the "forget the media element's media-resource-specific tracks
" algorithm in the HTML5 spec. |
| 189 void forgetResourceSpecificTracks(); | 183 void forgetResourceSpecificTracks(); |
| 190 | 184 |
| 191 void didAddTrackElement(HTMLTrackElement*); | 185 void didAddTrackElement(HTMLTrackElement*); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 203 | 197 |
| 204 void honorUserPreferencesForAutomaticTextTrackSelection(); | 198 void honorUserPreferencesForAutomaticTextTrackSelection(); |
| 205 | 199 |
| 206 bool textTracksAreReady() const; | 200 bool textTracksAreReady() const; |
| 207 enum VisibilityChangeAssumption { | 201 enum VisibilityChangeAssumption { |
| 208 AssumeNoVisibleChange, | 202 AssumeNoVisibleChange, |
| 209 AssumeVisibleChange | 203 AssumeVisibleChange |
| 210 }; | 204 }; |
| 211 void configureTextTrackDisplay(VisibilityChangeAssumption); | 205 void configureTextTrackDisplay(VisibilityChangeAssumption); |
| 212 void updateTextTrackDisplay(); | 206 void updateTextTrackDisplay(); |
| 207 double lastSeekTime() const { return m_lastSeekTime; } |
| 213 void textTrackReadyStateChanged(TextTrack*); | 208 void textTrackReadyStateChanged(TextTrack*); |
| 214 | 209 |
| 215 void textTrackKindChanged(TextTrack*); | 210 void textTrackKindChanged(TextTrack*); |
| 216 void textTrackModeChanged(TextTrack*); | 211 void textTrackModeChanged(TextTrack*); |
| 217 void textTrackAddCues(TextTrack*, const TextTrackCueList*); | |
| 218 void textTrackRemoveCues(TextTrack*, const TextTrackCueList*); | |
| 219 void textTrackAddCue(TextTrack*, PassRefPtrWillBeRawPtr<TextTrackCue>); | |
| 220 void textTrackRemoveCue(TextTrack*, PassRefPtrWillBeRawPtr<TextTrackCue>); | |
| 221 | 212 |
| 222 // EventTarget function. | 213 // EventTarget function. |
| 223 // Both Node (via HTMLElement) and ActiveDOMObject define this method, which | 214 // Both Node (via HTMLElement) and ActiveDOMObject define this method, which |
| 224 // causes an ambiguity error at compile time. This class's constructor | 215 // causes an ambiguity error at compile time. This class's constructor |
| 225 // ensures that both implementations return document, so return the result | 216 // ensures that both implementations return document, so return the result |
| 226 // of one of them here. | 217 // of one of them here. |
| 227 using HTMLElement::executionContext; | 218 using HTMLElement::executionContext; |
| 228 | 219 |
| 229 bool hasSingleSecurityOrigin() const { return !m_player || (webMediaPlayer()
&& webMediaPlayer()->hasSingleSecurityOrigin()); } | 220 bool hasSingleSecurityOrigin() const { return !m_player || (webMediaPlayer()
&& webMediaPlayer()->hasSingleSecurityOrigin()); } |
| 230 | 221 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 260 bool isSafeToLoadURL(const KURL&, InvalidURLAction); | 251 bool isSafeToLoadURL(const KURL&, InvalidURLAction); |
| 261 | 252 |
| 262 // Checks to see if current media data is CORS-same-origin as the | 253 // Checks to see if current media data is CORS-same-origin as the |
| 263 // specified origin. | 254 // specified origin. |
| 264 bool isMediaDataCORSSameOrigin(SecurityOrigin*) const; | 255 bool isMediaDataCORSSameOrigin(SecurityOrigin*) const; |
| 265 | 256 |
| 266 MediaController* controller() const; | 257 MediaController* controller() const; |
| 267 void setController(PassRefPtrWillBeRawPtr<MediaController>); // Resets the M
ediaGroup and sets the MediaController. | 258 void setController(PassRefPtrWillBeRawPtr<MediaController>); // Resets the M
ediaGroup and sets the MediaController. |
| 268 | 259 |
| 269 void scheduleEvent(PassRefPtrWillBeRawPtr<Event>); | 260 void scheduleEvent(PassRefPtrWillBeRawPtr<Event>); |
| 261 void scheduleTimeupdateEvent(bool periodicEvent); |
| 270 | 262 |
| 271 // Returns the "effective media volume" value as specified in the HTML5 spec
. | 263 // Returns the "effective media volume" value as specified in the HTML5 spec
. |
| 272 double effectiveMediaVolume() const; | 264 double effectiveMediaVolume() const; |
| 273 | 265 |
| 274 #if ENABLE(OILPAN) | 266 #if ENABLE(OILPAN) |
| 275 bool isFinalizing() const { return m_isFinalizing; } | 267 bool isFinalizing() const { return m_isFinalizing; } |
| 276 | 268 |
| 277 // Oilpan: finalization of the media element is observable from its | 269 // Oilpan: finalization of the media element is observable from its |
| 278 // attached MediaSource; it entering a closed state. | 270 // attached MediaSource; it entering a closed state. |
| 279 // | 271 // |
| (...skipping 18 matching lines...) Expand all Loading... |
| 298 virtual void attach(const AttachContext& = AttachContext()) override; | 290 virtual void attach(const AttachContext& = AttachContext()) override; |
| 299 | 291 |
| 300 virtual void didMoveToNewDocument(Document& oldDocument) override; | 292 virtual void didMoveToNewDocument(Document& oldDocument) override; |
| 301 | 293 |
| 302 enum DisplayMode { Unknown, Poster, Video }; | 294 enum DisplayMode { Unknown, Poster, Video }; |
| 303 DisplayMode displayMode() const { return m_displayMode; } | 295 DisplayMode displayMode() const { return m_displayMode; } |
| 304 virtual void setDisplayMode(DisplayMode mode) { m_displayMode = mode; } | 296 virtual void setDisplayMode(DisplayMode mode) { m_displayMode = mode; } |
| 305 | 297 |
| 306 void setControllerInternal(PassRefPtrWillBeRawPtr<MediaController>); | 298 void setControllerInternal(PassRefPtrWillBeRawPtr<MediaController>); |
| 307 | 299 |
| 308 bool ignoreTrackDisplayUpdateRequests() const { return m_ignoreTrackDisplayU
pdate > 0; } | |
| 309 void beginIgnoringTrackDisplayUpdateRequests(); | |
| 310 void endIgnoringTrackDisplayUpdateRequests(); | |
| 311 | |
| 312 private: | 300 private: |
| 313 void createMediaPlayer(); | 301 void createMediaPlayer(); |
| 314 | 302 |
| 315 virtual bool alwaysCreateUserAgentShadowRoot() const override final { return
true; } | 303 virtual bool alwaysCreateUserAgentShadowRoot() const override final { return
true; } |
| 316 virtual bool areAuthorShadowsAllowed() const override final { return false;
} | 304 virtual bool areAuthorShadowsAllowed() const override final { return false;
} |
| 317 | 305 |
| 318 virtual bool supportsFocus() const override final; | 306 virtual bool supportsFocus() const override final; |
| 319 virtual bool isMouseFocusable() const override final; | 307 virtual bool isMouseFocusable() const override final; |
| 320 virtual bool rendererIsNeeded(const LayoutStyle&) override; | 308 virtual bool rendererIsNeeded(const LayoutStyle&) override; |
| 321 virtual LayoutObject* createRenderer(const LayoutStyle&) override; | 309 virtual LayoutObject* createRenderer(const LayoutStyle&) override; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 void playbackProgressTimerFired(Timer<HTMLMediaElement>*); | 342 void playbackProgressTimerFired(Timer<HTMLMediaElement>*); |
| 355 void startPlaybackProgressTimer(); | 343 void startPlaybackProgressTimer(); |
| 356 void startProgressEventTimer(); | 344 void startProgressEventTimer(); |
| 357 void stopPeriodicTimers(); | 345 void stopPeriodicTimers(); |
| 358 | 346 |
| 359 void seek(double time); | 347 void seek(double time); |
| 360 void finishSeek(); | 348 void finishSeek(); |
| 361 void checkIfSeekNeeded(); | 349 void checkIfSeekNeeded(); |
| 362 void addPlayedRange(double start, double end); | 350 void addPlayedRange(double start, double end); |
| 363 | 351 |
| 364 void scheduleTimeupdateEvent(bool periodicEvent); | |
| 365 void scheduleEvent(const AtomicString& eventName); // FIXME: Rename to sched
uleNamedEvent for clarity. | 352 void scheduleEvent(const AtomicString& eventName); // FIXME: Rename to sched
uleNamedEvent for clarity. |
| 366 | 353 |
| 367 // loading | 354 // loading |
| 368 void prepareForLoad(); | 355 void prepareForLoad(); |
| 369 void loadInternal(); | 356 void loadInternal(); |
| 370 void selectMediaResource(); | 357 void selectMediaResource(); |
| 371 void loadResource(const KURL&, ContentType&, const String& keySystem); | 358 void loadResource(const KURL&, ContentType&, const String& keySystem); |
| 372 void startPlayerLoad(); | 359 void startPlayerLoad(); |
| 373 void setPlayerPreload(); | 360 void setPlayerPreload(); |
| 374 blink::WebMediaPlayer::LoadType loadType() const; | 361 blink::WebMediaPlayer::LoadType loadType() const; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 389 void mediaLoadingFailed(blink::WebMediaPlayer::NetworkState); | 376 void mediaLoadingFailed(blink::WebMediaPlayer::NetworkState); |
| 390 | 377 |
| 391 // deferred loading (preload=none) | 378 // deferred loading (preload=none) |
| 392 bool loadIsDeferred() const; | 379 bool loadIsDeferred() const; |
| 393 void deferLoad(); | 380 void deferLoad(); |
| 394 void cancelDeferredLoad(); | 381 void cancelDeferredLoad(); |
| 395 void startDeferredLoad(); | 382 void startDeferredLoad(); |
| 396 void executeDeferredLoad(); | 383 void executeDeferredLoad(); |
| 397 void deferredLoadTimerFired(Timer<HTMLMediaElement>*); | 384 void deferredLoadTimerFired(Timer<HTMLMediaElement>*); |
| 398 | 385 |
| 399 void updateActiveTextTrackCues(double); | |
| 400 HTMLTrackElement* showingTrackWithSameKind(HTMLTrackElement*) const; | 386 HTMLTrackElement* showingTrackWithSameKind(HTMLTrackElement*) const; |
| 401 | 387 |
| 402 void markCaptionAndSubtitleTracksAsUnconfigured(); | 388 void markCaptionAndSubtitleTracksAsUnconfigured(); |
| 403 | 389 |
| 404 // This does not check user gesture restrictions. | 390 // This does not check user gesture restrictions. |
| 405 void playInternal(); | 391 void playInternal(); |
| 406 | 392 |
| 407 void gesturelessInitialPlayHalted(); | 393 void gesturelessInitialPlayHalted(); |
| 408 void autoplayMediaEncountered(); | 394 void autoplayMediaEncountered(); |
| 409 void allowVideoRendering(); | 395 void allowVideoRendering(); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 | 538 |
| 553 bool m_tracksAreReady : 1; | 539 bool m_tracksAreReady : 1; |
| 554 bool m_haveVisibleTextTrack : 1; | 540 bool m_haveVisibleTextTrack : 1; |
| 555 bool m_processingPreferenceChange : 1; | 541 bool m_processingPreferenceChange : 1; |
| 556 bool m_remoteRoutesAvailable : 1; | 542 bool m_remoteRoutesAvailable : 1; |
| 557 bool m_playingRemotely : 1; | 543 bool m_playingRemotely : 1; |
| 558 #if ENABLE(OILPAN) | 544 #if ENABLE(OILPAN) |
| 559 bool m_isFinalizing : 1; | 545 bool m_isFinalizing : 1; |
| 560 bool m_closeMediaSourceWhenFinalizing : 1; | 546 bool m_closeMediaSourceWhenFinalizing : 1; |
| 561 #endif | 547 #endif |
| 562 double m_lastTextTrackUpdateTime; | |
| 563 bool m_initialPlayWithoutUserGestures : 1; | 548 bool m_initialPlayWithoutUserGestures : 1; |
| 564 bool m_autoplayMediaCounted : 1; | 549 bool m_autoplayMediaCounted : 1; |
| 565 | 550 |
| 566 RefPtrWillBeMember<AudioTrackList> m_audioTracks; | 551 RefPtrWillBeMember<AudioTrackList> m_audioTracks; |
| 567 RefPtrWillBeMember<VideoTrackList> m_videoTracks; | 552 RefPtrWillBeMember<VideoTrackList> m_videoTracks; |
| 568 RefPtrWillBeMember<TextTrackList> m_textTracks; | 553 RefPtrWillBeMember<TextTrackList> m_textTracks; |
| 569 WillBeHeapVector<RefPtrWillBeMember<TextTrack>> m_textTracksWhenResourceSele
ctionBegan; | 554 WillBeHeapVector<RefPtrWillBeMember<TextTrack>> m_textTracksWhenResourceSele
ctionBegan; |
| 570 | 555 |
| 571 CueIntervalTree m_cueTree; | 556 OwnPtrWillBeMember<CueTimeline> m_cueTimeline; |
| 572 | |
| 573 CueList m_currentlyActiveCues; | |
| 574 int m_ignoreTrackDisplayUpdate; | |
| 575 | 557 |
| 576 #if ENABLE(WEB_AUDIO) | 558 #if ENABLE(WEB_AUDIO) |
| 577 // This is a weak reference, since m_audioSourceNode holds a reference to us
. | 559 // This is a weak reference, since m_audioSourceNode holds a reference to us
. |
| 578 // FIXME: Oilpan: Consider making this a strongly traced pointer with oilpan
where strong cycles are not a problem. | 560 // FIXME: Oilpan: Consider making this a strongly traced pointer with oilpan
where strong cycles are not a problem. |
| 579 GC_PLUGIN_IGNORE("http://crbug.com/404577") | 561 GC_PLUGIN_IGNORE("http://crbug.com/404577") |
| 580 RawPtrWillBeWeakMember<AudioSourceProviderClient> m_audioSourceNode; | 562 RawPtrWillBeWeakMember<AudioSourceProviderClient> m_audioSourceNode; |
| 581 #endif | 563 #endif |
| 582 | 564 |
| 583 friend class MediaController; | 565 friend class MediaController; |
| 584 RefPtrWillBeMember<MediaController> m_mediaController; | 566 RefPtrWillBeMember<MediaController> m_mediaController; |
| 585 | 567 |
| 586 friend class Internals; | 568 friend class Internals; |
| 587 friend class TrackDisplayUpdateScope; | 569 friend class TrackDisplayUpdateScope; |
| 588 | 570 |
| 589 static URLRegistry* s_mediaStreamRegistry; | 571 static URLRegistry* s_mediaStreamRegistry; |
| 590 }; | 572 }; |
| 591 | 573 |
| 592 #ifndef NDEBUG | |
| 593 // Template specializations required by PodIntervalTree in debug mode. | |
| 594 template <> | |
| 595 struct ValueToString<double> { | |
| 596 static String string(const double value) | |
| 597 { | |
| 598 return String::number(value); | |
| 599 } | |
| 600 }; | |
| 601 | |
| 602 template <> | |
| 603 struct ValueToString<TextTrackCue*> { | |
| 604 static String string(TextTrackCue* const& cue) | |
| 605 { | |
| 606 return cue->toString(); | |
| 607 } | |
| 608 }; | |
| 609 #endif | |
| 610 | |
| 611 inline bool isHTMLMediaElement(const HTMLElement& element) | 574 inline bool isHTMLMediaElement(const HTMLElement& element) |
| 612 { | 575 { |
| 613 return isHTMLAudioElement(element) || isHTMLVideoElement(element); | 576 return isHTMLAudioElement(element) || isHTMLVideoElement(element); |
| 614 } | 577 } |
| 615 | 578 |
| 616 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); | 579 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); |
| 617 | 580 |
| 618 } // namespace blink | 581 } // namespace blink |
| 619 | 582 |
| 620 #endif // HTMLMediaElement_h | 583 #endif // HTMLMediaElement_h |
| OLD | NEW |