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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
126 bool paused() const; | 126 bool paused() const; |
127 double defaultPlaybackRate() const; | 127 double defaultPlaybackRate() const; |
128 void setDefaultPlaybackRate(double); | 128 void setDefaultPlaybackRate(double); |
129 double playbackRate() const; | 129 double playbackRate() const; |
130 void setPlaybackRate(double); | 130 void setPlaybackRate(double); |
131 void updatePlaybackRate(); | 131 void updatePlaybackRate(); |
132 TimeRanges* played(); | 132 TimeRanges* played(); |
133 TimeRanges* seekable() const; | 133 TimeRanges* seekable() const; |
134 bool ended() const; | 134 bool ended() const; |
135 bool autoplay() const; | 135 bool autoplay() const; |
136 enum class RecordMetricsBehavior { DoNotRecord, DoRecord }; | 136 bool shouldAutoplay(const AutoplayExperimentHelper::Client::RecordMetricsBeh avior = AutoplayExperimentHelper::Client::RecordMetricsBehavior::DoNotRecord); |
philipj_slow
2016/01/12 15:12:19
Can using RecordMetricsBehavior = AutoplayExperime
liberato (no reviews please)
2016/01/29 08:25:25
seems to work. good idea.
philipj_slow
2016/02/02 08:08:15
Isn't it possible to also replace AutoplayExperime
liberato (no reviews please)
2016/02/24 18:44:05
Done. in the interim, RecordMetricsBehavior was u
| |
137 bool shouldAutoplay(const RecordMetricsBehavior = RecordMetricsBehavior::DoN otRecord); | |
138 bool loop() const; | 137 bool loop() const; |
139 void setLoop(bool); | 138 void setLoop(bool); |
140 void play(); | 139 void play(); |
141 void pause(); | 140 void pause(); |
142 void requestRemotePlayback(); | 141 void requestRemotePlayback(); |
143 void requestRemotePlaybackControl(); | 142 void requestRemotePlaybackControl(); |
144 | 143 |
145 // statistics | 144 // statistics |
146 unsigned webkitAudioDecodedByteCount() const; | 145 unsigned webkitAudioDecodedByteCount() const; |
147 unsigned webkitVideoDecodedByteCount() const; | 146 unsigned webkitVideoDecodedByteCount() const; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
264 bool isURLAttribute(const Attribute&) const override; | 263 bool isURLAttribute(const Attribute&) const override; |
265 void attach(const AttachContext& = AttachContext()) override; | 264 void attach(const AttachContext& = AttachContext()) override; |
266 | 265 |
267 void didMoveToNewDocument(Document& oldDocument) override; | 266 void didMoveToNewDocument(Document& oldDocument) override; |
268 virtual KURL posterImageURL() const { return KURL(); } | 267 virtual KURL posterImageURL() const { return KURL(); } |
269 | 268 |
270 enum DisplayMode { Unknown, Poster, Video }; | 269 enum DisplayMode { Unknown, Poster, Video }; |
271 DisplayMode displayMode() const { return m_displayMode; } | 270 DisplayMode displayMode() const { return m_displayMode; } |
272 virtual void setDisplayMode(DisplayMode mode) { m_displayMode = mode; } | 271 virtual void setDisplayMode(DisplayMode mode) { m_displayMode = mode; } |
273 | 272 |
273 void recordAutoplayMetric(AutoplayMetrics); | |
274 | |
274 private: | 275 private: |
275 void resetMediaPlayerAndMediaSource(); | 276 void resetMediaPlayerAndMediaSource(); |
276 | 277 |
277 bool alwaysCreateUserAgentShadowRoot() const final { return true; } | 278 bool alwaysCreateUserAgentShadowRoot() const final { return true; } |
278 bool areAuthorShadowsAllowed() const final { return false; } | 279 bool areAuthorShadowsAllowed() const final { return false; } |
279 | 280 |
280 bool supportsFocus() const final; | 281 bool supportsFocus() const final; |
281 bool isMouseFocusable() const final; | 282 bool isMouseFocusable() const final; |
282 bool layoutObjectIsNeeded(const ComputedStyle&) override; | 283 bool layoutObjectIsNeeded(const ComputedStyle&) override; |
283 LayoutObject* createLayoutObject(const ComputedStyle&) override; | 284 LayoutObject* createLayoutObject(const ComputedStyle&) override; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
369 void deferredLoadTimerFired(Timer<HTMLMediaElement>*); | 370 void deferredLoadTimerFired(Timer<HTMLMediaElement>*); |
370 | 371 |
371 void markCaptionAndSubtitleTracksAsUnconfigured(); | 372 void markCaptionAndSubtitleTracksAsUnconfigured(); |
372 | 373 |
373 // This does not check user gesture restrictions. | 374 // This does not check user gesture restrictions. |
374 void playInternal(); | 375 void playInternal(); |
375 | 376 |
376 // This does not change the buffering strategy. | 377 // This does not change the buffering strategy. |
377 void pauseInternal(); | 378 void pauseInternal(); |
378 | 379 |
379 // If we are about to enter a paused state, call this to record | |
380 // autoplay metrics. If we were already in a stopped state, then | |
381 // this does nothing. | |
382 void recordMetricsIfPausing(); | |
383 // Could stopping at this point be considered a bailout of playback? | |
384 // (as in, "The user really didn't want to play this"). | |
385 bool isBailout() const; | |
386 void autoplayMediaEncountered(); | |
387 void allowVideoRendering(); | 380 void allowVideoRendering(); |
388 | 381 |
389 void updateVolume(); | 382 void updateVolume(); |
390 void updatePlayState(); | 383 void updatePlayState(); |
391 bool potentiallyPlaying() const; | 384 bool potentiallyPlaying() const; |
392 bool stoppedDueToErrors() const; | 385 bool stoppedDueToErrors() const; |
393 bool couldPlayIfEnoughData() const; | 386 bool couldPlayIfEnoughData() const; |
394 | 387 |
395 // 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 |
396 // 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... | |
408 TextTrackContainer& ensureTextTrackContainer(); | 401 TextTrackContainer& ensureTextTrackContainer(); |
409 | 402 |
410 void* preDispatchEventHandler(Event*) final; | 403 void* preDispatchEventHandler(Event*) final; |
411 | 404 |
412 void changeNetworkStateFromLoadingToIdle(); | 405 void changeNetworkStateFromLoadingToIdle(); |
413 | 406 |
414 bool isAutoplaying() const { return m_autoplaying; } | 407 bool isAutoplaying() const { return m_autoplaying; } |
415 | 408 |
416 void setAllowHiddenVolumeControls(bool); | 409 void setAllowHiddenVolumeControls(bool); |
417 | 410 |
418 void recordAutoplayMetric(AutoplayMetrics); | |
419 | |
420 WebMediaPlayer::CORSMode corsMode() const; | 411 WebMediaPlayer::CORSMode corsMode() const; |
421 | 412 |
422 // 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. |
423 enum DirectionOfPlayback { Backward, Forward }; | 414 enum DirectionOfPlayback { Backward, Forward }; |
424 DirectionOfPlayback directionOfPlayback() const; | 415 DirectionOfPlayback directionOfPlayback() const; |
425 | 416 |
426 // Creates placeholder AudioTrack and/or VideoTrack objects when WebMemediaP layer objects | 417 // Creates placeholder AudioTrack and/or VideoTrack objects when WebMemediaP layer objects |
427 // 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 |
428 // addAudioTrack() and addVideoTrack(). | 419 // addAudioTrack() and addVideoTrack(). |
429 // 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. |
430 void createPlaceholderTracksIfNecessary(); | 421 void createPlaceholderTracksIfNecessary(); |
431 | 422 |
432 // 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 |
433 // transition to HAVE_METADATA. | 424 // transition to HAVE_METADATA. |
434 void selectInitialTracksIfNecessary(); | 425 void selectInitialTracksIfNecessary(); |
435 | 426 |
436 // 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 |
437 // the media play. | 428 // the media play. |
438 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. | |
439 void removeUserGestureRequirement(); | 434 void removeUserGestureRequirement(); |
440 void setInitialPlayWithoutUserGestures(bool); | |
441 | 435 |
442 void setNetworkState(NetworkState); | 436 void setNetworkState(NetworkState); |
443 | 437 |
444 void audioTracksTimerFired(Timer<HTMLMediaElement>*); | 438 void audioTracksTimerFired(Timer<HTMLMediaElement>*); |
445 | 439 |
446 // TODO(liberato): remove once autoplay gesture override experiment conclude s. | 440 // TODO(liberato): remove once autoplay gesture override experiment conclude s. |
447 void triggerAutoplayViewportCheckForTesting(); | 441 void triggerAutoplayViewportCheckForTesting(); |
448 | 442 |
449 UnthrottledTimer<HTMLMediaElement> m_loadTimer; | 443 UnthrottledTimer<HTMLMediaElement> m_loadTimer; |
450 UnthrottledTimer<HTMLMediaElement> m_progressEventTimer; | 444 UnthrottledTimer<HTMLMediaElement> m_progressEventTimer; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
538 bool m_completelyLoaded : 1; | 532 bool m_completelyLoaded : 1; |
539 bool m_havePreparedToPlay : 1; | 533 bool m_havePreparedToPlay : 1; |
540 bool m_delayingLoadForPreloadNone : 1; | 534 bool m_delayingLoadForPreloadNone : 1; |
541 | 535 |
542 bool m_tracksAreReady : 1; | 536 bool m_tracksAreReady : 1; |
543 bool m_haveVisibleTextTrack : 1; | 537 bool m_haveVisibleTextTrack : 1; |
544 bool m_processingPreferenceChange : 1; | 538 bool m_processingPreferenceChange : 1; |
545 bool m_remoteRoutesAvailable : 1; | 539 bool m_remoteRoutesAvailable : 1; |
546 bool m_playingRemotely : 1; | 540 bool m_playingRemotely : 1; |
547 bool m_isFinalizing : 1; | 541 bool m_isFinalizing : 1; |
548 bool m_initialPlayWithoutUserGesture : 1; | |
549 bool m_autoplayMediaCounted : 1; | |
550 // Whether this element is in overlay fullscreen mode. | 542 // Whether this element is in overlay fullscreen mode. |
551 bool m_inOverlayFullscreenVideo : 1; | 543 bool m_inOverlayFullscreenVideo : 1; |
552 | 544 |
553 PersistentWillBeMember<AudioTrackList> m_audioTracks; | 545 PersistentWillBeMember<AudioTrackList> m_audioTracks; |
554 PersistentWillBeMember<VideoTrackList> m_videoTracks; | 546 PersistentWillBeMember<VideoTrackList> m_videoTracks; |
555 PersistentWillBeMember<TextTrackList> m_textTracks; | 547 PersistentWillBeMember<TextTrackList> m_textTracks; |
556 PersistentHeapVectorWillBeHeapVector<Member<TextTrack>> m_textTracksWhenReso urceSelectionBegan; | 548 PersistentHeapVectorWillBeHeapVector<Member<TextTrack>> m_textTracksWhenReso urceSelectionBegan; |
557 | 549 |
558 OwnPtrWillBeMember<CueTimeline> m_cueTimeline; | 550 OwnPtrWillBeMember<CueTimeline> m_cueTimeline; |
559 | 551 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
609 Mutex provideInputLock; | 601 Mutex provideInputLock; |
610 }; | 602 }; |
611 | 603 |
612 AudioSourceProviderImpl m_audioSourceProvider; | 604 AudioSourceProviderImpl m_audioSourceProvider; |
613 | 605 |
614 friend class Internals; | 606 friend class Internals; |
615 friend class TrackDisplayUpdateScope; | 607 friend class TrackDisplayUpdateScope; |
616 friend class AutoplayExperimentHelper; | 608 friend class AutoplayExperimentHelper; |
617 friend class MediaControlsTest; | 609 friend class MediaControlsTest; |
618 | 610 |
619 AutoplayExperimentHelper m_autoplayHelper; | 611 class AutoplayHelperClientImpl : public AutoplayExperimentHelper::Client { |
612 public: | |
613 AutoplayHelperClientImpl(HTMLMediaElement& element) : m_element(element) {} | |
614 virtual ~AutoplayHelperClientImpl(); | |
615 | |
616 double currentTime() const override { return m_element.currentTime(); } | |
617 double duration() const override { return m_element.duration(); } | |
618 bool paused() const override { return m_element.paused(); } | |
619 bool muted() const override { return m_element.muted(); } | |
620 void setMuted(bool muted) override { m_element.setMuted(muted); } | |
621 void playInternal() override { m_element.playInternal(); } | |
622 bool isUserGestureRequiredForPlay() const override { return m_element.is UserGestureRequiredForPlay(); } | |
623 void removeUserGestureRequirement() override { m_element.removeUserGestu reRequirement(); } | |
624 void recordAutoplayMetric(AutoplayMetrics metric) override { m_element.r ecordAutoplayMetric(metric); } | |
625 bool shouldAutoplay(RecordMetricsBehavior behavior) override { return m_ element.shouldAutoplay(behavior); } | |
626 bool isHTMLVideoElement() const override { return m_element.isHTMLVideoE lement(); } | |
627 bool isHTMLAudioElement() const override { return m_element.isHTMLAudioE lement(); } | |
628 | |
629 // Document | |
630 bool isLegacyViewportType() override; | |
631 PageVisibilityState pageVisibilityState() const override; | |
632 WTF::String autoplayExperimentMode() const override; | |
633 | |
634 // LayoutObject | |
635 void setRequestPositionUpdates(bool) override; | |
636 IntRect absoluteBoundingBoxRect() const override; | |
637 | |
638 private: | |
639 HTMLMediaElement& m_element; | |
640 }; | |
641 | |
642 AutoplayExperimentHelper::Client* m_autoplayHelperClient; | |
philipj_slow
2016/01/12 15:12:19
Why can't both of these be references still?
liberato (no reviews please)
2016/01/29 08:25:25
i don't like relying on destruction order, since i
philipj_slow
2016/02/02 08:08:15
Not sure why I said "references still" when it was
| |
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 |