shuisheng 2 年 前
コミット
5e7903ed2a
2 ファイル変更12 行追加12 行削除
  1. 10 10
      src/network/webRtc.ts
  2. 2 2
      src/views/webrtc-push/index.vue

+ 10 - 10
src/network/webRtc.ts

@@ -539,16 +539,16 @@ export class WebRTCClass {
     }
     }
     if (!this.peerConnection) {
     if (!this.peerConnection) {
       this.peerConnection = new RTCPeerConnection({
       this.peerConnection = new RTCPeerConnection({
-        // iceServers: [
-        //   // {
-        //   //   urls: 'stun:stun.l.google.com:19302',
-        //   // },
-        //   {
-        //     urls: 'turn:hsslive.cn:3478',
-        //     username: 'hss',
-        //     credential: '123456',
-        //   },
-        // ],
+        iceServers: [
+          // {
+          //   urls: 'stun:stun.l.google.com:19302',
+          // },
+          {
+            urls: 'turn:hsslive.cn:3478',
+            username: 'hss',
+            credential: '123456',
+          },
+        ],
       });
       });
       // this.dataChannel =
       // this.dataChannel =
       //   this.peerConnection.createDataChannel('MessageChannel');
       //   this.peerConnection.createDataChannel('MessageChannel');

+ 2 - 2
src/views/webrtc-push/index.vue

@@ -248,14 +248,14 @@ function handleCoverImg() {
   const canvas = document.createElement('canvas');
   const canvas = document.createElement('canvas');
   const { width, height } = localVideoRef.value!.getBoundingClientRect();
   const { width, height } = localVideoRef.value!.getBoundingClientRect();
   const rate = width / height;
   const rate = width / height;
-  const coverWidth = width * 1;
+  const coverWidth = width * 0.5;
   const coverHeight = coverWidth / rate;
   const coverHeight = coverWidth / rate;
   canvas.width = coverWidth;
   canvas.width = coverWidth;
   canvas.height = coverHeight;
   canvas.height = coverHeight;
   canvas
   canvas
     .getContext('2d')!
     .getContext('2d')!
     .drawImage(localVideoRef.value!, 0, 0, coverWidth, coverHeight);
     .drawImage(localVideoRef.value!, 0, 0, coverWidth, coverHeight);
-  // webp比png的体积小非常多!因此coverWidth就可以不压缩大小了
+  // webp比png的体积小非常多!因此coverWidth就可以不用压缩太夸张
   const dataURL = canvas.toDataURL('image/webp');
   const dataURL = canvas.toDataURL('image/webp');
   return dataURL;
   return dataURL;
 }
 }