| <!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> |