[*] 日常优化

This commit is contained in:
acgist
2023-12-26 07:31:10 +08:00
parent 1909bbb33d
commit b71e312700
5 changed files with 46 additions and 11 deletions

View File

@@ -14,7 +14,8 @@ const config = {
// 终端类型 // 终端类型
clientType: "WEB", clientType: "WEB",
}, },
} };
/** /**
* 音频默认配置 * 音频默认配置
* 配置:{ min: 8000, exact: 32000, ideal: 32000, max: 48000 } * 配置:{ min: 8000, exact: 32000, ideal: 32000, max: 48000 }
@@ -31,7 +32,7 @@ const defaultAudioConfig = {
// 延迟时间单位500毫秒以内较好 // 延迟时间单位500毫秒以内较好
// latency : 0.4, // latency : 0.4,
// 采样位数8|16|32 // 采样位数8|16|32
sampleSize : { min: 8, ideal: 16, max: 32 }, sampleSize : { min: 8, ideal: 16, max: 32 },
// 采样率8000|16000|32000|48000 // 采样率8000|16000|32000|48000
sampleRate : { min: 8000, ideal: 32000, max: 48000 }, sampleRate : { min: 8000, ideal: 32000, max: 48000 },
// 声道数量1|2 // 声道数量1|2
@@ -60,7 +61,7 @@ const defaultVideoConfig = {
// 高度 // 高度
height : { min: 480, ideal: 720, max: 2160 }, 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 // 摄像头user|left|right|environment
facingMode : "environment", facingMode : "environment",
// 裁剪 // 裁剪
@@ -81,7 +82,7 @@ const defaultShareScreenConfig = {
logicalSurface: true, logicalSurface: true,
// 视频来源window|monitor|browser|application // 视频来源window|monitor|browser|application
displaySurface: "monitor", displaySurface: "monitor",
} };
/** /**
* SVC默认配置 * SVC默认配置

View File

@@ -60,10 +60,10 @@ export default {
return { return {
audio : null, audio : null,
video : null, video : null,
clientRecord : false,
serverRecord : false,
audioStream : null, audioStream : null,
videoStream : null, videoStream : null,
clientRecord : false,
serverRecord : false,
dataProducer : null, dataProducer : null,
audioProducer: null, audioProducer: null,
videoProducer: null, videoProducer: null,

View File

@@ -63,10 +63,10 @@ export default {
return { return {
audio : null, audio : null,
video : null, video : null,
clientRecord : false,
serverRecord : false,
audioStream : null, audioStream : null,
videoStream : null, videoStream : null,
clientRecord : false,
serverRecord : false,
dataConsumer : null, dataConsumer : null,
audioConsumer: null, audioConsumer: null,
videoConsumer: null, videoConsumer: null,

View File

@@ -64,10 +64,10 @@ export default {
return { return {
audio : null, audio : null,
video : null, video : null,
clientRecord: false,
serverRecord: false,
audioStream : null, audioStream : null,
videoStream : null, videoStream : null,
clientRecord: false,
serverRecord: false,
}; };
}, },
async mounted() { async mounted() {

View File

@@ -1000,6 +1000,17 @@ class Taoyao extends RemoteClient {
stream = this.fileVideo.captureStream(); stream = this.fileVideo.captureStream();
} else if (this.videoSource === "camera") { } else if (this.videoSource === "camera") {
console.debug("媒体配置", this.audioConfig, this.videoConfig); 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({ stream = await navigator.mediaDevices.getUserMedia({
audio: audioEnabled && this.audioConfig, audio: audioEnabled && this.audioConfig,
video: videoEnabled && this.videoConfig, video: videoEnabled && this.videoConfig,
@@ -1055,6 +1066,11 @@ class Taoyao extends RemoteClient {
* @returns 音频轨道 * @returns 音频轨道
*/ */
async getAudioTrack() { 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({ const stream = await navigator.mediaDevices.getUserMedia({
audio: this.audioConfig, audio: this.audioConfig,
video: false, video: false,
@@ -1077,6 +1093,13 @@ class Taoyao extends RemoteClient {
await this.getFileVideo(); await this.getFileVideo();
stream = this.fileVideo.captureStream(); stream = this.fileVideo.captureStream();
} else if (this.videoSource === "camera") { } 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({ stream = await navigator.mediaDevices.getUserMedia({
audio: false, audio: false,
video: this.videoConfig, video: this.videoConfig,
@@ -3126,7 +3149,11 @@ class Taoyao extends RemoteClient {
return response; return response;
} }
const routerRtpCapabilities = response.body.rtpCapabilities; 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 }); await this.mediasoupDevice.load({ routerRtpCapabilities });
response = await this.request(protocol.buildMessage("room::enter", { response = await this.request(protocol.buildMessage("room::enter", {
roomId : roomId, roomId : roomId,
@@ -3829,6 +3856,13 @@ class Taoyao extends RemoteClient {
return stats; return stats;
} }
/**
* @returns 是否是苹果微信
*/
isIPhoneMicro() {
return navigator.userAgent.match(/iPhone/i) && navigator.userAgent.match(/(MicroMessenger|micromessenger)/i);
}
/** /**
* 关闭媒体资源 * 关闭媒体资源
* *