[*] 每日优化

This commit is contained in:
acgist
2023-07-07 08:30:09 +08:00
parent e4f2aa1a97
commit d415202d15
10 changed files with 274 additions and 82 deletions

View File

@@ -1,88 +1,147 @@
/**
* 配置:{ min: 8000, exact: 32000, ideal: 32000, max: 48000 }
*/
/**
* 音频默认配置
* TODOMediaStreamTrack.applyConstraints().then().catch();
* const setting = {
* autoGainControl: true,
* noiseSuppression: true
* }
await track.applyConstraints(Object.assign(track.getSettings(), setting));
* TODO播放音量audio标签配置、采集音量
* 支持属性navigator.mediaDevices.getSupportedConstraints()
*
* https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackSettings
*/
const defaultAudioConfig = {
// 设备
// deviceId : '',
// 指定设备
// deviceId : '',
// 标识会话
// groupId : '',
// 音量废弃0.0~1.0
// volume: 1.0,
// volume : 1.0,
// 延迟时间单位500毫秒以内较好
// latency: 0.4,
// 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 },
sampleRate : { min: 8000, ideal: 32000, max: 48000 },
// 声道数量1|2
channelCount: 1,
channelCount : 1,
// 是否开启自动增益true|false
autoGainControl: true,
autoGainControl : true,
// 是否开启降噪功能true|false
noiseSuppression: true,
// 是否开启回音消除true|false
echoCancellation: true,
// 消除回音方式system|browser
echoCancellationType: "system",
};
/**
* 视频默认配置
*
* https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackSettings
*/
const defaultVideoConfig = {
// 设备
// deviceId: '',
// 指定设备
// deviceId : '',
// 标识会话
// groupId : '',
// 宽度
width: { min: 720, ideal: 1280, max: 4096 },
width : { min: 720, ideal: 1280, max: 4096 },
// 高度
height: { min: 480, ideal: 720, max: 2160 },
height : { min: 480, ideal: 720, max: 2160 },
// 帧率
frameRate: { min: 15, ideal: 24, max: 45 },
// 摄像头user|left|right|environment
facingMode: "environment",
frameRate : { min: 15, ideal: 24, max: 45 },
// 摄像头user|left|right|environment
facingMode : "environment",
// 裁剪
// resizeMode : null,
// 宽高比
// aspectRatio: 1.7777777778,
};
/**
* VP9默认配置
* 共享屏幕默认配置
*
* https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackSettings
*/
const defaultKsvcEncodings = [{ scalabilityMode: "S3T3_KEY" }];
const defaultShareScreenConfig = {
// 显示鼠标always|motion|never
cursor : "always",
// 逻辑窗口捕获(没有完全显示)
logicalSurface: true,
// 视频来源window|monitor|browser|application
displaySurface: "monitor",
}
/**
* simulcast默认配置
* TODOupdate
* https://gitee.com/acgist/mediasoup-demo/commit/090c82920d1b8015d457e4fafbb06607cb232885
* https://gitee.com/acgist/mediasoup-demo/commit/e4f70da0c69226b997d174c477d82f8dbb997e91
* https://gitee.com/acgist/mediasoup-demo/commit/2c67601d0a231bf901242c8e14cdd0d1ba39f3a4
* https://gitee.com/acgist/mediasoup-demo/commit/b9f3f28d2eab314b95392fa698d518177d5ad767
* https://gitee.com/acgist/mediasoup-demo/commit/1c59132ca926a6f9ca0c5c2bb155fac58eed9b06
* https://gitee.com/acgist/mediasoup-demo/commit/d15a859306e1ba5d031cde90d02593e095719cbc
* https://gitee.com/acgist/mediasoup-demo/commit/13cf71cc608690ff96ec12e6d3f1262b40c4d8f3
* SVC默认配置
* 支持编码VP9
*
* https://w3c.github.io/webrtc-svc/
* https://mediasoup.org/documentation/v3/mediasoup/rtp-parameters-and-capabilities/
* https://mediasoup.org/documentation/v3/mediasoup/rtp-parameters-and-capabilities/#SVC
*/
const defaultSvcEncodings = [
{
dtx : true,
maxBitrate : 5000000,
scalabilityMode: 'L3T3_KEY'
}
];
/**
* Simulcast默认配置
* 支持编码VP8 H264
* 可以根据数量减少配置数量
* dtx屏幕贡献开启效果显著
*
* https://w3c.github.io/webrtc-svc/
* https://mediasoup.org/documentation/v3/mediasoup/rtp-parameters-and-capabilities/
* https://mediasoup.org/documentation/v3/mediasoup/rtp-parameters-and-capabilities/#Simulcast
*/
const defaultSimulcastEncodings = [
{ scaleResolutionDownBy: 4, maxBitrate: 500000, scalabilityMode: "S1T2" },
{ scaleResolutionDownBy: 2, maxBitrate: 1000000, scalabilityMode: "S1T2" },
{ scaleResolutionDownBy: 1, maxBitrate: 5000000, scalabilityMode: "S1T2" },
{
dtx : true,
maxBitrate : 5000000,
scalabilityMode : 'L1T3',
scaleResolutionDownBy: 1,
},
{
dtx : true,
maxBitrate : 1000000,
scalabilityMode : 'L1T3',
scaleResolutionDownBy: 2,
},
{
dtx : true,
maxBitrate : 500000,
scalabilityMode : 'L1T3',
scaleResolutionDownBy: 4,
},
];
/**
* RTCPeerConnection默认配置
*
* https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/RTCPeerConnection
*/
const defaultRTCPeerConnectionConfig = {
// ICE代理服务器
iceServers: [],
// ICE代理服务器
iceServers : [
{
// { "url": "stun:stun1.l.google.com:19302" },
urls: [
"stun:stun1.l.google.com:19302",
"stun:stun2.l.google.com:19302",
"stun:stun3.l.google.com:19302",
"stun:stun4.l.google.com:19302"
]
}
],
// 目标对等身份
// peerIdentity : null,
// 传输通道绑定策略balanced|max-compat|max-bundle
bundlePolicy: "balanced",
bundlePolicy : "balanced",
// RTCP多路复用策略require|negotiate
rtcpMuxPolicy: "require",
rtcpMuxPolicy : "require",
// 连接证书
// certificates : null,
// ICE传输策略all|relay
iceTransportPolicy: "all",
iceTransportPolicy : "all",
// ICE候选个数
iceCandidatePoolSize: 8,
};
@@ -90,7 +149,8 @@ const defaultRTCPeerConnectionConfig = {
export {
defaultAudioConfig,
defaultVideoConfig,
defaultKsvcEncodings,
defaultShareScreenConfig,
defaultSvcEncodings,
defaultSimulcastEncodings,
defaultRTCPeerConnectionConfig,
};