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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 bool paused() const; | 125 bool paused() const; |
126 double defaultPlaybackRate() const; | 126 double defaultPlaybackRate() const; |
127 void setDefaultPlaybackRate(double); | 127 void setDefaultPlaybackRate(double); |
128 double playbackRate() const; | 128 double playbackRate() const; |
129 void setPlaybackRate(double); | 129 void setPlaybackRate(double); |
130 void updatePlaybackRate(); | 130 void updatePlaybackRate(); |
131 TimeRanges* played(); | 131 TimeRanges* played(); |
132 TimeRanges* seekable() const; | 132 TimeRanges* seekable() const; |
133 bool ended() const; | 133 bool ended() const; |
134 bool autoplay() const; | 134 bool autoplay() const; |
135 enum class RecordMetricsBehavior { DoNotRecord, DoRecord }; | 135 using RecordMetricsBehavior = AutoplayExperimentHelper::Client::RecordMetric sBehavior; |
136 bool shouldAutoplay(const RecordMetricsBehavior = RecordMetricsBehavior::DoN otRecord); | 136 bool shouldAutoplay(const AutoplayExperimentHelper::Client::RecordMetricsBeh avior = RecordMetricsBehavior::DoNotRecord); |
137 bool loop() const; | 137 bool loop() const; |
138 void setLoop(bool); | 138 void setLoop(bool); |
139 void play(); | 139 void play(); |
140 void pause(); | 140 void pause(); |
141 void requestRemotePlayback(); | 141 void requestRemotePlayback(); |
142 void requestRemotePlaybackControl(); | 142 void requestRemotePlaybackControl(); |
143 | 143 |
144 // statistics | 144 // statistics |
145 unsigned webkitAudioDecodedByteCount() const; | 145 unsigned webkitAudioDecodedByteCount() const; |
146 unsigned webkitVideoDecodedByteCount() const; | 146 unsigned webkitVideoDecodedByteCount() const; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
263 bool isURLAttribute(const Attribute&) const override; | 263 bool isURLAttribute(const Attribute&) const override; |
264 void attach(const AttachContext& = AttachContext()) override; | 264 void attach(const AttachContext& = AttachContext()) override; |
265 | 265 |
266 void didMoveToNewDocument(Document& oldDocument) override; | 266 void didMoveToNewDocument(Document& oldDocument) override; |
267 virtual KURL posterImageURL() const { return KURL(); } | 267 virtual KURL posterImageURL() const { return KURL(); } |
268 | 268 |
269 enum DisplayMode { Unknown, Poster, Video }; | 269 enum DisplayMode { Unknown, Poster, Video }; |
270 DisplayMode displayMode() const { return m_displayMode; } | 270 DisplayMode displayMode() const { return m_displayMode; } |
271 virtual void setDisplayMode(DisplayMode mode) { m_displayMode = mode; } | 271 virtual void setDisplayMode(DisplayMode mode) { m_displayMode = mode; } |
272 | 272 |
273 void recordAutoplayMetric(AutoplayMetrics); | |
274 | |
273 private: | 275 private: |
274 void resetMediaPlayerAndMediaSource(); | 276 void resetMediaPlayerAndMediaSource(); |
275 | 277 |
276 bool alwaysCreateUserAgentShadowRoot() const final { return true; } | 278 bool alwaysCreateUserAgentShadowRoot() const final { return true; } |
277 bool areAuthorShadowsAllowed() const final { return false; } | 279 bool areAuthorShadowsAllowed() const final { return false; } |
278 | 280 |
279 bool supportsFocus() const final; | 281 bool supportsFocus() const final; |
280 bool isMouseFocusable() const final; | 282 bool isMouseFocusable() const final; |
281 bool layoutObjectIsNeeded(const ComputedStyle&) override; | 283 bool layoutObjectIsNeeded(const ComputedStyle&) override; |
282 LayoutObject* createLayoutObject(const ComputedStyle&) override; | 284 LayoutObject* createLayoutObject(const ComputedStyle&) override; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
368 void deferredLoadTimerFired(Timer<HTMLMediaElement>*); | 370 void deferredLoadTimerFired(Timer<HTMLMediaElement>*); |
369 | 371 |
370 void markCaptionAndSubtitleTracksAsUnconfigured(); | 372 void markCaptionAndSubtitleTracksAsUnconfigured(); |
371 | 373 |
372 // This does not check user gesture restrictions. | 374 // This does not check user gesture restrictions. |
373 void playInternal(); | 375 void playInternal(); |
374 | 376 |
375 // This does not change the buffering strategy. | 377 // This does not change the buffering strategy. |
376 void pauseInternal(); | 378 void pauseInternal(); |
377 | 379 |
378 // If we are about to enter a paused state, call this to record | |
379 // autoplay metrics. If we were already in a stopped state, then | |
380 // this does nothing. | |
381 void recordMetricsIfPausing(); | |
382 // Could stopping at this point be considered a bailout of playback? | |
383 // (as in, "The user really didn't want to play this"). | |
384 bool isBailout() const; | |
385 void autoplayMediaEncountered(); | |
386 void allowVideoRendering(); | 380 void allowVideoRendering(); |
387 | 381 |
388 void updateVolume(); | 382 void updateVolume(); |
389 void updatePlayState(); | 383 void updatePlayState(); |
390 bool potentiallyPlaying() const; | 384 bool potentiallyPlaying() const; |
391 bool stoppedDueToErrors() const; | 385 bool stoppedDueToErrors() const; |
392 bool couldPlayIfEnoughData() const; | 386 bool couldPlayIfEnoughData() const; |
393 | 387 |
394 // 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 |
395 // 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... | |
407 TextTrackContainer& ensureTextTrackContainer(); | 401 TextTrackContainer& ensureTextTrackContainer(); |
408 | 402 |
409 void* preDispatchEventHandler(Event*) final; | 403 void* preDispatchEventHandler(Event*) final; |
410 | 404 |
411 void changeNetworkStateFromLoadingToIdle(); | 405 void changeNetworkStateFromLoadingToIdle(); |
412 | 406 |
413 bool isAutoplaying() const { return m_autoplaying; } | 407 bool isAutoplaying() const { return m_autoplaying; } |
414 | 408 |
415 void setAllowHiddenVolumeControls(bool); | 409 void setAllowHiddenVolumeControls(bool); |
416 | 410 |
417 void recordAutoplayMetric(AutoplayMetrics); | |
418 | |
419 WebMediaPlayer::CORSMode corsMode() const; | 411 WebMediaPlayer::CORSMode corsMode() const; |
420 | 412 |
421 // 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. |
422 enum DirectionOfPlayback { Backward, Forward }; | 414 enum DirectionOfPlayback { Backward, Forward }; |
423 DirectionOfPlayback directionOfPlayback() const; | 415 DirectionOfPlayback directionOfPlayback() const; |
424 | 416 |
425 // Creates placeholder AudioTrack and/or VideoTrack objects when WebMemediaP layer objects | 417 // Creates placeholder AudioTrack and/or VideoTrack objects when WebMemediaP layer objects |
426 // 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 |
427 // addAudioTrack() and addVideoTrack(). | 419 // addAudioTrack() and addVideoTrack(). |
428 // 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. |
429 void createPlaceholderTracksIfNecessary(); | 421 void createPlaceholderTracksIfNecessary(); |
430 | 422 |
431 // 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 |
432 // transition to HAVE_METADATA. | 424 // transition to HAVE_METADATA. |
433 void selectInitialTracksIfNecessary(); | 425 void selectInitialTracksIfNecessary(); |
434 | 426 |
435 // 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 |
436 // the media play. | 428 // the media play. |
437 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. | |
438 void removeUserGestureRequirement(); | 434 void removeUserGestureRequirement(); |
439 void setInitialPlayWithoutUserGestures(bool); | |
440 | 435 |
441 void setNetworkState(NetworkState); | 436 void setNetworkState(NetworkState); |
442 | 437 |
443 void audioTracksTimerFired(Timer<HTMLMediaElement>*); | 438 void audioTracksTimerFired(Timer<HTMLMediaElement>*); |
444 | 439 |
445 // TODO(liberato): remove once autoplay gesture override experiment conclude s. | 440 // TODO(liberato): remove once autoplay gesture override experiment conclude s. |
446 void triggerAutoplayViewportCheckForTesting(); | 441 void triggerAutoplayViewportCheckForTesting(); |
447 | 442 |
448 UnthrottledTimer<HTMLMediaElement> m_loadTimer; | 443 UnthrottledTimer<HTMLMediaElement> m_loadTimer; |
449 UnthrottledTimer<HTMLMediaElement> m_progressEventTimer; | 444 UnthrottledTimer<HTMLMediaElement> m_progressEventTimer; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
537 bool m_completelyLoaded : 1; | 532 bool m_completelyLoaded : 1; |
538 bool m_havePreparedToPlay : 1; | 533 bool m_havePreparedToPlay : 1; |
539 bool m_delayingLoadForPreloadNone : 1; | 534 bool m_delayingLoadForPreloadNone : 1; |
540 | 535 |
541 bool m_tracksAreReady : 1; | 536 bool m_tracksAreReady : 1; |
542 bool m_haveVisibleTextTrack : 1; | 537 bool m_haveVisibleTextTrack : 1; |
543 bool m_processingPreferenceChange : 1; | 538 bool m_processingPreferenceChange : 1; |
544 bool m_remoteRoutesAvailable : 1; | 539 bool m_remoteRoutesAvailable : 1; |
545 bool m_playingRemotely : 1; | 540 bool m_playingRemotely : 1; |
546 bool m_isFinalizing : 1; | 541 bool m_isFinalizing : 1; |
547 bool m_initialPlayWithoutUserGesture : 1; | |
548 bool m_autoplayMediaCounted : 1; | |
549 // Whether this element is in overlay fullscreen mode. | 542 // Whether this element is in overlay fullscreen mode. |
550 bool m_inOverlayFullscreenVideo : 1; | 543 bool m_inOverlayFullscreenVideo : 1; |
551 | 544 |
552 PersistentWillBeMember<AudioTrackList> m_audioTracks; | 545 PersistentWillBeMember<AudioTrackList> m_audioTracks; |
553 PersistentWillBeMember<VideoTrackList> m_videoTracks; | 546 PersistentWillBeMember<VideoTrackList> m_videoTracks; |
554 PersistentWillBeMember<TextTrackList> m_textTracks; | 547 PersistentWillBeMember<TextTrackList> m_textTracks; |
555 PersistentHeapVectorWillBeHeapVector<Member<TextTrack>> m_textTracksWhenReso urceSelectionBegan; | 548 PersistentHeapVectorWillBeHeapVector<Member<TextTrack>> m_textTracksWhenReso urceSelectionBegan; |
556 | 549 |
557 OwnPtrWillBeMember<CueTimeline> m_cueTimeline; | 550 OwnPtrWillBeMember<CueTimeline> m_cueTimeline; |
558 | 551 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
608 Mutex provideInputLock; | 601 Mutex provideInputLock; |
609 }; | 602 }; |
610 | 603 |
611 AudioSourceProviderImpl m_audioSourceProvider; | 604 AudioSourceProviderImpl m_audioSourceProvider; |
612 | 605 |
613 friend class Internals; | 606 friend class Internals; |
614 friend class TrackDisplayUpdateScope; | 607 friend class TrackDisplayUpdateScope; |
615 friend class AutoplayExperimentHelper; | 608 friend class AutoplayExperimentHelper; |
616 friend class MediaControlsTest; | 609 friend class MediaControlsTest; |
617 | 610 |
618 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->i sUserGestureRequiredForPlay(); } | |
623 void removeUserGestureRequirement() override { m_element->removeUserGest ureRequirement(); } | |
624 void recordAutoplayMetric(AutoplayMetrics metric) override { m_element-> recordAutoplayMetric(metric); } | |
625 bool shouldAutoplay(RecordMetricsBehavior behavior) override { return m_ element->shouldAutoplay(behavior); } | |
626 bool isHTMLVideoElement() const override { return m_element->isHTMLVideo Element(); } | |
627 bool isHTMLAudioElement() const override { return m_element->isHTMLAudio Element(); } | |
628 | |
629 // Document | |
630 bool isLegacyViewportType() override; | |
631 PageVisibilityState pageVisibilityState() const override; | |
632 String autoplayExperimentMode() const override; | |
633 | |
634 // LayoutObject | |
635 void setRequestPositionUpdates(bool) override; | |
636 IntRect absoluteBoundingBoxRect() const override; | |
637 | |
638 private: | |
639 // AutoplayHelperClientImpl is destroyed by HTMLMediaElement, and is | |
640 // not itself GC'd. | |
641 RawPtr<HTMLMediaElement> m_element; | |
philipj_slow
2016/02/02 08:08:15
A plain RawPtr<T>, as opposed to an Oilpan transit
| |
642 }; | |
643 | |
644 OwnPtr<AutoplayExperimentHelper::Client> m_autoplayHelperClient; | |
645 OwnPtr<AutoplayExperimentHelper> m_autoplayHelper; | |
619 | 646 |
620 static URLRegistry* s_mediaStreamRegistry; | 647 static URLRegistry* s_mediaStreamRegistry; |
621 }; | 648 }; |
622 | 649 |
623 inline bool isHTMLMediaElement(const HTMLElement& element) | 650 inline bool isHTMLMediaElement(const HTMLElement& element) |
624 { | 651 { |
625 return isHTMLAudioElement(element) || isHTMLVideoElement(element); | 652 return isHTMLAudioElement(element) || isHTMLVideoElement(element); |
626 } | 653 } |
627 | 654 |
628 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); | 655 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); |
629 | 656 |
630 } // namespace blink | 657 } // namespace blink |
631 | 658 |
632 #endif // HTMLMediaElement_h | 659 #endif // HTMLMediaElement_h |
OLD | NEW |