PSSH是什么
PSSH: Protection System Specific Headers
PSSH 是一个标准化的容器,用来存放protection system使用到的一些metadata。
PSSH不直接包含加密的key,但是包含key ID、 encryption scheme、和其他的一些用来向license server获取key的一些信息。
如何使用
在对视频做DRM protection的时候,packager需要对视频本身进行加密,并且向内容中添加一些metadata,通常以PSSH Box的形式进行存储。针对不同的DRM system需要添加不同的PSSH Box,分别包含不同的DRM system指定的PSSH Data。
当player播放加密内容时, 读取其中的PSSH Box, 然后利用其中的信息向license server请求key。
PSSH Box 的格式
var pssh = [0x00, 0x00, 0x00, 0x44, 0x70, 0x73, 0x73, 0x68, // BMFF box header (68 bytes, 'pssh')0x01, 0x00, 0x00, 0x00, // Full box header (version = 1, flags = 0)0x10, 0x77, 0xef, 0xec, 0xc0, 0xb2, 0x4d, 0x02, // SystemID0xac, 0xe3, 0x3c, 0x1e, 0x52, 0xe2, 0xfb, 0x4b,0x00, 0x00, 0x00, 0x02, // KID_count (2)0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, // First KID ("0123456789012345")0x38, 0x39, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35,0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, // Second KID ("ABCDEFGHIJKLMNOP")0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,0x00, 0x00, 0x00, 0x00, // Size of Data (0)
];
以上为PSSH version 1格式,version 0不包含其中的KID_count和KID list.
不同DRM system的PSSH Data格式
PlayReady
<WRMHEADER xmlns="http://schemas.microsoft.com/drm/2007/03/PlayReadyHeader" version="4.3.0.0"><DATA><PROTECTINFO><KIDS><KID ALGID="AESCBC" VALUE="PV1LM/VEVk+kEOB8qqcWDg=="></KID><KID ALGID="AESCBC" VALUE="tuhDoKUN7EyxDPtMRNmhyA=="></KID></KIDS></PROTECTINFO><LA_URL>http://rm.contoso.com/rightsmanager.asmx</LA_URL><DS_ID>AH+03juKbUGbHl1V/QIwRA==</DS_ID></DATA>
</WRMHEADER>
Widevine PSSH data 的protobuf 表示
最终写入PSSH box的数据是protobuf序列化后的结果
// Copyright 2016 Google LLC. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
//
// This file defines Widevine Pssh Data proto format.syntax = "proto2";package shaka.media;message WidevinePsshData {enum Algorithm {UNENCRYPTED = 0;AESCTR = 1;};optional Algorithm algorithm = 1;repeated bytes key_id = 2;// Content provider name.optional string provider = 3;// A content identifier, specified by content provider.optional bytes content_id = 4;// The name of a registered policy to be used for this asset.optional string policy = 6;// Crypto period index, for media using key rotation.optional uint32 crypto_period_index = 7;// Optional protected context for group content. The grouped_license is a// serialized SignedMessage.optional bytes grouped_license = 8;// Protection scheme identifying the encryption algorithm. Represented as one// of the following 4CC values: 'cenc' (AES-CTR), 'cbc1' (AES-CBC),// 'cens' (AES-CTR subsample), 'cbcs' (AES-CBC subsample).optional uint32 protection_scheme = 9;
}// Derived from WidevinePsshData. The JSON format of this proto is used in
// Widevine HLS DRM signaling v1.
// We cannot build JSON from WidevinePsshData as |key_id| is required to be in
// hex format, while |bytes| type is translated to base64 by JSON formatter, so
// we have to use |string| type and do hex conversion in the code.
message WidevineHeader {repeated string key_ids = 2;// Content provider name.optional string provider = 3;// A content identifier, specified by content provider.optional bytes content_id = 4;
}
PSSH Data在m3u8中的表示
#EXT-X-KEY:METHOD=SAMPLE-AES,URI="data:text/plain;charset=UTF-16;base64,vgEAAAEAAQC0ATwAVwBSAE0AS",IV=0xaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbb,KEYFORMATVERSIONS="1",KEYFORMAT="com.microsoft.playready"
#EXT-X-KEY:METHOD=SAMPLE-AES,URI="data:text/plain;base64,AAAAOHBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAABgSEKqqqqqqqqqqqqqqqqbbbbBI88aJmwY=",KEYID=0xaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbb,IV=0xaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbb,KEYFORMATVERSIONS="1",KEYFORMAT="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"
#EXT-X-KEY:METHOD=SAMPLE-AES,URI="skd://aaaaaaaaaaaaaaaaaaaaaaaaaaaabbbb",KEYFORMATVERSIONS="1",KEYFORMAT="com.apple.streamingkeydelivery"
Reference
PSSH and PSSH Box - Protection System Specific Headers
PlayReady Header Specification
widevine_pssh_data.proto
Widevine_DRM_for_HLS