shell.dart 1010 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. part of 'data_host.dart';
  2. class _VidDataHostShell implements VidDataHostInterface {
  3. _VidDataHostShell(this.url);
  4. static PlatformService get _platform => VidDataHostEnv.platformGetter!.call();
  5. VidUsImageData? _data;
  6. @override
  7. final String url;
  8. @override
  9. int get frameCount => _data!.imageCount;
  10. @override
  11. VidUsProbe get probe => _data!.probe;
  12. @override
  13. Future<VidUsImageData?> getData() async => _data;
  14. @override
  15. Future<VidDataHostLoadInfo?> load() async {
  16. final rst = await _platform.getVidFile(url);
  17. if (rst == null || rst.isEmpty) return null;
  18. final buffer = const Base64Decoder().convert(rst);
  19. _data = VidUsImageData(buffer);
  20. final info = VidDataHostLoadInfo(_data!.probe);
  21. return info;
  22. }
  23. @override
  24. Future<VidUsImage?> getFrame<TProcessor extends VidFrameProcessor>(
  25. int index, {
  26. List<TProcessor>? processors,
  27. }) async {
  28. return _data?.getImage(index);
  29. }
  30. @override
  31. Future<void> release() async {
  32. _data = null;
  33. }
  34. }