[mirotalksfu] - add webRtcServer

هذا الالتزام موجود في:
Miroslav Pejic
2024-03-09 22:16:07 +01:00
الأصل f54f350929
التزام 071149b568
6 ملفات معدلة مع 51 إضافات و9 حذوفات

عرض الملف

@@ -8,6 +8,8 @@ module.exports = class Room {
constructor(room_id, worker, io) {
this.id = room_id;
this.worker = worker;
this.webRtcServer = worker.appData.webRtcServer;
this.webRtcServerActive = config.mediasoup.webRtcServerActive;
this.io = io;
this.audioLevelObserver = null;
this.audioLevelObserverEnabled = true;
@@ -248,13 +250,18 @@ module.exports = class Room {
const { maxIncomingBitrate, initialAvailableOutgoingBitrate, listenInfos } = this.webRtcTransport;
const transport = await this.router.createWebRtcTransport({
const webRtcTransportOptions = {
listenInfos: listenInfos,
enableUdp: true,
enableTcp: true,
preferUdp: true,
iceConsentTimeout: 20,
initialAvailableOutgoingBitrate,
});
};
if (this.webRtcServerActive) webRtcTransportOptions.webRtcServer = this.webRtcServer;
const transport = await this.router.createWebRtcTransport(webRtcTransportOptions);
if (!transport) {
throw new Error('Failed to create WebRTC transport');

عرض الملف

@@ -41,7 +41,7 @@ dependencies: {
* @license For commercial or closed source, contact us at license.mirotalk@gmail.com or purchase directly via CodeCanyon
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
* @version 1.3.88
* @version 1.3.90
*
*/
@@ -762,6 +762,26 @@ function startServer() {
setTimeout(() => process.exit(1), 2000);
});
workers.push(worker);
if (config.mediasoup.webRtcServerActive) {
//
log.debug('Create a WebRtcServer', { worker_pid: worker.pid });
const webRtcServerOptions = clone(config.mediasoup.webRtcServerOptions);
const portIncrement = numWorkers.length - 1;
for (const listenInfo of webRtcServerOptions.listenInfos) {
listenInfo.port += portIncrement;
}
const webRtcServer = await worker.createWebRtcServer(webRtcServerOptions);
worker.appData.webRtcServer = webRtcServer;
}
/*
setInterval(async () => {
const usage = await worker.getResourceUsage();
log.info('mediasoup Worker resource usage', { worker_pid: worker.pid, usage: usage });
const dump = await worker.dump();
log.info('mediasoup Worker dump', { worker_pid: worker.pid, dump: dump });
}, 120000);
*/
}
}
@@ -1691,6 +1711,13 @@ function startServer() {
}
});
function clone(value) {
if (value === undefined) return undefined;
if (Number.isNaN(value)) return NaN;
if (typeof structuredClone === 'function') return structuredClone(value);
return JSON.parse(JSON.stringify(value));
}
async function isPeerPresenter(room_id, peer_id, peer_name, peer_uuid) {
try {
if (

عرض الملف

@@ -356,18 +356,26 @@ module.exports = {
},
],
},
// WebRtcTransport settings
// WebRtcServerOptions
webRtcServerActive: false,
webRtcServerOptions: {
listenInfos: [
{ protocol: 'udp', ip: '0.0.0.0', announcedAddress: getLocalIp(), port: 44444 },
{ protocol: 'tcp', ip: '0.0.0.0', announcedAddress: getLocalIp(), port: 44444 },
],
},
// WebRtcTransport
webRtcTransport: {
listenInfos: [
{ protocol: 'udp', ip: '0.0.0.0', announcedAddress: getLocalIp() },
{ protocol: 'tcp', ip: '0.0.0.0', announcedAddress: getLocalIp() },
//announcedAddress: replace by 'public static IPV4 address' https://api.ipify.org (type string --> 'xx.xxx.xxx.xx' not xx.xxx.xxx.xx)
//announcedAddress: '' will be auto-detected on server start, for docker localPC set '127.0.0.1' otherwise the 'public static IPV4 address'
],
initialAvailableOutgoingBitrate: 1000000,
minimumAvailableOutgoingBitrate: 600000,
maxSctpMessageSize: 262144,
maxIncomingBitrate: 1500000,
},
//announcedAddress: replace by 'public static IPV4 address' https://api.ipify.org (type string --> 'xx.xxx.xxx.xx' not xx.xxx.xxx.xx)
//announcedAddress: '' will be auto-detected on server start, for docker localPC set '127.0.0.1' otherwise the 'public static IPV4 address'
},
};

عرض الملف

@@ -1,6 +1,6 @@
{
"name": "mirotalksfu",
"version": "1.3.88",
"version": "1.3.90",
"description": "WebRTC SFU browser-based video calls",
"main": "Server.js",
"scripts": {

عرض الملف

@@ -11,7 +11,7 @@ if (location.href.substr(0, 5) !== 'https') location.href = 'https' + location.h
* @license For commercial or closed source, contact us at license.mirotalk@gmail.com or purchase directly via CodeCanyon
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
* @version 1.3.88
* @version 1.3.90
*
*/

عرض الملف

@@ -9,7 +9,7 @@
* @license For commercial or closed source, contact us at license.mirotalk@gmail.com or purchase directly via CodeCanyon
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
* @version 1.3.88
* @version 1.3.90
*
*/