[+] 证书终端请求ID
This commit is contained in:
@@ -31,7 +31,7 @@ make -C worker
|
||||
```
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| HTTPS / WSS | | SCTP | SRTP / SRTCP |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ICE / SDP / SIP +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ICE / SDP +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| TLS | | |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ DTLS +-+-+-+-+-+-+-+-+-+
|
||||
| HTTP / WS | NAT / STUN / TURN | | RTP / RTCP |
|
||||
@@ -44,18 +44,15 @@ make -C worker
|
||||
|
||||
### 协议简介
|
||||
|
||||
* 会话通道:ICE/SIP/SDP
|
||||
* 会话通道:ICE/SDP
|
||||
* 媒体通道:RTP/RTCP/SRTP/SRTCP
|
||||
* RTP:实时传输协议(音频视频)
|
||||
* RTCP:RTP传输控制协议(监控数据传输质量并给予数据发送方反馈)
|
||||
* SCTP:流控制传输协议(自定义的应用数据传输)
|
||||
* RTMP:实时消息传送协议
|
||||
* RTSP:可以控制媒体(点播)
|
||||
|
||||
### ICE/SDP/SIP
|
||||
|
||||
ICE信息的描述格式通常采用标准的SDP,其全称为Session Description Protocol,即会话描述协议。<br />
|
||||
SDP只是一种信息格式的描述标准,不属于传输协议,但是可以被其他传输协议用来交换必要的信息,例如:SIP、RTSP等等。
|
||||
* SDP:会话描述协议(只是信息格式描述标准不是传输协议)
|
||||
* ICE:交互式连接建立(使用标准SDP描述)
|
||||
* RTP:实时传输协议
|
||||
* RTCP:RTP控制协议(监控数据传输质量提供反馈)
|
||||
* SCTP:流控制传输协议
|
||||
* RTSP:实时流传输协议(依赖RTP协议实时性好适合视频聊天视频监控)
|
||||
* RTMP:实时消息传输协议
|
||||
|
||||
## 其他常见WebRTC媒体服务
|
||||
|
||||
|
||||
@@ -117,20 +117,20 @@ module.exports = {
|
||||
// WebRtcServer:https://mediasoup.org/documentation/v3/mediasoup/api/#WebRtcServerOptions
|
||||
webRtcServerOptions: {
|
||||
listenInfos: [
|
||||
// UDP
|
||||
{
|
||||
protocol: "udp",
|
||||
ip: process.env.MEDIASOUP_LISTEN_IP || "0.0.0.0",
|
||||
port: 44444,
|
||||
// 公网地址
|
||||
announcedIp: process.env.MEDIASOUP_ANNOUNCED_IP || "192.168.1.110",
|
||||
},
|
||||
{
|
||||
protocol: "tcp",
|
||||
ip: process.env.MEDIASOUP_LISTEN_IP || "0.0.0.0",
|
||||
port: 44444,
|
||||
// 公网地址
|
||||
announcedIp: process.env.MEDIASOUP_ANNOUNCED_IP || "192.168.1.110",
|
||||
},
|
||||
// TCP
|
||||
// {
|
||||
// protocol: "tcp",
|
||||
// ip: process.env.MEDIASOUP_LISTEN_IP || "0.0.0.0",
|
||||
// port: 44444,
|
||||
// announcedIp: process.env.MEDIASOUP_ANNOUNCED_IP || "192.168.1.110",
|
||||
// },
|
||||
],
|
||||
},
|
||||
// WebRtcTransport:https://mediasoup.org/documentation/v3/mediasoup/api/#WebRtcTransportOptions
|
||||
@@ -138,7 +138,6 @@ module.exports = {
|
||||
listenIps: [
|
||||
{
|
||||
ip: process.env.MEDIASOUP_LISTEN_IP || "0.0.0.0",
|
||||
// 公网地址
|
||||
announcedIp: process.env.MEDIASOUP_ANNOUNCED_IP || "192.168.1.110",
|
||||
},
|
||||
],
|
||||
@@ -151,7 +150,6 @@ module.exports = {
|
||||
plainTransportOptions: {
|
||||
listenIp: {
|
||||
ip: process.env.MEDIASOUP_LISTEN_IP || "0.0.0.0",
|
||||
// 公网地址
|
||||
announcedIp: process.env.MEDIASOUP_ANNOUNCED_IP || "192.168.1.110",
|
||||
},
|
||||
maxSctpMessageSize: 262144,
|
||||
|
||||
@@ -44,7 +44,7 @@ async function buildMediasoupWorkers() {
|
||||
JSON.stringify(config.mediasoup.webRtcServerOptions)
|
||||
);
|
||||
for (const listenInfo of webRtcServerOptions.listenInfos) {
|
||||
listenInfo.port = listenInfo.port + mediasoupWorkers.length - 1;
|
||||
listenInfo.port = listenInfo.port + mediasoupWorkers.length;
|
||||
}
|
||||
const webRtcServer = await worker.createWebRtcServer(webRtcServerOptions);
|
||||
worker.appData.webRtcServer = webRtcServer;
|
||||
|
||||
@@ -9,15 +9,23 @@ const protocol = {
|
||||
// 当前索引
|
||||
index: 0,
|
||||
// 最大索引
|
||||
maxIndex: 1000,
|
||||
maxIndex: 999,
|
||||
// 终端索引
|
||||
clientIndex: 99999,
|
||||
/**
|
||||
* @returns 索引
|
||||
*/
|
||||
buildId() {
|
||||
if (++this.index >= this.maxIndex) {
|
||||
if (++this.index > this.maxIndex) {
|
||||
this.index = 0;
|
||||
}
|
||||
return Date.now() * 1000 + this.index;
|
||||
const date = new Date();
|
||||
return 100000000000000 * date.getDate() +
|
||||
1000000000000 * date.getHours() +
|
||||
10000000000 * date.getMinutes() +
|
||||
100000000 * date.getSeconds() +
|
||||
1000 * this.clientIndex +
|
||||
this.index;
|
||||
},
|
||||
/**
|
||||
* 生成信令消息
|
||||
@@ -188,15 +196,15 @@ const signalChannel = {
|
||||
);
|
||||
},
|
||||
/**
|
||||
* 推送消息
|
||||
* 异步请求
|
||||
*
|
||||
* @param {*} message 消息
|
||||
*/
|
||||
push(message) {
|
||||
push(message) {
|
||||
try {
|
||||
this.channel.send(JSON.stringify(message));
|
||||
} catch (error) {
|
||||
console.error("推送消息异常:", message, error);
|
||||
console.error("异步请求异常:", message, error);
|
||||
}
|
||||
},
|
||||
/**
|
||||
@@ -375,6 +383,9 @@ class Signal {
|
||||
case "client::shutdown":
|
||||
this.clientShutdown(message, body);
|
||||
break;
|
||||
case "client::register":
|
||||
protocol.clientIndex = body.index;
|
||||
break;
|
||||
case "media::ice::restart":
|
||||
this.mediaIceRestart(message, body);
|
||||
break;
|
||||
@@ -400,15 +411,19 @@ class Signal {
|
||||
}
|
||||
|
||||
/**
|
||||
* 通知信令
|
||||
* 异步请求
|
||||
*
|
||||
* @param {*} message 消息
|
||||
*/
|
||||
push(message) {
|
||||
signalChannel.push(message);
|
||||
try {
|
||||
signalChannel.channel.send(JSON.stringify(message));
|
||||
} catch (error) {
|
||||
console.error("异步请求异常:", message, error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* 同步请求
|
||||
*
|
||||
* @param {*} message 消息
|
||||
@@ -416,24 +431,24 @@ class Signal {
|
||||
* @returns Promise
|
||||
*/
|
||||
async request(message) {
|
||||
const self = this;
|
||||
const me = this;
|
||||
return new Promise((resolve, reject) => {
|
||||
let done = false;
|
||||
// 注册回调
|
||||
self.callbackMapping.set(message.header.id, (response) => {
|
||||
me.callbackMapping.set(message.header.id, (response) => {
|
||||
resolve(response);
|
||||
done = true;
|
||||
});
|
||||
// 发送消息
|
||||
try {
|
||||
self.channel.send(JSON.stringify(message));
|
||||
signalChannel.channel.send(JSON.stringify(message));
|
||||
} catch (error) {
|
||||
console.error("请求消息异常:", message, error);
|
||||
reject("同步请求异常", error);
|
||||
}
|
||||
// 设置超时
|
||||
setTimeout(() => {
|
||||
if (!done) {
|
||||
self.callbackMapping.delete(message.header.id);
|
||||
me.callbackMapping.delete(message.header.id);
|
||||
reject("请求超时", message);
|
||||
}
|
||||
}, 5000);
|
||||
|
||||
Reference in New Issue
Block a user