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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
267 bool isURLAttribute(const Attribute&) const override; | 267 bool isURLAttribute(const Attribute&) const override; |
268 void attach(const AttachContext& = AttachContext()) override; | 268 void attach(const AttachContext& = AttachContext()) override; |
269 | 269 |
270 void didMoveToNewDocument(Document& oldDocument) override; | 270 void didMoveToNewDocument(Document& oldDocument) override; |
271 virtual KURL posterImageURL() const { return KURL(); } | 271 virtual KURL posterImageURL() const { return KURL(); } |
272 | 272 |
273 enum DisplayMode { Unknown, Poster, Video }; | 273 enum DisplayMode { Unknown, Poster, Video }; |
274 DisplayMode displayMode() const { return m_displayMode; } | 274 DisplayMode displayMode() const { return m_displayMode; } |
275 virtual void setDisplayMode(DisplayMode mode) { m_displayMode = mode; } | 275 virtual void setDisplayMode(DisplayMode mode) { m_displayMode = mode; } |
276 | 276 |
277 void recordAutoplayMetric(AutoplayMetrics); | |
278 | |
277 private: | 279 private: |
278 void resetMediaPlayerAndMediaSource(); | 280 void resetMediaPlayerAndMediaSource(); |
279 | 281 |
280 bool alwaysCreateUserAgentShadowRoot() const final { return true; } | 282 bool alwaysCreateUserAgentShadowRoot() const final { return true; } |
281 bool areAuthorShadowsAllowed() const final { return false; } | 283 bool areAuthorShadowsAllowed() const final { return false; } |
282 | 284 |
283 bool supportsFocus() const final; | 285 bool supportsFocus() const final; |
284 bool isMouseFocusable() const final; | 286 bool isMouseFocusable() const final; |
285 bool layoutObjectIsNeeded(const ComputedStyle&) override; | 287 bool layoutObjectIsNeeded(const ComputedStyle&) override; |
286 LayoutObject* createLayoutObject(const ComputedStyle&) override; | 288 LayoutObject* createLayoutObject(const ComputedStyle&) override; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
372 void deferredLoadTimerFired(Timer<HTMLMediaElement>*); | 374 void deferredLoadTimerFired(Timer<HTMLMediaElement>*); |
373 | 375 |
374 void markCaptionAndSubtitleTracksAsUnconfigured(); | 376 void markCaptionAndSubtitleTracksAsUnconfigured(); |
375 | 377 |
376 // This does not check user gesture restrictions. | 378 // This does not check user gesture restrictions. |
377 void playInternal(); | 379 void playInternal(); |
378 | 380 |
379 // This does not change the buffering strategy. | 381 // This does not change the buffering strategy. |
380 void pauseInternal(); | 382 void pauseInternal(); |
381 | 383 |
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(); | 384 void allowVideoRendering(); |
391 | 385 |
392 void updateVolume(); | 386 void updateVolume(); |
393 void updatePlayState(); | 387 void updatePlayState(); |
394 bool potentiallyPlaying() const; | 388 bool potentiallyPlaying() const; |
395 bool stoppedDueToErrors() const; | 389 bool stoppedDueToErrors() const; |
396 bool couldPlayIfEnoughData() const; | 390 bool couldPlayIfEnoughData() const; |
397 | 391 |
398 // Generally the presence of the loop attribute should be considered to mean playback | 392 // 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 | 393 // has not "ended", as "ended" and "looping" are mutually exclusive. See |
(...skipping 11 matching lines...) Expand all Loading... | |
411 TextTrackContainer& ensureTextTrackContainer(); | 405 TextTrackContainer& ensureTextTrackContainer(); |
412 | 406 |
413 void* preDispatchEventHandler(Event*) final; | 407 void* preDispatchEventHandler(Event*) final; |
414 | 408 |
415 void changeNetworkStateFromLoadingToIdle(); | 409 void changeNetworkStateFromLoadingToIdle(); |
416 | 410 |
417 bool isAutoplaying() const { return m_autoplaying; } | 411 bool isAutoplaying() const { return m_autoplaying; } |
418 | 412 |
419 void setAllowHiddenVolumeControls(bool); | 413 void setAllowHiddenVolumeControls(bool); |
420 | 414 |
421 void recordAutoplayMetric(AutoplayMetrics); | |
422 | |
423 WebMediaPlayer::CORSMode corsMode() const; | 415 WebMediaPlayer::CORSMode corsMode() const; |
424 | 416 |
425 // Returns the "direction of playback" value as specified in the HTML5 spec. | 417 // Returns the "direction of playback" value as specified in the HTML5 spec. |
426 enum DirectionOfPlayback { Backward, Forward }; | 418 enum DirectionOfPlayback { Backward, Forward }; |
427 DirectionOfPlayback directionOfPlayback() const; | 419 DirectionOfPlayback directionOfPlayback() const; |
428 | 420 |
429 // Creates placeholder AudioTrack and/or VideoTrack objects when WebMemediaP layer objects | 421 // 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 | 422 // advertise they have audio and/or video, but don't explicitly signal them via |
431 // addAudioTrack() and addVideoTrack(). | 423 // addAudioTrack() and addVideoTrack(). |
432 // FIXME: Remove this once all WebMediaPlayer implementations properly repor t their track info. | 424 // FIXME: Remove this once all WebMediaPlayer implementations properly repor t their track info. |
433 void createPlaceholderTracksIfNecessary(); | 425 void createPlaceholderTracksIfNecessary(); |
434 | 426 |
435 // Sets the selected/enabled tracks if they aren't set before we initially | 427 // Sets the selected/enabled tracks if they aren't set before we initially |
436 // transition to HAVE_METADATA. | 428 // transition to HAVE_METADATA. |
437 void selectInitialTracksIfNecessary(); | 429 void selectInitialTracksIfNecessary(); |
438 | 430 |
439 // Return true if and only if we require a user gesture before letting | 431 // Return true if and only if we require a user gesture before letting |
440 // the media play. | 432 // the media play. |
441 bool isUserGestureRequiredForPlay() const; | 433 bool isUserGestureRequiredForPlay() const; |
434 | |
435 // If the user gesture is required, then this will remove it. Note that | |
436 // one should not generally call this method directly; use the one on | |
437 // m_helper and give it a reason. | |
442 void removeUserGestureRequirement(); | 438 void removeUserGestureRequirement(); |
443 void setInitialPlayWithoutUserGestures(bool); | |
444 | 439 |
445 void setNetworkState(NetworkState); | 440 void setNetworkState(NetworkState); |
446 | 441 |
447 void audioTracksTimerFired(Timer<HTMLMediaElement>*); | 442 void audioTracksTimerFired(Timer<HTMLMediaElement>*); |
448 | 443 |
449 // TODO(liberato): remove once autoplay gesture override experiment conclude s. | 444 // TODO(liberato): remove once autoplay gesture override experiment conclude s. |
450 void triggerAutoplayViewportCheckForTesting(); | 445 void triggerAutoplayViewportCheckForTesting(); |
451 | 446 |
452 UnthrottledTimer<HTMLMediaElement> m_loadTimer; | 447 UnthrottledTimer<HTMLMediaElement> m_loadTimer; |
453 UnthrottledTimer<HTMLMediaElement> m_progressEventTimer; | 448 UnthrottledTimer<HTMLMediaElement> m_progressEventTimer; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
538 | 533 |
539 bool m_closedCaptionsVisible : 1; | 534 bool m_closedCaptionsVisible : 1; |
540 | 535 |
541 bool m_havePreparedToPlay : 1; | 536 bool m_havePreparedToPlay : 1; |
542 | 537 |
543 bool m_tracksAreReady : 1; | 538 bool m_tracksAreReady : 1; |
544 bool m_processingPreferenceChange : 1; | 539 bool m_processingPreferenceChange : 1; |
545 bool m_remoteRoutesAvailable : 1; | 540 bool m_remoteRoutesAvailable : 1; |
546 bool m_playingRemotely : 1; | 541 bool m_playingRemotely : 1; |
547 bool m_isFinalizing : 1; | 542 bool m_isFinalizing : 1; |
548 bool m_initialPlayWithoutUserGesture : 1; | |
549 bool m_autoplayMediaCounted : 1; | |
550 // Whether this element is in overlay fullscreen mode. | 543 // Whether this element is in overlay fullscreen mode. |
551 bool m_inOverlayFullscreenVideo : 1; | 544 bool m_inOverlayFullscreenVideo : 1; |
552 | 545 |
553 PersistentWillBeMember<AudioTrackList> m_audioTracks; | 546 PersistentWillBeMember<AudioTrackList> m_audioTracks; |
554 PersistentWillBeMember<VideoTrackList> m_videoTracks; | 547 PersistentWillBeMember<VideoTrackList> m_videoTracks; |
555 PersistentWillBeMember<TextTrackList> m_textTracks; | 548 PersistentWillBeMember<TextTrackList> m_textTracks; |
556 PersistentHeapVectorWillBeHeapVector<Member<TextTrack>> m_textTracksWhenReso urceSelectionBegan; | 549 PersistentHeapVectorWillBeHeapVector<Member<TextTrack>> m_textTracksWhenReso urceSelectionBegan; |
557 | 550 |
558 OwnPtrWillBeMember<CueTimeline> m_cueTimeline; | 551 OwnPtrWillBeMember<CueTimeline> m_cueTimeline; |
559 | 552 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
604 DECLARE_TRACE(); | 597 DECLARE_TRACE(); |
605 | 598 |
606 private: | 599 private: |
607 WebAudioSourceProvider* m_webAudioSourceProvider; | 600 WebAudioSourceProvider* m_webAudioSourceProvider; |
608 PersistentWillBeMember<AudioClientImpl> m_client; | 601 PersistentWillBeMember<AudioClientImpl> m_client; |
609 Mutex provideInputLock; | 602 Mutex provideInputLock; |
610 }; | 603 }; |
611 | 604 |
612 AudioSourceProviderImpl m_audioSourceProvider; | 605 AudioSourceProviderImpl m_audioSourceProvider; |
613 | 606 |
607 class AutoplayHelperClientImpl; | |
sof
2016/02/25 18:55:44
Let's just leave this out (and make HTMLMediaEleme
liberato (no reviews please)
2016/03/14 17:09:13
it accesses private members, so it would need a fr
| |
608 | |
614 friend class Internals; | 609 friend class Internals; |
615 friend class TrackDisplayUpdateScope; | 610 friend class TrackDisplayUpdateScope; |
616 friend class AutoplayExperimentHelper; | 611 friend class AutoplayExperimentHelper; |
617 friend class MediaControlsTest; | 612 friend class MediaControlsTest; |
618 | 613 |
619 AutoplayExperimentHelper m_autoplayHelper; | 614 OwnPtrWillBeMember<AutoplayExperimentHelper::Client> m_autoplayHelperClient; |
615 OwnPtrWillBeMember<AutoplayExperimentHelper> m_autoplayHelper; | |
620 | 616 |
621 static URLRegistry* s_mediaStreamRegistry; | 617 static URLRegistry* s_mediaStreamRegistry; |
622 }; | 618 }; |
623 | 619 |
624 inline bool isHTMLMediaElement(const HTMLElement& element) | 620 inline bool isHTMLMediaElement(const HTMLElement& element) |
625 { | 621 { |
626 return isHTMLAudioElement(element) || isHTMLVideoElement(element); | 622 return isHTMLAudioElement(element) || isHTMLVideoElement(element); |
627 } | 623 } |
628 | 624 |
629 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); | 625 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); |
630 | 626 |
631 } // namespace blink | 627 } // namespace blink |
632 | 628 |
633 #endif // HTMLMediaElement_h | 629 #endif // HTMLMediaElement_h |
OLD | NEW |