Chromium Code Reviews| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 61 class WebInbandTextTrack; | 61 class WebInbandTextTrack; |
| 62 class WebLayer; | 62 class WebLayer; |
| 63 | 63 |
| 64 class CORE_EXPORT HTMLMediaElement : public HTMLElement, public WillBeHeapSupple mentable<HTMLMediaElement>, public ActiveDOMObject, private WebMediaPlayerClient { | 64 class CORE_EXPORT HTMLMediaElement : public HTMLElement, public WillBeHeapSupple mentable<HTMLMediaElement>, public ActiveDOMObject, private WebMediaPlayerClient { |
| 65 DEFINE_WRAPPERTYPEINFO(); | 65 DEFINE_WRAPPERTYPEINFO(); |
| 66 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLMediaElement); | 66 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLMediaElement); |
| 67 WILL_BE_USING_PRE_FINALIZER(HTMLMediaElement, dispose); | 67 WILL_BE_USING_PRE_FINALIZER(HTMLMediaElement, dispose); |
| 68 public: | 68 public: |
| 69 static WebMimeRegistry::SupportsType supportsType(const ContentType&); | 69 static WebMimeRegistry::SupportsType supportsType(const ContentType&); |
| 70 | 70 |
| 71 enum class RecordMetricsBehavior { | |
|
philipj_slow
2016/02/25 10:53:49
Given that's it's used for other things as well no
liberato (no reviews please)
2016/02/25 15:30:31
Done. luckily, the autoplay helper only ever sent
| |
| 72 DoNotRecord, | |
| 73 DoRecord | |
| 74 }; | |
| 75 | |
| 76 static void setMediaStreamRegistry(URLRegistry*); | 71 static void setMediaStreamRegistry(URLRegistry*); |
| 77 static bool isMediaStreamURL(const String& url); | 72 static bool isMediaStreamURL(const String& url); |
| 78 | 73 |
| 79 DECLARE_VIRTUAL_TRACE(); | 74 DECLARE_VIRTUAL_TRACE(); |
| 80 void clearWeakMembers(Visitor*); | 75 void clearWeakMembers(Visitor*); |
| 81 WebMediaPlayer* webMediaPlayer() const | 76 WebMediaPlayer* webMediaPlayer() const |
| 82 { | 77 { |
| 83 return m_webMediaPlayer.get(); | 78 return m_webMediaPlayer.get(); |
| 84 } | 79 } |
| 85 | 80 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 bool paused() const; | 125 bool paused() const; |
| 131 double defaultPlaybackRate() const; | 126 double defaultPlaybackRate() const; |
| 132 void setDefaultPlaybackRate(double); | 127 void setDefaultPlaybackRate(double); |
| 133 double playbackRate() const; | 128 double playbackRate() const; |
| 134 void setPlaybackRate(double); | 129 void setPlaybackRate(double); |
| 135 void updatePlaybackRate(); | 130 void updatePlaybackRate(); |
| 136 TimeRanges* played(); | 131 TimeRanges* played(); |
| 137 TimeRanges* seekable() const; | 132 TimeRanges* seekable() const; |
| 138 bool ended() const; | 133 bool ended() const; |
| 139 bool autoplay() const; | 134 bool autoplay() const; |
| 135 using RecordMetricsBehavior = AutoplayExperimentHelper::Client::RecordMetric sBehavior; | |
| 140 bool shouldAutoplay(const RecordMetricsBehavior = RecordMetricsBehavior::DoN otRecord); | 136 bool shouldAutoplay(const RecordMetricsBehavior = RecordMetricsBehavior::DoN otRecord); |
| 141 bool loop() const; | 137 bool loop() const; |
| 142 void setLoop(bool); | 138 void setLoop(bool); |
| 143 void play(); | 139 void play(); |
| 144 void pause(); | 140 void pause(); |
| 145 void requestRemotePlayback(); | 141 void requestRemotePlayback(); |
| 146 void requestRemotePlaybackControl(); | 142 void requestRemotePlaybackControl(); |
| 147 | 143 |
| 148 // statistics | 144 // statistics |
| 149 unsigned webkitAudioDecodedByteCount() const; | 145 unsigned webkitAudioDecodedByteCount() const; |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 267 bool isURLAttribute(const Attribute&) const override; | 263 bool isURLAttribute(const Attribute&) const override; |
| 268 void attach(const AttachContext& = AttachContext()) override; | 264 void attach(const AttachContext& = AttachContext()) override; |
| 269 | 265 |
| 270 void didMoveToNewDocument(Document& oldDocument) override; | 266 void didMoveToNewDocument(Document& oldDocument) override; |
| 271 virtual KURL posterImageURL() const { return KURL(); } | 267 virtual KURL posterImageURL() const { return KURL(); } |
| 272 | 268 |
| 273 enum DisplayMode { Unknown, Poster, Video }; | 269 enum DisplayMode { Unknown, Poster, Video }; |
| 274 DisplayMode displayMode() const { return m_displayMode; } | 270 DisplayMode displayMode() const { return m_displayMode; } |
| 275 virtual void setDisplayMode(DisplayMode mode) { m_displayMode = mode; } | 271 virtual void setDisplayMode(DisplayMode mode) { m_displayMode = mode; } |
| 276 | 272 |
| 273 void recordAutoplayMetric(AutoplayMetrics); | |
| 274 | |
| 277 private: | 275 private: |
| 278 void resetMediaPlayerAndMediaSource(); | 276 void resetMediaPlayerAndMediaSource(); |
| 279 | 277 |
| 280 bool alwaysCreateUserAgentShadowRoot() const final { return true; } | 278 bool alwaysCreateUserAgentShadowRoot() const final { return true; } |
| 281 bool areAuthorShadowsAllowed() const final { return false; } | 279 bool areAuthorShadowsAllowed() const final { return false; } |
| 282 | 280 |
| 283 bool supportsFocus() const final; | 281 bool supportsFocus() const final; |
| 284 bool isMouseFocusable() const final; | 282 bool isMouseFocusable() const final; |
| 285 bool layoutObjectIsNeeded(const ComputedStyle&) override; | 283 bool layoutObjectIsNeeded(const ComputedStyle&) override; |
| 286 LayoutObject* createLayoutObject(const ComputedStyle&) override; | 284 LayoutObject* createLayoutObject(const ComputedStyle&) override; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 372 void deferredLoadTimerFired(Timer<HTMLMediaElement>*); | 370 void deferredLoadTimerFired(Timer<HTMLMediaElement>*); |
| 373 | 371 |
| 374 void markCaptionAndSubtitleTracksAsUnconfigured(); | 372 void markCaptionAndSubtitleTracksAsUnconfigured(); |
| 375 | 373 |
| 376 // This does not check user gesture restrictions. | 374 // This does not check user gesture restrictions. |
| 377 void playInternal(); | 375 void playInternal(); |
| 378 | 376 |
| 379 // This does not change the buffering strategy. | 377 // This does not change the buffering strategy. |
| 380 void pauseInternal(); | 378 void pauseInternal(); |
| 381 | 379 |
| 382 // If we are about to enter a paused state, call this to record | |
| 383 // autoplay metrics. If we were already in a stopped state, then | |
| 384 // this does nothing. | |
| 385 void recordMetricsIfPausing(); | |
| 386 // Could stopping at this point be considered a bailout of playback? | |
| 387 // (as in, "The user really didn't want to play this"). | |
| 388 bool isBailout() const; | |
| 389 void autoplayMediaEncountered(); | |
| 390 void allowVideoRendering(); | 380 void allowVideoRendering(); |
| 391 | 381 |
| 392 void updateVolume(); | 382 void updateVolume(); |
| 393 void updatePlayState(); | 383 void updatePlayState(); |
| 394 bool potentiallyPlaying() const; | 384 bool potentiallyPlaying() const; |
| 395 bool stoppedDueToErrors() const; | 385 bool stoppedDueToErrors() const; |
| 396 bool couldPlayIfEnoughData() const; | 386 bool couldPlayIfEnoughData() const; |
| 397 | 387 |
| 398 // Generally the presence of the loop attribute should be considered to mean playback | 388 // Generally the presence of the loop attribute should be considered to mean playback |
| 399 // has not "ended", as "ended" and "looping" are mutually exclusive. See | 389 // has not "ended", as "ended" and "looping" are mutually exclusive. See |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 411 TextTrackContainer& ensureTextTrackContainer(); | 401 TextTrackContainer& ensureTextTrackContainer(); |
| 412 | 402 |
| 413 void* preDispatchEventHandler(Event*) final; | 403 void* preDispatchEventHandler(Event*) final; |
| 414 | 404 |
| 415 void changeNetworkStateFromLoadingToIdle(); | 405 void changeNetworkStateFromLoadingToIdle(); |
| 416 | 406 |
| 417 bool isAutoplaying() const { return m_autoplaying; } | 407 bool isAutoplaying() const { return m_autoplaying; } |
| 418 | 408 |
| 419 void setAllowHiddenVolumeControls(bool); | 409 void setAllowHiddenVolumeControls(bool); |
| 420 | 410 |
| 421 void recordAutoplayMetric(AutoplayMetrics); | |
| 422 | |
| 423 WebMediaPlayer::CORSMode corsMode() const; | 411 WebMediaPlayer::CORSMode corsMode() const; |
| 424 | 412 |
| 425 // Returns the "direction of playback" value as specified in the HTML5 spec. | 413 // Returns the "direction of playback" value as specified in the HTML5 spec. |
| 426 enum DirectionOfPlayback { Backward, Forward }; | 414 enum DirectionOfPlayback { Backward, Forward }; |
| 427 DirectionOfPlayback directionOfPlayback() const; | 415 DirectionOfPlayback directionOfPlayback() const; |
| 428 | 416 |
| 429 // Creates placeholder AudioTrack and/or VideoTrack objects when WebMemediaP layer objects | 417 // Creates placeholder AudioTrack and/or VideoTrack objects when WebMemediaP layer objects |
| 430 // advertise they have audio and/or video, but don't explicitly signal them via | 418 // advertise they have audio and/or video, but don't explicitly signal them via |
| 431 // addAudioTrack() and addVideoTrack(). | 419 // addAudioTrack() and addVideoTrack(). |
| 432 // FIXME: Remove this once all WebMediaPlayer implementations properly repor t their track info. | 420 // FIXME: Remove this once all WebMediaPlayer implementations properly repor t their track info. |
| 433 void createPlaceholderTracksIfNecessary(); | 421 void createPlaceholderTracksIfNecessary(); |
| 434 | 422 |
| 435 // Sets the selected/enabled tracks if they aren't set before we initially | 423 // Sets the selected/enabled tracks if they aren't set before we initially |
| 436 // transition to HAVE_METADATA. | 424 // transition to HAVE_METADATA. |
| 437 void selectInitialTracksIfNecessary(); | 425 void selectInitialTracksIfNecessary(); |
| 438 | 426 |
| 439 // Return true if and only if we require a user gesture before letting | 427 // Return true if and only if we require a user gesture before letting |
| 440 // the media play. | 428 // the media play. |
| 441 bool isUserGestureRequiredForPlay() const; | 429 bool isUserGestureRequiredForPlay() const; |
| 430 | |
| 431 // If the user gesture is required, then this will remove it. Note that | |
| 432 // one should not generally call this method directly; use the one on | |
| 433 // m_helper and give it a reason. | |
| 442 void removeUserGestureRequirement(); | 434 void removeUserGestureRequirement(); |
| 443 void setInitialPlayWithoutUserGestures(bool); | |
| 444 | 435 |
| 445 void setNetworkState(NetworkState); | 436 void setNetworkState(NetworkState); |
| 446 | 437 |
| 447 void audioTracksTimerFired(Timer<HTMLMediaElement>*); | 438 void audioTracksTimerFired(Timer<HTMLMediaElement>*); |
| 448 | 439 |
| 449 // TODO(liberato): remove once autoplay gesture override experiment conclude s. | 440 // TODO(liberato): remove once autoplay gesture override experiment conclude s. |
| 450 void triggerAutoplayViewportCheckForTesting(); | 441 void triggerAutoplayViewportCheckForTesting(); |
| 451 | 442 |
| 452 UnthrottledTimer<HTMLMediaElement> m_loadTimer; | 443 UnthrottledTimer<HTMLMediaElement> m_loadTimer; |
| 453 UnthrottledTimer<HTMLMediaElement> m_progressEventTimer; | 444 UnthrottledTimer<HTMLMediaElement> m_progressEventTimer; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 538 | 529 |
| 539 bool m_closedCaptionsVisible : 1; | 530 bool m_closedCaptionsVisible : 1; |
| 540 | 531 |
| 541 bool m_havePreparedToPlay : 1; | 532 bool m_havePreparedToPlay : 1; |
| 542 | 533 |
| 543 bool m_tracksAreReady : 1; | 534 bool m_tracksAreReady : 1; |
| 544 bool m_processingPreferenceChange : 1; | 535 bool m_processingPreferenceChange : 1; |
| 545 bool m_remoteRoutesAvailable : 1; | 536 bool m_remoteRoutesAvailable : 1; |
| 546 bool m_playingRemotely : 1; | 537 bool m_playingRemotely : 1; |
| 547 bool m_isFinalizing : 1; | 538 bool m_isFinalizing : 1; |
| 548 bool m_initialPlayWithoutUserGesture : 1; | |
| 549 bool m_autoplayMediaCounted : 1; | |
| 550 // Whether this element is in overlay fullscreen mode. | 539 // Whether this element is in overlay fullscreen mode. |
| 551 bool m_inOverlayFullscreenVideo : 1; | 540 bool m_inOverlayFullscreenVideo : 1; |
| 552 | 541 |
| 553 PersistentWillBeMember<AudioTrackList> m_audioTracks; | 542 PersistentWillBeMember<AudioTrackList> m_audioTracks; |
| 554 PersistentWillBeMember<VideoTrackList> m_videoTracks; | 543 PersistentWillBeMember<VideoTrackList> m_videoTracks; |
| 555 PersistentWillBeMember<TextTrackList> m_textTracks; | 544 PersistentWillBeMember<TextTrackList> m_textTracks; |
| 556 PersistentHeapVectorWillBeHeapVector<Member<TextTrack>> m_textTracksWhenReso urceSelectionBegan; | 545 PersistentHeapVectorWillBeHeapVector<Member<TextTrack>> m_textTracksWhenReso urceSelectionBegan; |
| 557 | 546 |
| 558 OwnPtrWillBeMember<CueTimeline> m_cueTimeline; | 547 OwnPtrWillBeMember<CueTimeline> m_cueTimeline; |
| 559 | 548 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 604 DECLARE_TRACE(); | 593 DECLARE_TRACE(); |
| 605 | 594 |
| 606 private: | 595 private: |
| 607 WebAudioSourceProvider* m_webAudioSourceProvider; | 596 WebAudioSourceProvider* m_webAudioSourceProvider; |
| 608 PersistentWillBeMember<AudioClientImpl> m_client; | 597 PersistentWillBeMember<AudioClientImpl> m_client; |
| 609 Mutex provideInputLock; | 598 Mutex provideInputLock; |
| 610 }; | 599 }; |
| 611 | 600 |
| 612 AudioSourceProviderImpl m_audioSourceProvider; | 601 AudioSourceProviderImpl m_audioSourceProvider; |
| 613 | 602 |
| 603 class AutoplayHelperClientImpl; | |
| 604 | |
| 614 friend class Internals; | 605 friend class Internals; |
| 615 friend class TrackDisplayUpdateScope; | 606 friend class TrackDisplayUpdateScope; |
| 616 friend class AutoplayExperimentHelper; | 607 friend class AutoplayExperimentHelper; |
| 617 friend class MediaControlsTest; | 608 friend class MediaControlsTest; |
| 618 | 609 |
| 619 AutoplayExperimentHelper m_autoplayHelper; | 610 OwnPtrWillBeMember<AutoplayExperimentHelper::Client> m_autoplayHelperClient; |
| 611 OwnPtrWillBeMember<AutoplayExperimentHelper> m_autoplayHelper; | |
| 620 | 612 |
| 621 static URLRegistry* s_mediaStreamRegistry; | 613 static URLRegistry* s_mediaStreamRegistry; |
| 622 }; | 614 }; |
| 623 | 615 |
| 624 inline bool isHTMLMediaElement(const HTMLElement& element) | 616 inline bool isHTMLMediaElement(const HTMLElement& element) |
| 625 { | 617 { |
| 626 return isHTMLAudioElement(element) || isHTMLVideoElement(element); | 618 return isHTMLAudioElement(element) || isHTMLVideoElement(element); |
| 627 } | 619 } |
| 628 | 620 |
| 629 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); | 621 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); |
| 630 | 622 |
| 631 } // namespace blink | 623 } // namespace blink |
| 632 | 624 |
| 633 #endif // HTMLMediaElement_h | 625 #endif // HTMLMediaElement_h |
| OLD | NEW |