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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
media / test / data / decode_capabilities_test.html [blame]
<!DOCTYPE html>
<title>Decode Capabilities Test</title>
<div id="console"></div>
<script type='text/javascript'>
function log(message) {
let consoleElement = document.getElementById('console');
let entry = document.createElement('div');
entry.appendChild(document.createTextNode(message));
consoleElement.appendChild(entry);
console.log(message);
}
function runTest(configuration) {
try {
navigator.mediaCapabilities.decodingInfo(configuration)
.then((result) => {
log('Decoding is '
+ (result.supported ? '' : 'un') + 'supported');
document.title = result.supported ? 'SUPPORTED' : 'UNSUPPORTED';
})
.catch((e) => {
log('Promise rejected: ' + e);
document.title = "ERROR";
});
} catch (e) {
log('Exception:' + e);
document.title = "ERROR";
}
}
function testVideoConfig(queryType, contentType) {
// Clear previous test result from title.
document.title = '';
log("Testing video content type: " + contentType);
const configuration = {
type : queryType,
video : {
contentType : contentType,
// Any reasonable value will do.
width : 640,
height : 480,
bitrate : 10000,
framerate : 30
}
};
runTest(configuration);
}
function testAudioConfig(queryType, contentType) {
// Clear previous test result from title.
document.title = '';
log("Testing audio content type: " + contentType);
const configuration = {
type : queryType,
audio : {
contentType : contentType
}
};
runTest(configuration);
}
function testAudioConfigWithSpatialRendering(spatialRendering, queryType, contentType) {
// Clear previous test result from title.
document.title = '';
log("Testing audio content type: " + contentType + ", spatialRendering: " + spatialRendering);
const configuration = {
type : queryType,
audio : {
contentType : contentType,
spatialRendering : spatialRendering
}
};
runTest(configuration);
}
function testVideoConfigWithHdrMetadata(hdrMetadataType,
colorGamut,
transferFunction,
queryType,
contentType) {
// Clear previous test result from title.
document.title = '';
log("Testing video content type: " + contentType +
", HDR metadata type: " + hdrMetadataType +
", color gamut: " + colorGamut +
", transfer function: " + transferFunction);
const configuration = {
type : queryType,
video : {
contentType : contentType,
hdrMetadataType : hdrMetadataType,
colorGamut : colorGamut,
transferFunction : transferFunction,
// Any reasonable value will do.
width : 640,
height : 480,
bitrate : 10000,
framerate : 30
}
};
runTest(configuration);
}
function testVideoConfigWithoutHdrMetadata(colorGamut,
transferFunction,
queryType,
contentType) {
// Clear previous test result from title.
document.title = '';
log("Testing video content type: " + contentType +
", color gamut: " + colorGamut +
", transfer function: " + transferFunction);
const configuration = {
type : queryType,
video : {
contentType : contentType,
colorGamut : colorGamut,
transferFunction : transferFunction,
// Any reasonable value will do.
width : 640,
height : 480,
bitrate : 10000,
framerate : 30
}
};
runTest(configuration);
}
</script>