Changeset 183509 in webkit
- Timestamp:
- Apr 28, 2015, 2:40:10 PM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r183499 r183509 1 2015-04-28 Eric Carlson <eric.carlson@apple.com> 2 3 [Mac] Simplify code to support media engines which do not support target playback 4 https://bugs.webkit.org/show_bug.cgi?id=144332 5 6 Reviewed by Jer Noble. 7 8 * Modules/mediasession/WebMediaSessionManager.cpp: 9 (WebCore::WebMediaSessionManager::externalOutputDeviceAvailableDidChange): Always make client 10 callback, let them decide if it is significant or not. 11 12 * html/HTMLMediaElement.cpp: 13 (WebCore::HTMLMediaElement::HTMLMediaElement): m_loadTimer -> m_pendingActionTimer. 14 (WebCore::HTMLMediaElement::scheduleDelayedAction): Handle CheckPlaybackTargetCompatablity. 15 (WebCore::HTMLMediaElement::scheduleNextSourceChild): m_loadTimer -> m_pendingActionTimer. 16 (WebCore::HTMLMediaElement::loadTimerFired): Renamed pendingActionTimerFired. 17 (WebCore::HTMLMediaElement::prepareForLoad): m_loadTimer -> m_pendingActionTimer. 18 (WebCore::HTMLMediaElement::setDefaultPlaybackRate): Add logging. 19 (WebCore::HTMLMediaElement::clearMediaPlayer): m_loadTimer -> m_pendingActionTimer. 20 (WebCore::HTMLMediaElement::webkitCurrentPlaybackTargetIsSupported): Removed. 21 (WebCore::HTMLMediaElement::dispatchEvent): If a 'webkitcurrentplaybacktargetiswirelesschanged' 22 event is dispatched when the current target is wireless but the media engine does not support 23 wireless playback, tell the media engine not to play to the target. 24 * html/HTMLMediaElement.h: 25 * html/HTMLMediaElement.idl: 26 27 * html/HTMLMediaSession.cpp: 28 (WebCore::HTMLMediaSession::showPlaybackTargetPicker): Drive-by fix to disallow audio-only files. 29 (WebCore::HTMLMediaSession::currentPlaybackTargetIsSupported): Deleted. 30 * html/HTMLMediaSession.h: 31 32 * platform/graphics/MediaPlayer.cpp: 33 (WebCore::MediaPlayer::isCurrentPlaybackTargetSupported): Deleted. 34 * platform/graphics/MediaPlayer.h: 35 * platform/graphics/MediaPlayerPrivate.h: 36 37 * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: 38 (WebCore::MediaPlayerPrivateAVFoundationObjC::setShouldPlayToPlaybackTarget): Use a RetainPtr 39 to explicitly manage the lifetime of the temporary object. 40 (WebCore::MediaPlayerPrivateAVFoundationObjC::isPlayingToWirelessPlaybackTarget): Ditto. 41 * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h: 42 43 * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm: 44 (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setShouldPlayToPlaybackTarget): 45 (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::isCurrentPlaybackTargetWireless): 46 (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::isCurrentPlaybackTargetSupported): Deleted. 47 48 * platform/graphics/mac/MediaPlayerPrivateQTKit.h: 49 * platform/graphics/mac/MediaPlayerPrivateQTKit.mm: 50 (WebCore::MediaPlayerPrivateQTKit::setShouldPlayToPlaybackTarget): 51 (WebCore::MediaPlayerPrivateQTKit::isCurrentPlaybackTargetWireless): 52 (WebCore::MediaPlayerPrivateQTKit::isCurrentPlaybackTargetSupported): Deleted. 53 1 54 2015-04-28 Alex Christensen <achristensen@webkit.org> 2 55 -
trunk/Source/WebCore/Modules/mediasession/WebMediaSessionManager.cpp
r183096 r183509 197 197 void WebMediaSessionManager::externalOutputDeviceAvailableDidChange(bool available) 198 198 { 199 if (m_externalOutputDeviceAvailable == available)200 return;201 202 199 m_externalOutputDeviceAvailable = available; 203 200 for (auto& state : m_clientState) -
trunk/Source/WebCore/html/HTMLMediaElement.cpp
r183428 r183509 257 257 : HTMLElement(tagName, document) 258 258 , ActiveDOMObject(&document) 259 , m_ loadTimer(*this, &HTMLMediaElement::loadTimerFired)259 , m_pendingActionTimer(*this, &HTMLMediaElement::pendingActionTimerFired) 260 260 , m_progressEventTimer(*this, &HTMLMediaElement::progressEventTimerFired) 261 261 , m_playbackProgressTimer(*this, &HTMLMediaElement::playbackProgressTimerFired) … … 695 695 #endif 696 696 697 m_loadTimer.startOneShot(0); 697 #if ENABLE(WIRELESS_PLAYBACK_TARGET) 698 if (actionType & CheckPlaybackTargetCompatablity) 699 setFlags(m_pendingActionFlags, CheckPlaybackTargetCompatablity); 700 #endif 701 702 m_pendingActionTimer.startOneShot(0); 698 703 } 699 704 … … 702 707 // Schedule the timer to try the next <source> element WITHOUT resetting state ala prepareForLoad. 703 708 setFlags(m_pendingActionFlags, LoadMediaResource); 704 m_ loadTimer.startOneShot(0);709 m_pendingActionTimer.startOneShot(0); 705 710 } 706 711 … … 718 723 } 719 724 720 void HTMLMediaElement:: loadTimerFired()725 void HTMLMediaElement::pendingActionTimerFired() 721 726 { 722 727 Ref<HTMLMediaElement> protect(*this); // loadNextSourceChild may fire 'beforeload', which can make arbitrary DOM mutations. … … 737 742 if (RuntimeEnabledFeatures::sharedFeatures().webkitVideoTrackEnabled() && (m_pendingActionFlags & TextTrackChangesNotification)) 738 743 notifyMediaPlayerOfTextTrackChanges(); 744 #endif 745 746 #if ENABLE(WIRELESS_PLAYBACK_TARGET) 747 if (m_pendingActionFlags & CheckPlaybackTargetCompatablity && m_player && m_player->isCurrentPlaybackTargetWireless() && !m_player->canPlayToWirelessPlaybackTarget()) { 748 LOG(Media, "HTMLMediaElement::pendingActionTimerFired(%p) - calling setShouldPlayToPlaybackTarget(false)", this); 749 m_player->setShouldPlayToPlaybackTarget(false); 750 } 739 751 #endif 740 752 … … 827 839 // Perform the cleanup required for the resource load algorithm to run. 828 840 stopPeriodicTimers(); 829 m_ loadTimer.stop();841 m_pendingActionTimer.stop(); 830 842 // FIXME: Figure out appropriate place to reset LoadTextTrackResource if necessary and set m_pendingActionFlags to 0 here. 831 843 m_pendingActionFlags &= ~LoadMediaResource; … … 2645 2657 { 2646 2658 if (m_defaultPlaybackRate != rate) { 2659 LOG(Media, "HTMLMediaElement::setDefaultPlaybackRate(%p) - %f", this, rate); 2647 2660 m_defaultPlaybackRate = rate; 2648 2661 scheduleEvent(eventNames().ratechangeEvent); … … 4710 4723 4711 4724 stopPeriodicTimers(); 4712 m_ loadTimer.stop();4725 m_pendingActionTimer.stop(); 4713 4726 4714 4727 clearFlags(m_pendingActionFlags, flags); … … 4859 4872 } 4860 4873 4861 bool HTMLMediaElement::webkitCurrentPlaybackTargetIsSupported() const4862 {4863 return m_mediaSession->currentPlaybackTargetIsSupported(*this);4864 }4865 4866 4874 void HTMLMediaElement::wirelessRoutesAvailableDidChange() 4867 4875 { … … 4874 4882 scheduleEvent(eventNames().webkitcurrentplaybacktargetiswirelesschangedEvent); 4875 4883 4876 #if ENABLE(WIRELESS_PLAYBACK_TARGET)4877 4884 m_mediaSession->mediaStateDidChange(*this, mediaState()); 4878 #endif 4885 } 4886 4887 bool HTMLMediaElement::dispatchEvent(PassRefPtr<Event> prpEvent) 4888 { 4889 RefPtr<Event> event = prpEvent; 4890 if (event->type() == eventNames().webkitcurrentplaybacktargetiswirelesschangedEvent) 4891 scheduleDelayedAction(CheckPlaybackTargetCompatablity); 4892 return HTMLElement::dispatchEvent(event); 4879 4893 } 4880 4894 -
trunk/Source/WebCore/html/HTMLMediaElement.h
r183160 r183509 140 140 TextTrackChangesNotification = 1 << 2, 141 141 ConfigureTextTrackDisplay = 1 << 3, 142 143 EveryDelayedAction = LoadMediaResource | ConfigureTextTracks | TextTrackChangesNotification | ConfigureTextTrackDisplay, 142 CheckPlaybackTargetCompatablity = 1 << 4, 143 144 EveryDelayedAction = LoadMediaResource | ConfigureTextTracks | TextTrackChangesNotification | ConfigureTextTrackDisplay | CheckPlaybackTargetCompatablity, 144 145 }; 145 146 void scheduleDelayedAction(DelayedActionType); … … 357 358 void webkitShowPlaybackTargetPicker(); 358 359 bool webkitCurrentPlaybackTargetIsWireless() const; 359 bool webkitCurrentPlaybackTargetIsSupported() const;360 360 361 361 virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture) override; … … 563 563 virtual void mediaPlayerCurrentPlaybackTargetIsWirelessChanged(MediaPlayer*) override; 564 564 void enqueuePlaybackTargetAvailabilityChangedEvent(); 565 566 using EventTarget::dispatchEvent; 567 virtual bool dispatchEvent(PassRefPtr<Event>) override; 565 568 #endif 566 569 … … 605 608 virtual double mediaPlayerRequestedPlaybackRate() const override final; 606 609 607 void loadTimerFired();610 void pendingActionTimerFired(); 608 611 void progressEventTimerFired(); 609 612 void playbackProgressTimerFired(); … … 734 737 void updateCaptionContainer(); 735 738 736 Timer m_ loadTimer;739 Timer m_pendingActionTimer; 737 740 Timer m_progressEventTimer; 738 741 Timer m_playbackProgressTimer; -
trunk/Source/WebCore/html/HTMLMediaElement.idl
r182240 r183509 117 117 [Conditional=WIRELESS_PLAYBACK_TARGET] void webkitShowPlaybackTargetPicker(); 118 118 [Conditional=WIRELESS_PLAYBACK_TARGET] readonly attribute boolean webkitCurrentPlaybackTargetIsWireless; 119 [Conditional=WIRELESS_PLAYBACK_TARGET] readonly attribute boolean webkitCurrentPlaybackTargetIsSupported;120 119 }; -
trunk/Source/WebCore/html/HTMLMediaSession.cpp
r183428 r183509 190 190 } 191 191 192 bool HTMLMediaSession::currentPlaybackTargetIsSupported(const HTMLMediaElement& element) const193 {194 MediaPlayer* player = element.player();195 if (!player) {196 LOG(Media, "HTMLMediaSession::currentPlaybackTargetIsSupported - returning FALSE because player is NULL");197 return false;198 }199 200 bool isSupported = player->isCurrentPlaybackTargetSupported();201 LOG(Media, "HTMLMediaSession::currentPlaybackTargetIsSupported - returning %s", isSupported ? "TRUE" : "FALSE");202 203 return isSupported;204 }205 206 192 void HTMLMediaSession::showPlaybackTargetPicker(const HTMLMediaElement& element) 207 193 { … … 217 203 return; 218 204 } 205 206 #if !PLATFORM(IOS) 207 if (!element.hasVideo()) { 208 LOG(Media, "HTMLMediaSession::showPlaybackTargetPicker - returning early because element has no video"); 209 return; 210 } 211 #endif 219 212 220 213 element.document().showPlaybackTargetPicker(*this, is<HTMLVideoElement>(element)); … … 389 382 390 383 #if ENABLE(WIRELESS_PLAYBACK_TARGET) 391 setWirelessVideoPlaybackDisabled(element, m_restrictions & WirelessVideoPlaybackDisabled); 384 if (m_restrictions & WirelessVideoPlaybackDisabled) 385 setWirelessVideoPlaybackDisabled(element, true); 392 386 if (m_playbackTarget) 393 387 client().setWirelessPlaybackTarget(*m_playbackTarget.copyRef()); -
trunk/Source/WebCore/html/HTMLMediaSession.h
r183428 r183509 57 57 void showPlaybackTargetPicker(const HTMLMediaElement&); 58 58 bool currentPlaybackTargetIsWireless(const HTMLMediaElement&) const; 59 bool currentPlaybackTargetIsSupported(const HTMLMediaElement&) const;60 59 bool hasWirelessPlaybackTargets(const HTMLMediaElement&) const; 61 60 -
trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp
r183096 r183509 844 844 } 845 845 846 bool MediaPlayer::isCurrentPlaybackTargetSupported() const847 {848 return m_private->isCurrentPlaybackTargetSupported();849 }850 851 846 String MediaPlayer::wirelessPlaybackTargetName() const 852 847 { -
trunk/Source/WebCore/platform/graphics/MediaPlayer.h
r183234 r183509 465 465 #if ENABLE(WIRELESS_PLAYBACK_TARGET) 466 466 bool isCurrentPlaybackTargetWireless() const; 467 bool isCurrentPlaybackTargetSupported() const;468 467 469 468 enum WirelessPlaybackTargetType { TargetTypeNone, TargetTypeAirPlay, TargetTypeTVOut }; -
trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h
r183096 r183509 162 162 #if ENABLE(WIRELESS_PLAYBACK_TARGET) 163 163 virtual bool isCurrentPlaybackTargetWireless() const { return false; } 164 virtual bool isCurrentPlaybackTargetSupported() const { return true; }165 164 166 165 virtual String wirelessPlaybackTargetName() const { return emptyString(); } -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
r183431 r183509 2799 2799 2800 2800 AVOutputContext *newContext = shouldPlay ? m_outputContext.get() : nil; 2801 AVOutputContext *currentContext = m_avPlayer.get().outputContext;2802 if ((!newContext && !currentContext ) || [currentContextisEqual:newContext])2801 RetainPtr<AVOutputContext> currentContext = m_avPlayer.get().outputContext; 2802 if ((!newContext && !currentContext.get()) || [currentContext.get() isEqual:newContext]) 2803 2803 return; 2804 2804 … … 2815 2815 return false; 2816 2816 2817 if (!m_outputContext || !m_outputContext.get().deviceName) 2818 return false; 2819 2820 return m_cachedRate; 2817 RetainPtr<AVOutputContext> currentContext = m_avPlayer.get().outputContext; 2818 return currentContext && currentContext.get().deviceName; 2821 2819 } 2822 2820 #endif // !PLATFORM(IOS) -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h
r183096 r183509 173 173 174 174 #if ENABLE(WIRELESS_PLAYBACK_TARGET) 175 virtual bool isCurrentPlaybackTarget Supported() const override;175 virtual bool isCurrentPlaybackTargetWireless() const override; 176 176 virtual void setWirelessPlaybackTarget(Ref<MediaPlaybackTarget>&&); 177 177 virtual void setShouldPlayToPlaybackTarget(bool) override; … … 221 221 #if ENABLE(WIRELESS_PLAYBACK_TARGET) 222 222 RefPtr<MediaPlaybackTarget> m_playbackTarget; 223 bool m_ currentPlaybackTargetIsSupported { true };223 bool m_shouldPlayToTarget { false }; 224 224 #endif 225 225 }; -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm
r183096 r183509 808 808 809 809 #if ENABLE(WIRELESS_PLAYBACK_TARGET) 810 bool MediaPlayerPrivateMediaSourceAVFObjC::isCurrentPlaybackTargetSupported() const 810 void MediaPlayerPrivateMediaSourceAVFObjC::setWirelessPlaybackTarget(Ref<MediaPlaybackTarget>&& target) 811 { 812 m_playbackTarget = WTF::move(target); 813 } 814 815 void MediaPlayerPrivateMediaSourceAVFObjC::setShouldPlayToPlaybackTarget(bool shouldPlayToTarget) 816 { 817 if (shouldPlayToTarget == m_shouldPlayToTarget) 818 return; 819 820 m_shouldPlayToTarget = shouldPlayToTarget; 821 822 if (m_player) 823 m_player->currentPlaybackTargetIsWirelessChanged(); 824 } 825 826 bool MediaPlayerPrivateMediaSourceAVFObjC::isCurrentPlaybackTargetWireless() const 811 827 { 812 828 if (!m_playbackTarget) 813 return true; 814 815 return !m_playbackTarget->hasActiveRoute(); 816 } 817 818 void MediaPlayerPrivateMediaSourceAVFObjC::setWirelessPlaybackTarget(Ref<MediaPlaybackTarget>&& target) 819 { 820 m_playbackTarget = WTF::move(target); 821 } 822 823 void MediaPlayerPrivateMediaSourceAVFObjC::setShouldPlayToPlaybackTarget(bool shouldPlayToTarget) 824 { 825 bool oldSupported = m_currentPlaybackTargetIsSupported; 826 m_currentPlaybackTargetIsSupported = !shouldPlayToTarget; 827 828 if (m_player && oldSupported != m_currentPlaybackTargetIsSupported) 829 m_player->currentPlaybackTargetIsWirelessChanged(); 829 return false; 830 831 return m_shouldPlayToTarget && m_playbackTarget->hasActiveRoute(); 830 832 } 831 833 #endif -
trunk/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h
r183096 r183509 181 181 182 182 #if ENABLE(WIRELESS_PLAYBACK_TARGET) 183 virtual bool isCurrentPlaybackTarget Supported() const override;183 virtual bool isCurrentPlaybackTargetWireless() const override; 184 184 virtual void setWirelessPlaybackTarget(Ref<MediaPlaybackTarget>&&); 185 185 virtual void setShouldPlayToPlaybackTarget(bool) override; 186 void togglePlayingToPlaybackTarget();187 186 #endif 188 187 … … 216 215 #if ENABLE(WIRELESS_PLAYBACK_TARGET) 217 216 RefPtr<MediaPlaybackTarget> m_playbackTarget; 218 bool m_ currentPlaybackTargetIsSupported { true };217 bool m_shouldPlayToTarget { false }; 219 218 #endif 220 219 }; -
trunk/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm
r183096 r183509 1542 1542 1543 1543 #if ENABLE(WIRELESS_PLAYBACK_TARGET) 1544 bool MediaPlayerPrivateQTKit::isCurrentPlaybackTargetSupported() const 1544 void MediaPlayerPrivateQTKit::setWirelessPlaybackTarget(Ref<MediaPlaybackTarget>&& target) 1545 { 1546 m_playbackTarget = WTF::move(target); 1547 } 1548 1549 void MediaPlayerPrivateQTKit::setShouldPlayToPlaybackTarget(bool shouldPlayToTarget) 1550 { 1551 if (shouldPlayToTarget == m_shouldPlayToTarget) 1552 return; 1553 1554 m_shouldPlayToTarget = shouldPlayToTarget; 1555 1556 if (m_player) 1557 m_player->currentPlaybackTargetIsWirelessChanged(); 1558 } 1559 1560 bool MediaPlayerPrivateQTKit::isCurrentPlaybackTargetWireless() const 1545 1561 { 1546 1562 if (!m_playbackTarget) 1547 return true; 1548 1549 return !m_playbackTarget->hasActiveRoute(); 1550 } 1551 1552 void MediaPlayerPrivateQTKit::setWirelessPlaybackTarget(Ref<MediaPlaybackTarget>&& target) 1553 { 1554 m_playbackTarget = WTF::move(target); 1555 } 1556 1557 void MediaPlayerPrivateQTKit::setShouldPlayToPlaybackTarget(bool shouldPlayToTarget) 1558 { 1559 bool oldSupported = m_currentPlaybackTargetIsSupported; 1560 m_currentPlaybackTargetIsSupported = !shouldPlayToTarget; 1561 1562 if (m_player && oldSupported != m_currentPlaybackTargetIsSupported) 1563 m_player->currentPlaybackTargetIsWirelessChanged(); 1563 return false; 1564 1565 return m_shouldPlayToTarget && m_playbackTarget->hasActiveRoute(); 1564 1566 } 1565 1567 #endif
Note:
See TracChangeset
for help on using the changeset viewer.