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