Compare commits

...

33 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
26345bd22b LAPI-675: Comment code<DEBUG> 2023-01-13 18:42:34 +02:00
9b4e0186ac LAPI-675: Update server go emit new-producer; Update client to handle this event 2023-01-13 18:32:11 +02:00
eece7d2ee3 LAPI-675: Added handler for new transport/newproducer/newconsumer 2023-01-13 13:27:59 +02:00
3 changed files with 25 additions and 10 deletions

23
app.js
View File

@ -28,8 +28,8 @@ let worker;
* initiatorConsumerVideo: Consumer,
* initiatorConsumerAudio: Consumer,
* initiatorConsumerTransport: Consumer Transport
* initiatorSockerId
* receiverSocketId
* initiatorSocket
* receiverSocket
* }
*
**/
@ -192,12 +192,11 @@ peers.on('connection', async socket => {
if (callId) {
console.log(`[createRoom] socket.id ${socket.id} callId ${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}`);
videoCalls[callId].receiverSocketId = socket.id
videoCalls[callId].receiverSocket = socket;
} else {
videoCalls[callId].initiatorSockerId = socket.id
videoCalls[callId].initiatorSocket = socket;
}
socketDetails[socket.id] = callId;
// rtpCapabilities is set for callback
@ -259,11 +258,19 @@ peers.on('connection', async socket => {
if (typeof dtlsParameters === 'string') dtlsParameters = JSON.parse(dtlsParameters);
console.log(`[transport-connect] socket ${socket.id} | callId ${callId}`);
if (!isInitiator(callId, socket.id)) {
await videoCalls[callId].receiverProducerTransport.connect({ dtlsParameters });
videoCalls[callId].initiatorSocket.emit('new-producer', {
callId
});
} else {
await videoCalls[callId].initiatorProducerTransport.connect({ dtlsParameters });
videoCalls[callId].receiverSocket.emit('new-producer', {
callId
});
}
} catch (error) {
console.log(`ERROR | transport-connect | callId ${socketDetails[socket.id]} | ${error.message}`);
}
@ -280,6 +287,7 @@ peers.on('connection', async socket => {
if (typeof rtpParameters === 'string') rtpParameters = JSON.parse(rtpParameters);
console.log(`[transport-produce] kind: ${kind} | socket: ${socket.id} | callId: ${callId}`);
if (kind === 'video') {
if (!isInitiator(callId, socket.id)) {
videoCalls[callId].receiverVideoProducer = await videoCalls[callId].receiverProducerTransport.produce({
@ -578,7 +586,7 @@ const consumeAudio = async (callId, socketId, rtpCapabilities) => {
}
const isInitiator = (callId, socketId) => {
return (videoCalls[callId].initiatorSockerId === socketId);
return (videoCalls[callId]?.initiatorSocket?.id === socketId);
}
/*
@ -606,7 +614,6 @@ const createWebRtcTransportLayer = async (callId, callback) => {
// https://mediasoup.org/documentation/v3/mediasoup/api/#router-createWebRtcTransport
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
transport.on('dtlsstatechange', dtlsState => {

View File

@ -20449,10 +20449,14 @@ setTimeout(() => {
console.log(`[MEDIA] ${config.mediasoupAddress} | connected: ${socket.connected} | existsProducer: ${existsProducer}`)
if (!IS_PRODUCER && existsProducer && consumer === undefined) {
goConnect()
// document.getElementById('btnRecvSendTransport').click();
}
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) {

View File

@ -91,10 +91,14 @@ setTimeout(() => {
console.log(`[MEDIA] ${config.mediasoupAddress} | connected: ${socket.connected} | existsProducer: ${existsProducer}`)
if (!IS_PRODUCER && existsProducer && consumer === undefined) {
goConnect()
// document.getElementById('btnRecvSendTransport').click();
}
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) {