File: missing-sinf.html

package info (click to toggle)
firefox 147.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,683,484 kB
  • sloc: cpp: 7,607,246; javascript: 6,533,185; ansic: 3,775,227; python: 1,415,393; xml: 634,561; asm: 438,951; java: 186,241; sh: 62,752; makefile: 18,079; objc: 13,092; perl: 12,808; yacc: 4,583; cs: 3,846; pascal: 3,448; lex: 1,720; ruby: 1,003; php: 436; lisp: 258; awk: 247; sql: 66; sed: 54; csh: 10; exp: 6
file content (68 lines) | stat: -rw-r--r-- 2,517 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<!doctype html>
<html>
  <head>
    <meta charset=utf-8>
    <title>Missing scheme information box in protected sample entry</title>
    <link rel="help" href="https://w3c.github.io/encrypted-media/">

    <!-- Web Platform Test Harness scripts -->
    <script src=/resources/testharness.js></script>
    <script src=/resources/testharnessreport.js></script>

    <!-- Content metadata -->
    <script src=/encrypted-media/content/content-metadata.js></script>
  </head>
  <body>
    <div id='log'></div>
    <div id='audio'>
      <audio id="audioelement" width="200px"></video>
    </div>
  </body>
  <script>
const contentItem = content['mp4-av-multikey'];
const audio = document.getElementById('audioelement');

// Test that a non conforming mp4 protected sample entry triggers the append
// error algorithm.
// https://w3c.github.io/media-source/#sourcebuffer-segment-parser-loop
// 2. If the [[input buffer]] contains bytes that violate the SourceBuffer
//    byte stream format specification, then run the append error algorithm and
//    abort this algorithm.
promise_test(async t => {
  audio.watcher = new EventWatcher(t, audio, ['error']);

  const response = await fetch(contentItem.audio.path);
  assert_true(response.ok, 'response.ok');
  const audioMedia = new Uint8Array(await response.arrayBuffer());

  const source = new MediaSource();
  source.watcher = new EventWatcher(t, source, ['sourceopen']);
  audio.src = URL.createObjectURL(source);
  await source.watcher.wait_for('sourceopen');

  const mediaType = contentItem.audio.type;
  assert_implements_optional(MediaSource.isTypeSupported(mediaType),
                             `${mediaType} supported`);
  const buffer = source.addSourceBuffer(mediaType);
  buffer.watcher = new EventWatcher(t, buffer, ['error', 'updateend']);

  // ISO/IEC 14496-12:2015(E)
  // 8.12.1 Protection Scheme Information Box
  // 8.12.1.1 Definition
  // "At least one protection scheme information box must occur in a protected
  //  sample entry."
  //
  // Change the 'sinf' box type to 'sin ' so that there is no protection
  // scheme information box in the protected sample entry.
  // 4-byte offset for the `type` field after `size` and 3 bytes to index the
  // last character of the type.
  audioMedia[contentItem.audio.sinfStart + 4 + 3] = ' '.charCodeAt();

  buffer.appendBuffer(audioMedia);
  await Promise.all([
    buffer.watcher.wait_for(['error', 'updateend']),
    audio.watcher.wait_for('error'),
  ]);
}, 'missing-sinf');
  </script>
</html>