[doc] Update raw key tutorial

Change-Id: Ife841975c036cf8042c9775583c409e0daa089c7
This commit is contained in:
KongQun Yang 2017-10-17 15:47:43 -07:00
parent 1bf1ec2445
commit 7c38963c29
7 changed files with 64 additions and 44 deletions

View File

@ -0,0 +1,15 @@
DRM related Stream descriptor fields
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
:skip_encryption=0|1:
Optional. Defaults to 0 if not specified. If it is set to 1, no encryption
of the stream will be made.
:drm_label:
Optional value for custom DRM label, which defines the encryption key
applied to the stream. Typically values include AUDIO, SD, HD, UHD1, UHD2.
For raw key, it should be a label defined in --keys. If not provided, the
DRM label is derived from stream type (video, audio), resolutions, etc.
Note that it is case sensitive.

View File

@ -23,14 +23,6 @@ Raw key encryption options
*key_id* and *key* should be 32-digit hex strings.
--key_id <32-digit hex string>
The key id in hex string format. Deprecated. Use --keys instead.
--key <32-digit hex string>
The key in hex string format. Deprecated. Use --keys instead.
--iv <16-digit or 32-digit hex string>
IV in hex string format. If not specified, a random IV will be generated.

View File

@ -4,7 +4,7 @@ Stream descriptors
There can be multiple *stream_descriptor* with input from the same "file" or
multiple different "files".
Stream is of the form::
Stream descriptor is of the form::
{field}={value}[,{field}={value}]...
@ -57,23 +57,11 @@ These are the available fields:
If not specified, it will be derived from the file extension of the output
file.
:skip_encryption=0|1:
Optional. Defaults to 0 if not specified. If it is set to 1, no encryption
of the stream will be made.
:drm_label:
Optional value for custom DRM label, which defines the encryption key
applied to the stream. Typically values include AUDIO, SD, HD, UHD1, UHD2.
For raw key, it should be a label defined in --keys. If not provided, the
DRM label is derived from stream type (video, audio), resolutions, etc.
Note that it is case sensitive.
:trick_play_factor (tpf):
Optional value which specifies the trick play, a.k.a. trick mode, stream
sampling rate among key frames. If specified, the output is a trick play
stream.
.. include:: /options/drm_stream_descriptors.rst
.. include:: /options/hls_stream_descriptors.rst

View File

@ -10,19 +10,24 @@ Synopsis
$ packager {stream_descriptor} [stream_descriptor] ... \
--enable_fixed_key_encryption \
--key_id <key_id> --key <key> \
--keys <key_info_string[,key_info_string][,key_info_string]...> \
[--pssh <concatenated PSSHs>] \
[Other options, e.g. DASH options, HLS options]
**key_info_string** is of the form::
label={label}:key_id={key_id}:key={key}
Custom PSSH(s) can be provided in *--pssh*. If absent,
`v1 common PSSH box <https://goo.gl/s8RIhr>`_ is generated.
Examples
--------
The examples below uses the H264 streams created in :doc:`encoding`. Here are examples with DASH. It can be applied to HLS in a similar way.
The examples below uses the H264 streams created in :doc:`encoding`. Here are
examples with DASH. It can be applied to HLS in a similar way.
Common PSSH::
Common PSSH (one key for all streams)::
$ packager \
in=h264_baseline_360p_600.mp4,stream=audio,output=audio.mp4 \
@ -31,21 +36,31 @@ Common PSSH::
in=h264_main_720p_3000.mp4,stream=video,output=h264_720p.mp4 \
in=h264_high_1080p_6000.mp4,stream=video,output=h264_1080p.mp4 \
--enable_fixed_key_encryption \
--key_id abba271e8bcf552bbd2e86a434a9a5d9 \
--key 69eaa802a6763af979e8d1940fb88392 \
--keys label=:key_id=abba271e8bcf552bbd2e86a434a9a5d9:key=69eaa802a6763af979e8d1940fb88392 \
--mpd_output h264.mpd
Widevine PSSH::
Common PSSH (different keys for different streams)::
$ packager \
in=h264_baseline_360p_600.mp4,stream=audio,output=audio.mp4 \
in=h264_baseline_360p_600.mp4,stream=video,output=h264_360p.mp4 \
in=h264_main_480p_1000.mp4,stream=video,output=h264_480p.mp4 \
in=h264_main_720p_3000.mp4,stream=video,output=h264_720p.mp4 \
in=h264_high_1080p_6000.mp4,stream=video,output=h264_1080p.mp4 \
in=h264_baseline_360p_600.mp4,stream=audio,output=audio.mp4,drm_label=AUDIO \
in=h264_baseline_360p_600.mp4,stream=video,output=h264_360p.mp4,drm_label=SD \
in=h264_main_480p_1000.mp4,stream=video,output=h264_480p.mp4,drm_label=SD \
in=h264_main_720p_3000.mp4,stream=video,output=h264_720p.mp4,drm_label=HD \
in=h264_high_1080p_6000.mp4,stream=video,output=h264_1080p.mp4,drm_label=HD \
--enable_fixed_key_encryption \
--key_id abba271e8bcf552bbd2e86a434a9a5d9 \
--key 69eaa802a6763af979e8d1940fb88392 \
--keys label=AUDIO:key_id=f3c5e0361e6654b28f8049c778b23946:key=a4631a153a443df9eed0593043db7519,label=SD:key_id=abba271e8bcf552bbd2e86a434a9a5d9:key=69eaa802a6763af979e8d1940fb88392,label=HD:key_id=6d76f25cb17f5e16b8eaef6bbf582d8e:key=cb541084c99731aef4fff74500c12ead \
--mpd_output h264.mpd
Widevine PSSH (different keys for different streams)::
$ packager \
in=h264_baseline_360p_600.mp4,stream=audio,output=audio.mp4,drm_label=AUDIO \
in=h264_baseline_360p_600.mp4,stream=video,output=h264_360p.mp4,drm_label=SD \
in=h264_main_480p_1000.mp4,stream=video,output=h264_480p.mp4,drm_label=SD \
in=h264_main_720p_3000.mp4,stream=video,output=h264_720p.mp4,drm_label=HD \
in=h264_high_1080p_6000.mp4,stream=video,output=h264_1080p.mp4,drm_label=HD \
--enable_fixed_key_encryption \
--keys label=AUDIO:key_id=f3c5e0361e6654b28f8049c778b23946:key=a4631a153a443df9eed0593043db7519,label=SD:key_id=abba271e8bcf552bbd2e86a434a9a5d9:key=69eaa802a6763af979e8d1940fb88392,label=HD:key_id=6d76f25cb17f5e16b8eaef6bbf582d8e:key=cb541084c99731aef4fff74500c12ead \
--pssh 000000407073736800000000edef8ba979d64acea3c827dcd51d21ed000000201a0d7769646576696e655f74657374220f7465737420636f6e74656e74206964 \
--mpd_output h264.mpd
@ -56,19 +71,23 @@ on how to config the DRM in Shaka Player.
Test vectors used in this tutorial
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Key ID
:Key ID:
abba271e8bcf552bbd2e86a434a9a5d9
| SD: abba271e8bcf552bbd2e86a434a9a5d9
| HD: 6d76f25cb17f5e16b8eaef6bbf582d8e
| AUDIO: f3c5e0361e6654b28f8049c778b23946
Key ID must be 16 bytes or 32 digits in HEX.
Key
:Key:
69eaa802a6763af979e8d1940fb88392
| SD: 69eaa802a6763af979e8d1940fb88392
| HD: cb541084c99731aef4fff74500c12ead
| AUDIO: a4631a153a443df9eed0593043db7519
Key must be 16 bytes or 32 digits in HEX.
Widevine PSSH
:Widevine PSSH:
000000407073736800000000edef8ba979d64acea3c827dcd51d21ed000000201a0d7769646576696e655f74657374220f7465737420636f6e74656e74206964
@ -78,6 +97,7 @@ Widevine PSSH
$ pssh-box.py --widevine-system-id \
--content-id 7465737420636f6e74656e74206964 --provider widevine_test
.. include:: /options/drm_stream_descriptors.rst
.. include:: /options/raw_key_encryption_options.rst
pssh-box (Utility to generate PSSH boxes)

View File

@ -62,19 +62,19 @@ Widevine test credential
Here is the test crendential used in this tutorial.
key_server_url
:key_server_url:
https://license.uat.widevine.com/cenc/getcontentkey/widevine_test
signer
:signer:
widevine_test
aes_signing_key
:aes_signing_key:
1ae8ccd0e7985cc0b6203a55855a1034afc252980e970ca90e5202689f947ab9
aes_signing_iv
:aes_signing_iv:
d58ce954203b7c9a9a9d467f59839249

View File

@ -182,10 +182,14 @@ bool ParseKeys(const std::string& keys, RawKeyParams* raw_key) {
auto& key_info = raw_key->key_map[drm_label];
if (value_map[kKeyIdLabel].empty() ||
!base::HexStringToBytes(value_map[kKeyIdLabel], &key_info.key_id)) {
LOG(ERROR) << "Empty key id or invalid hex string for key id: "
<< value_map[kKeyIdLabel];
return false;
}
if (value_map[kKeyLabel].empty() ||
!base::HexStringToBytes(value_map[kKeyLabel], &key_info.key)) {
LOG(ERROR) << "Empty key or invalid hex string for key: "
<< value_map[kKeyLabel];
return false;
}
}

View File

@ -558,6 +558,7 @@ bool WidevineKeySource::ExtractEncryptionKey(
std::string stream_label;
RCHECK(track_dict->GetString("type", &stream_label));
RCHECK(encryption_key_map.find(stream_label) == encryption_key_map.end());
VLOG(2) << "drm label:" << stream_label;
std::unique_ptr<EncryptionKey> encryption_key(new EncryptionKey());