From ae92b6823499cfab77201b4033922fa373fb37a3 Mon Sep 17 00:00:00 2001 From: ‘liusuyi’ <1951119284@qq.com> Date: 星期六, 21 十月 2023 14:03:50 +0800 Subject: [PATCH] 优化 --- ard-work/src/main/resources/templates/preview.html | 21 +++++++++++++-------- 1 files changed, 13 insertions(+), 8 deletions(-) diff --git a/ard-work/src/main/resources/templates/preview.html b/ard-work/src/main/resources/templates/preview.html index fd773b0..616b08e 100644 --- a/ard-work/src/main/resources/templates/preview.html +++ b/ard-work/src/main/resources/templates/preview.html @@ -101,13 +101,16 @@ <button class="toggle-button" onclick="changeGrid(7, 7)">7x7</button> <button class="toggle-button" onclick="changeGrid(8, 8)">8x8</button> <button class="toggle-button" onclick="changeGrid(9, 9)">9x9</button> - <input id="videoUrl" type="text" value="http://192.168.1.11:8889/164/" style="width: 250px"/> + <input id="videoUrl" type="text" value="" style="width: 250px"/> </div> </div> </div> <script> + console.log(RTCRtpReceiver.getCapabilities('video').codecs) + console.log(RTCRtpReceiver.getCapabilities('audio').codecs) //whep鎿嶄綔鏂规硶 + const restartPause = 2000; const linkToIceServers = (links) => ( (links !== null) ? links.split(', ').map((link) => { const m = link.match(/^<(.+?)>; rel="ice-server"(; username="(.*?)"; credential="(.*?)"; credential-type="password")?/i); @@ -174,9 +177,9 @@ } class WHEPClient { - constructor(wurl, videoId) { + constructor(whepUrl, videoId) { this.video = videoId; - this.url = new URL('whep', wurl); + this.wurl = new URL('whep', whepUrl); this.pc = null; this.restartTimeout = null; this.eTag = ''; @@ -186,7 +189,7 @@ start() { console.log("requesting ICE servers"); - fetch(this.url, { + fetch(this.wurl, { method: 'OPTIONS', }) .then((res) => this.onIceServers(res)) @@ -223,7 +226,7 @@ console.log("sending offer"); - fetch(this.url, { + fetch(this.wurl, { method: 'POST', headers: { 'Content-Type': 'application/sdp', @@ -234,7 +237,8 @@ if (res.status !== 201) { throw new Error('bad status code'); } - this.eTag = res.headers.get('E-Tag'); + // this.eTag = res.headers.get('ETag'); + this.eTag = res.headers.get("ETag") || res.headers.get('E-Tag'); return res.text(); }) .then((sdp) => this.onRemoteAnswer(new RTCSessionDescription({ @@ -288,12 +292,13 @@ } sendLocalCandidates(candidates) { - fetch(this.url, { + fetch(this.wurl, { method: 'PATCH', headers: { 'Content-Type': 'application/trickle-ice-sdpfrag', 'If-Match': this.eTag, }, + body: generateSdpFragment(this.offerData, candidates), }) .then((res) => { @@ -346,7 +351,7 @@ chanMap.set("video" + i, videoUrl); } console.log(chanMap); - changeGrid(2, 2); + //changeGrid(2, 2); } //缁戝畾鐐瑰嚮浜嬩欢 let playMap = new Map(); -- Gitblit v1.9.3