Browse Source

录制方法

gemercheung 3 years ago
parent
commit
82f02ccb4c
2 changed files with 25 additions and 17 deletions
  1. 16 12
      src/Workers.js
  2. 9 5
      src/v2Decoder/index.js

+ 16 - 12
src/Workers.js

@@ -693,6 +693,17 @@ export default class Workers {
     });
     });
     this.decoderWorker = new Worker(URL.createObjectURL(i));
     this.decoderWorker = new Worker(URL.createObjectURL(i));
 
 
+    window.startRecord = ()=>{
+      this.decoderWorker.postMessage({
+        t:6
+      })
+    }
+
+    window.stopRecord = ()=>{
+      this.decoderWorker.postMessage({
+        t:7
+      })
+    } 
     // this.enable_decoder_queue_logging();
     // this.enable_decoder_queue_logging();
 
 
     this.decoderWorker.postMessage({
     this.decoderWorker.postMessage({
@@ -721,18 +732,11 @@ export default class Workers {
             this.SendCacheFrameInfo(s);
             this.SendCacheFrameInfo(s);
             break;
             break;
           case 4: {
           case 4: {
-            const c = new Date().toISOString(),
-              d =
-                USER_ID +
-                "-" +
-                PAGE_SESSION +
-                "-" +
-                SERVER_SESSION +
-                "-" +
-                c +
-                ".264";
-            console.log(" s.data.fileObj", s.data.fileObj);
-            // uploadStream(COS_PREFIX + d, s.data.fileObj);
+            this.downloadBlob(
+              s.data.data,
+              "test.264",
+              "application/octet-stream"
+            );
             break;
             break;
           }
           }
           case 5:
           case 5:

+ 9 - 5
src/v2Decoder/index.js

@@ -946,11 +946,15 @@ if ("function" === typeof importScripts) {
     }
     }
 
 
     if (this.saveRecord) {
     if (this.saveRecord) {
-      downloadBlob(
-        this.mediaCacheBuffer.subarray(0, this.mediaCacheSize),
-        "test.264",
-        "application/octet-stream"
-      );
+      // downloadBlob(
+      //   this.mediaCacheBuffer.subarray(0, this.mediaCacheSize),
+      //   "test.264",
+      //   "application/octet-stream"
+      // );
+      self.postMessage({
+        t: MessageEvent.RecordVideo,
+        data:this.mediaCacheBuffer.subarray(0, this.mediaCacheSize),
+      });
       this.mediaCacheSize = 0;
       this.mediaCacheSize = 0;
       this.saveRecord = false;
       this.saveRecord = false;
       this.startRecord = false;
       this.startRecord = false;