Add support for HEVC codec types in Media Capabilities
[WebKit-https.git] / LayoutTests / media / hevc-codec-parameters.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4     <script src="video-test.js"></script>
5     <script>
6     function HEVCParameterSetToString(set) {
7         return `{ ${set.generalProfileSpace }, ${set.generalProfileIDC }, ${set.generalProfileCompatibilityFlags }, ${set.generalTierFlag }, ${set.generalLevelIDC } }`;
8     }
9     function isEqualHEVCParameterSet(setA, setB) {
10         return setA.generalProfileSpace === setB.generalProfileSpace
11             && setA.generalProfileIDC === setB.generalProfileIDC
12             && setA.generalProfileCompatibilityFlags === setB.generalProfileCompatibilityFlags
13             && setA.generalTierFlag === setB.generalTierFlag
14             && setA.generalLevelIDC === setB.generalLevelIDC
15     }
16     function makeHEVCParameterSet(generalProfileSpace, generalProfileIDC, generalProfileCompatibilityFlags, generalTierFlag, generalLevelIDC)
17     {
18         return {
19             generalProfileSpace: generalProfileSpace,
20             generalProfileIDC: generalProfileIDC,
21             generalProfileCompatibilityFlags: generalProfileCompatibilityFlags,
22             generalTierFlag: generalTierFlag,
23             generalLevelIDC: generalLevelIDC,
24         };
25     }
26     function testExpectedHEVCParameterSet(testFuncString, expected)
27     {
28         let observed = eval(testFuncString);
29         let success = isEqualHEVCParameterSet(observed, expected);
30         reportExpected(success, testFuncString, '===', HEVCParameterSetToString(expected), HEVCParameterSetToString(observed));
31     }
32     window.addEventListener('load', event => {
33         testExpected('internals.parseHEVCCodecParameters("bad-parameter")', null);
34         testExpected('internals.parseHEVCCodecParameters("hvc1")', null);
35         testExpectedHEVCParameterSet('internals.parseHEVCCodecParameters("hev1.1.6.L93")', makeHEVCParameterSet(0, 1, 6, false, 93));
36         testExpectedHEVCParameterSet('internals.parseHEVCCodecParameters("hev1.A4.41.H120")', makeHEVCParameterSet(1, 4, 65, true, 120));
37         testExpectedHEVCParameterSet('internals.parseHEVCCodecParameters("hev1.B1.4.L63")', makeHEVCParameterSet(2, 1, 4, false, 63));
38         testExpected('internals.parseHEVCCodecParameters("hev1.D1.4.L63")', null);
39         testExpected('internals.parseHEVCCodecParameters("hev1.B1.4.L68000")', null);
40         endTest();
41     }, { once: true });
42     </script>
43 </head>
44 <body>
45 </body>
46 </html>