瀏覽代碼

fix shell vid channel receive chunk bug

melon 2 年之前
父節點
當前提交
9fe7047f0e

+ 3 - 0
lib/async_vid/shell/reader.dart

@@ -47,6 +47,9 @@ class AsyncShellVidDataReader extends AsyncVidDataReaderBase {
         'MinChunkSize': minChunkSize,
       },
     );
+    if (result != null) {
+      initChunk(result!);
+    }
     return result;
   }
 }

+ 1 - 1
lib/async_vid/vid_data.dart

@@ -78,7 +78,7 @@ abstract class AsyncVidImageDataBase {
     if (!_initialized) {
       var header = await _readHeader();
       if (header != vid_header) {
-        // throw Exception("The input data is not a VID data.");
+        throw Exception("The input data is not a VID data.");
       }
       _version = await _readVersion();
       //Get probe info

+ 4 - 0
lib/data_channel/channel.dart

@@ -26,6 +26,10 @@ abstract class VidDataChannel {
     return VidDataChannelImpl(url);
   }
 
+  static void receiveChunk(String id, Uint8List chunk) {
+    VidDataChannelImpl.receiveChunk(id, chunk);
+  }
+
   /// 下载进度变更事件
   final downloadProgressChanged = FEventHandler<VidDownloadProgressInfo>();
 

+ 4 - 0
lib/data_channel/channel_io.dart

@@ -1,3 +1,5 @@
+import 'dart:typed_data';
+
 import 'package:fis_vid/async_vid/cached/vid_data.dart';
 import 'package:fis_vid/async_vid/http/vid_data.dart';
 import 'package:fis_vid/async_vid/vid_data.dart';
@@ -9,6 +11,8 @@ import 'channel.dart';
 class VidDataChannelImpl extends VidDataChannel {
   VidDataChannelImpl(String url) : super(url);
 
+  static void receiveChunk(String id, Uint8List chunk) {}
+
   @override
   Future<AsyncVidImageDataBase> buildSource() async {
     final cacheBuffer = await VidNativeCache.ins.getCache(url);

+ 4 - 0
lib/data_channel/channel_stub.dart

@@ -1,3 +1,5 @@
+import 'dart:typed_data';
+
 import 'package:fis_vid/async_vid/vid_data.dart';
 
 import 'channel.dart';
@@ -5,6 +7,8 @@ import 'channel.dart';
 class VidDataChannelImpl extends VidDataChannel {
   VidDataChannelImpl(String url) : super(url);
 
+  static void receiveChunk(String id, Uint8List chunk) {}
+
   @override
   Future<AsyncVidImageDataBase> buildSource() {
     // TODO: implement buildSource

+ 8 - 0
lib/data_channel/channel_web.dart

@@ -1,3 +1,5 @@
+import 'dart:typed_data';
+
 import 'package:fis_common/env/env.dart';
 import 'package:fis_vid/async_vid/http/vid_data.dart';
 import 'package:fis_vid/async_vid/shell/vid_data.dart';
@@ -8,6 +10,12 @@ import 'channel.dart';
 class VidDataChannelImpl extends VidDataChannel {
   VidDataChannelImpl(String url) : super(url);
 
+  static void receiveChunk(String id, Uint8List chunk) {
+    if (FPlatform.isPureWeb == false) {
+      AsyncShellVidImageData.receiveChunk(id, chunk);
+    }
+  }
+
   @override
   Future<AsyncVidImageDataBase> buildSource() async {
     if (FPlatform.isPureWeb) {