| 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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 void scheduleEvent(PassRefPtrWillBeRawPtr<Event>); | 256 void scheduleEvent(PassRefPtrWillBeRawPtr<Event>); |
| 256 void scheduleTimeupdateEvent(bool periodicEvent); | 257 void scheduleTimeupdateEvent(bool periodicEvent); |
| 257 | 258 |
| 258 // Returns the "effective media volume" value as specified in the HTML5 spec
. | 259 // Returns the "effective media volume" value as specified in the HTML5 spec
. |
| 259 double effectiveMediaVolume() const; | 260 double effectiveMediaVolume() const; |
| 260 | 261 |
| 261 // Predicates also used when dispatching wrapper creation (cf. [SpecialWrapF
or] IDL attribute usage.) | 262 // Predicates also used when dispatching wrapper creation (cf. [SpecialWrapF
or] IDL attribute usage.) |
| 262 virtual bool isHTMLAudioElement() const { return false; } | 263 virtual bool isHTMLAudioElement() const { return false; } |
| 263 virtual bool isHTMLVideoElement() const { return false; } | 264 virtual bool isHTMLVideoElement() const { return false; } |
| 264 | 265 |
| 266 // Temporary callback for crbug.com/487345,402044 |
| 267 void notifyPositionMayHaveChanged(); |
| 268 |
| 265 protected: | 269 protected: |
| 266 HTMLMediaElement(const QualifiedName&, Document&); | 270 HTMLMediaElement(const QualifiedName&, Document&); |
| 267 ~HTMLMediaElement() override; | 271 ~HTMLMediaElement() override; |
| 268 #if ENABLE(OILPAN) | 272 #if ENABLE(OILPAN) |
| 269 void dispose(); | 273 void dispose(); |
| 270 #endif | 274 #endif |
| 271 | 275 |
| 272 void parseAttribute(const QualifiedName&, const AtomicString&) override; | 276 void parseAttribute(const QualifiedName&, const AtomicString&) override; |
| 273 void finishParsingChildren() final; | 277 void finishParsingChildren() final; |
| 274 bool isURLAttribute(const Attribute&) const override; | 278 bool isURLAttribute(const Attribute&) const override; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 void cancelDeferredLoad(); | 383 void cancelDeferredLoad(); |
| 380 void startDeferredLoad(); | 384 void startDeferredLoad(); |
| 381 void executeDeferredLoad(); | 385 void executeDeferredLoad(); |
| 382 void deferredLoadTimerFired(Timer<HTMLMediaElement>*); | 386 void deferredLoadTimerFired(Timer<HTMLMediaElement>*); |
| 383 | 387 |
| 384 void markCaptionAndSubtitleTracksAsUnconfigured(); | 388 void markCaptionAndSubtitleTracksAsUnconfigured(); |
| 385 | 389 |
| 386 // This does not check user gesture restrictions. | 390 // This does not check user gesture restrictions. |
| 387 void playInternal(); | 391 void playInternal(); |
| 388 | 392 |
| 389 void gesturelessInitialPlayHalted(); | 393 // If we are about to enter a paused state, call this to record |
| 394 // autoplay metrics. If we were already in a stopped state, then |
| 395 // this does nothing. |
| 396 void recordMetricsIfPausing(); |
| 397 // Could stopping at this point be considered a bailout of playback? |
| 398 // (as in, "The user really didn't want to play this"). |
| 399 bool isBailout() const; |
| 390 void autoplayMediaEncountered(); | 400 void autoplayMediaEncountered(); |
| 391 void allowVideoRendering(); | 401 void allowVideoRendering(); |
| 392 | 402 |
| 393 void updateVolume(); | 403 void updateVolume(); |
| 394 void updatePlayState(); | 404 void updatePlayState(); |
| 395 bool potentiallyPlaying() const; | 405 bool potentiallyPlaying() const; |
| 396 bool stoppedDueToErrors() const; | 406 bool stoppedDueToErrors() const; |
| 397 bool couldPlayIfEnoughData() const; | 407 bool couldPlayIfEnoughData() const; |
| 398 | 408 |
| 399 // Generally the presence of the loop attribute should be considered to mean
playback | 409 // Generally the presence of the loop attribute should be considered to mean
playback |
| (...skipping 17 matching lines...) Expand all Loading... |
| 417 | 427 |
| 418 const AtomicString& mediaGroup() const; | 428 const AtomicString& mediaGroup() const; |
| 419 void setMediaGroup(const AtomicString&); | 429 void setMediaGroup(const AtomicString&); |
| 420 void updateMediaController(); | 430 void updateMediaController(); |
| 421 bool isBlocked() const; | 431 bool isBlocked() const; |
| 422 bool isBlockedOnMediaController() const; | 432 bool isBlockedOnMediaController() const; |
| 423 bool isAutoplaying() const { return m_autoplaying; } | 433 bool isAutoplaying() const { return m_autoplaying; } |
| 424 | 434 |
| 425 void setAllowHiddenVolumeControls(bool); | 435 void setAllowHiddenVolumeControls(bool); |
| 426 | 436 |
| 437 void recordAutoplayMetric(AutoplayMetrics); |
| 438 |
| 427 WebMediaPlayer::CORSMode corsMode() const; | 439 WebMediaPlayer::CORSMode corsMode() const; |
| 428 | 440 |
| 429 // Returns the "direction of playback" value as specified in the HTML5 spec. | 441 // Returns the "direction of playback" value as specified in the HTML5 spec. |
| 430 enum DirectionOfPlayback { Backward, Forward }; | 442 enum DirectionOfPlayback { Backward, Forward }; |
| 431 DirectionOfPlayback directionOfPlayback() const; | 443 DirectionOfPlayback directionOfPlayback() const; |
| 432 | 444 |
| 433 // Returns the "effective playback rate" value as specified in the HTML5 spe
c. | 445 // Returns the "effective playback rate" value as specified in the HTML5 spe
c. |
| 434 double effectivePlaybackRate() const; | 446 double effectivePlaybackRate() const; |
| 435 | 447 |
| 436 // Creates placeholder AudioTrack and/or VideoTrack objects when WebMemediaP
layer objects | 448 // 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 | 449 // advertise they have audio and/or video, but don't explicitly signal them
via |
| 438 // addAudioTrack() and addVideoTrack(). | 450 // addAudioTrack() and addVideoTrack(). |
| 439 // FIXME: Remove this once all WebMediaPlayer implementations properly repor
t their track info. | 451 // FIXME: Remove this once all WebMediaPlayer implementations properly repor
t their track info. |
| 440 void createPlaceholderTracksIfNecessary(); | 452 void createPlaceholderTracksIfNecessary(); |
| 441 | 453 |
| 442 // Sets the selected/enabled tracks if they aren't set before we initially | 454 // Sets the selected/enabled tracks if they aren't set before we initially |
| 443 // transition to HAVE_METADATA. | 455 // transition to HAVE_METADATA. |
| 444 void selectInitialTracksIfNecessary(); | 456 void selectInitialTracksIfNecessary(); |
| 445 | 457 |
| 458 // Return true if and only if we require a user gesture before letting |
| 459 // the media play. |
| 460 bool isUserGestureRequiredForPlay() const; |
| 461 void removeUserGestureRequirement(); |
| 462 void setInitialPlayWithoutUserGestures(bool); |
| 463 |
| 446 void audioTracksTimerFired(Timer<HTMLMediaElement>*); | 464 void audioTracksTimerFired(Timer<HTMLMediaElement>*); |
| 447 | 465 |
| 466 // For tests. |
| 467 void triggerAutoplayViewportCheck(); |
| 468 |
| 448 Timer<HTMLMediaElement> m_loadTimer; | 469 Timer<HTMLMediaElement> m_loadTimer; |
| 449 Timer<HTMLMediaElement> m_progressEventTimer; | 470 Timer<HTMLMediaElement> m_progressEventTimer; |
| 450 Timer<HTMLMediaElement> m_playbackProgressTimer; | 471 Timer<HTMLMediaElement> m_playbackProgressTimer; |
| 451 Timer<HTMLMediaElement> m_audioTracksTimer; | 472 Timer<HTMLMediaElement> m_audioTracksTimer; |
| 452 PersistentWillBeMember<TimeRanges> m_playedTimeRanges; | 473 PersistentWillBeMember<TimeRanges> m_playedTimeRanges; |
| 453 OwnPtrWillBeMember<GenericEventQueue> m_asyncEventQueue; | 474 OwnPtrWillBeMember<GenericEventQueue> m_asyncEventQueue; |
| 454 | 475 |
| 455 double m_playbackRate; | 476 double m_playbackRate; |
| 456 double m_defaultPlaybackRate; | 477 double m_defaultPlaybackRate; |
| 457 NetworkState m_networkState; | 478 NetworkState m_networkState; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 bool m_completelyLoaded : 1; | 558 bool m_completelyLoaded : 1; |
| 538 bool m_havePreparedToPlay : 1; | 559 bool m_havePreparedToPlay : 1; |
| 539 bool m_delayingLoadForPreloadNone : 1; | 560 bool m_delayingLoadForPreloadNone : 1; |
| 540 | 561 |
| 541 bool m_tracksAreReady : 1; | 562 bool m_tracksAreReady : 1; |
| 542 bool m_haveVisibleTextTrack : 1; | 563 bool m_haveVisibleTextTrack : 1; |
| 543 bool m_processingPreferenceChange : 1; | 564 bool m_processingPreferenceChange : 1; |
| 544 bool m_remoteRoutesAvailable : 1; | 565 bool m_remoteRoutesAvailable : 1; |
| 545 bool m_playingRemotely : 1; | 566 bool m_playingRemotely : 1; |
| 546 bool m_isFinalizing : 1; | 567 bool m_isFinalizing : 1; |
| 547 bool m_initialPlayWithoutUserGestures : 1; | 568 bool m_initialPlayWithoutUserGesture : 1; |
| 548 bool m_autoplayMediaCounted : 1; | 569 bool m_autoplayMediaCounted : 1; |
| 549 // Whether this element is in overlay fullscreen mode. | 570 // Whether this element is in overlay fullscreen mode. |
| 550 bool m_inOverlayFullscreenVideo : 1; | 571 bool m_inOverlayFullscreenVideo : 1; |
| 551 | 572 |
| 552 PersistentWillBeMember<AudioTrackList> m_audioTracks; | 573 PersistentWillBeMember<AudioTrackList> m_audioTracks; |
| 553 PersistentWillBeMember<VideoTrackList> m_videoTracks; | 574 PersistentWillBeMember<VideoTrackList> m_videoTracks; |
| 554 PersistentWillBeMember<TextTrackList> m_textTracks; | 575 PersistentWillBeMember<TextTrackList> m_textTracks; |
| 555 PersistentHeapVectorWillBeHeapVector<Member<TextTrack>> m_textTracksWhenReso
urceSelectionBegan; | 576 PersistentHeapVectorWillBeHeapVector<Member<TextTrack>> m_textTracksWhenReso
urceSelectionBegan; |
| 556 | 577 |
| 557 OwnPtrWillBeMember<CueTimeline> m_cueTimeline; | 578 OwnPtrWillBeMember<CueTimeline> m_cueTimeline; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 }; | 631 }; |
| 611 | 632 |
| 612 AudioSourceProviderImpl m_audioSourceProvider; | 633 AudioSourceProviderImpl m_audioSourceProvider; |
| 613 #endif | 634 #endif |
| 614 | 635 |
| 615 friend class MediaController; | 636 friend class MediaController; |
| 616 PersistentWillBeMember<MediaController> m_mediaController; | 637 PersistentWillBeMember<MediaController> m_mediaController; |
| 617 | 638 |
| 618 friend class Internals; | 639 friend class Internals; |
| 619 friend class TrackDisplayUpdateScope; | 640 friend class TrackDisplayUpdateScope; |
| 641 friend class AutoplayExperimentHelper; |
| 642 |
| 643 AutoplayExperimentHelper m_autoplayHelper; |
| 620 | 644 |
| 621 static URLRegistry* s_mediaStreamRegistry; | 645 static URLRegistry* s_mediaStreamRegistry; |
| 622 }; | 646 }; |
| 623 | 647 |
| 624 inline bool isHTMLMediaElement(const HTMLElement& element) | 648 inline bool isHTMLMediaElement(const HTMLElement& element) |
| 625 { | 649 { |
| 626 return isHTMLAudioElement(element) || isHTMLVideoElement(element); | 650 return isHTMLAudioElement(element) || isHTMLVideoElement(element); |
| 627 } | 651 } |
| 628 | 652 |
| 629 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); | 653 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); |
| 630 | 654 |
| 631 } // namespace blink | 655 } // namespace blink |
| 632 | 656 |
| 633 #endif // HTMLMediaElement_h | 657 #endif // HTMLMediaElement_h |
| OLD | NEW |