Changeset 201524 in webkit
- Timestamp:
- May 31, 2016, 2:24:19 PM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
-
ChangeLog (modified) (1 diff)
-
platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.h (modified) (2 diffs)
-
platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.mm (modified) (3 diffs)
-
platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h (modified) (3 diffs)
-
platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r201522 r201524 1 2016-05-31 Jer Noble <jer.noble@apple.com> 2 3 [EME] Sound continues playing when video's src is changed 4 https://bugs.webkit.org/show_bug.cgi?id=158233 5 6 Reviewed by Eric Carlson. 7 8 When CDMSessionAVFoundation began listening for outputObscuredDueToInsufficientExternalProtection 9 KVO notifications, it retained the AVPlayer owned by MediaPlayerPrivateAVFoundationObjC, which 10 caused the AVPlayer to outlive its original owner, and to continue playing even after the 11 MediaPlayerPrivateAVFoundationObjC had been destroyed. 12 13 Rather than observe for outputObscuredDueToInsufficientExternalProtection changes in 14 CDMSessionAVFoundation, add a backreference from the media player to the session, listen for changes 15 in the player, and have the player notify the session when the value of that property changes. 16 17 * platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.h: 18 (WebCore::CDMSessionAVFoundationObjC::createWeakPtr): 19 * platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.mm: 20 (WebCore::CDMSessionAVFoundationObjC::CDMSessionAVFoundationObjC): 21 (-[WebCDMSessionAVFoundationObjCListener initWithParent:player:]): Deleted. 22 (-[WebCDMSessionAVFoundationObjCListener invalidate]): Deleted. 23 (-[WebCDMSessionAVFoundationObjCListener observeValueForKeyPath:ofObject:change:context:]): Deleted. 24 (WebCore::CDMSessionAVFoundationObjC::~CDMSessionAVFoundationObjC): Deleted. 25 * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h: 26 * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: 27 (WebCore::MediaPlayerPrivateAVFoundationObjC::removeSession): 28 (WebCore::MediaPlayerPrivateAVFoundationObjC::createSession): 29 (WebCore::MediaPlayerPrivateAVFoundationObjC::outputObscuredDueToInsufficientExternalProtectionChanged): 30 (WebCore::playerKVOProperties): 31 (-[WebCoreAVFMovieObserver observeValueForKeyPath:ofObject:change:context:]): 32 1 33 2016-05-31 Eric Carlson <eric.carlson@apple.com> 2 34 -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.h
r199672 r201524 54 54 void playerDidReceiveError(NSError *); 55 55 56 WeakPtr<CDMSessionAVFoundationObjC> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); } 57 56 58 protected: 57 59 WeakPtr<MediaPlayerPrivateAVFoundationObjC> m_parent; … … 59 61 String m_sessionId; 60 62 RetainPtr<AVAssetResourceLoadingRequest> m_request; 61 RetainPtr<WebCDMSessionAVFoundationObjCListener> m_listener;63 WeakPtrFactory<CDMSessionAVFoundationObjC> m_weakPtrFactory; 62 64 }; 63 65 -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.mm
r201482 r201524 47 47 #define AVAssetResourceLoadingRequest getAVAssetResourceLoadingRequest() 48 48 49 @interface WebCDMSessionAVFoundationObjCListener : NSObject {50 WebCore::CDMSessionAVFoundationObjC* _parent;51 RetainPtr<AVPlayer> _player;52 }53 - (id)initWithParent:(WebCore::CDMSessionAVFoundationObjC*)parent player:(AVPlayer *)player;54 - (void)invalidate;55 @end56 57 @implementation WebCDMSessionAVFoundationObjCListener58 - (id)initWithParent:(WebCore::CDMSessionAVFoundationObjC*)parent player:(AVPlayer *)player59 {60 self = [super init];61 if (!self)62 return nil;63 64 _parent = parent;65 _player = player;66 [player addObserver:self forKeyPath:@"outputObscuredDueToInsufficientExternalProtection" options:NSKeyValueObservingOptionNew context:nil];67 68 return self;69 }70 71 - (void)invalidate72 {73 _parent = nullptr;74 [_player removeObserver:self forKeyPath:@"outputObscuredDueToInsufficientExternalProtection"];75 _player = nullptr;76 }77 78 - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context79 {80 UNUSED_PARAM(context);81 UNUSED_PARAM(object);82 ASSERT(_parent);83 84 if ([keyPath isEqualTo:@"outputObscuredDueToInsufficientExternalProtection"]) {85 if ([[change valueForKey:NSKeyValueChangeNewKey] intValue] == 1) {86 RetainPtr<NSError> error = [NSError errorWithDomain:@"com.apple.WebKit" code:'HDCP' userInfo:nil];87 RetainPtr<WebCDMSessionAVFoundationObjCListener> protectedSelf = { self };88 callOnMainThread([protectedSelf = WTFMove(protectedSelf), error = WTFMove(error)] {89 if (protectedSelf->_parent)90 protectedSelf->_parent->playerDidReceiveError(error.get());91 });92 }93 } else94 ASSERT_NOT_REACHED();95 }96 @end97 98 49 namespace WebCore { 99 50 … … 102 53 , m_client(client) 103 54 , m_sessionId(createCanonicalUUIDString()) 104 , m_ listener(adoptNS([[WebCDMSessionAVFoundationObjCListener alloc] initWithParent:this player:parent->avPlayer()]))55 , m_weakPtrFactory(this) 105 56 { 106 57 } … … 108 59 CDMSessionAVFoundationObjC::~CDMSessionAVFoundationObjC() 109 60 { 110 [m_listener invalidate];111 61 } 112 62 -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h
r201474 r201524 68 68 class AudioSourceProviderAVFObjC; 69 69 class AudioTrackPrivateAVFObjC; 70 class CDMSessionAVFoundationObjC; 70 71 class InbandMetadataTextTrackPrivateAVF; 71 72 class InbandTextTrackPrivateAVFObjC; … … 143 144 void playbackTargetIsWirelessDidChange(); 144 145 #endif 145 146 147 #if ENABLE(ENCRYPTED_MEDIA_V2) 148 void outputObscuredDueToInsufficientExternalProtectionChanged(bool); 149 #endif 150 146 151 #if ENABLE(AVF_CAPTIONS) 147 152 void notifyTrackModeChanged() override; 148 153 void synchronizeTextTrackState() override; 149 154 #endif 150 155 156 #if ENABLE(ENCRYPTED_MEDIA_V2) 157 void removeSession(CDMSession&); 158 #endif 159 151 160 WeakPtr<MediaPlayerPrivateAVFoundationObjC> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); } 152 161 … … 391 400 RetainPtr<AVOutputContext> m_outputContext; 392 401 RefPtr<MediaPlaybackTarget> m_playbackTarget { nullptr }; 402 #endif 403 404 #if ENABLE(ENCRYPTED_MEDIA_V2) 405 WeakPtr<CDMSessionAVFoundationObjC> m_session; 393 406 #endif 394 407 -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
r201482 r201524 2586 2586 } 2587 2587 2588 void MediaPlayerPrivateAVFoundationObjC::removeSession(CDMSession& session) 2589 { 2590 ASSERT(&session == m_session); 2591 m_session = nullptr; 2592 } 2593 2588 2594 std::unique_ptr<CDMSession> MediaPlayerPrivateAVFoundationObjC::createSession(const String& keySystem, CDMSessionClient* client) 2589 2595 { 2590 2596 if (!keySystemIsSupported(keySystem)) 2591 2597 return nullptr; 2592 2593 return std::make_unique<CDMSessionAVFoundationObjC>(this, client); 2598 auto session = std::make_unique<CDMSessionAVFoundationObjC>(this, client); 2599 m_session = session->createWeakPtr(); 2600 return WTFMove(session); 2601 } 2602 2603 void MediaPlayerPrivateAVFoundationObjC::outputObscuredDueToInsufficientExternalProtectionChanged(bool newValue) 2604 { 2605 if (m_session && newValue) 2606 m_session->playerDidReceiveError([NSError errorWithDomain:@"com.apple.WebKit" code:'HDCP' userInfo:nil]); 2594 2607 } 2595 2608 #endif … … 3294 3307 #if ENABLE(WIRELESS_PLAYBACK_TARGET) 3295 3308 @"externalPlaybackActive", @"allowsExternalPlayback", 3309 #endif 3310 #if ENABLE(ENCRYPTED_MEDIA_V2) 3311 @"outputObscuredDueToInsufficientExternalProtection", 3296 3312 #endif 3297 3313 nil]; … … 3417 3433 function = std::bind(&MediaPlayerPrivateAVFoundationObjC::playbackTargetIsWirelessDidChange, m_callback); 3418 3434 #endif 3435 #if ENABLE(ENCRYPTED_MEDIA_V2) 3436 else if ([keyPath isEqualToString:@"outputObscuredDueToInsufficientExternalProtection"]) 3437 function = std::bind(&MediaPlayerPrivateAVFoundationObjC::outputObscuredDueToInsufficientExternalProtectionChanged, m_callback, [newValue boolValue]); 3438 #endif 3419 3439 } 3420 3440
Note:
See TracChangeset
for help on using the changeset viewer.