Skip to content

Commit 0a93006

Browse files
ArnaudBiennermoz-wptsync-bot
authored andcommitted
fMP4: parse senc box and use it to retrieve crypto info by default.
Still use auxiliary data (saio/saiz), but as fallback in case senc is not present or couldn't be parsed. Differential Revision: https://phabricator.services.mozilla.com/D272640 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1505675 gecko-commit: 328fa2efad688fc9b14d4acb115b85aa262f5aea gecko-reviewers: karlt, media-playback-reviewers
1 parent 7733484 commit 0a93006

File tree

4 files changed

+134
-2
lines changed

4 files changed

+134
-2
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset=utf-8>
5+
<title>Encrypted Media Extensions: Successful Playback, Temporary session with Clear Key, mp4, multiple keys for audio/video, with no saio boxes</title>
6+
<link rel="help" href="https://w3c.github.io/encrypted-media/">
7+
8+
<!-- Web Platform Test Harness scripts -->
9+
<script src=/resources/testharness.js></script>
10+
<script src=/resources/testharnessreport.js></script>
11+
12+
<!-- Helper scripts for Encrypted Media Extensions tests -->
13+
<script src=/encrypted-media/util/utils.js></script>
14+
<script src=/encrypted-media/util/testmediasource.js></script>
15+
<script src=/encrypted-media/util/utf8.js></script>
16+
17+
<!-- Content metadata -->
18+
<script src=/encrypted-media/content/content-metadata.js></script>
19+
20+
<!-- Message handler for Clear Key keysystem -->
21+
<script src=/encrypted-media/util/clearkey-messagehandler.js></script>
22+
23+
<!-- The script for this specific test -->
24+
<script src=/encrypted-media/scripts/playback-temporary.js></script>
25+
26+
</head>
27+
<body>
28+
<div id='log'></div>
29+
30+
<div id='video'>
31+
<video id="videoelement" width="200px"></video>
32+
</div>
33+
34+
<script>
35+
var contentitem = content['mp4-av-multikey'],
36+
handler = new MessageHandler( 'org.w3.clearkey', contentitem ),
37+
config = { video: document.getElementById('videoelement'),
38+
keysystem: 'org.w3.clearkey',
39+
messagehandler: handler.messagehandler,
40+
audioPath: contentitem.audio.path,
41+
videoPath: contentitem.video.path,
42+
audioType: contentitem.audio.type,
43+
videoType: contentitem.video.type,
44+
// Replace 'saio' text by ' aio', and 'saiz' by ' aiz'
45+
// to make those boxes unrecognized: 'senc' boxes shall
46+
// be used instead
47+
audioBlankBytes: contentitem.audio.saioStarts.concat(contentitem.audio.saizStarts),
48+
videoBlankBytes: contentitem.video.saioStarts.concat(contentitem.video.saizStarts),
49+
initDataType: 'keyids',
50+
initData: getInitData(contentitem,'keyids'),
51+
testcase: 'multikey audio/video' };
52+
53+
54+
runTest(config);
55+
</script>
56+
</body>
57+
</html>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset=utf-8>
5+
<title>Encrypted Media Extensions: Successful Playback, Temporary session with Clear Key, mp4, multiple keys for audio/video, with no senc boxes</title>
6+
<link rel="help" href="https://w3c.github.io/encrypted-media/">
7+
8+
<!-- Web Platform Test Harness scripts -->
9+
<script src=/resources/testharness.js></script>
10+
<script src=/resources/testharnessreport.js></script>
11+
12+
<!-- Helper scripts for Encrypted Media Extensions tests -->
13+
<script src=/encrypted-media/util/utils.js></script>
14+
<script src=/encrypted-media/util/testmediasource.js></script>
15+
<script src=/encrypted-media/util/utf8.js></script>
16+
17+
<!-- Content metadata -->
18+
<script src=/encrypted-media/content/content-metadata.js></script>
19+
20+
<!-- Message handler for Clear Key keysystem -->
21+
<script src=/encrypted-media/util/clearkey-messagehandler.js></script>
22+
23+
<!-- The script for this specific test -->
24+
<script src=/encrypted-media/scripts/playback-temporary.js></script>
25+
26+
</head>
27+
<body>
28+
<div id='log'></div>
29+
30+
<div id='video'>
31+
<video id="videoelement" width="200px"></video>
32+
</div>
33+
34+
<script>
35+
var contentitem = content['mp4-av-multikey'],
36+
handler = new MessageHandler( 'org.w3.clearkey', contentitem ),
37+
config = { video: document.getElementById('videoelement'),
38+
keysystem: 'org.w3.clearkey',
39+
messagehandler: handler.messagehandler,
40+
audioPath: contentitem.audio.path,
41+
videoPath: contentitem.video.path,
42+
audioType: contentitem.audio.type,
43+
videoType: contentitem.video.type,
44+
// Replace 'senc' text by ' enc' to make those boxes
45+
// unrecognized: auxiliary data ('saio' boxes) shall be
46+
// used instead
47+
audioBlankBytes: contentitem.audio.sencStarts,
48+
videoBlankBytes: contentitem.video.sencStarts,
49+
initDataType: 'keyids',
50+
initData: getInitData(contentitem,'keyids'),
51+
testcase: 'multikey audio/video' };
52+
53+
54+
runTest(config);
55+
</script>
56+
</body>
57+
</html>

encrypted-media/content/content-metadata.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,15 @@ content = addMemberListToObject( {
5252
associatedInitData: true, // indicates that initData for one key causes other keys to be returned as well
5353
audio: { type: 'audio/mp4;codecs="mp4a.40.2"',
5454
path: '/encrypted-media/content/audio_aac-lc_128k_enc_dashinit.mp4',
55-
sinfStart: 0x02aa },
55+
sinfStart: 0x02aa,
56+
saizStarts: [0x081b, 0x9065, 0x1150a],
57+
saioStarts: [0x0802, 0x906e, 0x11523],
58+
sencStarts: [0x9c3, 0x9226] },
5659
video : { type: 'video/mp4;codecs="avc1.4d401e"',
57-
path: '/encrypted-media/content/video_512x288_h264-360k_enc_dashinit.mp4' },
60+
path: '/encrypted-media/content/video_512x288_h264-360k_enc_dashinit.mp4',
61+
saizStarts: [0x840, 0x18031, 0x2ebad],
62+
saioStarts: [0x889, 0x1804a, 0x2ebc6],
63+
sencStarts: [0x2ec62] },
5864
keys : [ { kid: [ 0xad, 0x13, 0xf9, 0xea, 0x2b, 0xe6, 0x98, 0xb8, 0x75, 0xf5, 0x04, 0xa8, 0xe3, 0xcc, 0xea, 0x64 ],
5965
key: [ 0xbe, 0x7d, 0xf8, 0xa3, 0x66, 0x7a, 0x6a, 0x8f, 0xd5, 0x64, 0xd0, 0xed, 0x81, 0x33, 0x9a, 0x95 ],
6066
initDataType: 'cenc',

encrypted-media/util/testmediasource.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@ function testmediasource(config) {
1212
Promise.all(fetches).then(function(resources) {
1313
config.audioMedia = resources[0];
1414
config.videoMedia = resources[1];
15+
if (Object.hasOwn(config, 'audioBlankBytes')) {
16+
audioMedia = new Uint8Array(config.audioMedia);
17+
for (const pos of config.audioBlankBytes) {
18+
audioMedia[pos] = ' '.charCodeAt();
19+
}
20+
}
21+
if (Object.hasOwn(config, 'videoBlankBytes')) {
22+
videoMedia = new Uint8Array(config.videoMedia);
23+
for (const pos of config.videoBlankBytes) {
24+
videoMedia[pos] = ' '.charCodeAt();
25+
}
26+
}
1527

1628
// Create media source
1729
var source = new MediaSource();

0 commit comments

Comments
 (0)