<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[164529] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/164529">164529</a></dd>
<dt>Author</dt> <dd>jer.noble@apple.com</dd>
<dt>Date</dt> <dd>2014-02-21 22:17:53 -0800 (Fri, 21 Feb 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>[EME] Add a CDMSession for MediaPlayerPrivateMediaSourceAVFObjC
https://bugs.webkit.org/show_bug.cgi?id=129166

Reviewed by Eric Carlson.

Add a new CDMSession, cerated by MediaPlayerPrivateMediaSourceAVFObjC allowing
media-source-backed media elements to play protected content.

Add a new CDMSessionMediaSourceAVFObjC class:
* platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.h: Added.
(WebCore::CDMSessionMediaSourceAVFObjC::~CDMSessionMediaSourceAVFObjC):
* platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm: Added.
(WebCore::CDMSessionMediaSourceAVFObjC::CDMSessionMediaSourceAVFObjC):
(WebCore::CDMSessionMediaSourceAVFObjC::generateKeyRequest): Do not actually generate a
    key request until the certificate data has been added via update();
(WebCore::CDMSessionMediaSourceAVFObjC::releaseKeys): No-op.
(WebCore::CDMSessionMediaSourceAVFObjC::update): If no certificate data has yet been
    added, assume the incoming message contains it.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::registerMediaEngine): Add supportsKeySystem.
(WebCore::keySystemIsSupported): Use &quot;com.apple.fps.2_0&quot; to distinguish from the not-media-source scheme.
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::supportsType): Check the keySystem type.
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::supportsKeySystem): Added.
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::createSession): Added, pass through to MediaSourcePrivate.
* platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h:
* platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm:
(WebCore::MediaSourcePrivateAVFObjC::createSession): Added.
(WebCore::MediaSourcePrivateAVFObjC::sourceBufferKeyNeeded): Pass through to MediaPlayer.
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
(-[WebAVStreamDataParserListener streamDataParser:didProvideContentKeyRequestInitializationData:forTrackID:]):
    Added, pass through to SourceBufferPrivate.
(WebCore::SourceBufferPrivateAVFObjC::SourceBufferPrivateAVFObjC):
(WebCore::SourceBufferPrivateAVFObjC::didProvideContentKeyRequestInitializationDataForTrackID): Remember
    which track is requesting the key, and pass the request to MediaSourcePrivate.

Add new files to the project.
* WebCore.xcodeproj/project.pbxproj:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsavfoundationobjcMediaPlayerPrivateMediaSourceAVFObjCh">trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsavfoundationobjcMediaPlayerPrivateMediaSourceAVFObjCmm">trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsavfoundationobjcMediaSourcePrivateAVFObjCh">trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsavfoundationobjcMediaSourcePrivateAVFObjCmm">trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsavfoundationobjcSourceBufferPrivateAVFObjCh">trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsavfoundationobjcSourceBufferPrivateAVFObjCmm">trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformgraphicsavfoundationobjcCDMSessionMediaSourceAVFObjCh">trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsavfoundationobjcCDMSessionMediaSourceAVFObjCmm">trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (164528 => 164529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-02-22 06:07:41 UTC (rev 164528)
+++ trunk/Source/WebCore/ChangeLog        2014-02-22 06:17:53 UTC (rev 164529)
</span><span class="lines">@@ -1,3 +1,46 @@
</span><ins>+2014-02-21  Jer Noble  &lt;jer.noble@apple.com&gt;
+
+        [EME] Add a CDMSession for MediaPlayerPrivateMediaSourceAVFObjC
+        https://bugs.webkit.org/show_bug.cgi?id=129166
+
+        Reviewed by Eric Carlson.
+
+        Add a new CDMSession, cerated by MediaPlayerPrivateMediaSourceAVFObjC allowing
+        media-source-backed media elements to play protected content.
+
+        Add a new CDMSessionMediaSourceAVFObjC class:
+        * platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.h: Added.
+        (WebCore::CDMSessionMediaSourceAVFObjC::~CDMSessionMediaSourceAVFObjC):
+        * platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm: Added.
+        (WebCore::CDMSessionMediaSourceAVFObjC::CDMSessionMediaSourceAVFObjC):
+        (WebCore::CDMSessionMediaSourceAVFObjC::generateKeyRequest): Do not actually generate a
+            key request until the certificate data has been added via update();
+        (WebCore::CDMSessionMediaSourceAVFObjC::releaseKeys): No-op.
+        (WebCore::CDMSessionMediaSourceAVFObjC::update): If no certificate data has yet been
+            added, assume the incoming message contains it.
+
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::registerMediaEngine): Add supportsKeySystem.
+        (WebCore::keySystemIsSupported): Use &quot;com.apple.fps.2_0&quot; to distinguish from the not-media-source scheme.
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::supportsType): Check the keySystem type.
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::supportsKeySystem): Added.
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::createSession): Added, pass through to MediaSourcePrivate.
+        * platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h:
+        * platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm:
+        (WebCore::MediaSourcePrivateAVFObjC::createSession): Added.
+        (WebCore::MediaSourcePrivateAVFObjC::sourceBufferKeyNeeded): Pass through to MediaPlayer.
+        * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
+        * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
+        (-[WebAVStreamDataParserListener streamDataParser:didProvideContentKeyRequestInitializationData:forTrackID:]):
+            Added, pass through to SourceBufferPrivate.
+        (WebCore::SourceBufferPrivateAVFObjC::SourceBufferPrivateAVFObjC):
+        (WebCore::SourceBufferPrivateAVFObjC::didProvideContentKeyRequestInitializationDataForTrackID): Remember
+            which track is requesting the key, and pass the request to MediaSourcePrivate.
+
+        Add new files to the project.
+        * WebCore.xcodeproj/project.pbxproj:
+
</ins><span class="cx"> 2014-02-21  Alexey Proskuryakov  &lt;ap@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerify contains seemingly accidental unreachable code
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (164528 => 164529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-02-22 06:07:41 UTC (rev 164528)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-02-22 06:17:53 UTC (rev 164529)
</span><span class="lines">@@ -5541,6 +5541,7 @@
</span><span class="cx">                 CDDC1E7A18A952F30027A9D4 /* MediaSourcePrivateClient.h in Headers */ = {isa = PBXBuildFile; fileRef = CDDC1E7918A952F30027A9D4 /* MediaSourcePrivateClient.h */; };
</span><span class="cx">                 CDDD571518B57A8200A94FCB /* CDMSession.h in Headers */ = {isa = PBXBuildFile; fileRef = CDDE02E918B3DFC700CF7FF1 /* CDMSession.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 CDDE02ED18B3ED6D00CF7FF1 /* CDMSessionAVFoundationObjC.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDDE02EB18B3ED6D00CF7FF1 /* CDMSessionAVFoundationObjC.mm */; };
</span><ins>+                CDDE02F018B5651300CF7FF1 /* CDMSessionMediaSourceAVFObjC.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDDE02EF18B5651200CF7FF1 /* CDMSessionMediaSourceAVFObjC.mm */; };
</ins><span class="cx">                 CDE3A85417F5FCE600C5BE20 /* AudioTrackPrivateAVF.h in Headers */ = {isa = PBXBuildFile; fileRef = CDE3A85217F5FCE600C5BE20 /* AudioTrackPrivateAVF.h */; };
</span><span class="cx">                 CDE3A85717F6020400C5BE20 /* AudioTrackPrivateAVFObjC.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDE3A85517F6020400C5BE20 /* AudioTrackPrivateAVFObjC.mm */; };
</span><span class="cx">                 CDE3A85817F6020400C5BE20 /* AudioTrackPrivateAVFObjC.h in Headers */ = {isa = PBXBuildFile; fileRef = CDE3A85617F6020400C5BE20 /* AudioTrackPrivateAVFObjC.h */; };
</span><span class="lines">@@ -12809,6 +12810,8 @@
</span><span class="cx">                 CDDE02E918B3DFC700CF7FF1 /* CDMSession.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CDMSession.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CDDE02EA18B3ED6D00CF7FF1 /* CDMSessionAVFoundationObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDMSessionAVFoundationObjC.h; path = objc/CDMSessionAVFoundationObjC.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CDDE02EB18B3ED6D00CF7FF1 /* CDMSessionAVFoundationObjC.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = CDMSessionAVFoundationObjC.mm; path = objc/CDMSessionAVFoundationObjC.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                CDDE02EE18B564FA00CF7FF1 /* CDMSessionMediaSourceAVFObjC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = CDMSessionMediaSourceAVFObjC.h; path = objc/CDMSessionMediaSourceAVFObjC.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                CDDE02EF18B5651200CF7FF1 /* CDMSessionMediaSourceAVFObjC.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = CDMSessionMediaSourceAVFObjC.mm; path = objc/CDMSessionMediaSourceAVFObjC.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 CDE3A85217F5FCE600C5BE20 /* AudioTrackPrivateAVF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioTrackPrivateAVF.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CDE3A85517F6020400C5BE20 /* AudioTrackPrivateAVFObjC.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AudioTrackPrivateAVFObjC.mm; path = objc/AudioTrackPrivateAVFObjC.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CDE3A85617F6020400C5BE20 /* AudioTrackPrivateAVFObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AudioTrackPrivateAVFObjC.h; path = objc/AudioTrackPrivateAVFObjC.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -21012,6 +21015,8 @@
</span><span class="cx">                                 CD336F5F17F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.mm */,
</span><span class="cx">                                 CDDE02EA18B3ED6D00CF7FF1 /* CDMSessionAVFoundationObjC.h */,
</span><span class="cx">                                 CDDE02EB18B3ED6D00CF7FF1 /* CDMSessionAVFoundationObjC.mm */,
</span><ins>+                                CDDE02EE18B564FA00CF7FF1 /* CDMSessionMediaSourceAVFObjC.h */,
+                                CDDE02EF18B5651200CF7FF1 /* CDMSessionMediaSourceAVFObjC.mm */,
</ins><span class="cx">                                 07AA6B69166D019500D45671 /* InbandTextTrackPrivateAVFObjC.h */,
</span><span class="cx">                                 07AA6B6A166D019500D45671 /* InbandTextTrackPrivateAVFObjC.mm */,
</span><span class="cx">                                 07367DDD172CA67F00D861B9 /* InbandTextTrackPrivateLegacyAVFObjC.h */,
</span><span class="lines">@@ -29015,6 +29020,7 @@
</span><span class="cx">                                 511EF2C617F0FD3500E4FA16 /* JSIDBKeyRange.cpp in Sources */,
</span><span class="cx">                                 49C7B9D41042D32F0009D447 /* WebGLObject.cpp in Sources */,
</span><span class="cx">                                 51D719D8181106E00016DC51 /* IDBIndex.cpp in Sources */,
</span><ins>+                                CDDE02F018B5651300CF7FF1 /* CDMSessionMediaSourceAVFObjC.mm in Sources */,
</ins><span class="cx">                                 49C7B9D61042D32F0009D447 /* WebGLProgram.cpp in Sources */,
</span><span class="cx">                                 49C7B9D91042D32F0009D447 /* WebGLRenderbuffer.cpp in Sources */,
</span><span class="cx">                                 49C7B9DF1042D32F0009D447 /* WebGLRenderingContext.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsavfoundationobjcCDMSessionMediaSourceAVFObjCh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.h (0 => 164529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.h                                (rev 0)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.h        2014-02-22 06:17:53 UTC (rev 164529)
</span><span class="lines">@@ -0,0 +1,62 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CDMSessionMediaSourceAVFObjC_h
+#define CDMSessionMediaSourceAVFObjC_h
+
+#include &quot;CDMSession.h&quot;
+#include &lt;wtf/PassOwnPtr.h&gt;
+#include &lt;wtf/RetainPtr.h&gt;
+
+#if ENABLE(ENCRYPTED_MEDIA_V2) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 1090
+
+namespace WebCore {
+
+class SourceBufferPrivateAVFObjC;
+
+class CDMSessionMediaSourceAVFObjC : public CDMSession {
+public:
+    CDMSessionMediaSourceAVFObjC(SourceBufferPrivateAVFObjC* parent);
+    virtual ~CDMSessionMediaSourceAVFObjC() { }
+
+    virtual void setClient(CDMSessionClient* client) override { m_client = client; }
+    virtual const String&amp; sessionId() const override { return m_sessionId; }
+    virtual PassRefPtr&lt;Uint8Array&gt; generateKeyRequest(const String&amp; mimeType, Uint8Array* initData, String&amp; destinationURL, unsigned short&amp; errorCode, unsigned long&amp; systemCode) override;
+    virtual void releaseKeys() override;
+    virtual bool update(Uint8Array*, RefPtr&lt;Uint8Array&gt;&amp; nextMessage, unsigned short&amp; errorCode, unsigned long&amp; systemCode) override;
+
+protected:
+    SourceBufferPrivateAVFObjC* m_parent;
+    CDMSessionClient* m_client;
+    RefPtr&lt;Uint8Array&gt; m_initData;
+    RefPtr&lt;Uint8Array&gt; m_certificate;
+    String m_sessionId;
+};
+
+}
+
+#endif
+
+#endif // CDMSessionMediaSourceAVFObjC_h
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsavfoundationobjcCDMSessionMediaSourceAVFObjCmm"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm (0 => 164529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm                                (rev 0)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm        2014-02-22 06:17:53 UTC (rev 164529)
</span><span class="lines">@@ -0,0 +1,118 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import &quot;config.h&quot;
+#import &quot;CDMSessionMediaSourceAVFObjC.h&quot;
+
+#if ENABLE(ENCRYPTED_MEDIA_V2) &amp;&amp; __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 1090
+
+#import &quot;CDM.h&quot;
+#import &quot;CDMSession.h&quot;
+#import &quot;ExceptionCode.h&quot;
+#import &quot;Logging.h&quot;
+#import &quot;MediaPlayer.h&quot;
+#import &quot;SourceBufferPrivateAVFObjC.h&quot;
+#import &quot;SoftLinking.h&quot;
+#import &quot;UUID.h&quot;
+#import &lt;CoreMedia/CMBase.h&gt;
+#import &lt;objc/objc-runtime.h&gt;
+
+SOFT_LINK_FRAMEWORK_OPTIONAL(AVFoundation)
+SOFT_LINK_CLASS(AVFoundation, AVStreamDataParser);
+#define AVAssetResourceLoadingRequest getAVStreamDataParser()
+
+@interface AVStreamDataParser : NSObject
+- (void)processContentKeyResponseData:(NSData *)contentKeyResponseData forTrackID:(CMPersistentTrackID)trackID;
+- (void)processContentKeyResponseError:(NSError *)error forTrackID:(CMPersistentTrackID)trackID;
+- (void)renewExpiringContentKeyResponseDataForTrackID:(CMPersistentTrackID)trackID;
+- (NSData *)streamingContentKeyRequestDataForApp:(NSData *)appIdentifier contentIdentifier:(NSData *)contentIdentifier trackID:(CMPersistentTrackID)trackID options:(NSDictionary *)options error:(NSError **)outError;
+@end
+
+namespace WebCore {
+
+CDMSessionMediaSourceAVFObjC::CDMSessionMediaSourceAVFObjC(SourceBufferPrivateAVFObjC* parent)
+    : m_parent(parent)
+    , m_client(nullptr)
+    , m_sessionId(createCanonicalUUIDString())
+{
+}
+
+PassRefPtr&lt;Uint8Array&gt; CDMSessionMediaSourceAVFObjC::generateKeyRequest(const String&amp; mimeType, Uint8Array* initData, String&amp; destinationURL, unsigned short&amp; errorCode, unsigned long&amp; systemCode)
+{
+    UNUSED_PARAM(mimeType);
+    UNUSED_PARAM(destinationURL);
+    ASSERT(initData);
+
+    LOG(Media, &quot;CDMSessionMediaSourceAVFObjC::generateKeyRequest(%p)&quot;, this);
+
+    errorCode = MediaPlayer::NoError;
+    systemCode = 0;
+
+    m_initData = initData;
+    String certificateString(ASCIILiteral(&quot;certificate&quot;));
+    return Uint8Array::create((uint8_t*)certificateString.getCharactersWithUpconvert&lt;UChar&gt;(), certificateString.length() * sizeof(UChar));
+}
+
+void CDMSessionMediaSourceAVFObjC::releaseKeys()
+{
+    LOG(Media, &quot;CDMSessionMediaSourceAVFObjC::releaseKeys(%p)&quot;, this);
+}
+
+bool CDMSessionMediaSourceAVFObjC::update(Uint8Array* key, RefPtr&lt;Uint8Array&gt;&amp; nextMessage, unsigned short&amp; errorCode, unsigned long&amp; systemCode)
+{
+    if (!m_certificate) {
+        LOG(Media, &quot;CDMSessionMediaSourceAVFObjC::update(%p) - certificate data&quot;, this);
+
+        m_certificate = key;
+
+        RetainPtr&lt;NSData&gt; certificateData = adoptNS([[NSData alloc] initWithBytes:m_certificate-&gt;data() length:m_certificate-&gt;length()]);
+        RetainPtr&lt;NSData&gt; initData = adoptNS([[NSData alloc] initWithBytes:m_initData-&gt;data() length:m_initData-&gt;length()]);
+
+        NSError* error = nil;
+        RetainPtr&lt;NSData&gt; request = adoptNS([m_parent-&gt;parser() streamingContentKeyRequestDataForApp:certificateData.get() contentIdentifier:initData.get() trackID:m_parent-&gt;protectedTrackID() options:nil error:&amp;error]);
+
+        if (error) {
+            LOG(Media, &quot;CDMSessionMediaSourceAVFObjC::update(%p) - error:%@&quot;, this, [error description]);
+            errorCode = MediaPlayer::InvalidPlayerState;
+            systemCode = [error code];
+            return false;
+        }
+
+        nextMessage = Uint8Array::create([request length]);
+        [request getBytes:nextMessage-&gt;data() length:nextMessage-&gt;length()];
+        return false;
+    }
+
+    LOG(Media, &quot;CDMSessionMediaSourceAVFObjC::update(%p) - key data&quot;, this);
+    errorCode = MediaPlayer::NoError;
+    systemCode = 0;
+    RetainPtr&lt;NSData&gt; keyData = adoptNS([[NSData alloc] initWithBytes:key-&gt;data() length:key-&gt;length()]);
+    [m_parent-&gt;parser() processContentKeyResponseData:keyData.get() forTrackID:m_parent-&gt;protectedTrackID()];
+    return true;
+}
+
+}
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsavfoundationobjcMediaPlayerPrivateMediaSourceAVFObjCh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h (164528 => 164529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h        2014-02-22 06:07:41 UTC (rev 164528)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h        2014-02-22 06:17:53 UTC (rev 164529)
</span><span class="lines">@@ -73,6 +73,7 @@
</span><span class="cx">     void sizeChanged();
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(ENCRYPTED_MEDIA_V2)
</span><ins>+    virtual std::unique_ptr&lt;CDMSession&gt; createSession(const String&amp;);
</ins><span class="cx">     void keyNeeded(Uint8Array*);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -159,6 +160,7 @@
</span><span class="cx">     static bool isAvailable();
</span><span class="cx">     static void getSupportedTypes(HashSet&lt;String&gt;&amp; types);
</span><span class="cx">     static MediaPlayer::SupportsType supportsType(const MediaEngineSupportParameters&amp;);
</span><ins>+    static bool supportsKeySystem(const String&amp; keySystem, const String&amp; mimeType);
</ins><span class="cx"> 
</span><span class="cx">     friend class MediaSourcePrivateAVFObjC;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsavfoundationobjcMediaPlayerPrivateMediaSourceAVFObjCmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm (164528 => 164529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm        2014-02-22 06:07:41 UTC (rev 164528)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm        2014-02-22 06:17:53 UTC (rev 164529)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(MEDIA_SOURCE) &amp;&amp; USE(AVFOUNDATION)
</span><span class="cx"> 
</span><ins>+#import &quot;CDMSession.h&quot;
</ins><span class="cx"> #import &quot;MediaSourcePrivateAVFObjC.h&quot;
</span><span class="cx"> #import &quot;MediaSourcePrivateClient.h&quot;
</span><span class="cx"> #import &quot;MediaTimeMac.h&quot;
</span><span class="lines">@@ -165,7 +166,7 @@
</span><span class="cx"> void MediaPlayerPrivateMediaSourceAVFObjC::registerMediaEngine(MediaEngineRegistrar registrar)
</span><span class="cx"> {
</span><span class="cx">     if (isAvailable())
</span><del>-        registrar(create, getSupportedTypes, supportsType, 0, 0, 0, 0);
</del><ins>+        registrar(create, getSupportedTypes, supportsType, 0, 0, 0, supportsKeySystem);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> PassOwnPtr&lt;MediaPlayerPrivateInterface&gt; MediaPlayerPrivateMediaSourceAVFObjC::create(MediaPlayer* player)
</span><span class="lines">@@ -204,8 +205,20 @@
</span><span class="cx">     types = mimeTypeCache();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if ENABLE(ENCRYPTED_MEDIA_V2)
+static bool keySystemIsSupported(const String&amp; keySystem)
+{
+    return equalIgnoringCase(keySystem, &quot;com.apple.fps.2_0&quot;);
+}
+#endif
+
</ins><span class="cx"> MediaPlayer::SupportsType MediaPlayerPrivateMediaSourceAVFObjC::supportsType(const MediaEngineSupportParameters&amp; parameters)
</span><span class="cx"> {
</span><ins>+#if ENABLE(ENCRYPTED_MEDIA_V2)
+    if (!parameters.keySystem.isEmpty() &amp;&amp; !keySystemIsSupported(parameters.keySystem))
+            return MediaPlayer::IsNotSupported;
+#endif
+
</ins><span class="cx">     // This engine does not support non-media-source sources.
</span><span class="cx">     if (!parameters.isMediaSource)
</span><span class="cx">         return MediaPlayer::IsNotSupported;
</span><span class="lines">@@ -222,6 +235,25 @@
</span><span class="cx">     return [getAVURLAssetClass() isPlayableExtendedMIMEType:typeString] ? MediaPlayer::IsSupported : MediaPlayer::MayBeSupported;;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool MediaPlayerPrivateMediaSourceAVFObjC::supportsKeySystem(const String&amp; keySystem, const String&amp; mimeType)
+{
+#if ENABLE(ENCRYPTED_MEDIA_V2)
+    if (!keySystem.isEmpty()) {
+        if (!keySystemIsSupported(keySystem))
+            return false;
+
+        if (!mimeType.isEmpty() &amp;&amp; !mimeTypeCache().contains(mimeType))
+            return false;
+
+        return true;
+    }
+#else
+    UNUSED_PARAM(keySystem);
+    UNUSED_PARAM(mimeType);
+#endif
+    return false;
+}
+
</ins><span class="cx"> #pragma mark -
</span><span class="cx"> #pragma mark MediaPlayerPrivateInterface Overrides
</span><span class="cx"> 
</span><span class="lines">@@ -535,6 +567,14 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(ENCRYPTED_MEDIA_V2)
</span><ins>+std::unique_ptr&lt;CDMSession&gt; MediaPlayerPrivateMediaSourceAVFObjC::createSession(const String&amp; keySystem)
+{
+    if (!m_mediaSourcePrivate)
+        return nullptr;
+
+    return m_mediaSourcePrivate-&gt;createSession(keySystem);
+}
+
</ins><span class="cx"> void MediaPlayerPrivateMediaSourceAVFObjC::keyNeeded(Uint8Array* initData)
</span><span class="cx"> {
</span><span class="cx">     m_player-&gt;keyNeeded(initData);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsavfoundationobjcMediaSourcePrivateAVFObjCh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h (164528 => 164529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h        2014-02-22 06:07:41 UTC (rev 164528)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h        2014-02-22 06:17:53 UTC (rev 164529)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #if ENABLE(MEDIA_SOURCE) &amp;&amp; USE(AVFOUNDATION)
</span><span class="cx"> 
</span><span class="cx"> #include &quot;MediaSourcePrivate.h&quot;
</span><ins>+#include &lt;wtf/Deque.h&gt;
</ins><span class="cx"> #include &lt;wtf/HashMap.h&gt;
</span><span class="cx"> #include &lt;wtf/RefPtr.h&gt;
</span><span class="cx"> #include &lt;wtf/RetainPtr.h&gt;
</span><span class="lines">@@ -42,6 +43,7 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+class CDMSession;
</ins><span class="cx"> class MediaPlayerPrivateMediaSourceAVFObjC;
</span><span class="cx"> class SourceBufferPrivateAVFObjC;
</span><span class="cx"> class TimeRanges;
</span><span class="lines">@@ -68,11 +70,18 @@
</span><span class="cx">     MediaTime seekToTime(MediaTime, MediaTime negativeThreshold, MediaTime positiveThreshold);
</span><span class="cx">     IntSize naturalSize() const;
</span><span class="cx"> 
</span><ins>+#if ENABLE(ENCRYPTED_MEDIA_V2)
+    std::unique_ptr&lt;CDMSession&gt; createSession(const String&amp;);
+#endif
+
</ins><span class="cx"> private:
</span><span class="cx">     MediaSourcePrivateAVFObjC(MediaPlayerPrivateMediaSourceAVFObjC*);
</span><span class="cx"> 
</span><span class="cx">     void sourceBufferPrivateDidChangeActiveState(SourceBufferPrivateAVFObjC*, bool active);
</span><span class="cx">     void sourceBufferPrivateDidReceiveInitializationSegment(SourceBufferPrivateAVFObjC*);
</span><ins>+#if ENABLE(ENCRYPTED_MEDIA_V2)
+    void sourceBufferKeyNeeded(SourceBufferPrivateAVFObjC*, Uint8Array*);
+#endif
</ins><span class="cx">     void monitorSourceBuffers();
</span><span class="cx">     void removeSourceBuffer(SourceBufferPrivate*);
</span><span class="cx"> 
</span><span class="lines">@@ -82,6 +91,7 @@
</span><span class="cx">     double m_duration;
</span><span class="cx">     Vector&lt;RefPtr&lt;SourceBufferPrivateAVFObjC&gt;&gt; m_sourceBuffers;
</span><span class="cx">     Vector&lt;SourceBufferPrivateAVFObjC*&gt; m_activeSourceBuffers;
</span><ins>+    Deque&lt;SourceBufferPrivateAVFObjC*&gt; m_sourceBuffersNeedingSessions;
</ins><span class="cx">     bool m_isEnded;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsavfoundationobjcMediaSourcePrivateAVFObjCmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm (164528 => 164529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm        2014-02-22 06:07:41 UTC (rev 164528)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm        2014-02-22 06:17:53 UTC (rev 164529)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(MEDIA_SOURCE) &amp;&amp; USE(AVFOUNDATION)
</span><span class="cx"> 
</span><ins>+#import &quot;CDMSessionMediaSourceAVFObjC.h&quot;
</ins><span class="cx"> #import &quot;ContentType.h&quot;
</span><span class="cx"> #import &quot;ExceptionCodePlaceholder.h&quot;
</span><span class="cx"> #import &quot;MediaPlayerPrivateMediaSourceAVFObjC.h&quot;
</span><span class="lines">@@ -137,6 +138,26 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if ENABLE(ENCRYPTED_MEDIA_V2)
+std::unique_ptr&lt;CDMSession&gt; MediaSourcePrivateAVFObjC::createSession(const String&amp;)
+{
+#if __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 1090
+    if (m_sourceBuffersNeedingSessions.isEmpty())
+        return nullptr;
+    return std::make_unique&lt;CDMSessionMediaSourceAVFObjC&gt;(m_sourceBuffersNeedingSessions.takeFirst());
+#endif
+    return nullptr;
+}
+#endif
+
+#if ENABLE(ENCRYPTED_MEDIA_V2)
+void MediaSourcePrivateAVFObjC::sourceBufferKeyNeeded(SourceBufferPrivateAVFObjC* buffer, Uint8Array* initData)
+{
+    m_sourceBuffersNeedingSessions.append(buffer);
+    player()-&gt;keyNeeded(initData);
+}
+#endif
+
</ins><span class="cx"> static bool MediaSourcePrivateAVFObjCHasAudio(PassRefPtr&lt;SourceBufferPrivateAVFObjC&gt; prpSourceBuffer)
</span><span class="cx"> {
</span><span class="cx">     RefPtr&lt;SourceBufferPrivateAVFObjC&gt; sourceBuffer = prpSourceBuffer;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsavfoundationobjcSourceBufferPrivateAVFObjCh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h (164528 => 164529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h        2014-02-22 06:07:41 UTC (rev 164528)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h        2014-02-22 06:17:53 UTC (rev 164529)
</span><span class="lines">@@ -42,6 +42,7 @@
</span><span class="cx"> OBJC_CLASS AVStreamDataParser;
</span><span class="cx"> OBJC_CLASS AVSampleBufferAudioRenderer;
</span><span class="cx"> OBJC_CLASS AVSampleBufferDisplayLayer;
</span><ins>+OBJC_CLASS NSData;
</ins><span class="cx"> OBJC_CLASS NSError;
</span><span class="cx"> OBJC_CLASS NSObject;
</span><span class="cx"> typedef struct opaqueCMSampleBuffer *CMSampleBufferRef;
</span><span class="lines">@@ -68,6 +69,7 @@
</span><span class="cx">     void didFailToParseStreamDataWithError(NSError*);
</span><span class="cx">     void didProvideMediaDataForTrackID(int trackID, CMSampleBufferRef, const String&amp; mediaType, unsigned flags);
</span><span class="cx">     void didReachEndOfTrackWithTrackID(int trackID, const String&amp; mediaType);
</span><ins>+    void didProvideContentKeyRequestInitializationDataForTrackID(NSData*, int trackID);
</ins><span class="cx"> 
</span><span class="cx">     bool processCodedFrame(int trackID, CMSampleBufferRef, const String&amp; mediaType);
</span><span class="cx"> 
</span><span class="lines">@@ -81,6 +83,9 @@
</span><span class="cx">     MediaTime fastSeekTimeForMediaTime(MediaTime, MediaTime negativeThreshold, MediaTime positiveThreshold);
</span><span class="cx">     IntSize naturalSize();
</span><span class="cx"> 
</span><ins>+    int protectedTrackID() const { return m_protectedTrackID; }
+    AVStreamDataParser* parser() const { return m_parser.get(); }
+
</ins><span class="cx"> private:
</span><span class="cx">     explicit SourceBufferPrivateAVFObjC(MediaSourcePrivateAVFObjC*);
</span><span class="cx"> 
</span><span class="lines">@@ -119,6 +124,7 @@
</span><span class="cx"> 
</span><span class="cx">     bool m_parsingSucceeded;
</span><span class="cx">     int m_enabledVideoTrackID;
</span><ins>+    int m_protectedTrackID;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsavfoundationobjcSourceBufferPrivateAVFObjCmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm (164528 => 164529)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm        2014-02-22 06:07:41 UTC (rev 164528)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm        2014-02-22 06:17:53 UTC (rev 164529)
</span><span class="lines">@@ -115,6 +115,10 @@
</span><span class="cx"> - (void)appendStreamData:(NSData *)data;
</span><span class="cx"> - (void)setShouldProvideMediaData:(BOOL)shouldProvideMediaData forTrackID:(CMPersistentTrackID)trackID;
</span><span class="cx"> - (BOOL)shouldProvideMediaDataForTrackID:(CMPersistentTrackID)trackID;
</span><ins>+- (void)processContentKeyResponseData:(NSData *)contentKeyResponseData forTrackID:(CMPersistentTrackID)trackID;
+- (void)processContentKeyResponseError:(NSError *)error forTrackID:(CMPersistentTrackID)trackID;
+- (void)renewExpiringContentKeyResponseDataForTrackID:(CMPersistentTrackID)trackID;
+- (NSData *)streamingContentKeyRequestDataForApp:(NSData *)appIdentifier contentIdentifier:(NSData *)contentIdentifier trackID:(CMPersistentTrackID)trackID options:(NSDictionary *)options error:(NSError **)outError;
</ins><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> #pragma mark -
</span><span class="lines">@@ -218,6 +222,15 @@
</span><span class="cx">     ASSERT(streamDataParser == _parser);
</span><span class="cx">     _parent-&gt;didReachEndOfTrackWithTrackID(trackID, mediaType);
</span><span class="cx"> }
</span><ins>+
+- (void)streamDataParser:(AVStreamDataParser *)streamDataParser didProvideContentKeyRequestInitializationData:(NSData *)initData forTrackID:(CMPersistentTrackID)trackID
+{
+#if ASSERT_DISABLED
+    UNUSED_PARAM(streamDataParser);
+#endif
+    ASSERT(streamDataParser == _parser);
+    _parent-&gt;didProvideContentKeyRequestInitializationDataForTrackID(initData, trackID);
+}
</ins><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -327,6 +340,7 @@
</span><span class="cx">     , m_client(0)
</span><span class="cx">     , m_parsingSucceeded(true)
</span><span class="cx">     , m_enabledVideoTrackID(-1)
</span><ins>+    , m_protectedTrackID(-1)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -412,6 +426,20 @@
</span><span class="cx">     notImplemented();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void SourceBufferPrivateAVFObjC::didProvideContentKeyRequestInitializationDataForTrackID(NSData* initData, int trackID)
+{
+    UNUSED_PARAM(trackID);
+#if ENABLE(ENCRYPTED_MEDIA_V2)
+    LOG(Media, &quot;SourceBufferPrivateAVFObjC::didProvideContentKeyRequestInitializationDataForTrackID(%p) - track:%d&quot;, this, trackID);
+    m_protectedTrackID = trackID;
+    RefPtr&lt;Uint8Array&gt; initDataArray = Uint8Array::create([initData length]);
+    [initData getBytes:initDataArray-&gt;data() length:initDataArray-&gt;length()];
+    m_mediaSource-&gt;sourceBufferKeyNeeded(this, initDataArray.get());
+#else
+    UNUSED_PARAM(initData);
+#endif
+}
+
</ins><span class="cx"> void SourceBufferPrivateAVFObjC::setClient(SourceBufferPrivateClient* client)
</span><span class="cx"> {
</span><span class="cx">     m_client = client;
</span></span></pre>
</div>
</div>

</body>
</html>