[EME][Mac] Fix a few issues in CDMSessionMediaSourceAVFObjC.
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Feb 2014 18:24:13 +0000 (18:24 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Feb 2014 18:24:13 +0000 (18:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=129310

Reviewed by Eric Carlson.

Only send a 'keyerror' event if an actual error code was returned, not just
when no key was added:
* Modules/encryptedmedia/MediaKeySession.cpp:
(WebCore::MediaKeySession::addKeyTimerFired):

The 'length' parameter to a typed ArrayBufferView is the number of entries
in the array, not the byte length:
* platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm:
(WebCore::CDMSessionMediaSourceAVFObjC::generateKeyRequest):

The return value of streamingContentKeyRequestDataForApp:contentIdentifier:trackId:options:error
is autoreleased; do not wrap it in an adoptNS:
* platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm:
(WebCore::CDMSessionMediaSourceAVFObjC::update):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@164656 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp
Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm

index 735e932..630d697 100644 (file)
@@ -1,3 +1,25 @@
+2014-02-25  Jer Noble  <jer.noble@apple.com>
+
+        [EME][Mac] Fix a few issues in CDMSessionMediaSourceAVFObjC.
+        https://bugs.webkit.org/show_bug.cgi?id=129310
+
+        Reviewed by Eric Carlson.
+
+        Only send a 'keyerror' event if an actual error code was returned, not just
+        when no key was added:
+        * Modules/encryptedmedia/MediaKeySession.cpp:
+        (WebCore::MediaKeySession::addKeyTimerFired):
+
+        The 'length' parameter to a typed ArrayBufferView is the number of entries
+        in the array, not the byte length:
+        * platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm:
+        (WebCore::CDMSessionMediaSourceAVFObjC::generateKeyRequest):
+
+        The return value of streamingContentKeyRequestDataForApp:contentIdentifier:trackId:options:error
+        is autoreleased; do not wrap it in an adoptNS:
+        * platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm:
+        (WebCore::CDMSessionMediaSourceAVFObjC::update):
+
 2014-02-25  Thiago de Barros Lacerda  <thiago.lacerda@openbossa.org>
 
         [MediaStream] Adding mock implementation of UserMediaClient
index 70a73ce..442fd7b 100644 (file)
@@ -200,7 +200,7 @@ void MediaKeySession::addKeyTimerFired(Timer<MediaKeySession>&)
         }
 
         // 2.8. If any of the preceding steps in the task failed
-        if (!didStoreKey) {
+        if (errorCode) {
             // 2.8.1. Create a new MediaKeyError object with the following attributes:
             //        code = the appropriate MediaKeyError code
             //        systemCode = a Key System-specific value, if provided, and 0 otherwise
index ea8c068..d78de27 100644 (file)
@@ -74,7 +74,7 @@ PassRefPtr<Uint8Array> CDMSessionMediaSourceAVFObjC::generateKeyRequest(const St
 
     String certificateString(ASCIILiteral("certificate"));
     RefPtr<ArrayBuffer> buffer = ArrayBuffer::create(certificateString.length(), 2);
-    RefPtr<JSC::Uint16Array> array = JSC::Uint16Array::create(buffer, 0, buffer->byteLength());
+    RefPtr<JSC::Uint16Array> array = JSC::Uint16Array::create(buffer, 0, certificateString.length());
     for (unsigned i = 0, length = certificateString.length(); i < length; ++i)
         array->set(i, certificateString[i]);
     return Uint8Array::create(buffer, 0, buffer->byteLength());
@@ -96,7 +96,7 @@ bool CDMSessionMediaSourceAVFObjC::update(Uint8Array* key, RefPtr<Uint8Array>& n
         RetainPtr<NSData> initData = adoptNS([[NSData alloc] initWithBytes:m_initData->data() length:m_initData->length()]);
 
         NSError* error = nil;
-        RetainPtr<NSData> request = adoptNS([m_parent->parser() streamingContentKeyRequestDataForApp:certificateData.get() contentIdentifier:initData.get() trackID:m_parent->protectedTrackID() options:nil error:&error]);
+        RetainPtr<NSData> request = [m_parent->parser() streamingContentKeyRequestDataForApp:certificateData.get() contentIdentifier:initData.get() trackID:m_parent->protectedTrackID() options:nil error:&error];
 
         if (error) {
             LOG(Media, "CDMSessionMediaSourceAVFObjC::update(%p) - error:%@", this, [error description]);