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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 void didMoveToNewDocument(Document& oldDocument) override; | 279 void didMoveToNewDocument(Document& oldDocument) override; |
280 virtual KURL posterImageURL() const { return KURL(); } | 280 virtual KURL posterImageURL() const { return KURL(); } |
281 | 281 |
282 enum DisplayMode { Unknown, Poster, Video }; | 282 enum DisplayMode { Unknown, Poster, Video }; |
283 DisplayMode displayMode() const { return m_displayMode; } | 283 DisplayMode displayMode() const { return m_displayMode; } |
284 virtual void setDisplayMode(DisplayMode mode) { m_displayMode = mode; } | 284 virtual void setDisplayMode(DisplayMode mode) { m_displayMode = mode; } |
285 | 285 |
286 void setControllerInternal(MediaController*); | 286 void setControllerInternal(MediaController*); |
287 | 287 |
288 private: | 288 private: |
| 289 // These values are used for a histogram. Do not reorder. |
| 290 enum AutoplayMetrics { |
| 291 // Media element with autoplay seen. |
| 292 AutoplayMediaFound = 0, |
| 293 // Autoplay enabled and user stopped media play at any point. |
| 294 AutoplayStopped = 1, |
| 295 // Autoplay enabled but user bailed out on media play early. |
| 296 AutoplayBailout = 2, |
| 297 // Autoplay disabled but user manually started media. |
| 298 AutoplayManualStart = 3, |
| 299 // Autoplay was (re)enabled through a user-gesture triggered load() |
| 300 AutoplayEnabledThroughLoad = 4, |
| 301 // Autoplay disabled by sandbox flags. |
| 302 AutoplayDisabledBySandbox = 5, |
| 303 |
| 304 // These metrics indicate "no gesture but gesture requirement was |
| 305 // overridden by experiment". They do not include cases where no |
| 306 // user gesture is required (!m_userGestureRequiredForPlay). |
| 307 // Gestureless playback when media scrolled into view. We don't |
| 308 // record whether it was a javascript or attribute autoplay request. |
| 309 GesturelessPlaybackStartedByScroll = 6, |
| 310 // Autoplay started by experiment override during initial load. |
| 311 GesturelessPlaybackStartedByLoad = 7, |
| 312 // Autoplay started by experiment override in play() call. |
| 313 GesturelessPlaybackStartedByPlayMethod = 8, |
| 314 |
| 315 // play() failed to play due to gesture requirement. |
| 316 PlayMethodFailed = 9, |
| 317 |
| 318 // Some play, whether user initiated or not, started. |
| 319 AnyPlaybackStarted = 10, |
| 320 // Some play, whether user initiated or not, stopped. |
| 321 AnyPlaybackStopped = 11, |
| 322 // Some playback, whether user initiated or not, bailed out early. |
| 323 AnyPlaybackBailout = 12, |
| 324 |
| 325 // This enum value must be last. |
| 326 NumberOfAutoplayMetrics, |
| 327 }; |
| 328 |
289 void resetMediaPlayerAndMediaSource(); | 329 void resetMediaPlayerAndMediaSource(); |
290 | 330 |
291 bool alwaysCreateUserAgentShadowRoot() const final { return true; } | 331 bool alwaysCreateUserAgentShadowRoot() const final { return true; } |
292 bool areAuthorShadowsAllowed() const final { return false; } | 332 bool areAuthorShadowsAllowed() const final { return false; } |
293 | 333 |
294 bool supportsFocus() const final; | 334 bool supportsFocus() const final; |
295 bool isMouseFocusable() const final; | 335 bool isMouseFocusable() const final; |
296 bool layoutObjectIsNeeded(const ComputedStyle&) override; | 336 bool layoutObjectIsNeeded(const ComputedStyle&) override; |
297 LayoutObject* createLayoutObject(const ComputedStyle&) override; | 337 LayoutObject* createLayoutObject(const ComputedStyle&) override; |
298 InsertionNotificationRequest insertedInto(ContainerNode*) final; | 338 InsertionNotificationRequest insertedInto(ContainerNode*) final; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 void executeDeferredLoad(); | 423 void executeDeferredLoad(); |
384 void deferredLoadTimerFired(Timer<HTMLMediaElement>*); | 424 void deferredLoadTimerFired(Timer<HTMLMediaElement>*); |
385 | 425 |
386 HTMLTrackElement* showingTrackWithSameKind(HTMLTrackElement*) const; | 426 HTMLTrackElement* showingTrackWithSameKind(HTMLTrackElement*) const; |
387 | 427 |
388 void markCaptionAndSubtitleTracksAsUnconfigured(); | 428 void markCaptionAndSubtitleTracksAsUnconfigured(); |
389 | 429 |
390 // This does not check user gesture restrictions. | 430 // This does not check user gesture restrictions. |
391 void playInternal(); | 431 void playInternal(); |
392 | 432 |
393 void gesturelessInitialPlayHalted(); | 433 // If we are about to enter a stopped state, call this to record |
| 434 // autoplay metrics. If we were already in a stopped state, then |
| 435 // this does nothing. |
| 436 void recordMetricsIfStopping(); |
| 437 // Could stopping at this point be considered a bailout of playback? |
| 438 // (as in, "The user really didn't want to play this"). |
| 439 bool isBailout() const; |
394 void autoplayMediaEncountered(); | 440 void autoplayMediaEncountered(); |
395 void allowVideoRendering(); | 441 void allowVideoRendering(); |
396 | 442 |
397 void updateVolume(); | 443 void updateVolume(); |
398 void updatePlayState(); | 444 void updatePlayState(); |
399 bool potentiallyPlaying() const; | 445 bool potentiallyPlaying() const; |
400 bool stoppedDueToErrors() const; | 446 bool stoppedDueToErrors() const; |
401 bool couldPlayIfEnoughData() const; | 447 bool couldPlayIfEnoughData() const; |
402 | 448 |
403 // Generally the presence of the loop attribute should be considered to mean
playback | 449 // Generally the presence of the loop attribute should be considered to mean
playback |
(...skipping 15 matching lines...) Expand all Loading... |
419 | 465 |
420 void changeNetworkStateFromLoadingToIdle(); | 466 void changeNetworkStateFromLoadingToIdle(); |
421 | 467 |
422 const AtomicString& mediaGroup() const; | 468 const AtomicString& mediaGroup() const; |
423 void setMediaGroup(const AtomicString&); | 469 void setMediaGroup(const AtomicString&); |
424 void updateMediaController(); | 470 void updateMediaController(); |
425 bool isBlocked() const; | 471 bool isBlocked() const; |
426 bool isBlockedOnMediaController() const; | 472 bool isBlockedOnMediaController() const; |
427 bool isAutoplaying() const { return m_autoplaying; } | 473 bool isAutoplaying() const { return m_autoplaying; } |
428 | 474 |
| 475 void recordAutoplayMetric(AutoplayMetrics); |
| 476 |
| 477 // vvvv Helpers for clank autoplay investigation vvvv |
| 478 |
| 479 // Install an event listener to check for changes in visibility. If a |
| 480 // listener is already installed, then this does nothing. |
| 481 void autoplayExperimentInstallEventListenerIfNeeded(); |
| 482 |
| 483 // Remove any event listener. It's okay to call this if one isn't |
| 484 // installed already. |
| 485 void autoplayExperimentClearEventListenerIfNeeded(); |
| 486 |
| 487 // Return true if any only if this player meets (most) of the eligibility |
| 488 // requirements for the experiment to override the need for a user |
| 489 // gesture. This includes everything except the visibility test. |
| 490 bool autoplayExperimentIsEligible() const; |
| 491 |
| 492 // Return true if and only if the player is visible. |
| 493 bool autoplayExperimentIsInViewportIfNeeded(); |
| 494 |
| 495 // Set the mute flag on the media if we're in an experiment mode that |
| 496 // requires it, else do nothing. |
| 497 void autoplayExperimentMuteIfNeeded(); |
| 498 |
| 499 // Maybe override the requirement for a user gesture, and start playing |
| 500 // autoplay media. Returns true if only if it starts playback. |
| 501 bool autoplayExperimentMaybeStartPlaying(); |
| 502 |
| 503 // Configure internal state to record that the autoplay experiment is |
| 504 // going to start playback. This doesn't actually start playback, since |
| 505 // there are several different cases. |
| 506 void autoplayExperimentPrepareToPlay(AutoplayMetrics); |
| 507 |
| 508 // Begin (or start over) a periodic check for visibility. We will poll |
| 509 // during this check to see if the video is in the viewport. |
| 510 void notifyScrolled(); |
| 511 |
| 512 // Process a timer for checking visibility. |
| 513 void viewportTimerFired(Timer<HTMLMediaElement>*); |
| 514 // ^^^^ Helpers for clank autoplay investigation ^^^^ |
| 515 |
429 WebMediaPlayer::CORSMode corsMode() const; | 516 WebMediaPlayer::CORSMode corsMode() const; |
430 | 517 |
431 // Returns the "direction of playback" value as specified in the HTML5 spec. | 518 // Returns the "direction of playback" value as specified in the HTML5 spec. |
432 enum DirectionOfPlayback { Backward, Forward }; | 519 enum DirectionOfPlayback { Backward, Forward }; |
433 DirectionOfPlayback directionOfPlayback() const; | 520 DirectionOfPlayback directionOfPlayback() const; |
434 | 521 |
435 // Returns the "effective playback rate" value as specified in the HTML5 spe
c. | 522 // Returns the "effective playback rate" value as specified in the HTML5 spe
c. |
436 double effectivePlaybackRate() const; | 523 double effectivePlaybackRate() const; |
437 | 524 |
438 // Creates placeholder AudioTrack and/or VideoTrack objects when WebMemediaP
layer objects | 525 // Creates placeholder AudioTrack and/or VideoTrack objects when WebMemediaP
layer objects |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 bool m_playingRemotely : 1; | 634 bool m_playingRemotely : 1; |
548 bool m_isFinalizing : 1; | 635 bool m_isFinalizing : 1; |
549 bool m_initialPlayWithoutUserGestures : 1; | 636 bool m_initialPlayWithoutUserGestures : 1; |
550 bool m_autoplayMediaCounted : 1; | 637 bool m_autoplayMediaCounted : 1; |
551 | 638 |
552 PersistentWillBeMember<AudioTrackList> m_audioTracks; | 639 PersistentWillBeMember<AudioTrackList> m_audioTracks; |
553 PersistentWillBeMember<VideoTrackList> m_videoTracks; | 640 PersistentWillBeMember<VideoTrackList> m_videoTracks; |
554 PersistentWillBeMember<TextTrackList> m_textTracks; | 641 PersistentWillBeMember<TextTrackList> m_textTracks; |
555 PersistentHeapVectorWillBeHeapVector<Member<TextTrack>> m_textTracksWhenReso
urceSelectionBegan; | 642 PersistentHeapVectorWillBeHeapVector<Member<TextTrack>> m_textTracksWhenReso
urceSelectionBegan; |
556 | 643 |
| 644 // Autoplay experiment state. |
| 645 // True if we've received a play() without a pause(). |
| 646 bool m_autoplayExperimentPlayPending : 1; |
| 647 |
| 648 // Autoplay experiment state. |
| 649 // True if and only if we initiated playback because of the autoplay |
| 650 // experiment. Once set, this is never unset. |
| 651 bool m_autoplayExperimentStartedByExperiment : 1; |
| 652 |
| 653 // Autoplay experiment state. |
| 654 // Touch listener for the autoplay experiment. |
| 655 class AutoplayExperimentTouchListener; |
| 656 friend class AutoplayExperimentTouchListener; |
| 657 RefPtrWillBeMember<EventListener> m_autoplayExperimentTouchListener; |
| 658 |
| 659 enum AutoplayExperimentMode { |
| 660 ExperimentOff = 0, |
| 661 ExperimentEnabled = 1 << 0, |
| 662 ExperimentIfViewport = 1 << 1, |
| 663 ExperimentIfMuted = 1 << 2, |
| 664 ExperimentIfMobile = 1 << 3, |
| 665 ExperimentPlayMuted = 1 << 4 |
| 666 }; |
| 667 int m_autoplayExperimentMode; // Bitwise-or of AutoplayExperimentMode |
| 668 |
557 OwnPtrWillBeMember<CueTimeline> m_cueTimeline; | 669 OwnPtrWillBeMember<CueTimeline> m_cueTimeline; |
558 | 670 |
559 #if ENABLE(WEB_AUDIO) | 671 #if ENABLE(WEB_AUDIO) |
560 // This is a weak reference, since m_audioSourceNode holds a reference to us
. | 672 // This is a weak reference, since m_audioSourceNode holds a reference to us
. |
561 // FIXME: Oilpan: Consider making this a strongly traced pointer with oilpan
where strong cycles are not a problem. | 673 // FIXME: Oilpan: Consider making this a strongly traced pointer with oilpan
where strong cycles are not a problem. |
562 GC_PLUGIN_IGNORE("http://crbug.com/404577") | 674 GC_PLUGIN_IGNORE("http://crbug.com/404577") |
563 RawPtrWillBeWeakMember<AudioSourceProviderClient> m_audioSourceNode; | 675 RawPtrWillBeWeakMember<AudioSourceProviderClient> m_audioSourceNode; |
564 | 676 |
565 // AudioClientImpl wraps an AudioSourceProviderClient. | 677 // AudioClientImpl wraps an AudioSourceProviderClient. |
566 // When the audio format is known, Chromium calls setFormat(). | 678 // When the audio format is known, Chromium calls setFormat(). |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 | 717 |
606 private: | 718 private: |
607 WebAudioSourceProvider* m_webAudioSourceProvider; | 719 WebAudioSourceProvider* m_webAudioSourceProvider; |
608 PersistentWillBeMember<AudioClientImpl> m_client; | 720 PersistentWillBeMember<AudioClientImpl> m_client; |
609 Mutex provideInputLock; | 721 Mutex provideInputLock; |
610 }; | 722 }; |
611 | 723 |
612 AudioSourceProviderImpl m_audioSourceProvider; | 724 AudioSourceProviderImpl m_audioSourceProvider; |
613 #endif | 725 #endif |
614 | 726 |
| 727 Timer<HTMLMediaElement> m_autoplayViewportTimer; |
| 728 double m_autoplayLastScrollX; |
| 729 double m_autoplayLastScrollY; |
| 730 double m_autoplayViewportTimerSpan; |
| 731 |
615 friend class MediaController; | 732 friend class MediaController; |
616 PersistentWillBeMember<MediaController> m_mediaController; | 733 PersistentWillBeMember<MediaController> m_mediaController; |
617 | 734 |
618 friend class Internals; | 735 friend class Internals; |
619 friend class TrackDisplayUpdateScope; | 736 friend class TrackDisplayUpdateScope; |
620 | 737 |
621 static URLRegistry* s_mediaStreamRegistry; | 738 static URLRegistry* s_mediaStreamRegistry; |
622 }; | 739 }; |
623 | 740 |
624 inline bool isHTMLMediaElement(const HTMLElement& element) | 741 inline bool isHTMLMediaElement(const HTMLElement& element) |
625 { | 742 { |
626 return isHTMLAudioElement(element) || isHTMLVideoElement(element); | 743 return isHTMLAudioElement(element) || isHTMLVideoElement(element); |
627 } | 744 } |
628 | 745 |
629 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); | 746 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); |
630 | 747 |
631 } // namespace blink | 748 } // namespace blink |
632 | 749 |
633 #endif // HTMLMediaElement_h | 750 #endif // HTMLMediaElement_h |
OLD | NEW |