| 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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 , m_seeking(false) | 345 , m_seeking(false) |
| 346 , m_sentStalledEvent(false) | 346 , m_sentStalledEvent(false) |
| 347 , m_sentEndEvent(false) | 347 , m_sentEndEvent(false) |
| 348 , m_pausedInternal(false) | 348 , m_pausedInternal(false) |
| 349 , m_closedCaptionsVisible(false) | 349 , m_closedCaptionsVisible(false) |
| 350 , m_completelyLoaded(false) | 350 , m_completelyLoaded(false) |
| 351 , m_havePreparedToPlay(false) | 351 , m_havePreparedToPlay(false) |
| 352 , m_tracksAreReady(true) | 352 , m_tracksAreReady(true) |
| 353 , m_haveVisibleTextTrack(false) | 353 , m_haveVisibleTextTrack(false) |
| 354 , m_processingPreferenceChange(false) | 354 , m_processingPreferenceChange(false) |
| 355 , m_remoteRoutesAvailable(false) |
| 356 , m_playingRemotely(false) |
| 355 #if ENABLE(OILPAN) | 357 #if ENABLE(OILPAN) |
| 356 , m_isFinalizing(false) | 358 , m_isFinalizing(false) |
| 357 , m_closeMediaSourceWhenFinalizing(false) | 359 , m_closeMediaSourceWhenFinalizing(false) |
| 358 #endif | 360 #endif |
| 359 , m_lastTextTrackUpdateTime(-1) | 361 , m_lastTextTrackUpdateTime(-1) |
| 360 , m_audioTracks(AudioTrackList::create(*this)) | 362 , m_audioTracks(AudioTrackList::create(*this)) |
| 361 , m_videoTracks(VideoTrackList::create(*this)) | 363 , m_videoTracks(VideoTrackList::create(*this)) |
| 362 , m_textTracks(nullptr) | 364 , m_textTracks(nullptr) |
| 363 , m_ignoreTrackDisplayUpdate(0) | 365 , m_ignoreTrackDisplayUpdate(0) |
| 364 #if ENABLE(WEB_AUDIO) | 366 #if ENABLE(WEB_AUDIO) |
| (...skipping 1904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2269 | 2271 |
| 2270 if (!m_paused) { | 2272 if (!m_paused) { |
| 2271 m_paused = true; | 2273 m_paused = true; |
| 2272 scheduleTimeupdateEvent(false); | 2274 scheduleTimeupdateEvent(false); |
| 2273 scheduleEvent(EventTypeNames::pause); | 2275 scheduleEvent(EventTypeNames::pause); |
| 2274 } | 2276 } |
| 2275 | 2277 |
| 2276 updatePlayState(); | 2278 updatePlayState(); |
| 2277 } | 2279 } |
| 2278 | 2280 |
| 2281 void HTMLMediaElement::requestRemotePlayback() |
| 2282 { |
| 2283 ASSERT(m_remoteRoutesAvailable); |
| 2284 webMediaPlayer()->requestRemotePlayback(); |
| 2285 } |
| 2286 |
| 2287 void HTMLMediaElement::requestRemotePlaybackControl() |
| 2288 { |
| 2289 ASSERT(m_remoteRoutesAvailable); |
| 2290 webMediaPlayer()->requestRemotePlaybackControl(); |
| 2291 } |
| 2292 |
| 2279 void HTMLMediaElement::closeMediaSource() | 2293 void HTMLMediaElement::closeMediaSource() |
| 2280 { | 2294 { |
| 2281 if (!m_mediaSource) | 2295 if (!m_mediaSource) |
| 2282 return; | 2296 return; |
| 2283 | 2297 |
| 2284 m_mediaSource->close(); | 2298 m_mediaSource->close(); |
| 2285 m_mediaSource = nullptr; | 2299 m_mediaSource = nullptr; |
| 2286 } | 2300 } |
| 2287 | 2301 |
| 2288 bool HTMLMediaElement::loop() const | 2302 bool HTMLMediaElement::loop() const |
| (...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3173 void HTMLMediaElement::mediaPlayerRequestSeek(double time) | 3187 void HTMLMediaElement::mediaPlayerRequestSeek(double time) |
| 3174 { | 3188 { |
| 3175 // The player is the source of this seek request. | 3189 // The player is the source of this seek request. |
| 3176 if (m_mediaController) { | 3190 if (m_mediaController) { |
| 3177 m_mediaController->setCurrentTime(time); | 3191 m_mediaController->setCurrentTime(time); |
| 3178 return; | 3192 return; |
| 3179 } | 3193 } |
| 3180 setCurrentTime(time, ASSERT_NO_EXCEPTION); | 3194 setCurrentTime(time, ASSERT_NO_EXCEPTION); |
| 3181 } | 3195 } |
| 3182 | 3196 |
| 3197 void HTMLMediaElement::remoteRouteAvailabilityChanged(bool routesAvailable) |
| 3198 { |
| 3199 m_remoteRoutesAvailable = routesAvailable; |
| 3200 if (hasMediaControls()) |
| 3201 mediaControls()->refreshCastButtonVisibility(); |
| 3202 } |
| 3203 |
| 3204 void HTMLMediaElement::connectedToRemoteDevice() |
| 3205 { |
| 3206 m_playingRemotely = true; |
| 3207 if (hasMediaControls()) |
| 3208 mediaControls()->startedCasting(); |
| 3209 } |
| 3210 |
| 3211 void HTMLMediaElement::disconnectedFromRemoteDevice() |
| 3212 { |
| 3213 m_playingRemotely = false; |
| 3214 if (hasMediaControls()) |
| 3215 mediaControls()->stoppedCasting(); |
| 3216 } |
| 3217 |
| 3183 // MediaPlayerPresentation methods | 3218 // MediaPlayerPresentation methods |
| 3184 void HTMLMediaElement::mediaPlayerRepaint() | 3219 void HTMLMediaElement::mediaPlayerRepaint() |
| 3185 { | 3220 { |
| 3186 if (m_webLayer) | 3221 if (m_webLayer) |
| 3187 m_webLayer->invalidate(); | 3222 m_webLayer->invalidate(); |
| 3188 | 3223 |
| 3189 updateDisplayState(); | 3224 updateDisplayState(); |
| 3190 if (renderer()) | 3225 if (renderer()) |
| 3191 renderer()->setShouldDoFullPaintInvalidation(true); | 3226 renderer()->setShouldDoFullPaintInvalidation(true); |
| 3192 } | 3227 } |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3428 AudioSourceProviderClientLockScope scope(*this); | 3463 AudioSourceProviderClientLockScope scope(*this); |
| 3429 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); | 3464 clearMediaPlayerAndAudioSourceProviderClientWithoutLocking(); |
| 3430 } | 3465 } |
| 3431 | 3466 |
| 3432 stopPeriodicTimers(); | 3467 stopPeriodicTimers(); |
| 3433 m_loadTimer.stop(); | 3468 m_loadTimer.stop(); |
| 3434 | 3469 |
| 3435 m_pendingActionFlags &= ~flags; | 3470 m_pendingActionFlags &= ~flags; |
| 3436 m_loadState = WaitingForSource; | 3471 m_loadState = WaitingForSource; |
| 3437 | 3472 |
| 3473 // We can't cast if we don't have a media player. |
| 3474 m_remoteRoutesAvailable = false; |
| 3475 m_playingRemotely = false; |
| 3476 if (hasMediaControls()) { |
| 3477 mediaControls()->refreshCastButtonVisibility(); |
| 3478 } |
| 3479 |
| 3438 if (m_textTracks) | 3480 if (m_textTracks) |
| 3439 configureTextTrackDisplay(AssumeNoVisibleChange); | 3481 configureTextTrackDisplay(AssumeNoVisibleChange); |
| 3440 } | 3482 } |
| 3441 | 3483 |
| 3442 void HTMLMediaElement::stop() | 3484 void HTMLMediaElement::stop() |
| 3443 { | 3485 { |
| 3444 WTF_LOG(Media, "HTMLMediaElement::stop(%p)", this); | 3486 WTF_LOG(Media, "HTMLMediaElement::stop(%p)", this); |
| 3445 | 3487 |
| 3446 m_active = false; | 3488 m_active = false; |
| 3447 userCancelledLoad(); | 3489 userCancelledLoad(); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3628 ensureUserAgentShadowRoot().appendChild(mediaControls); | 3670 ensureUserAgentShadowRoot().appendChild(mediaControls); |
| 3629 | 3671 |
| 3630 if (!shouldShowControls() || !inDocument()) | 3672 if (!shouldShowControls() || !inDocument()) |
| 3631 mediaControls->hide(); | 3673 mediaControls->hide(); |
| 3632 | 3674 |
| 3633 return true; | 3675 return true; |
| 3634 } | 3676 } |
| 3635 | 3677 |
| 3636 void HTMLMediaElement::configureMediaControls() | 3678 void HTMLMediaElement::configureMediaControls() |
| 3637 { | 3679 { |
| 3638 if (!shouldShowControls() || !inDocument()) { | 3680 if (!inDocument()) { |
| 3639 if (hasMediaControls()) | 3681 if (hasMediaControls()) |
| 3640 mediaControls()->hide(); | 3682 mediaControls()->hide(); |
| 3641 return; | 3683 return; |
| 3642 } | 3684 } |
| 3643 | 3685 |
| 3644 if (!createMediaControls()) | 3686 if (!createMediaControls()) |
| 3645 return; | 3687 return; |
| 3646 | 3688 |
| 3647 mediaControls()->reset(); | 3689 mediaControls()->reset(); |
| 3648 mediaControls()->show(); | 3690 if (shouldShowControls()) |
| 3691 mediaControls()->show(); |
| 3692 else |
| 3693 mediaControls()->hide(); |
| 3649 } | 3694 } |
| 3650 | 3695 |
| 3651 void HTMLMediaElement::configureTextTrackDisplay(VisibilityChangeAssumption assu
mption) | 3696 void HTMLMediaElement::configureTextTrackDisplay(VisibilityChangeAssumption assu
mption) |
| 3652 { | 3697 { |
| 3653 ASSERT(m_textTracks); | 3698 ASSERT(m_textTracks); |
| 3654 WTF_LOG(Media, "HTMLMediaElement::configureTextTrackDisplay(%p)", this); | 3699 WTF_LOG(Media, "HTMLMediaElement::configureTextTrackDisplay(%p)", this); |
| 3655 | 3700 |
| 3656 if (m_processingPreferenceChange) | 3701 if (m_processingPreferenceChange) |
| 3657 return; | 3702 return; |
| 3658 | 3703 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3711 } | 3756 } |
| 3712 | 3757 |
| 3713 void HTMLMediaElement::createMediaPlayer() | 3758 void HTMLMediaElement::createMediaPlayer() |
| 3714 { | 3759 { |
| 3715 AudioSourceProviderClientLockScope scope(*this); | 3760 AudioSourceProviderClientLockScope scope(*this); |
| 3716 | 3761 |
| 3717 closeMediaSource(); | 3762 closeMediaSource(); |
| 3718 | 3763 |
| 3719 m_player = MediaPlayer::create(this); | 3764 m_player = MediaPlayer::create(this); |
| 3720 | 3765 |
| 3766 // We haven't yet found out if any remote routes are available. |
| 3767 m_remoteRoutesAvailable = false; |
| 3768 m_playingRemotely = false; |
| 3769 |
| 3721 #if ENABLE(WEB_AUDIO) | 3770 #if ENABLE(WEB_AUDIO) |
| 3722 if (m_audioSourceNode && audioSourceProvider()) { | 3771 if (m_audioSourceNode && audioSourceProvider()) { |
| 3723 // When creating the player, make sure its AudioSourceProvider knows abo
ut the client. | 3772 // When creating the player, make sure its AudioSourceProvider knows abo
ut the client. |
| 3724 audioSourceProvider()->setClient(m_audioSourceNode); | 3773 audioSourceProvider()->setClient(m_audioSourceNode); |
| 3725 } | 3774 } |
| 3726 #endif | 3775 #endif |
| 3727 } | 3776 } |
| 3728 | 3777 |
| 3729 #if ENABLE(WEB_AUDIO) | 3778 #if ENABLE(WEB_AUDIO) |
| 3730 void HTMLMediaElement::setAudioSourceNode(AudioSourceProviderClient* sourceNode) | 3779 void HTMLMediaElement::setAudioSourceNode(AudioSourceProviderClient* sourceNode) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 3747 | 3796 |
| 3748 const AtomicString& HTMLMediaElement::mediaGroup() const | 3797 const AtomicString& HTMLMediaElement::mediaGroup() const |
| 3749 { | 3798 { |
| 3750 return fastGetAttribute(mediagroupAttr); | 3799 return fastGetAttribute(mediagroupAttr); |
| 3751 } | 3800 } |
| 3752 | 3801 |
| 3753 void HTMLMediaElement::setMediaGroup(const AtomicString& group) | 3802 void HTMLMediaElement::setMediaGroup(const AtomicString& group) |
| 3754 { | 3803 { |
| 3755 // When a media element is created with a mediagroup attribute, and when a m
edia element's mediagroup | 3804 // When a media element is created with a mediagroup attribute, and when a m
edia element's mediagroup |
| 3756 // attribute is set, changed, or removed, the user agent must run the follow
ing steps: | 3805 // attribute is set, changed, or removed, the user agent must run the follow
ing steps: |
| 3757 // 1. Let m [this] be the media element in question. | 3806 // 1. Let _R [this] be the media element in question. |
| 3758 // 2. Let m have no current media controller, if it currently has one. | 3807 // 2. Let m have no current media controller, if it currently has one. |
| 3759 setControllerInternal(nullptr); | 3808 setControllerInternal(nullptr); |
| 3760 | 3809 |
| 3761 // 3. If m's mediagroup attribute is being removed, then abort these steps. | 3810 // 3. If m's mediagroup attribute is being removed, then abort these steps. |
| 3762 if (group.isNull() || group.isEmpty()) | 3811 if (group.isNull() || group.isEmpty()) |
| 3763 return; | 3812 return; |
| 3764 | 3813 |
| 3765 // 4. If there is another media element whose Document is the same as m's Do
cument (even if one or both | 3814 // 4. If there is another media element whose Document is the same as m's Do
cument (even if one or both |
| 3766 // of these elements are not actually in the Document), | 3815 // of these elements are not actually in the Document), |
| 3767 WeakMediaElementSet elements = documentToElementSetMap().get(&document()); | 3816 WeakMediaElementSet elements = documentToElementSetMap().get(&document()); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3976 | 4025 |
| 3977 #if ENABLE(WEB_AUDIO) | 4026 #if ENABLE(WEB_AUDIO) |
| 3978 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) | 4027 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) |
| 3979 { | 4028 { |
| 3980 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) | 4029 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) |
| 3981 audioSourceProvider()->setClient(0); | 4030 audioSourceProvider()->setClient(0); |
| 3982 } | 4031 } |
| 3983 #endif | 4032 #endif |
| 3984 | 4033 |
| 3985 } | 4034 } |
| OLD | NEW |