| 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 11 matching lines...) Expand all Loading... |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 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/CoreExport.h" | 29 #include "core/CoreExport.h" |
| 30 #include "core/dom/ActiveDOMObject.h" | 30 #include "core/dom/ActiveDOMObject.h" |
| 31 #include "core/events/GenericEventQueue.h" | 31 #include "core/events/GenericEventQueue.h" |
| 32 #include "core/html/AutoplayExperimentHelper.h" |
| 32 #include "core/html/HTMLElement.h" | 33 #include "core/html/HTMLElement.h" |
| 33 #include "core/html/track/TextTrack.h" | 34 #include "core/html/track/TextTrack.h" |
| 34 #include "platform/Supplementable.h" | 35 #include "platform/Supplementable.h" |
| 35 #include "public/platform/WebMediaPlayerClient.h" | 36 #include "public/platform/WebMediaPlayerClient.h" |
| 36 #include "public/platform/WebMimeRegistry.h" | 37 #include "public/platform/WebMimeRegistry.h" |
| 37 | 38 |
| 38 #if ENABLE(WEB_AUDIO) | 39 #if ENABLE(WEB_AUDIO) |
| 39 #include "platform/audio/AudioSourceProvider.h" | 40 #include "platform/audio/AudioSourceProvider.h" |
| 40 #include "public/platform/WebAudioSourceProviderClient.h" | 41 #include "public/platform/WebAudioSourceProviderClient.h" |
| 41 #endif | 42 #endif |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 bool paused() const; | 134 bool paused() const; |
| 134 double defaultPlaybackRate() const; | 135 double defaultPlaybackRate() const; |
| 135 void setDefaultPlaybackRate(double); | 136 void setDefaultPlaybackRate(double); |
| 136 double playbackRate() const; | 137 double playbackRate() const; |
| 137 void setPlaybackRate(double); | 138 void setPlaybackRate(double); |
| 138 void updatePlaybackRate(); | 139 void updatePlaybackRate(); |
| 139 TimeRanges* played(); | 140 TimeRanges* played(); |
| 140 TimeRanges* seekable() const; | 141 TimeRanges* seekable() const; |
| 141 bool ended() const; | 142 bool ended() const; |
| 142 bool autoplay() const; | 143 bool autoplay() const; |
| 144 bool shouldAutoplay() const; |
| 143 bool loop() const; | 145 bool loop() const; |
| 144 void setLoop(bool); | 146 void setLoop(bool); |
| 145 void play(); | 147 void play(); |
| 146 void pause(); | 148 void pause(); |
| 147 void requestRemotePlayback(); | 149 void requestRemotePlayback(); |
| 148 void requestRemotePlaybackControl(); | 150 void requestRemotePlaybackControl(); |
| 149 | 151 |
| 150 // statistics | 152 // statistics |
| 151 unsigned webkitAudioDecodedByteCount() const; | 153 unsigned webkitAudioDecodedByteCount() const; |
| 152 unsigned webkitVideoDecodedByteCount() const; | 154 unsigned webkitVideoDecodedByteCount() const; |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 void cancelDeferredLoad(); | 381 void cancelDeferredLoad(); |
| 380 void startDeferredLoad(); | 382 void startDeferredLoad(); |
| 381 void executeDeferredLoad(); | 383 void executeDeferredLoad(); |
| 382 void deferredLoadTimerFired(Timer<HTMLMediaElement>*); | 384 void deferredLoadTimerFired(Timer<HTMLMediaElement>*); |
| 383 | 385 |
| 384 void markCaptionAndSubtitleTracksAsUnconfigured(); | 386 void markCaptionAndSubtitleTracksAsUnconfigured(); |
| 385 | 387 |
| 386 // This does not check user gesture restrictions. | 388 // This does not check user gesture restrictions. |
| 387 void playInternal(); | 389 void playInternal(); |
| 388 | 390 |
| 389 void gesturelessInitialPlayHalted(); | 391 // If we are about to enter a paused state, call this to record |
| 392 // autoplay metrics. If we were already in a stopped state, then |
| 393 // this does nothing. |
| 394 void recordMetricsIfPausing(); |
| 395 // Could stopping at this point be considered a bailout of playback? |
| 396 // (as in, "The user really didn't want to play this"). |
| 397 bool isBailout() const; |
| 390 void autoplayMediaEncountered(); | 398 void autoplayMediaEncountered(); |
| 391 void allowVideoRendering(); | 399 void allowVideoRendering(); |
| 392 | 400 |
| 393 void updateVolume(); | 401 void updateVolume(); |
| 394 void updatePlayState(); | 402 void updatePlayState(); |
| 395 bool potentiallyPlaying() const; | 403 bool potentiallyPlaying() const; |
| 396 bool stoppedDueToErrors() const; | 404 bool stoppedDueToErrors() const; |
| 397 bool couldPlayIfEnoughData() const; | 405 bool couldPlayIfEnoughData() const; |
| 398 | 406 |
| 399 // Generally the presence of the loop attribute should be considered to mean
playback | 407 // Generally the presence of the loop attribute should be considered to mean
playback |
| (...skipping 17 matching lines...) Expand all Loading... |
| 417 | 425 |
| 418 const AtomicString& mediaGroup() const; | 426 const AtomicString& mediaGroup() const; |
| 419 void setMediaGroup(const AtomicString&); | 427 void setMediaGroup(const AtomicString&); |
| 420 void updateMediaController(); | 428 void updateMediaController(); |
| 421 bool isBlocked() const; | 429 bool isBlocked() const; |
| 422 bool isBlockedOnMediaController() const; | 430 bool isBlockedOnMediaController() const; |
| 423 bool isAutoplaying() const { return m_autoplaying; } | 431 bool isAutoplaying() const { return m_autoplaying; } |
| 424 | 432 |
| 425 void setAllowHiddenVolumeControls(bool); | 433 void setAllowHiddenVolumeControls(bool); |
| 426 | 434 |
| 435 void recordAutoplayMetric(AutoplayMetrics); |
| 436 |
| 427 WebMediaPlayer::CORSMode corsMode() const; | 437 WebMediaPlayer::CORSMode corsMode() const; |
| 428 | 438 |
| 429 // Returns the "direction of playback" value as specified in the HTML5 spec. | 439 // Returns the "direction of playback" value as specified in the HTML5 spec. |
| 430 enum DirectionOfPlayback { Backward, Forward }; | 440 enum DirectionOfPlayback { Backward, Forward }; |
| 431 DirectionOfPlayback directionOfPlayback() const; | 441 DirectionOfPlayback directionOfPlayback() const; |
| 432 | 442 |
| 433 // Returns the "effective playback rate" value as specified in the HTML5 spe
c. | 443 // Returns the "effective playback rate" value as specified in the HTML5 spe
c. |
| 434 double effectivePlaybackRate() const; | 444 double effectivePlaybackRate() const; |
| 435 | 445 |
| 436 // Creates placeholder AudioTrack and/or VideoTrack objects when WebMemediaP
layer objects | 446 // Creates placeholder AudioTrack and/or VideoTrack objects when WebMemediaP
layer objects |
| 437 // advertise they have audio and/or video, but don't explicitly signal them
via | 447 // advertise they have audio and/or video, but don't explicitly signal them
via |
| 438 // addAudioTrack() and addVideoTrack(). | 448 // addAudioTrack() and addVideoTrack(). |
| 439 // FIXME: Remove this once all WebMediaPlayer implementations properly repor
t their track info. | 449 // FIXME: Remove this once all WebMediaPlayer implementations properly repor
t their track info. |
| 440 void createPlaceholderTracksIfNecessary(); | 450 void createPlaceholderTracksIfNecessary(); |
| 441 | 451 |
| 442 // Sets the selected/enabled tracks if they aren't set before we initially | 452 // Sets the selected/enabled tracks if they aren't set before we initially |
| 443 // transition to HAVE_METADATA. | 453 // transition to HAVE_METADATA. |
| 444 void selectInitialTracksIfNecessary(); | 454 void selectInitialTracksIfNecessary(); |
| 445 | 455 |
| 456 // Return true if and only if we require a user gesture before letting |
| 457 // the media play. |
| 458 bool isUserGestureRequiredForPlay() const; |
| 459 void removeUserGestureRequirement(); |
| 460 void setInitialPlayWithoutUserGestures(bool); |
| 461 |
| 446 void audioTracksTimerFired(Timer<HTMLMediaElement>*); | 462 void audioTracksTimerFired(Timer<HTMLMediaElement>*); |
| 447 | 463 |
| 448 Timer<HTMLMediaElement> m_loadTimer; | 464 Timer<HTMLMediaElement> m_loadTimer; |
| 449 Timer<HTMLMediaElement> m_progressEventTimer; | 465 Timer<HTMLMediaElement> m_progressEventTimer; |
| 450 Timer<HTMLMediaElement> m_playbackProgressTimer; | 466 Timer<HTMLMediaElement> m_playbackProgressTimer; |
| 451 Timer<HTMLMediaElement> m_audioTracksTimer; | 467 Timer<HTMLMediaElement> m_audioTracksTimer; |
| 452 PersistentWillBeMember<TimeRanges> m_playedTimeRanges; | 468 PersistentWillBeMember<TimeRanges> m_playedTimeRanges; |
| 453 OwnPtrWillBeMember<GenericEventQueue> m_asyncEventQueue; | 469 OwnPtrWillBeMember<GenericEventQueue> m_asyncEventQueue; |
| 454 | 470 |
| 455 double m_playbackRate; | 471 double m_playbackRate; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 bool m_completelyLoaded : 1; | 553 bool m_completelyLoaded : 1; |
| 538 bool m_havePreparedToPlay : 1; | 554 bool m_havePreparedToPlay : 1; |
| 539 bool m_delayingLoadForPreloadNone : 1; | 555 bool m_delayingLoadForPreloadNone : 1; |
| 540 | 556 |
| 541 bool m_tracksAreReady : 1; | 557 bool m_tracksAreReady : 1; |
| 542 bool m_haveVisibleTextTrack : 1; | 558 bool m_haveVisibleTextTrack : 1; |
| 543 bool m_processingPreferenceChange : 1; | 559 bool m_processingPreferenceChange : 1; |
| 544 bool m_remoteRoutesAvailable : 1; | 560 bool m_remoteRoutesAvailable : 1; |
| 545 bool m_playingRemotely : 1; | 561 bool m_playingRemotely : 1; |
| 546 bool m_isFinalizing : 1; | 562 bool m_isFinalizing : 1; |
| 547 bool m_initialPlayWithoutUserGestures : 1; | 563 bool m_initialPlayWithoutUserGesture : 1; |
| 548 bool m_autoplayMediaCounted : 1; | 564 bool m_autoplayMediaCounted : 1; |
| 549 // Whether this element is in overlay fullscreen mode. | 565 // Whether this element is in overlay fullscreen mode. |
| 550 bool m_inOverlayFullscreenVideo : 1; | 566 bool m_inOverlayFullscreenVideo : 1; |
| 551 | 567 |
| 552 PersistentWillBeMember<AudioTrackList> m_audioTracks; | 568 PersistentWillBeMember<AudioTrackList> m_audioTracks; |
| 553 PersistentWillBeMember<VideoTrackList> m_videoTracks; | 569 PersistentWillBeMember<VideoTrackList> m_videoTracks; |
| 554 PersistentWillBeMember<TextTrackList> m_textTracks; | 570 PersistentWillBeMember<TextTrackList> m_textTracks; |
| 555 PersistentHeapVectorWillBeHeapVector<Member<TextTrack>> m_textTracksWhenReso
urceSelectionBegan; | 571 PersistentHeapVectorWillBeHeapVector<Member<TextTrack>> m_textTracksWhenReso
urceSelectionBegan; |
| 556 | 572 |
| 557 OwnPtrWillBeMember<CueTimeline> m_cueTimeline; | 573 OwnPtrWillBeMember<CueTimeline> m_cueTimeline; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 }; | 626 }; |
| 611 | 627 |
| 612 AudioSourceProviderImpl m_audioSourceProvider; | 628 AudioSourceProviderImpl m_audioSourceProvider; |
| 613 #endif | 629 #endif |
| 614 | 630 |
| 615 friend class MediaController; | 631 friend class MediaController; |
| 616 PersistentWillBeMember<MediaController> m_mediaController; | 632 PersistentWillBeMember<MediaController> m_mediaController; |
| 617 | 633 |
| 618 friend class Internals; | 634 friend class Internals; |
| 619 friend class TrackDisplayUpdateScope; | 635 friend class TrackDisplayUpdateScope; |
| 636 friend class AutoplayExperimentHelper; |
| 637 |
| 638 AutoplayExperimentHelper m_autoplayHelper; |
| 620 | 639 |
| 621 static URLRegistry* s_mediaStreamRegistry; | 640 static URLRegistry* s_mediaStreamRegistry; |
| 622 }; | 641 }; |
| 623 | 642 |
| 624 inline bool isHTMLMediaElement(const HTMLElement& element) | 643 inline bool isHTMLMediaElement(const HTMLElement& element) |
| 625 { | 644 { |
| 626 return isHTMLAudioElement(element) || isHTMLVideoElement(element); | 645 return isHTMLAudioElement(element) || isHTMLVideoElement(element); |
| 627 } | 646 } |
| 628 | 647 |
| 629 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); | 648 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); |
| 630 | 649 |
| 631 } // namespace blink | 650 } // namespace blink |
| 632 | 651 |
| 633 #endif // HTMLMediaElement_h | 652 #endif // HTMLMediaElement_h |
| OLD | NEW |