Procházet zdrojové kódy

feat:配置fps协议

leo před 1 rokem
rodič
revize
25a1ce9473

+ 2 - 0
static/webRtcYJ/WXtrialInterface.html

@@ -406,6 +406,7 @@
       });
     </script>
     <script>
+      // let vc = new VConsole()
       // 如果immediate为true,就是立即执行防抖,反之就是延迟防抖
       function debounce(fn, delay, immediate) {
         let timeout;
@@ -1407,6 +1408,7 @@
             if (input[23] == 0x5c) {
               if (CheckVerifyCode(input)) {
                 webSocketWorker.postMessage(ConfigChannel('RK3923C1201900139'));
+                webSocketWorker.postMessage(setFps())
                 var checkBuffer = GetScreenState();
                 webSocketWorker.postMessage(checkBuffer);
               } else {

+ 9 - 0
static/webRtcYJ/helper.js

@@ -272,3 +272,12 @@ function RequestIFrame() {
   var outPut = new Uint8Array([0x20]);
   return makeFrameExtend(sn, 6, outPut);
 }
+
+// 设置fps
+function setFps(frameRate) {
+  let sn = 'RK3923C1201900139';
+  let jsonObj = { type: 5, data: { frame_rate: 20 } };
+  let jsonStr = JSON.stringify(jsonObj);
+  let outPut = new TextEncoder('utf-8').encode(jsonStr);
+  return makeFrameExtend(sn, 0x0D, outPut);
+}

+ 13 - 4
static/webRtcYJ/rtcEngine.min.js

@@ -3,7 +3,8 @@
 	typeof define === 'function' && define.amd ? define(factory) :
 	(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.RtcEngine = factory());
 })(this, (function () { 'use strict';
-
+	let ws = null, heartBeatFlag = null;
+	
 	//此文件实现将控制命令封装成协议,具体协议内容请看:
 	//链接:http://note.youdao.com/noteshare?id=dabda6c613adef7a416bd2625cd770a1
 
@@ -146,10 +147,10 @@
 
 	 function setFps(frameRate) {
 		let sn = "RK3923C1201900139";
-		let jsonObj = { "type": 1, "data": { "frame_rate": frameRate } };
+		let jsonObj = { "type": 5, "data": { "frame_rate": frameRate } };
 	    let jsonStr = JSON.stringify(jsonObj);
 		let outPut = new TextEncoder("utf-8").encode(jsonStr);
-		return makeFrameExtend(sn, 0xD, outPut);
+		return makeFrameExtend(sn, 0x0D, outPut);
 	 }
 
 	const Authen_ID	  	    = 0x5C;//鉴权标识
@@ -498,6 +499,7 @@
 			let verifyBuffer = VerifyCode(sn, this.token);
 			this.ws.send(verifyBuffer);
 			this.heartBeatFlag = setInterval(this.heartBeat, 2000);
+			heartBeatFlag  = this.heartBeatFlag
 		}
 
 		wsOnClose(event) {
@@ -8524,6 +8526,9 @@
 						}).catch(e => {
 							error(this.TAG, e);
 						});
+					}).catch(err => {
+						clearInterval(heartBeatFlag)
+						ws.close()
 					});
 				});
 			}).catch(e => {
@@ -8559,7 +8564,7 @@
 			});
 			// console.log("=======ip---------", window.cloudgame_sdk.extraData.remainingTimeData.data.extranetIp, window.cloudgame_sdk.extraData.remainingTimeData.data.extranetPort);
 			let aaa =
-				`a=candidate:udpcandidate 1 udp 120 ${extranetIp} ${extranetPort} typ host`;
+				`a=candidate:udpcandidate 1 udp 120 typ host`;
 
       var data = '';
 			// const deviceInline = CLOUD_GAME_SDK.getQueryVariable("deviceInline")
@@ -8839,6 +8844,7 @@
 	        this.startPlay      = this.startPlay.bind(this);
 
 	        this.ws             = new WebSocket(this.url);
+			ws                  = this.ws
 			this.ws.binaryType  = 'arraybuffer';
 			this.ws.onmessage   = this.wsOnMessage;
 			this.ws.onopen      = this.wsOpen;
@@ -8965,7 +8971,10 @@
 			let sn = "RK3923C1201900139";
 			let verifyBuffer = VerifyCode(sn, this.token);
 			this.ws.send(verifyBuffer);
+			let fps = setFps(20)
+			this.ws.send(fps)
 			this.heartBeatFlag = setInterval(this.heartBeat, 2000);
+			heartBeatFlag  = this.heartBeatFlag
 		}
 
 		wsOnClose(event) {