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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
534 | 529 |
535 bool m_closedCaptionsVisible : 1; | 530 bool m_closedCaptionsVisible : 1; |
536 | 531 |
537 bool m_havePreparedToPlay : 1; | 532 bool m_havePreparedToPlay : 1; |
538 | 533 |
539 bool m_tracksAreReady : 1; | 534 bool m_tracksAreReady : 1; |
540 bool m_processingPreferenceChange : 1; | 535 bool m_processingPreferenceChange : 1; |
541 bool m_remoteRoutesAvailable : 1; | 536 bool m_remoteRoutesAvailable : 1; |
542 bool m_playingRemotely : 1; | 537 bool m_playingRemotely : 1; |
543 bool m_isFinalizing : 1; | 538 bool m_isFinalizing : 1; |
544 bool m_initialPlayWithoutUserGesture : 1; | |
545 bool m_autoplayMediaCounted : 1; | |
546 // Whether this element is in overlay fullscreen mode. | 539 // Whether this element is in overlay fullscreen mode. |
547 bool m_inOverlayFullscreenVideo : 1; | 540 bool m_inOverlayFullscreenVideo : 1; |
548 | 541 |
549 PersistentWillBeMember<AudioTrackList> m_audioTracks; | 542 PersistentWillBeMember<AudioTrackList> m_audioTracks; |
550 PersistentWillBeMember<VideoTrackList> m_videoTracks; | 543 PersistentWillBeMember<VideoTrackList> m_videoTracks; |
551 PersistentWillBeMember<TextTrackList> m_textTracks; | 544 PersistentWillBeMember<TextTrackList> m_textTracks; |
552 PersistentHeapVectorWillBeHeapVector<Member<TextTrack>> m_textTracksWhenReso urceSelectionBegan; | 545 PersistentHeapVectorWillBeHeapVector<Member<TextTrack>> m_textTracksWhenReso urceSelectionBegan; |
553 | 546 |
554 OwnPtrWillBeMember<CueTimeline> m_cueTimeline; | 547 OwnPtrWillBeMember<CueTimeline> m_cueTimeline; |
555 | 548 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
605 Mutex provideInputLock; | 598 Mutex provideInputLock; |
606 }; | 599 }; |
607 | 600 |
608 AudioSourceProviderImpl m_audioSourceProvider; | 601 AudioSourceProviderImpl m_audioSourceProvider; |
609 | 602 |
610 friend class Internals; | 603 friend class Internals; |
611 friend class TrackDisplayUpdateScope; | 604 friend class TrackDisplayUpdateScope; |
612 friend class AutoplayExperimentHelper; | 605 friend class AutoplayExperimentHelper; |
613 friend class MediaControlsTest; | 606 friend class MediaControlsTest; |
614 | 607 |
615 AutoplayExperimentHelper m_autoplayHelper; | 608 class AutoplayHelperClientImpl : public AutoplayExperimentHelper::Client { |
sof
2016/02/16 08:40:06
You need to turn this into an Oilpan controlled ob
liberato (no reviews please)
2016/02/24 18:44:06
declaring this to be a subclass of NoBase... cause
| |
609 public: | |
610 AutoplayHelperClientImpl(HTMLMediaElement* element) : m_element(element) {} | |
611 virtual ~AutoplayHelperClientImpl(); | |
612 | |
613 double currentTime() const override { return m_element->currentTime(); } | |
614 double duration() const override { return m_element->duration(); } | |
615 bool paused() const override { return m_element->paused(); } | |
616 bool muted() const override { return m_element->muted(); } | |
617 void setMuted(bool muted) override { m_element->setMuted(muted); } | |
618 void playInternal() override { m_element->playInternal(); } | |
619 bool isUserGestureRequiredForPlay() const override { return m_element->i sUserGestureRequiredForPlay(); } | |
620 void removeUserGestureRequirement() override { m_element->removeUserGest ureRequirement(); } | |
621 void recordAutoplayMetric(AutoplayMetrics metric) override { m_element-> recordAutoplayMetric(metric); } | |
622 bool shouldAutoplay(RecordMetricsBehavior behavior) override { return m_ element->shouldAutoplay(behavior); } | |
623 bool isHTMLVideoElement() const override { return m_element->isHTMLVideo Element(); } | |
624 bool isHTMLAudioElement() const override { return m_element->isHTMLAudio Element(); } | |
625 | |
626 // Document | |
627 bool isLegacyViewportType() override; | |
628 PageVisibilityState pageVisibilityState() const override; | |
629 String autoplayExperimentMode() const override; | |
630 | |
631 // LayoutObject | |
632 void setRequestPositionUpdates(bool) override; | |
633 IntRect absoluteBoundingBoxRect() const override; | |
634 | |
635 private: | |
636 // AutoplayHelperClientImpl is destroyed by HTMLMediaElement, and is | |
637 // not itself GC'd. | |
638 RawPtrWillBeUntracedMember<HTMLMediaElement> m_element; | |
sof
2016/02/16 08:40:06
RawPtrWillBeMember<HTMLMediaElement> + it needs to
liberato (no reviews please)
2016/02/24 18:44:06
Done.
| |
639 }; | |
640 | |
641 OwnPtr<AutoplayExperimentHelper::Client> m_autoplayHelperClient; | |
sof
2016/02/16 08:40:06
OwnPtrWillBeMember<..> + it needs to be traced.
liberato (no reviews please)
2016/02/24 18:44:05
Done.
| |
642 OwnPtr<AutoplayExperimentHelper> m_autoplayHelper; | |
sof
2016/02/16 08:40:06
OwnPtrWillBeMemer<AutoplayExperimentHelper> m_auto
liberato (no reviews please)
2016/02/24 18:44:05
Done.
| |
616 | 643 |
617 static URLRegistry* s_mediaStreamRegistry; | 644 static URLRegistry* s_mediaStreamRegistry; |
618 }; | 645 }; |
619 | 646 |
620 inline bool isHTMLMediaElement(const HTMLElement& element) | 647 inline bool isHTMLMediaElement(const HTMLElement& element) |
621 { | 648 { |
622 return isHTMLAudioElement(element) || isHTMLVideoElement(element); | 649 return isHTMLAudioElement(element) || isHTMLVideoElement(element); |
623 } | 650 } |
624 | 651 |
625 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); | 652 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); |
626 | 653 |
627 } // namespace blink | 654 } // namespace blink |
628 | 655 |
629 #endif // HTMLMediaElement_h | 656 #endif // HTMLMediaElement_h |
OLD | NEW |