Compare commits

..

30 Commits

Author SHA1 Message Date
abfa1f628e test 2023-01-13 20:04:43 +02:00
a56c7c9b95 test 2023-01-13 20:04:22 +02:00
6efa8005b0 test 2023-01-13 20:03:53 +02:00
af85026bd2 test 2023-01-13 19:59:12 +02:00
91b21f862c test 2023-01-13 19:53:14 +02:00
26b54d0a63 test 2023-01-13 19:50:24 +02:00
6a570879e1 test 2023-01-13 19:49:21 +02:00
57f994f95b test 2023-01-13 19:47:15 +02:00
a647ea9a82 test 2023-01-13 19:46:17 +02:00
33e4122e11 test 2023-01-13 19:40:50 +02:00
1f3fbba5c0 test 2023-01-13 19:37:27 +02:00
c7049ef909 test 2023-01-13 19:36:04 +02:00
b287e7d0e7 test 2023-01-13 19:33:24 +02:00
bd02ad1c95 test 2023-01-13 19:29:49 +02:00
4574b9daf0 test 2023-01-13 19:27:44 +02:00
5ef8b4f15c test 2023-01-13 19:21:37 +02:00
059cbce4c4 test 2023-01-13 19:20:03 +02:00
a75476a1b1 test 2023-01-13 19:16:06 +02:00
7b75c64c42 test 2023-01-13 19:14:53 +02:00
ffb4bd59ea test 2023-01-13 19:13:29 +02:00
eb68830e3e test 2023-01-13 19:11:56 +02:00
18aa9c93ed test 2023-01-13 19:10:04 +02:00
3c5719c3c8 test 2023-01-13 19:09:20 +02:00
5b9768b5de test 2023-01-13 19:07:27 +02:00
57108bf41e test 2023-01-13 19:04:09 +02:00
2a43cd2603 test 2023-01-13 19:01:54 +02:00
256687f284 test 2023-01-13 18:59:25 +02:00
020be2f7b9 test 2023-01-13 18:54:20 +02:00
ed7feaecd5 test 2023-01-13 18:51:47 +02:00
b1dbc401a5 test 2023-01-13 18:48:57 +02:00
3 changed files with 18 additions and 73 deletions

77
app.js
View File

@ -192,7 +192,6 @@ peers.on('connection', async socket => {
if (callId) { if (callId) {
console.log(`[createRoom] socket.id ${socket.id} callId ${callId}`); console.log(`[createRoom] socket.id ${socket.id} callId ${callId}`);
if (!videoCalls[callId]) { if (!videoCalls[callId]) {
console.log('[createRoom] callId', callId);
videoCalls[callId] = { router: await worker.createRouter({ mediaCodecs }) }; videoCalls[callId] = { router: await worker.createRouter({ mediaCodecs }) };
console.log(`[createRoom] Router ID: ${videoCalls[callId].router.id}`); console.log(`[createRoom] Router ID: ${videoCalls[callId].router.id}`);
videoCalls[callId].receiverSocket = socket; videoCalls[callId].receiverSocket = socket;
@ -259,11 +258,19 @@ peers.on('connection', async socket => {
if (typeof dtlsParameters === 'string') dtlsParameters = JSON.parse(dtlsParameters); if (typeof dtlsParameters === 'string') dtlsParameters = JSON.parse(dtlsParameters);
console.log(`[transport-connect] socket ${socket.id} | callId ${callId}`); console.log(`[transport-connect] socket ${socket.id} | callId ${callId}`);
if (!isInitiator(callId, socket.id)) { if (!isInitiator(callId, socket.id)) {
await videoCalls[callId].receiverProducerTransport.connect({ dtlsParameters }); await videoCalls[callId].receiverProducerTransport.connect({ dtlsParameters });
videoCalls[callId].initiatorSocket.emit('new-producer', {
callId
});
} else { } else {
await videoCalls[callId].initiatorProducerTransport.connect({ dtlsParameters }); await videoCalls[callId].initiatorProducerTransport.connect({ dtlsParameters });
videoCalls[callId].receiverSocket.emit('new-producer', {
callId
});
} }
} catch (error) { } catch (error) {
console.log(`ERROR | transport-connect | callId ${socketDetails[socket.id]} | ${error.message}`); console.log(`ERROR | transport-connect | callId ${socketDetails[socket.id]} | ${error.message}`);
} }
@ -280,71 +287,6 @@ peers.on('connection', async socket => {
if (typeof rtpParameters === 'string') rtpParameters = JSON.parse(rtpParameters); if (typeof rtpParameters === 'string') rtpParameters = JSON.parse(rtpParameters);
console.log(`[transport-produce] kind: ${kind} | socket: ${socket.id} | callId: ${callId}`); console.log(`[transport-produce] kind: ${kind} | socket: ${socket.id} | callId: ${callId}`);
// const router = videoCalls[callId].router;
// router.observer.on("newtransport", (transport) => {
// transport.observer.on("newproducer", (producer) => {
// console.log(
// "new producer created [worker.pid:%d, router.id:%s, transport.id:%s, producer.id:%s]",
// worker.pid, router.id, transport.id, producer.id
// );
// if (!isInitiator(callId, socket.id)) {
// console.log('🟥 Emit to initiatorSocket');
// initiatorSocket.emit('new-producer', {
// callId
// });
// } else {
// console.log('🟥 Emit to receiverSocket');
// receiverSocket.emit('new-producer', {
// callId
// });
// }
// });
// });
if (kind === 'video') { if (kind === 'video') {
if (!isInitiator(callId, socket.id)) { if (!isInitiator(callId, socket.id)) {
@ -644,7 +586,7 @@ const consumeAudio = async (callId, socketId, rtpCapabilities) => {
} }
const isInitiator = (callId, socketId) => { const isInitiator = (callId, socketId) => {
return (videoCalls[callId].initiatorSocket.id === socketId); return (videoCalls[callId]?.initiatorSocket?.id === socketId);
} }
/* /*
@ -672,7 +614,6 @@ const createWebRtcTransportLayer = async (callId, callback) => {
// https://mediasoup.org/documentation/v3/mediasoup/api/#router-createWebRtcTransport // https://mediasoup.org/documentation/v3/mediasoup/api/#router-createWebRtcTransport
let transport = await videoCalls[callId].router.createWebRtcTransport(webRtcTransport_options) let transport = await videoCalls[callId].router.createWebRtcTransport(webRtcTransport_options)
console.log(`callId: ${callId} | transport id: ${transport.id}`)
// Handler for when DTLS(Datagram Transport Layer Security) changes // Handler for when DTLS(Datagram Transport Layer Security) changes
transport.on('dtlsstatechange', dtlsState => { transport.on('dtlsstatechange', dtlsState => {

View File

@ -20449,10 +20449,14 @@ setTimeout(() => {
console.log(`[MEDIA] ${config.mediasoupAddress} | connected: ${socket.connected} | existsProducer: ${existsProducer}`) console.log(`[MEDIA] ${config.mediasoupAddress} | connected: ${socket.connected} | existsProducer: ${existsProducer}`)
if (!IS_PRODUCER && existsProducer && consumer === undefined) { if (!IS_PRODUCER && existsProducer && consumer === undefined) {
goConnect() goConnect()
// document.getElementById('btnRecvSendTransport').click();
} }
if (IS_PRODUCER && urlParams.get('testing') === 'true') { getLocalStream() } if (IS_PRODUCER && urlParams.get('testing') === 'true') { getLocalStream() }
}) })
socket.on('new-producer', ({ callId }) => {
console.log(`🟢 new-producer | callId: ${callId} | Ready to consume`);
consume()
})
} }
if (IS_PRODUCER === true) { if (IS_PRODUCER === true) {

View File

@ -91,14 +91,14 @@ setTimeout(() => {
console.log(`[MEDIA] ${config.mediasoupAddress} | connected: ${socket.connected} | existsProducer: ${existsProducer}`) console.log(`[MEDIA] ${config.mediasoupAddress} | connected: ${socket.connected} | existsProducer: ${existsProducer}`)
if (!IS_PRODUCER && existsProducer && consumer === undefined) { if (!IS_PRODUCER && existsProducer && consumer === undefined) {
goConnect() goConnect()
// document.getElementById('btnRecvSendTransport').click();
} }
if (IS_PRODUCER && urlParams.get('testing') === 'true') { getLocalStream() } if (IS_PRODUCER && urlParams.get('testing') === 'true') { getLocalStream() }
}) })
// socket.on('new-producer', ({ callId }) => { socket.on('new-producer', ({ callId }) => {
// console.log(`🟥 new-producer | callId: ${callId}`); console.log(`🟢 new-producer | callId: ${callId} | Ready to consume`);
// }) consume()
})
} }
if (IS_PRODUCER === true) { if (IS_PRODUCER === true) {