diff --git a/tests/test.h264.js b/tests/test.h264.js index 2f67391c..e6fbacb8 100644 --- a/tests/test.h264.js +++ b/tests/test.h264.js @@ -4,6 +4,7 @@ import Display from '../core/display.js'; import { H264Parser } from '../core/decoders/h264.js'; import H264Decoder from '../core/decoders/h264.js'; import Base64 from '../core/base64.js'; +import { supportsWebCodecsH264Decode } from '../core/util/browser.js'; import FakeWebSocket from './fake.websocket.js'; @@ -29,32 +30,6 @@ const redGreenBlue16x16Video = new Uint8Array(Base64.decode( '4AA5DRJMnkycJk4TPwAAAAFBiIga8RigADVVHAAGaGOAANtuAAAAAUGIkBr///wRRQABVf8c' + 'AAcho4AAiD4=')); -let _haveH264Decode = null; - -async function haveH264Decode() { - if (_haveH264Decode !== null) { - return _haveH264Decode; - } - - if (!('VideoDecoder' in window)) { - _haveH264Decode = false; - return false; - } - - // We'll need to make do with some placeholders here - const config = { - codec: 'avc1.42401f', - codedWidth: 1920, - codedHeight: 1080, - optimizeForLatency: true, - }; - - let support = await VideoDecoder.isConfigSupported(config); - _haveH264Decode = support.supported; - - return _haveH264Decode; -} - function createSolidColorFrameBuffer(color, width, height) { const r = (color >> 24) & 0xff; const g = (color >> 16) & 0xff; @@ -158,8 +133,8 @@ describe('H.264 Parser', function () { describe('H.264 Decoder Unit Test', function () { let decoder; - beforeEach(async function () { - if (!await haveH264Decode()) { + beforeEach(function () { + if (!supportsWebCodecsH264Decode) { this.skip(); return; } @@ -213,8 +188,8 @@ describe('H.264 Decoder Functional Test', function () { before(FakeWebSocket.replace); after(FakeWebSocket.restore); - beforeEach(async function () { - if (!await haveH264Decode()) { + beforeEach(function () { + if (!supportsWebCodecsH264Decode) { this.skip(); return; }