<!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>[244439] trunk</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/244439">244439</a></dd>
<dt>Author</dt> <dd>jer.noble@apple.com</dd>
<dt>Date</dt> <dd>2019-04-18 15:07:56 -0700 (Thu, 18 Apr 2019)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add support for parsing FairPlayStreaming PSSH boxes.
https://bugs.webkit.org/show_bug.cgi?id=197064

Reviewed by Eric Carlson.

Source/WebCore:

API Tests: ISO.ISOFairPlayStreamingPsshBox

Add a new set of ISOBox classes for parsing the contents of a FairPlayStreaming PSSH box,
and add support for this new box to CDMFairPlayStreaming.

Drive-by fix: add an explicit include for MainThread.h to LibWebRTCProviderCocoa.cpp.

* SourcesCocoa.txt:
* WebCore.xcodeproj/project.pbxproj:
* platform/graphics/FourCC.h:
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::CDMPrivateFairPlayStreaming::cencName):
(WebCore::fairPlaySystemID):
(WebCore::extractSchemeAndKeyIdFromCenc):
(WebCore::CDMPrivateFairPlayStreaming::extractKeyIDsCenc):
(WebCore::CDMPrivateFairPlayStreaming::sanitizeCenc):
(WebCore::validInitDataTypes):
(WebCore::CDMFactory::platformRegisterFactories):
* platform/graphics/avfoundation/CDMFairPlayStreaming.h:
* platform/graphics/avfoundation/ISOFairPlayStreamingPsshBox.cpp: Added.
(WebCore::ISOFairPlayStreamingPsshBox::fairPlaySystemID):
(WebCore::ISOFairPlayStreamingInfoBox::parse):
(WebCore::ISOFairPlayStreamingKeyRequestInfoBox::parse):
(WebCore::ISOFairPlayStreamingKeyAssetIdBox::parse):
(WebCore::ISOFairPlayStreamingKeyContextBox::parse):
(WebCore::ISOFairPlayStreamingKeyVersionListBox::parse):
(WebCore::ISOFairPlayStreamingKeyRequestBox::parse):
(WebCore::ISOFairPlayStreamingInitDataBox::parse):
(WebCore::ISOFairPlayStreamingPsshBox::parse):
* platform/graphics/avfoundation/ISOFairPlayStreamingPsshBox.h: Added.
* platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.cpp:

Source/WTF:

* wtf/Platform.h:

Tools:

* TestWebKitAPI/Tests/WebCore/ISOBox.cpp:
(TestWebKitAPI::TEST):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFwtfPlatformh">trunk/Source/WTF/wtf/Platform.h</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreSourcesCocoatxt">trunk/Source/WebCore/SourcesCocoa.txt</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsFourCCh">trunk/Source/WebCore/platform/graphics/FourCC.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsavfoundationCDMFairPlayStreamingcpp">trunk/Source/WebCore/platform/graphics/avfoundation/CDMFairPlayStreaming.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsavfoundationCDMFairPlayStreamingh">trunk/Source/WebCore/platform/graphics/avfoundation/CDMFairPlayStreaming.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreamlibwebrtcLibWebRTCProviderCocoacpp">trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.cpp</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebCoreISOBoxcpp">trunk/Tools/TestWebKitAPI/Tests/WebCore/ISOBox.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformgraphicsavfoundationISOFairPlayStreamingPsshBoxcpp">trunk/Source/WebCore/platform/graphics/avfoundation/ISOFairPlayStreamingPsshBox.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsavfoundationISOFairPlayStreamingPsshBoxh">trunk/Source/WebCore/platform/graphics/avfoundation/ISOFairPlayStreamingPsshBox.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (244438 => 244439)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog       2019-04-18 21:57:48 UTC (rev 244438)
+++ trunk/Source/WTF/ChangeLog  2019-04-18 22:07:56 UTC (rev 244439)
</span><span class="lines">@@ -1,3 +1,12 @@
</span><ins>+2019-04-18  Jer Noble  <jer.noble@apple.com>
+
+        Add support for parsing FairPlayStreaming PSSH boxes.
+        https://bugs.webkit.org/show_bug.cgi?id=197064
+
+        Reviewed by Eric Carlson.
+
+        * wtf/Platform.h:
+
</ins><span class="cx"> 2019-04-18  Yusuke Suzuki  <ysuzuki@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [WTF] StringBuilder should set correct m_is8Bit flag when merging
</span></span></pre></div>
<a id="trunkSourceWTFwtfPlatformh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/Platform.h (244438 => 244439)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/Platform.h  2019-04-18 21:57:48 UTC (rev 244438)
+++ trunk/Source/WTF/wtf/Platform.h     2019-04-18 22:07:56 UTC (rev 244439)
</span><span class="lines">@@ -1517,6 +1517,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000) || (PLATFORM(WATCHOS) && __WATCH_OS_VERSION_MIN_REQUIRED >= 60000) || (PLATFORM(APPLETV) && __TV_OS_VERSION_MIN_REQUIRED >= 130000)
</span><span class="cx"> #define HAVE_ALLOWS_SENSITIVE_LOGGING 1
</span><ins>+#define HAVE_FAIRPLAYSTREAMING_CENC_INITDATA 1
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000) || (PLATFORM(WATCHOS) && __WATCH_OS_VERSION_MIN_REQUIRED >= 60000) || (PLATFORM(APPLETV) && __TV_OS_VERSION_MIN_REQUIRED >= 130000)
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (244438 => 244439)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2019-04-18 21:57:48 UTC (rev 244438)
+++ trunk/Source/WebCore/ChangeLog      2019-04-18 22:07:56 UTC (rev 244439)
</span><span class="lines">@@ -1,3 +1,42 @@
</span><ins>+2019-04-18  Jer Noble  <jer.noble@apple.com>
+
+        Add support for parsing FairPlayStreaming PSSH boxes.
+        https://bugs.webkit.org/show_bug.cgi?id=197064
+
+        Reviewed by Eric Carlson.
+
+        API Tests: ISO.ISOFairPlayStreamingPsshBox
+
+        Add a new set of ISOBox classes for parsing the contents of a FairPlayStreaming PSSH box,
+        and add support for this new box to CDMFairPlayStreaming.
+
+        Drive-by fix: add an explicit include for MainThread.h to LibWebRTCProviderCocoa.cpp.
+
+        * SourcesCocoa.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/graphics/FourCC.h:
+        * platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
+        (WebCore::CDMPrivateFairPlayStreaming::cencName):
+        (WebCore::fairPlaySystemID):
+        (WebCore::extractSchemeAndKeyIdFromCenc):
+        (WebCore::CDMPrivateFairPlayStreaming::extractKeyIDsCenc):
+        (WebCore::CDMPrivateFairPlayStreaming::sanitizeCenc):
+        (WebCore::validInitDataTypes):
+        (WebCore::CDMFactory::platformRegisterFactories):
+        * platform/graphics/avfoundation/CDMFairPlayStreaming.h:
+        * platform/graphics/avfoundation/ISOFairPlayStreamingPsshBox.cpp: Added.
+        (WebCore::ISOFairPlayStreamingPsshBox::fairPlaySystemID):
+        (WebCore::ISOFairPlayStreamingInfoBox::parse):
+        (WebCore::ISOFairPlayStreamingKeyRequestInfoBox::parse):
+        (WebCore::ISOFairPlayStreamingKeyAssetIdBox::parse):
+        (WebCore::ISOFairPlayStreamingKeyContextBox::parse):
+        (WebCore::ISOFairPlayStreamingKeyVersionListBox::parse):
+        (WebCore::ISOFairPlayStreamingKeyRequestBox::parse):
+        (WebCore::ISOFairPlayStreamingInitDataBox::parse):
+        (WebCore::ISOFairPlayStreamingPsshBox::parse):
+        * platform/graphics/avfoundation/ISOFairPlayStreamingPsshBox.h: Added.
+        * platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.cpp:
+
</ins><span class="cx"> 2019-04-18  Sihui Liu  <sihui_liu@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Blob type cannot be stored correctly in IDB when IDBObjectStore has autoIncrement and keyPath options
</span></span></pre></div>
<a id="trunkSourceWebCoreSourcesCocoatxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/SourcesCocoa.txt (244438 => 244439)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/SourcesCocoa.txt    2019-04-18 21:57:48 UTC (rev 244438)
+++ trunk/Source/WebCore/SourcesCocoa.txt       2019-04-18 22:07:56 UTC (rev 244439)
</span><span class="lines">@@ -225,6 +225,7 @@
</span><span class="cx"> platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.mm @no-unify
</span><span class="cx"> platform/graphics/avfoundation/InbandMetadataTextTrackPrivateAVF.cpp @no-unify
</span><span class="cx"> platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp @no-unify
</span><ins>+platform/graphics/avfoundation/ISOFairPlayStreamingPsshBox.cpp
</ins><span class="cx"> platform/graphics/avfoundation/MediaPlaybackTargetMac.mm @no-unify
</span><span class="cx"> platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp @no-unify
</span><span class="cx"> platform/graphics/avfoundation/MediaSelectionGroupAVFObjC.mm @no-unify
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (244438 => 244439)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj   2019-04-18 21:57:48 UTC (rev 244438)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj      2019-04-18 22:07:56 UTC (rev 244439)
</span><span class="lines">@@ -4046,6 +4046,7 @@
</span><span class="cx">          CD62FB961AF018E70012ED7D /* GenericTaskQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = CD62FB941AF018E70012ED7D /* GenericTaskQueue.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">          CD641EB31818F5ED00EE4C41 /* MediaSourcePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = CD641EB11818F5ED00EE4C41 /* MediaSourcePrivate.h */; };
</span><span class="cx">          CD641EB41818F5ED00EE4C41 /* SourceBufferPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = CD641EB21818F5ED00EE4C41 /* SourceBufferPrivate.h */; };
</span><ins>+               CD720B4F2268B51300047FDE /* ISOFairPlayStreamingPsshBox.h in Headers */ = {isa = PBXBuildFile; fileRef = CD720B4922682C7F00047FDE /* ISOFairPlayStreamingPsshBox.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">           CD7D33441C7A123F00041293 /* PixelBufferConformerCV.h in Headers */ = {isa = PBXBuildFile; fileRef = CD7D33421C7A123F00041293 /* PixelBufferConformerCV.h */; };
</span><span class="cx">          CD7D33481C7A16BF00041293 /* CoreVideoSoftLink.h in Headers */ = {isa = PBXBuildFile; fileRef = CD7D33461C7A16BF00041293 /* CoreVideoSoftLink.h */; };
</span><span class="cx">          CD7DBB2918CA19C600C11066 /* CSSGridLineNamesValue.h in Headers */ = {isa = PBXBuildFile; fileRef = CD7DBB2718CA11FF00C11066 /* CSSGridLineNamesValue.h */; };
</span><span class="lines">@@ -13499,6 +13500,8 @@
</span><span class="cx">          CD641EB11818F5ED00EE4C41 /* MediaSourcePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaSourcePrivate.h; sourceTree = "<group>"; };
</span><span class="cx">          CD641EB21818F5ED00EE4C41 /* SourceBufferPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SourceBufferPrivate.h; sourceTree = "<group>"; };
</span><span class="cx">          CD641EC7181ED60100EE4C41 /* MediaSample.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MediaSample.h; sourceTree = "<group>"; };
</span><ins>+               CD720B4722682C7E00047FDE /* ISOFairPlayStreamingPsshBox.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ISOFairPlayStreamingPsshBox.cpp; sourceTree = "<group>"; };
+               CD720B4922682C7F00047FDE /* ISOFairPlayStreamingPsshBox.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ISOFairPlayStreamingPsshBox.h; sourceTree = "<group>"; };
</ins><span class="cx">           CD78A2EC1F75648600DE371B /* CDMInstanceFairPlayStreamingAVFObjC.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CDMInstanceFairPlayStreamingAVFObjC.mm; sourceTree = "<group>"; };
</span><span class="cx">          CD78A2EE1F75648600DE371B /* CDMInstanceFairPlayStreamingAVFObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDMInstanceFairPlayStreamingAVFObjC.h; sourceTree = "<group>"; };
</span><span class="cx">          CD7D33411C7A123F00041293 /* PixelBufferConformerCV.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PixelBufferConformerCV.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -15872,6 +15875,8 @@
</span><span class="cx">                          07E9E12D18F5E2760011A3A4 /* InbandMetadataTextTrackPrivateAVF.h */,
</span><span class="cx">                          07B442D4166C70B000556CAD /* InbandTextTrackPrivateAVF.cpp */,
</span><span class="cx">                          07B442D5166C70B000556CAD /* InbandTextTrackPrivateAVF.h */,
</span><ins>+                               CD720B4722682C7E00047FDE /* ISOFairPlayStreamingPsshBox.cpp */,
+                               CD720B4922682C7F00047FDE /* ISOFairPlayStreamingPsshBox.h */,
</ins><span class="cx">                           071E496F1AD5AB5E008A50B4 /* MediaPlaybackTargetMac.h */,
</span><span class="cx">                          071E496D1AD5AA0D008A50B4 /* MediaPlaybackTargetMac.mm */,
</span><span class="cx">                          076F0D0912B8192700C26AA4 /* MediaPlayerPrivateAVFoundation.cpp */,
</span><span class="lines">@@ -29456,6 +29461,7 @@
</span><span class="cx">                          2D0B4AAB18DA1CCD00434DE1 /* IOSurface.h in Headers */,
</span><span class="cx">                          1C21E57D183ED1FF001C289D /* IOSurfacePool.h in Headers */,
</span><span class="cx">                          CD5FF4992162E2BE004BD86F /* ISOBox.h in Headers */,
</span><ins>+                               CD720B4F2268B51300047FDE /* ISOFairPlayStreamingPsshBox.h in Headers */,
</ins><span class="cx">                           CD5FF49E2162E4E8004BD86F /* ISOOriginalFormatBox.h in Headers */,
</span><span class="cx">                          CD5FF49D2162E4DB004BD86F /* ISOProtectionSchemeInfoBox.h in Headers */,
</span><span class="cx">                          CD5FF49C2162E4CF004BD86F /* ISOProtectionSystemSpecificHeaderBox.h in Headers */,
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFourCCh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/FourCC.h (244438 => 244439)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/FourCC.h  2019-04-18 21:57:48 UTC (rev 244438)
+++ trunk/Source/WebCore/platform/graphics/FourCC.h     2019-04-18 22:07:56 UTC (rev 244439)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> struct FourCC {
</span><ins>+    FourCC() = default;
</ins><span class="cx">     FourCC(uint32_t value) : value(value) { }
</span><span class="cx"> 
</span><span class="cx">     template<std::size_t N>
</span><span class="lines">@@ -45,7 +46,7 @@
</span><span class="cx">     bool operator==(const FourCC& other) const { return value == other.value; }
</span><span class="cx">     bool operator!=(const FourCC& other) const { return value != other.value; }
</span><span class="cx"> 
</span><del>-    uint32_t value;
</del><ins>+    uint32_t value { 0 };
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsavfoundationCDMFairPlayStreamingcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/avfoundation/CDMFairPlayStreaming.cpp (244438 => 244439)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/CDMFairPlayStreaming.cpp     2019-04-18 21:57:48 UTC (rev 244438)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/CDMFairPlayStreaming.cpp        2019-04-18 22:07:56 UTC (rev 244439)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> #include "CDMKeySystemConfiguration.h"
</span><span class="cx"> #include "CDMRestrictions.h"
</span><span class="cx"> #include "CDMSessionType.h"
</span><ins>+#include "ISOFairPlayStreamingPsshBox.h"
</ins><span class="cx"> #include "ISOSchemeInformationBox.h"
</span><span class="cx"> #include "ISOSchemeTypeBox.h"
</span><span class="cx"> #include "ISOTrackEncryptionBox.h"
</span><span class="lines">@@ -74,6 +75,18 @@
</span><span class="cx">     return skd;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+const AtomicString& CDMPrivateFairPlayStreaming::cencName()
+{
+    static NeverDestroyed<AtomicString> cenc { MAKE_STATIC_STRING_IMPL("cenc") };
+    return cenc;
+}
+
+static const Vector<uint8_t>& fairPlaySystemID()
+{
+    static NeverDestroyed<Vector<uint8_t>> systemID = Vector<uint8_t>({ 0x94, 0xCE, 0x86, 0xFB, 0x07, 0xFF, 0x4F, 0x43, 0xAD, 0xB8, 0x93, 0xD2, 0xFA, 0x96, 0x8C, 0xA2 });
+    return systemID;
+}
+
</ins><span class="cx"> static Vector<Ref<SharedBuffer>> extractSinfData(const SharedBuffer& buffer)
</span><span class="cx"> {
</span><span class="cx">     // JSON of the format: "{ sinf: [ <base64-encoded-string> ] }"
</span><span class="lines">@@ -171,6 +184,54 @@
</span><span class="cx">     return keyIDs;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static SchemeAndKeyResult extractSchemeAndKeyIdFromCenc(const SharedBuffer& buffer)
+{
+    auto arrayBuffer = buffer.tryCreateArrayBuffer();
+    if (!arrayBuffer)
+        return { };
+
+    auto view = JSC::DataView::create(WTFMove(arrayBuffer), 0, buffer.size());
+    unsigned offset { 0 };
+
+    SchemeAndKeyResult result;
+    while (offset < buffer.size()) {
+        auto peekResult = ISOBox::peekBox(view, offset);
+        if (!peekResult || peekResult.value().first != ISOProtectionSystemSpecificHeaderBox::boxTypeName())
+            return { };
+
+        ISOProtectionSystemSpecificHeaderBox psshBox;
+        if (!psshBox.read(view, offset))
+            return { };
+
+        if (psshBox.systemID() != fairPlaySystemID())
+            continue;
+
+        ISOFairPlayStreamingPsshBox fpsPssh;
+        offset -= psshBox.size();
+        if (!fpsPssh.read(view, offset))
+            return { };
+
+        FourCC scheme = fpsPssh.initDataBox().info().scheme();
+        for (auto request : fpsPssh.initDataBox().requests())
+            result.append(std::make_pair(scheme, request.requestInfo().keyID()));
+    }
+
+    return result;
+}
+
+Optional<Vector<Ref<SharedBuffer>>> CDMPrivateFairPlayStreaming::extractKeyIDsCenc(const SharedBuffer& buffer)
+{
+    Vector<Ref<SharedBuffer>> keyIDs;
+    auto results = extractSchemeAndKeyIdFromCenc(buffer);
+
+    for (auto& result : results) {
+        if (validFairPlayStreamingSchemes().contains(result.first))
+            keyIDs.append(SharedBuffer::create(result.second.data(), result.second.size()));
+    }
+
+    return keyIDs;
+}
+
</ins><span class="cx"> RefPtr<SharedBuffer> CDMPrivateFairPlayStreaming::sanitizeSinf(const SharedBuffer& buffer)
</span><span class="cx"> {
</span><span class="cx">     // Common SINF Box Format
</span><span class="lines">@@ -186,6 +247,13 @@
</span><span class="cx">     return buffer.copy();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+RefPtr<SharedBuffer> CDMPrivateFairPlayStreaming::sanitizeCenc(const SharedBuffer& buffer)
+{
+    UNUSED_PARAM(buffer);
+    notImplemented();
+    return buffer.copy();
+}
+
</ins><span class="cx"> Optional<Vector<Ref<SharedBuffer>>> CDMPrivateFairPlayStreaming::extractKeyIDsSkd(const SharedBuffer& buffer)
</span><span class="cx"> {
</span><span class="cx">     // In the 'skd' scheme, the init data is the key ID.
</span><span class="lines">@@ -196,7 +264,13 @@
</span><span class="cx"> 
</span><span class="cx"> static const HashSet<AtomicString>& validInitDataTypes()
</span><span class="cx"> {
</span><del>-    static NeverDestroyed<HashSet<AtomicString>> validTypes = HashSet<AtomicString>({ CDMPrivateFairPlayStreaming::sinfName(), CDMPrivateFairPlayStreaming::skdName() });
</del><ins>+    static NeverDestroyed<HashSet<AtomicString>> validTypes = HashSet<AtomicString>({
+        CDMPrivateFairPlayStreaming::sinfName(),
+        CDMPrivateFairPlayStreaming::skdName(),
+#if HAVE(FAIRPLAYSTREAMING_CENC_INITDATA)
+        CDMPrivateFairPlayStreaming::cencName(),
+#endif
+    });
</ins><span class="cx">     return validTypes;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -207,6 +281,9 @@
</span><span class="cx"> 
</span><span class="cx">     InitDataRegistry::shared().registerInitDataType(CDMPrivateFairPlayStreaming::sinfName(), { CDMPrivateFairPlayStreaming::sanitizeSinf, CDMPrivateFairPlayStreaming::extractKeyIDsSinf });
</span><span class="cx">     InitDataRegistry::shared().registerInitDataType(CDMPrivateFairPlayStreaming::skdName(), { CDMPrivateFairPlayStreaming::sanitizeSkd, CDMPrivateFairPlayStreaming::extractKeyIDsSkd });
</span><ins>+#if HAVE(FAIRPLAYSTREAMING_CENC_INITDATA)
+    InitDataRegistry::shared().registerInitDataType(CDMPrivateFairPlayStreaming::cencName(), { CDMPrivateFairPlayStreaming::sanitizeCenc, CDMPrivateFairPlayStreaming::extractKeyIDsCenc });
+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> CDMFactoryFairPlayStreaming& CDMFactoryFairPlayStreaming::singleton()
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsavfoundationCDMFairPlayStreamingh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/avfoundation/CDMFairPlayStreaming.h (244438 => 244439)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/CDMFairPlayStreaming.h       2019-04-18 21:57:48 UTC (rev 244438)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/CDMFairPlayStreaming.h  2019-04-18 22:07:56 UTC (rev 244439)
</span><span class="lines">@@ -74,6 +74,10 @@
</span><span class="cx">     static const AtomicString& skdName();
</span><span class="cx">     static Optional<Vector<Ref<SharedBuffer>>> extractKeyIDsSkd(const SharedBuffer&);
</span><span class="cx">     static RefPtr<SharedBuffer> sanitizeSkd(const SharedBuffer&);
</span><ins>+
+    static const AtomicString& cencName();
+    static Optional<Vector<Ref<SharedBuffer>>> extractKeyIDsCenc(const SharedBuffer&);
+    static RefPtr<SharedBuffer> sanitizeCenc(const SharedBuffer&);
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsavfoundationISOFairPlayStreamingPsshBoxcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/avfoundation/ISOFairPlayStreamingPsshBox.cpp (0 => 244439)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/ISOFairPlayStreamingPsshBox.cpp                              (rev 0)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/ISOFairPlayStreamingPsshBox.cpp 2019-04-18 22:07:56 UTC (rev 244439)
</span><span class="lines">@@ -0,0 +1,251 @@
</span><ins>+/*
+ * Copyright (C) 2019 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.
+ */
+
+#include "config.h"
+#include "ISOFairPlayStreamingPsshBox.h"
+
+#include <JavaScriptCore/DataView.h>
+
+namespace WebCore {
+
+const Vector<uint8_t>& ISOFairPlayStreamingPsshBox::fairPlaySystemID()
+{
+    static NeverDestroyed<Vector<uint8_t>> systemID = Vector<uint8_t>({ 0x94, 0xCE, 0x86, 0xFB, 0x07, 0xFF, 0x4F, 0x43, 0xAD, 0xB8, 0x93, 0xD2, 0xFA, 0x96, 0x8C, 0xA2 });
+    return systemID;
+}
+
+bool ISOFairPlayStreamingInfoBox::parse(JSC::DataView& view, unsigned& offset)
+{
+    if (!ISOFullBox::parse(view, offset))
+        return false;
+
+    return checkedRead<uint32_t>(m_scheme, view, offset, BigEndian);
+}
+
+bool ISOFairPlayStreamingKeyRequestInfoBox::parse(JSC::DataView& view, unsigned& offset)
+{
+    unsigned localOffset = offset;
+    if (!ISOBox::parse(view, localOffset))
+        return false;
+
+    Checked<uint64_t, RecordOverflow> remaining = m_size;
+    remaining -= (localOffset - offset);
+    if (remaining.hasOverflowed())
+        return false;
+
+    if (remaining < m_keyID.capacity())
+        return false;
+
+    auto buffer = view.possiblySharedBuffer();
+    if (!buffer)
+        return false;
+
+    auto keyID = buffer->slice(localOffset, localOffset + m_keyID.capacity());
+    localOffset += m_keyID.capacity();
+
+    m_keyID.resize(m_keyID.capacity());
+    memcpy(m_keyID.data(), keyID->data(), m_keyID.capacity());
+
+    offset = localOffset;
+    return true;
+}
+
+bool ISOFairPlayStreamingKeyAssetIdBox::parse(JSC::DataView& view, unsigned& offset)
+{
+    unsigned localOffset = offset;
+    if (!ISOBox::parse(view, localOffset))
+        return false;
+
+    if (localOffset - offset == m_size) {
+        m_data.clear();
+        offset = localOffset;
+        return true;
+    }
+
+    auto buffer = view.possiblySharedBuffer();
+    if (!buffer)
+        return false;
+
+    uint64_t dataSize;
+    if (!WTF::safeSub(m_size, localOffset - offset, dataSize))
+        return false;
+
+    auto parsedData = buffer->slice(localOffset, localOffset + dataSize);
+    localOffset += dataSize;
+
+    m_data.resize(dataSize);
+    memcpy(m_data.data(), parsedData->data(), dataSize);
+    offset = localOffset;
+    return true;
+}
+
+bool ISOFairPlayStreamingKeyContextBox::parse(JSC::DataView& view, unsigned& offset)
+{
+    unsigned localOffset = offset;
+    if (!ISOBox::parse(view, localOffset))
+        return false;
+
+    if (localOffset - offset == m_size) {
+        m_data.clear();
+        offset = localOffset;
+        return true;
+    }
+
+    auto buffer = view.possiblySharedBuffer();
+    if (!buffer)
+        return false;
+
+    uint64_t dataSize;
+    if (!WTF::safeSub(m_size, localOffset - offset, dataSize))
+        return false;
+
+    auto parsedData = buffer->slice(localOffset, localOffset + dataSize);
+    localOffset += dataSize;
+
+    m_data.resize(dataSize);
+    memcpy(m_data.data(), parsedData->data(), dataSize);
+    offset = localOffset;
+    return true;
+}
+
+bool ISOFairPlayStreamingKeyVersionListBox::parse(JSC::DataView& view, unsigned& offset)
+{
+    unsigned localOffset = offset;
+    if (!ISOBox::parse(view, localOffset))
+        return false;
+
+    do {
+        if (localOffset - offset == m_size)
+            break;
+
+        uint64_t remaining;
+        if (!WTF::safeSub(m_size, localOffset - offset, remaining))
+            return false;
+
+        if (remaining < sizeof(uint32_t))
+            return false;
+
+        uint32_t version;
+        if (!checkedRead<uint32_t>(version, view, localOffset, BigEndian))
+            return false;
+        m_versions.append(version);
+    } while (true);
+
+    offset = localOffset;
+    return true; 
+}
+
+bool ISOFairPlayStreamingKeyRequestBox::parse(JSC::DataView& view, unsigned& offset)
+{
+    unsigned localOffset = offset;
+    if (!ISOBox::parse(view, localOffset))
+        return false;
+
+    if (!m_requestInfo.read(view, localOffset))
+        return false;
+
+    while (localOffset - offset < m_size) {
+        auto result = peekBox(view, localOffset);
+        if (!result)
+            return false;
+
+        auto name = result.value().first;
+        if (name == ISOFairPlayStreamingKeyAssetIdBox::boxTypeName()) {
+            if (m_assetID)
+                return false;
+
+            ISOFairPlayStreamingKeyAssetIdBox assetID;
+            if (!assetID.read(view, localOffset))
+                return false;
+
+            m_assetID = WTFMove(assetID);
+            continue;
+        }
+
+        if (name == ISOFairPlayStreamingKeyContextBox::boxTypeName()) {
+            if (m_context)
+                return false;
+
+            ISOFairPlayStreamingKeyContextBox context;
+            if (!context.read(view, localOffset))
+                return false;
+
+            m_context = WTFMove(context);
+            continue;
+        }
+
+        if (name == ISOFairPlayStreamingKeyVersionListBox::boxTypeName()) {
+            if (m_versionList)
+                return false;
+
+            ISOFairPlayStreamingKeyVersionListBox versionList;
+            if (!versionList.read(view, localOffset))
+                return false;
+
+            m_versionList = WTFMove(versionList);
+            continue;
+        }
+
+        // Unknown box type; error.
+        return false;
+    }   
+    
+    offset = localOffset;
+    return true; 
+}
+
+bool ISOFairPlayStreamingInitDataBox::parse(JSC::DataView& view, unsigned& offset)
+{
+    unsigned localOffset = offset;
+    if (!ISOBox::parse(view, localOffset))
+        return false;
+
+    if (!m_info.read(view, localOffset))
+        return false;
+
+    while (localOffset - offset < m_size) {
+        ISOFairPlayStreamingKeyRequestBox request;
+        if (!request.read(view, localOffset))
+            return false;
+
+        m_requests.append(WTFMove(request));
+    }
+
+    offset = localOffset;
+    return true;
+}
+
+bool ISOFairPlayStreamingPsshBox::parse(JSC::DataView& view, unsigned& offset)
+{
+    if (!ISOProtectionSystemSpecificHeaderBox::parse(view, offset))
+        return false;
+
+    // Back up the offset by exactly the size of m_data:
+    offset -= m_data.size();
+
+    return m_initDataBox.read(view, offset);
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsavfoundationISOFairPlayStreamingPsshBoxh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/avfoundation/ISOFairPlayStreamingPsshBox.h (0 => 244439)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/ISOFairPlayStreamingPsshBox.h                                (rev 0)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/ISOFairPlayStreamingPsshBox.h   2019-04-18 22:07:56 UTC (rev 244439)
</span><span class="lines">@@ -0,0 +1,135 @@
</span><ins>+/*
+ * Copyright (C) 2019 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.
+ */
+
+#pragma once
+
+#include "ISOProtectionSystemSpecificHeaderBox.h"
+#include <wtf/Optional.h>
+
+namespace WebCore {
+
+class WEBCORE_EXPORT ISOFairPlayStreamingInfoBox : public ISOFullBox {
+public:
+    static FourCC boxTypeName() { return "fpsi"; }
+
+    FourCC scheme() const { return m_scheme; }
+
+private:
+    bool parse(JSC::DataView&, unsigned& offset) override;
+
+    FourCC m_scheme;
+};
+
+class WEBCORE_EXPORT ISOFairPlayStreamingKeyRequestInfoBox : public ISOBox {
+public:
+    static FourCC boxTypeName() { return "fkri"; }
+
+    using KeyID = Vector<uint8_t, 16>;
+    const KeyID& keyID() const { return m_keyID; }
+
+private:
+    bool parse(JSC::DataView&, unsigned& offset) override;
+
+    KeyID m_keyID;
+};
+
+class WEBCORE_EXPORT ISOFairPlayStreamingKeyAssetIdBox : public ISOBox {
+public:
+    static FourCC boxTypeName() { return "fkai"; }
+    const Vector<uint8_t> data() const { return m_data; }
+
+private:
+    bool parse(JSC::DataView&, unsigned& offset) override;
+
+    Vector<uint8_t> m_data;
+};
+
+class WEBCORE_EXPORT ISOFairPlayStreamingKeyContextBox : public ISOBox {
+public:
+    static FourCC boxTypeName() { return "fkcx"; }
+    const Vector<uint8_t> data() const { return m_data; }
+
+private:
+    bool parse(JSC::DataView&, unsigned& offset) override;
+
+    Vector<uint8_t> m_data;
+};
+
+class WEBCORE_EXPORT ISOFairPlayStreamingKeyVersionListBox : public ISOBox {
+public:
+    static FourCC boxTypeName() { return "fkvl"; }
+    const Vector<uint8_t> versions() const { return m_versions; }
+
+private:
+    bool parse(JSC::DataView&, unsigned& offset) override;
+
+    Vector<uint8_t> m_versions;
+};
+
+class WEBCORE_EXPORT ISOFairPlayStreamingKeyRequestBox : public ISOBox {
+public:
+    static FourCC boxTypeName() { return "fpsk"; }
+
+    const ISOFairPlayStreamingKeyRequestInfoBox& requestInfo() const { return m_requestInfo; }
+    const Optional<ISOFairPlayStreamingKeyAssetIdBox>& assetID() const { return m_assetID; }
+    const Optional<ISOFairPlayStreamingKeyContextBox>& content() const { return m_context; }
+    const Optional<ISOFairPlayStreamingKeyVersionListBox>& versionList() const { return m_versionList; }
+
+private:
+    bool parse(JSC::DataView&, unsigned& offset) override;
+
+    ISOFairPlayStreamingKeyRequestInfoBox m_requestInfo;
+    Optional<ISOFairPlayStreamingKeyAssetIdBox> m_assetID;
+    Optional<ISOFairPlayStreamingKeyContextBox> m_context;
+    Optional<ISOFairPlayStreamingKeyVersionListBox> m_versionList;
+};
+
+class WEBCORE_EXPORT ISOFairPlayStreamingInitDataBox : public ISOBox {
+public:
+    static FourCC boxTypeName() { return "fps "; }
+
+    const ISOFairPlayStreamingInfoBox& info() const { return m_info; }
+    const Vector<ISOFairPlayStreamingKeyRequestBox>& requests() const { return m_requests; }
+
+private:
+    bool parse(JSC::DataView&, unsigned& offset) override;
+
+    ISOFairPlayStreamingInfoBox m_info;
+    Vector<ISOFairPlayStreamingKeyRequestBox> m_requests;
+};
+
+class WEBCORE_EXPORT ISOFairPlayStreamingPsshBox : public ISOProtectionSystemSpecificHeaderBox {
+public:
+    static const Vector<uint8_t>& fairPlaySystemID();
+
+    const ISOFairPlayStreamingInitDataBox& initDataBox() { return m_initDataBox; }
+
+private:
+    bool parse(JSC::DataView&, unsigned& offset) override;
+
+    ISOFairPlayStreamingInitDataBox m_initDataBox;
+};
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreamlibwebrtcLibWebRTCProviderCocoacpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.cpp (244438 => 244439)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.cpp   2019-04-18 21:57:48 UTC (rev 244438)
+++ trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProviderCocoa.cpp      2019-04-18 22:07:56 UTC (rev 244439)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> #include <webrtc/media/engine/webrtcvideodecoderfactory.h>
</span><span class="cx"> #include <webrtc/media/engine/webrtcvideoencoderfactory.h>
</span><span class="cx"> #include <webrtc/sdk/WebKit/WebKitUtilities.h>
</span><ins>+#include <wtf/MainThread.h>
</ins><span class="cx"> #include <wtf/darwin/WeakLinking.h>
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (244438 => 244439)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog    2019-04-18 21:57:48 UTC (rev 244438)
+++ trunk/Tools/ChangeLog       2019-04-18 22:07:56 UTC (rev 244439)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2019-04-18  Jer Noble  <jer.noble@apple.com>
+
+        Add support for parsing FairPlayStreaming PSSH boxes.
+        https://bugs.webkit.org/show_bug.cgi?id=197064
+
+        Reviewed by Eric Carlson.
+
+        * TestWebKitAPI/Tests/WebCore/ISOBox.cpp:
+        (TestWebKitAPI::TEST):
+
</ins><span class="cx"> 2019-04-18  Brent Fulgham  <bfulgham@apple.com>
</span><span class="cx"> 
</span><span class="cx">         InjectedBundle parameters often need initialization function called before unarchiving
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebCoreISOBoxcpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/ISOBox.cpp (244438 => 244439)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebCore/ISOBox.cpp       2019-04-18 21:57:48 UTC (rev 244438)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/ISOBox.cpp  2019-04-18 22:07:56 UTC (rev 244439)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include "Test.h"
</span><span class="cx"> #include <JavaScriptCore/DataView.h>
</span><ins>+#include <WebCore/ISOFairPlayStreamingPsshBox.h>
</ins><span class="cx"> #include <WebCore/ISOProtectionSchemeInfoBox.h>
</span><span class="cx"> #include <WebCore/ISOSchemeInformationBox.h>
</span><span class="cx"> #include <WebCore/ISOSchemeTypeBox.h>
</span><span class="lines">@@ -73,4 +74,39 @@
</span><span class="cx">     ASSERT_EQ(defaultIV, trackEncryptionBox->defaultConstantIV());
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static const char* base64EncodedPsshWithAssetId = "AAAAqHBzc2gAAAAAlM6G+wf/T0OtuJPS+paMogAAAIgAAACIZnBzZAAAABBmcHNpAAAAAGNlbmMAAAA4ZnBzawAAABhma3JpAAAAAAAAAAAAAAAAAAAAAQAAABhma2FpAAAAAAAAAAAAAAAAAAAA8QAAADhmcHNrAAAAGGZrcmkAAAAAAAAAAAAAAAAAAAACAAAAGGZrYWkAAAAAAAAAAAAAAAAAAADy";
+
+TEST(ISOBox, ISOFairPlayStreamingPsshBox)
+{
+    Vector<uint8_t> psshArray;
+    ASSERT_TRUE(base64Decode(StringView(base64EncodedPsshWithAssetId), psshArray));
+    ASSERT_EQ(168UL, psshArray.size());
+
+    auto view = JSC::DataView::create(ArrayBuffer::create(psshArray.data(), psshArray.size()), 0, psshArray.size());
+
+    ISOFairPlayStreamingPsshBox psshBox;
+
+    ASSERT_TRUE(psshBox.read(view));
+
+    auto infoBox = psshBox.initDataBox().info();
+    ASSERT_EQ(FourCC('cenc'), infoBox.scheme());
+
+    auto requests = psshBox.initDataBox().requests();
+    ASSERT_EQ(2UL, requests.size());
+
+    Vector<uint8_t, 16> expectedFirstKeyID = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
+    ASSERT_EQ(requests[0].requestInfo().keyID(), expectedFirstKeyID);
+
+    Vector<uint8_t> expectedFirstAssetID = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xF1 };
+    ASSERT_TRUE(requests[0].assetID());
+    ASSERT_EQ(requests[0].assetID().value().data(), expectedFirstAssetID);
+
+    Vector<uint8_t, 16> expectedSecondKeyID = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2 };
+    ASSERT_EQ(requests[1].requestInfo().keyID(), expectedSecondKeyID);
+
+    Vector<uint8_t> expectedSecondAssetID = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xF2 };
+    ASSERT_TRUE(requests[1].assetID());
+    ASSERT_EQ(requests[1].assetID().value().data(), expectedSecondAssetID);
</ins><span class="cx"> }
</span><ins>+
+}
</ins></span></pre>
</div>
</div>

</body>
</html>