From e5c8f327e3735a252610eb167d08ae3773b65184 Mon Sep 17 00:00:00 2001 From: zhangnaisong <2434969829@qq.com> Date: 星期六, 20 一月 2024 15:20:46 +0800 Subject: [PATCH] 查询本部门在线PC端通过websocket判断提交 --- ard-work/src/main/resources/templates/preview.html | 20 ++++++++++++++------ 1 files changed, 14 insertions(+), 6 deletions(-) diff --git a/ard-work/src/main/resources/templates/preview.html b/ard-work/src/main/resources/templates/preview.html index a115bf1..273683e 100644 --- a/ard-work/src/main/resources/templates/preview.html +++ b/ard-work/src/main/resources/templates/preview.html @@ -107,7 +107,13 @@ </div> <script> + console.log(RTCRtpReceiver.getCapabilities('video').codecs) + console.log(RTCRtpReceiver.getCapabilities('audio').codecs) //whep鎿嶄綔鏂规硶 + const restartPause = 2000; + const unquoteCredential = (v) => ( + JSON.parse(`"${v}"`) + ); const linkToIceServers = (links) => ( (links !== null) ? links.split(', ').map((link) => { const m = link.match(/^<(.+?)>; rel="ice-server"(; username="(.*?)"; credential="(.*?)"; credential-type="password")?/i); @@ -174,9 +180,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 +192,7 @@ start() { console.log("requesting ICE servers"); - fetch(this.url, { + fetch(this.wurl, { method: 'OPTIONS', }) .then((res) => this.onIceServers(res)) @@ -223,7 +229,7 @@ console.log("sending offer"); - fetch(this.url, { + fetch(this.wurl, { method: 'POST', headers: { 'Content-Type': 'application/sdp', @@ -234,7 +240,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 +295,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) => { -- Gitblit v1.9.3