From b71e312700b468c3a74ddda4ecd7ccdaeb91418a Mon Sep 17 00:00:00 2001 From: acgist <289547414@qq.com> Date: Tue, 26 Dec 2023 07:31:10 +0800 Subject: [PATCH] =?UTF-8?q?[*]=20=E6=97=A5=E5=B8=B8=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- taoyao-client-web/src/components/Config.js | 9 ++--- .../src/components/LocalClient.vue | 4 +-- .../src/components/RemoteClient.vue | 4 +-- .../src/components/SessionClient.vue | 4 +-- taoyao-client-web/src/components/Taoyao.js | 36 ++++++++++++++++++- 5 files changed, 46 insertions(+), 11 deletions(-) diff --git a/taoyao-client-web/src/components/Config.js b/taoyao-client-web/src/components/Config.js index 3842c98..81720c6 100644 --- a/taoyao-client-web/src/components/Config.js +++ b/taoyao-client-web/src/components/Config.js @@ -14,7 +14,8 @@ const config = { // 终端类型 clientType: "WEB", }, -} +}; + /** * 音频默认配置 * 配置:{ min: 8000, exact: 32000, ideal: 32000, max: 48000 } @@ -31,7 +32,7 @@ const defaultAudioConfig = { // 延迟时间(单位:秒):500毫秒以内较好 // latency : 0.4, // 采样位数:8|16|32 - sampleSize : { min: 8, ideal: 16, max: 32 }, + sampleSize : { min: 8, ideal: 16, max: 32 }, // 采样率:8000|16000|32000|48000 sampleRate : { min: 8000, ideal: 32000, max: 48000 }, // 声道数量:1|2 @@ -60,7 +61,7 @@ const defaultVideoConfig = { // 高度 height : { min: 480, ideal: 720, max: 2160 }, // 帧率 - frameRate : { min: 15, ideal: 24, max: 45 }, + frameRate : { min: 15, ideal: 24, max: 45 }, // 摄像头:user|left|right|environment facingMode : "environment", // 裁剪 @@ -81,7 +82,7 @@ const defaultShareScreenConfig = { logicalSurface: true, // 视频来源:window|monitor|browser|application displaySurface: "monitor", -} +}; /** * SVC默认配置 diff --git a/taoyao-client-web/src/components/LocalClient.vue b/taoyao-client-web/src/components/LocalClient.vue index 50ebefe..5258db8 100644 --- a/taoyao-client-web/src/components/LocalClient.vue +++ b/taoyao-client-web/src/components/LocalClient.vue @@ -60,10 +60,10 @@ export default { return { audio : null, video : null, - clientRecord : false, - serverRecord : false, audioStream : null, videoStream : null, + clientRecord : false, + serverRecord : false, dataProducer : null, audioProducer: null, videoProducer: null, diff --git a/taoyao-client-web/src/components/RemoteClient.vue b/taoyao-client-web/src/components/RemoteClient.vue index 9857115..80dcb1f 100644 --- a/taoyao-client-web/src/components/RemoteClient.vue +++ b/taoyao-client-web/src/components/RemoteClient.vue @@ -63,10 +63,10 @@ export default { return { audio : null, video : null, - clientRecord : false, - serverRecord : false, audioStream : null, videoStream : null, + clientRecord : false, + serverRecord : false, dataConsumer : null, audioConsumer: null, videoConsumer: null, diff --git a/taoyao-client-web/src/components/SessionClient.vue b/taoyao-client-web/src/components/SessionClient.vue index 21d9291..b0c958d 100644 --- a/taoyao-client-web/src/components/SessionClient.vue +++ b/taoyao-client-web/src/components/SessionClient.vue @@ -64,10 +64,10 @@ export default { return { audio : null, video : null, - clientRecord: false, - serverRecord: false, audioStream : null, videoStream : null, + clientRecord: false, + serverRecord: false, }; }, async mounted() { diff --git a/taoyao-client-web/src/components/Taoyao.js b/taoyao-client-web/src/components/Taoyao.js index e8c5b89..de963bb 100644 --- a/taoyao-client-web/src/components/Taoyao.js +++ b/taoyao-client-web/src/components/Taoyao.js @@ -1000,6 +1000,17 @@ class Taoyao extends RemoteClient { stream = this.fileVideo.captureStream(); } else if (this.videoSource === "camera") { console.debug("媒体配置", this.audioConfig, this.videoConfig); + // 删除min/max + // delete this.audioConfig.sampleSize.min; + // delete this.audioConfig.sampleSize.max; + // delete this.audioConfig.sampleRate.min; + // delete this.audioConfig.sampleRate.max; + // delete this.videoConfig.width.min; + // delete this.videoConfig.width.max; + // delete this.videoConfig.height.min; + // delete this.videoConfig.height.max; + // delete this.videoConfig.frameRate.min; + // delete this.videoConfig.frameRate.max; stream = await navigator.mediaDevices.getUserMedia({ audio: audioEnabled && this.audioConfig, video: videoEnabled && this.videoConfig, @@ -1055,6 +1066,11 @@ class Taoyao extends RemoteClient { * @returns 音频轨道 */ async getAudioTrack() { + // 删除min/max + // delete this.audioConfig.sampleSize.min; + // delete this.audioConfig.sampleSize.max; + // delete this.audioConfig.sampleRate.min; + // delete this.audioConfig.sampleRate.max; const stream = await navigator.mediaDevices.getUserMedia({ audio: this.audioConfig, video: false, @@ -1077,6 +1093,13 @@ class Taoyao extends RemoteClient { await this.getFileVideo(); stream = this.fileVideo.captureStream(); } else if (this.videoSource === "camera") { + // 删除min/max + // delete this.videoConfig.width.min; + // delete this.videoConfig.width.max; + // delete this.videoConfig.height.min; + // delete this.videoConfig.height.max; + // delete this.videoConfig.frameRate.min; + // delete this.videoConfig.frameRate.max; stream = await navigator.mediaDevices.getUserMedia({ audio: false, video: this.videoConfig, @@ -3126,7 +3149,11 @@ class Taoyao extends RemoteClient { return response; } const routerRtpCapabilities = response.body.rtpCapabilities; - this.mediasoupDevice = new mediasoupClient.Device(); + if (this.isIPhoneMicro()) { + this.mediasoupDevice = new mediasoupClient.Device({ handlerName: "Safari12" }); + } else { + this.mediasoupDevice = new mediasoupClient.Device(); + } await this.mediasoupDevice.load({ routerRtpCapabilities }); response = await this.request(protocol.buildMessage("room::enter", { roomId : roomId, @@ -3829,6 +3856,13 @@ class Taoyao extends RemoteClient { return stats; } + /** + * @returns 是否是苹果微信 + */ + isIPhoneMicro() { + return navigator.userAgent.match(/iPhone/i) && navigator.userAgent.match(/(MicroMessenger|micromessenger)/i); + } + /** * 关闭媒体资源 *