|
@@ -5,32 +5,29 @@ class _VidDataHostShell implements VidDataHostInterface {
|
|
|
|
|
|
static PlatformService get _platform => VidDataHostEnv.platformGetter!.call();
|
|
|
|
|
|
- VidUsProbe? _probe;
|
|
|
- int? _frameCount;
|
|
|
+ VidUsImageData? _data;
|
|
|
|
|
|
@override
|
|
|
final String url;
|
|
|
|
|
|
@override
|
|
|
- int get frameCount => _frameCount!;
|
|
|
+ int get frameCount => _data!.imageCount;
|
|
|
|
|
|
@override
|
|
|
- VidUsProbe get probe => _probe!;
|
|
|
+ VidUsProbe get probe => _data!.probe;
|
|
|
|
|
|
@override
|
|
|
- Future<VidUsImageData?> getData() async => null;
|
|
|
+ Future<VidUsImageData?> getData() async => _data;
|
|
|
|
|
|
@override
|
|
|
Future<VidDataHostLoadInfo?> load() async {
|
|
|
- final rst = await _platform.loadVid(url);
|
|
|
- if (!rst.isSuccess) return null;
|
|
|
+ final rst = await _platform.getVidFile(url);
|
|
|
+ if (rst == null || rst.isEmpty) return null;
|
|
|
|
|
|
- final buffer = const Base64Decoder().convert(rst.probeBase64!);
|
|
|
- final probe = VidUsProbe.fromBytes(buffer);
|
|
|
- _probe = probe;
|
|
|
- _frameCount = rst.frameCount;
|
|
|
+ final buffer = const Base64Decoder().convert(rst);
|
|
|
+ _data = VidUsImageData(buffer);
|
|
|
|
|
|
- final info = VidDataHostLoadInfo(probe);
|
|
|
+ final info = VidDataHostLoadInfo(_data!.probe);
|
|
|
return info;
|
|
|
}
|
|
|
|
|
@@ -39,45 +36,11 @@ class _VidDataHostShell implements VidDataHostInterface {
|
|
|
int index, {
|
|
|
List<TProcessor>? processors,
|
|
|
}) async {
|
|
|
- final rpcProcessors = _convert2RpcProcessors(processors);
|
|
|
- final rst = await _platform.getVidFrame(GetVidFrameRequest(
|
|
|
- index: index,
|
|
|
- processors: rpcProcessors,
|
|
|
- ));
|
|
|
- if (!rst.isSuccess) return null;
|
|
|
-
|
|
|
- final buffer = const Base64Decoder().convert(rst.frameBase64!);
|
|
|
- final frame = VidUsImage.fromBytes(buffer);
|
|
|
- return frame;
|
|
|
+ return _data?.getImage(index);
|
|
|
}
|
|
|
|
|
|
@override
|
|
|
Future<void> release() async {
|
|
|
- _platform.releaseVid();
|
|
|
- }
|
|
|
-
|
|
|
- List<TOut>? _convert2RpcProcessors<TIn extends VidFrameProcessor,
|
|
|
- TOut extends VidFrameProcessorBase>(List<TIn>? processors) {
|
|
|
- if (processors == null || processors.isEmpty) return null;
|
|
|
-
|
|
|
- final result = <TOut>[];
|
|
|
- for (final processor in processors) {
|
|
|
- final converted = _convert2RpcProcessor<TIn, TOut>(processor);
|
|
|
- if (converted != null) {
|
|
|
- result.add(converted);
|
|
|
- }
|
|
|
- }
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
- TOut? _convert2RpcProcessor<TIn extends VidFrameProcessor,
|
|
|
- TOut extends VidFrameProcessorBase>(TIn processor) {
|
|
|
- if (processor is VidBrightnessProcessor) {
|
|
|
- return VidFrameBrightnessProcessor(processor.brightness) as TOut;
|
|
|
- }
|
|
|
- if (processor is VidContrastProcessor) {
|
|
|
- return VidFrameContrastProcessor(processor.contrast) as TOut;
|
|
|
- }
|
|
|
- return null;
|
|
|
+ _data = null;
|
|
|
}
|
|
|
}
|