xushiting 3 年之前
父节点
当前提交
f740b10f9f
共有 2 个文件被更改,包括 18 次插入6 次删除
  1. 2 1
      dist/index.html
  2. 16 5
      dist/libs/decoder.js

+ 2 - 1
dist/index.html

@@ -65,7 +65,7 @@
     <script src="./shader.js"></script>
     <!-- <script src="./webrtc//adapter-7.4.0.min.js"></script>
     <script src="./webrtc/srs.sdk.js"></script> -->
-
+    <script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script>
     <link rel="stylesheet" href="./css/index.3c280baa.css" />
 
     <div id="root">
@@ -89,6 +89,7 @@
     </div>
     
     <script>
+    var vConsole = new window.VConsole();
     function _mergeNamespaces(d, o) {
         return o.forEach(function(s) {
             s && typeof s != "string" && !Array.isArray(s) && Object.keys(s).forEach(function(c) {

+ 16 - 5
dist/libs/decoder.js

@@ -404,7 +404,17 @@ if ('function' === typeof importScripts) {
 
   Decoder.prototype.procBufItem = function (index) {
     this.dumpJitterBufInfo('Entering Decoder.prototype.procBufItem')
-    // console.log('[][Core][WASM], pts: %s, isIDR: %s, length: %s', mediaArray[index].pts, mediaArray[index].isIDR, mediaArray[index].media.length)
+    // if(mediaArray[index].media != null && mediaArray[index].media.byteLength != 0){
+    //   console.log('[][Core][WASM], pts: %s, isIDR: %s, length: %s,trace_id: %s,time: %s', mediaArray[index].pts, mediaArray[index].isIDR, mediaArray[index].media.length,mediaArray[index].metadata.traceIds,new Date().getTime())
+    // }
+    self.postMessage({
+      t: 11,
+      pts: mediaArray[index].pts,
+      isIDR: mediaArray[index].isIDR,
+      mediaLength: mediaArray[index].media.length,
+      traceIds:mediaArray[index].metadata.traceIds,
+      time:new Date().getTime()
+    });
     // var loginfo = 'pts: %s, isIDR: %s, length: %s', mediaArray[index].pts, mediaArray[index].isIDR, mediaArray[index].media.length
 
     needToSkip = this.skipFrameUntilI && !mediaArray[index].isIDR
@@ -486,7 +496,7 @@ if ('function' === typeof importScripts) {
     while (this.getNumOfPktToBeDec() > 0) {
       index = this.readPtr
       if (this.slotHasMedia(index)) {
-        // dropMedia until IDR // \u6765\u4E0D\u53CA\u89E3\u7801\u4E22\u5E27
+        // dropMedia until IDR // 来不及解码丢帧
         this.packetsDrop += 1
         if (untilIDR) {
           if (mediaArray[index].isIDR == true) {
@@ -637,14 +647,14 @@ if ('function' === typeof importScripts) {
         t: MessageEvent.UpdateStats,
         mediaBytesReceived: self.decoder.mediaBytesReceived,
         metaBytesReceived: self.decoder.metaBytesReceived,
-        packetsLost: self.decoder.packetsLost, // \u7F51\u7EDC\u4E22\u5E27
-        packetsDrop: self.decoder.packetsDrop, // \u6765\u4E0D\u53CA\u89E3\u7801\u4E22\u5E27
+        packetsLost: self.decoder.packetsLost, // 网络丢帧
+        packetsDrop: self.decoder.packetsDrop, // 来不及解码丢帧
         framesReceived: self.decoder.receivedMedia,
         framesDecoded: self.decoder.receivedYUV,
         framesRendered: self.decoder.receivedEmit,
         framesReturned: framesReturned,
         // framesAwait: leastReceivePts - lastProcessPts,
-        framesAwait: self.decoder.getNumOfPktToBeDec(), // \u7B49\u5F85\u89E3\u7801\u7684\u5E27
+        framesAwait: self.decoder.getNumOfPktToBeDec(), // 等待解码的帧
         decodeTimePerFrame: dtpf,
         decodeTimeMaxFrame: dtmf,
         sendOutBuffer: send_out_buffer,
@@ -1313,6 +1323,7 @@ if ('function' === typeof importScripts) {
   // console.log(getRandomInt(30));
 
   self.decoder = new Decoder()
+
   netArray = []
 
   var gTmpIdx = 0