melon.yin 2 роки тому
батько
коміт
2bee87e8e4
2 змінених файлів з 121 додано та 1 видалено
  1. 27 1
      lib/services/platform.dart
  2. 94 0
      lib/services/platform.m.dart

+ 27 - 1
lib/services/platform.dart

@@ -1,4 +1,7 @@
+import 'package:fis_common/json_convert.dart';
+
 import '../client_base.dart';
+import 'platform.m.dart';
 
 /// 平台服务
 class PlatformService extends JsonRpcClientBase {
@@ -12,7 +15,11 @@ class PlatformService extends JsonRpcClientBase {
           serviceName,
           headers: headers,
           timeout: timeout,
-        );
+        ) {
+    /// 注册响应实体反序列化处理器
+    FJsonConvert.setDecoder((map) => LoadVidResult.fromJson(map));
+    FJsonConvert.setDecoder((map) => GetVidFrameResult.fromJson(map));
+  }
 
   /// 加载主题
   Future<bool> loadTheme(String name) async {
@@ -51,4 +58,23 @@ class PlatformService extends JsonRpcClientBase {
     var rpcRst = await call("GetText", name);
     return rpcRst;
   }
+
+  /// 加载Vid文件
+  ///
+  /// [url] Vid文件链接
+  Future<LoadVidResult> loadVid(String url) async {
+    var rpcRst = await call("LoadVid", url);
+    var result = LoadVidResult.fromJson(rpcRst as Map<String, dynamic>);
+    return result;
+  }
+
+  /// 获取Vid单针帧图
+  Future<GetVidFrameResult> getVidFrame(GetVidFrameRequest request) async {
+    var rpcRst = await call("GetVidFrame", request);
+    var result = GetVidFrameResult.fromJson(rpcRst as Map<String, dynamic>);
+    return result;
+  }
+
+  /// 释放Vid缓存资源
+  void releaseVid() => notify("ReleaseVid");
 }

+ 94 - 0
lib/services/platform.m.dart

@@ -1 +1,95 @@
+class LoadVidResult {
+  LoadVidResult({
+    this.isSuccess = false,
+    this.probeBase64,
+  });
 
+  String? probeBase64;
+  bool isSuccess;
+
+  factory LoadVidResult.fromJson(Map<String, dynamic> map) {
+    return LoadVidResult(
+      isSuccess: map['IsSuccess'],
+      probeBase64: map["ProbeBase64"],
+    );
+  }
+}
+
+abstract class VidFrameProcessorBase {
+  Map<String, dynamic> toJson() {
+    return <String, dynamic>{};
+  }
+}
+
+class VidFrameBrightnessProcessor extends VidFrameProcessorBase {
+  VidFrameBrightnessProcessor(this.brightness);
+  int brightness;
+
+  factory VidFrameBrightnessProcessor.fromJson(Map<String, dynamic> map) {
+    return VidFrameBrightnessProcessor(map['Brightness']);
+  }
+
+  Map<String, dynamic> toJson() {
+    final map = super.toJson();
+    map["Brightness"] = brightness;
+    return map;
+  }
+}
+
+class VidFrameContrastProcessor extends VidFrameProcessorBase {
+  VidFrameContrastProcessor(this.contrast);
+  int contrast;
+
+  factory VidFrameContrastProcessor.fromJson(Map<String, dynamic> map) {
+    return VidFrameContrastProcessor(map['Contrast']);
+  }
+
+  Map<String, dynamic> toJson() {
+    final map = super.toJson();
+    map["Contrast"] = contrast;
+    return map;
+  }
+}
+
+class GetVidFrameRequest {
+  /// 获取Vid帧请求
+  ///
+  /// [name] Vid缓存文件名
+  ///
+  /// [index] 帧索引
+  ///
+  /// [processors] 图像处理器集合
+  GetVidFrameRequest({
+    required this.index,
+    this.processors,
+  });
+
+  int index;
+  List<VidFrameProcessorBase>? processors;
+
+  Map<String, dynamic> toJson() {
+    final map = <String, dynamic>{};
+    map['Index'] = index;
+    if (processors != null) {
+      map['Processors'] = processors!.map((e) => e.toJson());
+    }
+    return map;
+  }
+}
+
+class GetVidFrameResult {
+  GetVidFrameResult({
+    this.isSuccess = false,
+    this.frameBase64,
+  });
+
+  String? frameBase64;
+  bool isSuccess;
+
+  factory GetVidFrameResult.fromJson(Map<String, dynamic> map) {
+    return GetVidFrameResult(
+      isSuccess: map['IsSuccess'],
+      frameBase64: map["FrameBase64"],
+    );
+  }
+}