2024-06-30 03:35:34 -06:00
|
|
|
/// <reference lib="dom" />
|
|
|
|
import type {VideoDecoderPropertiesType} from './specs/VideoNativeComponent';
|
|
|
|
|
2024-07-08 23:38:47 -06:00
|
|
|
const canPlay = (codec: string): boolean => {
|
|
|
|
// most chrome based browser (and safari I think) supports matroska but reports they do not.
|
|
|
|
// for those browsers, only check the codecs and not the container.
|
|
|
|
if (navigator.userAgent.search('Firefox') === -1) {
|
|
|
|
codec = codec.replace('video/x-matroska', 'video/mp4');
|
2024-06-30 03:35:34 -06:00
|
|
|
}
|
|
|
|
|
2024-07-08 23:38:47 -06:00
|
|
|
return !!MediaSource.isTypeSupported(codec);
|
|
|
|
};
|
2024-06-30 03:35:34 -06:00
|
|
|
|
2024-07-08 23:38:47 -06:00
|
|
|
export const VideoDecoderProperties = {
|
|
|
|
async getWidevineLevel() {
|
|
|
|
return 0;
|
|
|
|
},
|
2024-06-30 03:35:34 -06:00
|
|
|
|
|
|
|
async isCodecSupported(
|
|
|
|
mimeType: string,
|
|
|
|
_width: number,
|
|
|
|
_height: number,
|
|
|
|
): Promise<'unsupported' | 'hardware' | 'software'> {
|
|
|
|
// TODO: Figure out if we can get hardware support information
|
2024-07-08 23:38:47 -06:00
|
|
|
return canPlay(mimeType) ? 'software' : 'unsupported';
|
|
|
|
},
|
2024-06-30 03:35:34 -06:00
|
|
|
|
|
|
|
async isHEVCSupported(): Promise<'unsupported' | 'hardware' | 'software'> {
|
|
|
|
// Just a dummy vidoe mime type codec with HEVC to check.
|
2024-07-08 23:38:47 -06:00
|
|
|
return canPlay('video/x-matroska; codecs="hvc1.1.4.L96.BO"')
|
2024-06-30 03:35:34 -06:00
|
|
|
? 'software'
|
|
|
|
: 'unsupported';
|
2024-07-08 23:38:47 -06:00
|
|
|
},
|
|
|
|
} satisfies VideoDecoderPropertiesType;
|