decode_capabilities_test.html 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <!DOCTYPE html>
  2. <title>Decode Capabilities Test</title>
  3. <div id="console"></div>
  4. <script type='text/javascript'>
  5. function log(message) {
  6. let consoleElement = document.getElementById('console');
  7. let entry = document.createElement('div');
  8. entry.appendChild(document.createTextNode(message));
  9. consoleElement.appendChild(entry);
  10. console.log(message);
  11. }
  12. function runTest(configuration) {
  13. try {
  14. navigator.mediaCapabilities.decodingInfo(configuration)
  15. .then((result) => {
  16. log('Decoding is '
  17. + (result.supported ? '' : 'un') + 'supported');
  18. document.title = result.supported ? 'SUPPORTED' : 'UNSUPPORTED';
  19. })
  20. .catch((e) => {
  21. log('Promise rejected: ' + e);
  22. document.title = "ERROR";
  23. });
  24. } catch (e) {
  25. log('Exception:' + e);
  26. document.title = "ERROR";
  27. }
  28. }
  29. function testVideoConfig(queryType, contentType) {
  30. // Clear previous test result from title.
  31. document.title = '';
  32. log("Testing video content type: " + contentType);
  33. const configuration = {
  34. type : queryType,
  35. video : {
  36. contentType : contentType,
  37. // Any reasonable value will do.
  38. width : 640,
  39. height : 480,
  40. bitrate : 10000,
  41. framerate : 30
  42. }
  43. };
  44. runTest(configuration);
  45. }
  46. function testAudioConfig(queryType, contentType) {
  47. // Clear previous test result from title.
  48. document.title = '';
  49. log("Testing audio content type: " + contentType);
  50. const configuration = {
  51. type : queryType,
  52. audio : {
  53. contentType : contentType
  54. }
  55. };
  56. runTest(configuration);
  57. }
  58. function testAudioConfigWithSpatialRendering(spatialRendering, queryType, contentType) {
  59. // Clear previous test result from title.
  60. document.title = '';
  61. log("Testing audio content type: " + contentType + ", spatialRendering: " + spatialRendering);
  62. const configuration = {
  63. type : queryType,
  64. audio : {
  65. contentType : contentType,
  66. spatialRendering : spatialRendering
  67. }
  68. };
  69. runTest(configuration);
  70. }
  71. function testVideoConfigWithHdrMetadata(hdrMetadataType,
  72. colorGamut,
  73. transferFunction,
  74. queryType,
  75. contentType) {
  76. // Clear previous test result from title.
  77. document.title = '';
  78. log("Testing video content type: " + contentType +
  79. ", HDR metadata type: " + hdrMetadataType +
  80. ", color gamut: " + colorGamut +
  81. ", transfer function: " + transferFunction);
  82. const configuration = {
  83. type : queryType,
  84. video : {
  85. contentType : contentType,
  86. hdrMetadataType : hdrMetadataType,
  87. colorGamut : colorGamut,
  88. transferFunction : transferFunction,
  89. // Any reasonable value will do.
  90. width : 640,
  91. height : 480,
  92. bitrate : 10000,
  93. framerate : 30
  94. }
  95. };
  96. runTest(configuration);
  97. }
  98. function testVideoConfigWithoutHdrMetadata(colorGamut,
  99. transferFunction,
  100. queryType,
  101. contentType) {
  102. // Clear previous test result from title.
  103. document.title = '';
  104. log("Testing video content type: " + contentType +
  105. ", color gamut: " + colorGamut +
  106. ", transfer function: " + transferFunction);
  107. const configuration = {
  108. type : queryType,
  109. video : {
  110. contentType : contentType,
  111. colorGamut : colorGamut,
  112. transferFunction : transferFunction,
  113. // Any reasonable value will do.
  114. width : 640,
  115. height : 480,
  116. bitrate : 10000,
  117. framerate : 30
  118. }
  119. };
  120. runTest(configuration);
  121. }
  122. </script>