Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Side by Side Diff: Source/core/html/HTMLMediaElement.cpp

Issue 291163004: Implement media cast buttons (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase to fix merge problem with TestExpectations Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 , m_seeking(false) 346 , m_seeking(false)
347 , m_sentStalledEvent(false) 347 , m_sentStalledEvent(false)
348 , m_sentEndEvent(false) 348 , m_sentEndEvent(false)
349 , m_pausedInternal(false) 349 , m_pausedInternal(false)
350 , m_closedCaptionsVisible(false) 350 , m_closedCaptionsVisible(false)
351 , m_completelyLoaded(false) 351 , m_completelyLoaded(false)
352 , m_havePreparedToPlay(false) 352 , m_havePreparedToPlay(false)
353 , m_tracksAreReady(true) 353 , m_tracksAreReady(true)
354 , m_haveVisibleTextTrack(false) 354 , m_haveVisibleTextTrack(false)
355 , m_processingPreferenceChange(false) 355 , m_processingPreferenceChange(false)
356 , m_remoteRoutesAvailable(false)
357 , m_playingRemotely(false)
356 #if ENABLE(OILPAN) 358 #if ENABLE(OILPAN)
357 , m_isFinalizing(false) 359 , m_isFinalizing(false)
358 , m_closeMediaSourceWhenFinalizing(false) 360 , m_closeMediaSourceWhenFinalizing(false)
359 #endif 361 #endif
360 , m_lastTextTrackUpdateTime(-1) 362 , m_lastTextTrackUpdateTime(-1)
361 , m_audioTracks(AudioTrackList::create(*this)) 363 , m_audioTracks(AudioTrackList::create(*this))
362 , m_videoTracks(VideoTrackList::create(*this)) 364 , m_videoTracks(VideoTrackList::create(*this))
363 , m_textTracks(nullptr) 365 , m_textTracks(nullptr)
364 , m_ignoreTrackDisplayUpdate(0) 366 , m_ignoreTrackDisplayUpdate(0)
365 #if ENABLE(WEB_AUDIO) 367 #if ENABLE(WEB_AUDIO)
(...skipping 1904 matching lines...) Expand 10 before | Expand all | Expand 10 after
2270 2272
2271 if (!m_paused) { 2273 if (!m_paused) {
2272 m_paused = true; 2274 m_paused = true;
2273 scheduleTimeupdateEvent(false); 2275 scheduleTimeupdateEvent(false);
2274 scheduleEvent(EventTypeNames::pause); 2276 scheduleEvent(EventTypeNames::pause);
2275 } 2277 }
2276 2278
2277 updatePlayState(); 2279 updatePlayState();
2278 } 2280 }
2279 2281
2282 void HTMLMediaElement::requestRemotePlayback()
2283 {
2284 ASSERT(m_remoteRoutesAvailable);
2285 webMediaPlayer()->requestRemotePlayback();
2286 }
2287
2288 void HTMLMediaElement::requestRemotePlaybackControl()
2289 {
2290 ASSERT(m_remoteRoutesAvailable);
2291 webMediaPlayer()->requestRemotePlaybackControl();
2292 }
2293
2280 void HTMLMediaElement::closeMediaSource() 2294 void HTMLMediaElement::closeMediaSource()
2281 { 2295 {
2282 if (!m_mediaSource) 2296 if (!m_mediaSource)
2283 return; 2297 return;
2284 2298
2285 m_mediaSource->close(); 2299 m_mediaSource->close();
2286 m_mediaSource = nullptr; 2300 m_mediaSource = nullptr;
2287 } 2301 }
2288 2302
2289 bool HTMLMediaElement::loop() const 2303 bool HTMLMediaElement::loop() const
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after
3180 void HTMLMediaElement::mediaPlayerRequestSeek(double time) 3194 void HTMLMediaElement::mediaPlayerRequestSeek(double time)
3181 { 3195 {
3182 // The player is the source of this seek request. 3196 // The player is the source of this seek request.
3183 if (m_mediaController) { 3197 if (m_mediaController) {
3184 m_mediaController->setCurrentTime(time); 3198 m_mediaController->setCurrentTime(time);
3185 return; 3199 return;
3186 } 3200 }
3187 setCurrentTime(time, ASSERT_NO_EXCEPTION); 3201 setCurrentTime(time, ASSERT_NO_EXCEPTION);
3188 } 3202 }
3189 3203
3204 void HTMLMediaElement::remoteRouteAvailabilityChanged(bool routesAvailable)
3205 {
3206 m_remoteRoutesAvailable = routesAvailable;
3207 if (hasMediaControls())
3208 mediaControls()->refreshCastButtonVisibility();
3209 }
3210
3211 void HTMLMediaElement::connectedToRemoteDevice()
3212 {
3213 m_playingRemotely = true;
3214 if (hasMediaControls())
3215 mediaControls()->startedCasting();
3216 }
3217
3218 void HTMLMediaElement::disconnectedFromRemoteDevice()
3219 {
3220 m_playingRemotely = false;
3221 if (hasMediaControls())
3222 mediaControls()->stoppedCasting();
3223 }
3224
3190 // MediaPlayerPresentation methods 3225 // MediaPlayerPresentation methods
3191 void HTMLMediaElement::mediaPlayerRepaint() 3226 void HTMLMediaElement::mediaPlayerRepaint()
3192 { 3227 {
3193 if (m_webLayer) 3228 if (m_webLayer)
3194 m_webLayer->invalidate(); 3229 m_webLayer->invalidate();
3195 3230
3196 updateDisplayState(); 3231 updateDisplayState();
3197 if (renderer()) 3232 if (renderer())
3198 renderer()->setShouldDoFullPaintInvalidation(true); 3233 renderer()->setShouldDoFullPaintInvalidation(true);
3199 } 3234 }
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
3435 AudioSourceProviderClientLockScope scope(*this); 3470 AudioSourceProviderClientLockScope scope(*this);
3436 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); 3471 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking();
3437 } 3472 }
3438 3473
3439 stopPeriodicTimers(); 3474 stopPeriodicTimers();
3440 m_loadTimer.stop(); 3475 m_loadTimer.stop();
3441 3476
3442 m_pendingActionFlags &= ~flags; 3477 m_pendingActionFlags &= ~flags;
3443 m_loadState = WaitingForSource; 3478 m_loadState = WaitingForSource;
3444 3479
3480 // We can't cast if we don't have a media player.
3481 m_remoteRoutesAvailable = false;
3482 m_playingRemotely = false;
3483 if (hasMediaControls()) {
3484 mediaControls()->refreshCastButtonVisibility();
3485 }
3486
3445 if (m_textTracks) 3487 if (m_textTracks)
3446 configureTextTrackDisplay(AssumeNoVisibleChange); 3488 configureTextTrackDisplay(AssumeNoVisibleChange);
3447 } 3489 }
3448 3490
3449 void HTMLMediaElement::stop() 3491 void HTMLMediaElement::stop()
3450 { 3492 {
3451 WTF_LOG(Media, "HTMLMediaElement::stop(%p)", this); 3493 WTF_LOG(Media, "HTMLMediaElement::stop(%p)", this);
3452 3494
3453 m_active = false; 3495 m_active = false;
3454 userCancelledLoad(); 3496 userCancelledLoad();
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
3635 ensureUserAgentShadowRoot().appendChild(mediaControls); 3677 ensureUserAgentShadowRoot().appendChild(mediaControls);
3636 3678
3637 if (!shouldShowControls() || !inDocument()) 3679 if (!shouldShowControls() || !inDocument())
3638 mediaControls->hide(); 3680 mediaControls->hide();
3639 3681
3640 return true; 3682 return true;
3641 } 3683 }
3642 3684
3643 void HTMLMediaElement::configureMediaControls() 3685 void HTMLMediaElement::configureMediaControls()
3644 { 3686 {
3645 if (!shouldShowControls() || !inDocument()) { 3687 if (!inDocument()) {
3646 if (hasMediaControls()) 3688 if (hasMediaControls())
3647 mediaControls()->hide(); 3689 mediaControls()->hide();
3648 return; 3690 return;
3649 } 3691 }
3650 3692
3651 if (!createMediaControls()) 3693 if (!createMediaControls())
3652 return; 3694 return;
3653 3695
3654 mediaControls()->reset(); 3696 mediaControls()->reset();
3655 mediaControls()->show(); 3697 if (shouldShowControls())
3698 mediaControls()->show();
3699 else
3700 mediaControls()->hide();
3656 } 3701 }
3657 3702
3658 void HTMLMediaElement::configureTextTrackDisplay(VisibilityChangeAssumption assu mption) 3703 void HTMLMediaElement::configureTextTrackDisplay(VisibilityChangeAssumption assu mption)
3659 { 3704 {
3660 ASSERT(m_textTracks); 3705 ASSERT(m_textTracks);
3661 WTF_LOG(Media, "HTMLMediaElement::configureTextTrackDisplay(%p)", this); 3706 WTF_LOG(Media, "HTMLMediaElement::configureTextTrackDisplay(%p)", this);
3662 3707
3663 if (m_processingPreferenceChange) 3708 if (m_processingPreferenceChange)
3664 return; 3709 return;
3665 3710
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
3718 } 3763 }
3719 3764
3720 void HTMLMediaElement::createMediaPlayer() 3765 void HTMLMediaElement::createMediaPlayer()
3721 { 3766 {
3722 AudioSourceProviderClientLockScope scope(*this); 3767 AudioSourceProviderClientLockScope scope(*this);
3723 3768
3724 closeMediaSource(); 3769 closeMediaSource();
3725 3770
3726 m_player = MediaPlayer::create(this); 3771 m_player = MediaPlayer::create(this);
3727 3772
3773 // We haven't yet found out if any remote routes are available.
3774 m_remoteRoutesAvailable = false;
3775 m_playingRemotely = false;
3776
3728 #if ENABLE(WEB_AUDIO) 3777 #if ENABLE(WEB_AUDIO)
3729 if (m_audioSourceNode && audioSourceProvider()) { 3778 if (m_audioSourceNode && audioSourceProvider()) {
3730 // When creating the player, make sure its AudioSourceProvider knows abo ut the client. 3779 // When creating the player, make sure its AudioSourceProvider knows abo ut the client.
3731 audioSourceProvider()->setClient(m_audioSourceNode); 3780 audioSourceProvider()->setClient(m_audioSourceNode);
3732 } 3781 }
3733 #endif 3782 #endif
3734 } 3783 }
3735 3784
3736 #if ENABLE(WEB_AUDIO) 3785 #if ENABLE(WEB_AUDIO)
3737 void HTMLMediaElement::setAudioSourceNode(AudioSourceProviderClient* sourceNode) 3786 void HTMLMediaElement::setAudioSourceNode(AudioSourceProviderClient* sourceNode)
(...skipping 16 matching lines...) Expand all
3754 3803
3755 const AtomicString& HTMLMediaElement::mediaGroup() const 3804 const AtomicString& HTMLMediaElement::mediaGroup() const
3756 { 3805 {
3757 return fastGetAttribute(mediagroupAttr); 3806 return fastGetAttribute(mediagroupAttr);
3758 } 3807 }
3759 3808
3760 void HTMLMediaElement::setMediaGroup(const AtomicString& group) 3809 void HTMLMediaElement::setMediaGroup(const AtomicString& group)
3761 { 3810 {
3762 // When a media element is created with a mediagroup attribute, and when a m edia element's mediagroup 3811 // When a media element is created with a mediagroup attribute, and when a m edia element's mediagroup
3763 // attribute is set, changed, or removed, the user agent must run the follow ing steps: 3812 // attribute is set, changed, or removed, the user agent must run the follow ing steps:
3764 // 1. Let m [this] be the media element in question. 3813 // 1. Let _R [this] be the media element in question.
3765 // 2. Let m have no current media controller, if it currently has one. 3814 // 2. Let m have no current media controller, if it currently has one.
3766 setControllerInternal(nullptr); 3815 setControllerInternal(nullptr);
3767 3816
3768 // 3. If m's mediagroup attribute is being removed, then abort these steps. 3817 // 3. If m's mediagroup attribute is being removed, then abort these steps.
3769 if (group.isNull() || group.isEmpty()) 3818 if (group.isNull() || group.isEmpty())
3770 return; 3819 return;
3771 3820
3772 // 4. If there is another media element whose Document is the same as m's Do cument (even if one or both 3821 // 4. If there is another media element whose Document is the same as m's Do cument (even if one or both
3773 // of these elements are not actually in the Document), 3822 // of these elements are not actually in the Document),
3774 WeakMediaElementSet elements = documentToElementSetMap().get(&document()); 3823 WeakMediaElementSet elements = documentToElementSetMap().get(&document());
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
3983 4032
3984 #if ENABLE(WEB_AUDIO) 4033 #if ENABLE(WEB_AUDIO)
3985 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) 4034 void HTMLMediaElement::clearWeakMembers(Visitor* visitor)
3986 { 4035 {
3987 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) 4036 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider())
3988 audioSourceProvider()->setClient(0); 4037 audioSourceProvider()->setClient(0);
3989 } 4038 }
3990 #endif 4039 #endif
3991 4040
3992 } 4041 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698