createDecoder method

  1. @override
Future<PlatformDecoder?> createDecoder(
  1. DecoderConfig config, {
  2. BackendContext? context,
})
override

Implementation

@override
Future<PlatformDecoder?> createDecoder(
  DecoderConfig config, {
  BackendContext? context,
}) async {
  if (!_videoCodecs.contains(config.codec)) return null;
  if (!WebCapability.hasVideoDecoder) return null;
  // Symmetry with createEncoder (and with audio decode): HEVC/AV1 support
  // varies by browser and by hardware, so ask before committing rather than
  // configuring and throwing.
  if (!await WebCapability.isVideoDecoderSupported(
    toWebCodecsString(config.codec, config.backendOptions),
  )) {
    return null;
  }
  return WebCodecsVideoDecoder.create(config);
}