Title: [167161] trunk/Source/WebCore
Revision
167161
Author
jer.no...@apple.com
Date
2014-04-11 15:17:52 -0700 (Fri, 11 Apr 2014)

Log Message

[EME][Mac] Using KeySession.update([renew]) should trigger KeyMessage event instead of NeedKey event
https://bugs.webkit.org/show_bug.cgi?id=131527

Reviewed by Eric Carlson.

Rather than triggering a needKey() event, necessatating the creation
of an entirely new MediaKeySession, cause a new key request to be
created by sending the same initData back into the AVSampleDataParser.

Also, do some drive-by clean up suggested by Darin in the review for
r166509.

* platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm:
(WebCore::isEqual): Support an alloc-free equality check between
    Uint8Array and static strings.
(WebCore::CDMSessionMediaSourceAVFObjC::update):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (167160 => 167161)


--- trunk/Source/WebCore/ChangeLog	2014-04-11 22:13:46 UTC (rev 167160)
+++ trunk/Source/WebCore/ChangeLog	2014-04-11 22:17:52 UTC (rev 167161)
@@ -1,3 +1,22 @@
+2014-04-10  Jer Noble  <jer.no...@apple.com>
+
+        [EME][Mac] Using KeySession.update([renew]) should trigger KeyMessage event instead of NeedKey event
+        https://bugs.webkit.org/show_bug.cgi?id=131527
+
+        Reviewed by Eric Carlson.
+
+        Rather than triggering a needKey() event, necessatating the creation
+        of an entirely new MediaKeySession, cause a new key request to be
+        created by sending the same initData back into the AVSampleDataParser.
+
+        Also, do some drive-by clean up suggested by Darin in the review for
+        r166509.
+
+        * platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm:
+        (WebCore::isEqual): Support an alloc-free equality check between
+            Uint8Array and static strings.
+        (WebCore::CDMSessionMediaSourceAVFObjC::update):
+
 2014-04-11  David Kilzer  <ddkil...@apple.com>
 
         Build fix (r167151): Do not dereference Node::document() before passing to Range::create()

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm (167160 => 167161)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm	2014-04-11 22:13:46 UTC (rev 167160)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm	2014-04-11 22:17:52 UTC (rev 167161)
@@ -85,13 +85,32 @@
     LOG(Media, "CDMSessionMediaSourceAVFObjC::releaseKeys(%p)", this);
 }
 
+static bool isEqual(Uint8Array* data, const char* literal)
+{
+    ASSERT(data);
+    ASSERT(literal);
+    unsigned length = data->length();
+
+    for (unsigned i = 0; i < length; ++i) {
+        if (!literal[i])
+            return false;
+
+        if (data->item(i) != static_cast<uint8_t>(literal[i]))
+            return false;
+    }
+    return !literal[length];
+}
+
 bool CDMSessionMediaSourceAVFObjC::update(Uint8Array* key, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, unsigned long& systemCode)
 {
+    bool shouldGenerateKeyRequest = !m_certificate || isEqual(key, "renew");
     if (!m_certificate) {
         LOG(Media, "CDMSessionMediaSourceAVFObjC::update(%p) - certificate data", this);
 
         m_certificate = key;
+    }
 
+    if (shouldGenerateKeyRequest) {
         RetainPtr<NSData> certificateData = adoptNS([[NSData alloc] initWithBytes:m_certificate->data() length:m_certificate->length()]);
         RetainPtr<NSData> initData = adoptNS([[NSData alloc] initWithBytes:m_initData->data() length:m_initData->length()]);
 
@@ -110,14 +129,6 @@
         return false;
     }
 
-    static NeverDestroyed<String> renewMessage("renew");
-    String keyAsString(key->data(), key->length());
-
-    if (keyAsString == renewMessage) {
-        [m_parent->parser() renewExpiringContentKeyResponseDataForTrackID:m_parent->protectedTrackID()];
-        return true;
-    }
-
     LOG(Media, "CDMSessionMediaSourceAVFObjC::update(%p) - key data", this);
     errorCode = MediaPlayer::NoError;
     systemCode = 0;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to