Skip to content
Permalink
Browse files
[Mac][EME] Protected content over HLS is not notified when a HDCP vio…
…lation occurs.

https://bugs.webkit.org/show_bug.cgi?id=156633

Reviewed by Eric Carlson.

Pass through the existing "outputObscuredDueToInsufficientExternalProtection" status as an
error, similarly to what we do for CDMSessionMediaSourceAVFObjC.

* platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.h:
(WebCore::CDMSessionAVFoundationObjC::~CDMSessionAVFoundationObjC): Deleted.
* platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.mm:
(SOFT_LINK_CLASS):
(-[WebCDMSessionAVFoundationObjCListener initWithParent:player:]):
(-[WebCDMSessionAVFoundationObjCListener invalidate]):
(-[WebCDMSessionAVFoundationObjCListener observeValueForKeyPath:ofObject:change:context:]):
(WebCore::CDMSessionAVFoundationObjC::CDMSessionAVFoundationObjC):
(WebCore::CDMSessionAVFoundationObjC::~CDMSessionAVFoundationObjC):
(WebCore::CDMSessionAVFoundationObjC::generateKeyRequest):
(WebCore::CDMSessionAVFoundationObjC::playerDidReceiveError):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
(WebCore::MediaPlayerPrivateAVFoundationObjC::avPlayer):

Canonical link: https://commits.webkit.org/174807@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@199672 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
jernoble committed Apr 18, 2016
1 parent cd1f97c commit 3e0604cce7789c2eb030a0c4f0f5a983d31fdcc0
@@ -1,3 +1,27 @@
2016-04-15 Jer Noble <jer.noble@apple.com>

[Mac][EME] Protected content over HLS is not notified when a HDCP violation occurs.
https://bugs.webkit.org/show_bug.cgi?id=156633

Reviewed by Eric Carlson.

Pass through the existing "outputObscuredDueToInsufficientExternalProtection" status as an
error, similarly to what we do for CDMSessionMediaSourceAVFObjC.

* platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.h:
(WebCore::CDMSessionAVFoundationObjC::~CDMSessionAVFoundationObjC): Deleted.
* platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.mm:
(SOFT_LINK_CLASS):
(-[WebCDMSessionAVFoundationObjCListener initWithParent:player:]):
(-[WebCDMSessionAVFoundationObjCListener invalidate]):
(-[WebCDMSessionAVFoundationObjCListener observeValueForKeyPath:ofObject:change:context:]):
(WebCore::CDMSessionAVFoundationObjC::CDMSessionAVFoundationObjC):
(WebCore::CDMSessionAVFoundationObjC::~CDMSessionAVFoundationObjC):
(WebCore::CDMSessionAVFoundationObjC::generateKeyRequest):
(WebCore::CDMSessionAVFoundationObjC::playerDidReceiveError):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
(WebCore::MediaPlayerPrivateAVFoundationObjC::avPlayer):

2016-04-18 Chris Dumez <cdumez@apple.com>

Unreviewed, rolling out r199644.
@@ -28,10 +28,12 @@

#include "CDMSession.h"
#include <wtf/RetainPtr.h>
#include <wtf/WeakPtr.h>

#if ENABLE(ENCRYPTED_MEDIA_V2)

OBJC_CLASS AVAssetResourceLoadingRequest;
OBJC_CLASS WebCDMSessionAVFoundationObjCListener;

namespace WebCore {

@@ -40,7 +42,7 @@ class MediaPlayerPrivateAVFoundationObjC;
class CDMSessionAVFoundationObjC : public CDMSession {
public:
CDMSessionAVFoundationObjC(MediaPlayerPrivateAVFoundationObjC* parent, CDMSessionClient*);
virtual ~CDMSessionAVFoundationObjC() { }
virtual ~CDMSessionAVFoundationObjC();

CDMSessionType type() override { return CDMSessionTypeAVFoundationObjC; }
void setClient(CDMSessionClient* client) override { m_client = client; }
@@ -49,11 +51,14 @@ class CDMSessionAVFoundationObjC : public CDMSession {
void releaseKeys() override;
bool update(Uint8Array*, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, uint32_t& systemCode) override;

void playerDidReceiveError(NSError *);

protected:
MediaPlayerPrivateAVFoundationObjC* m_parent;
WeakPtr<MediaPlayerPrivateAVFoundationObjC> m_parent;
CDMSessionClient* m_client;
String m_sessionId;
RetainPtr<AVAssetResourceLoadingRequest> m_request;
RetainPtr<WebCDMSessionAVFoundationObjCListener> m_listener;
};

}
@@ -38,26 +38,87 @@
#import "WebCoreNSErrorExtras.h"
#import <AVFoundation/AVFoundation.h>
#import <objc/objc-runtime.h>
#import <wtf/MainThread.h>

SOFT_LINK_FRAMEWORK_OPTIONAL(AVFoundation)
SOFT_LINK_CLASS(AVFoundation, AVURLAsset)
SOFT_LINK_CLASS(AVFoundation, AVAssetResourceLoadingRequest)
#define AVURLAsset getAVURLAssetClass()
#define AVAssetResourceLoadingRequest getAVAssetResourceLoadingRequest()

@interface WebCDMSessionAVFoundationObjCListener : NSObject {
WebCore::CDMSessionAVFoundationObjC* _parent;
RetainPtr<AVPlayer> _player;
}
- (id)initWithParent:(WebCore::CDMSessionAVFoundationObjC*)parent player:(AVPlayer *)player;
- (void)invalidate;
@end

@implementation WebCDMSessionAVFoundationObjCListener
- (id)initWithParent:(WebCore::CDMSessionAVFoundationObjC*)parent player:(AVPlayer *)player
{
self = [super init];
if (!self)
return nil;

_parent = parent;
_player = player;
[player addObserver:self forKeyPath:@"outputObscuredDueToInsufficientExternalProtection" options:NSKeyValueObservingOptionNew context:nil];

return self;
}

- (void)invalidate
{
_parent = nullptr;
[_player removeObserver:self forKeyPath:@"outputObscuredDueToInsufficientExternalProtection"];
_player = nullptr;
}

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
UNUSED_PARAM(context);
UNUSED_PARAM(object);
ASSERT(_parent);

if ([keyPath isEqualTo:@"outputObscuredDueToInsufficientExternalProtection"]) {
if ([[change valueForKey:NSKeyValueChangeNewKey] intValue] == 1) {
RetainPtr<NSError> error = [NSError errorWithDomain:@"com.apple.WebKit" code:'HDCP' userInfo:nil];
RetainPtr<WebCDMSessionAVFoundationObjCListener> strongSelf = { self };
callOnMainThread([strongSelf, error] {
if (strongSelf->_parent)
strongSelf->_parent->playerDidReceiveError(error.get());
});
}
} else
ASSERT_NOT_REACHED();
}
@end

namespace WebCore {

CDMSessionAVFoundationObjC::CDMSessionAVFoundationObjC(MediaPlayerPrivateAVFoundationObjC* parent, CDMSessionClient* client)
: m_parent(parent)
: m_parent(parent->createWeakPtr())
, m_client(client)
, m_sessionId(createCanonicalUUIDString())
, m_listener(adoptNS([[WebCDMSessionAVFoundationObjCListener alloc] initWithParent:this player:parent->avPlayer()]))
{
}

CDMSessionAVFoundationObjC::~CDMSessionAVFoundationObjC()
{
[m_listener invalidate];
}

RefPtr<Uint8Array> CDMSessionAVFoundationObjC::generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, uint32_t& systemCode)
{
UNUSED_PARAM(mimeType);

if (!m_parent) {
errorCode = CDM::UnknownError;
return nullptr;
}

String keyURI;
String keyID;
RefPtr<Uint8Array> certificate;
@@ -108,6 +169,15 @@
return true;
}

void CDMSessionAVFoundationObjC::playerDidReceiveError(NSError *error)
{
if (!m_client)
return;

unsigned long code = mediaKeyErrorSystemCode(error);
m_client->sendError(CDMSessionClient::MediaKeyErrorDomain, code);
}

}

#endif
@@ -99,6 +99,7 @@ class MediaPlayerPrivateAVFoundationObjC : public MediaPlayerPrivateAVFoundation
void processCue(NSArray *, NSArray *, const MediaTime&);
void flushCues();
#endif
AVPlayer *avPlayer() const { return m_avPlayer.get(); }

#if HAVE(AVFOUNDATION_LOADER_DELEGATE)
bool shouldWaitForLoadingOfResource(AVAssetResourceLoadingRequest*);

0 comments on commit 3e0604c

Please sign in to comment.