Compare commits
33 Commits
develop
...
LAPI-675-g
Author | SHA1 | Date | |
---|---|---|---|
abfa1f628e | |||
a56c7c9b95 | |||
6efa8005b0 | |||
af85026bd2 | |||
91b21f862c | |||
26b54d0a63 | |||
6a570879e1 | |||
57f994f95b | |||
a647ea9a82 | |||
33e4122e11 | |||
1f3fbba5c0 | |||
c7049ef909 | |||
b287e7d0e7 | |||
bd02ad1c95 | |||
4574b9daf0 | |||
5ef8b4f15c | |||
059cbce4c4 | |||
a75476a1b1 | |||
7b75c64c42 | |||
ffb4bd59ea | |||
eb68830e3e | |||
18aa9c93ed | |||
3c5719c3c8 | |||
5b9768b5de | |||
57108bf41e | |||
2a43cd2603 | |||
256687f284 | |||
020be2f7b9 | |||
ed7feaecd5 | |||
b1dbc401a5 | |||
26345bd22b | |||
9b4e0186ac | |||
eece7d2ee3 |
23
app.js
23
app.js
@ -28,8 +28,8 @@ let worker;
|
|||||||
* initiatorConsumerVideo: Consumer,
|
* initiatorConsumerVideo: Consumer,
|
||||||
* initiatorConsumerAudio: Consumer,
|
* initiatorConsumerAudio: Consumer,
|
||||||
* initiatorConsumerTransport: Consumer Transport
|
* initiatorConsumerTransport: Consumer Transport
|
||||||
* initiatorSockerId
|
* initiatorSocket
|
||||||
* receiverSocketId
|
* receiverSocket
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
@ -192,12 +192,11 @@ 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].receiverSocketId = socket.id
|
videoCalls[callId].receiverSocket = socket;
|
||||||
} else {
|
} else {
|
||||||
videoCalls[callId].initiatorSockerId = socket.id
|
videoCalls[callId].initiatorSocket = socket;
|
||||||
}
|
}
|
||||||
socketDetails[socket.id] = callId;
|
socketDetails[socket.id] = callId;
|
||||||
// rtpCapabilities is set for callback
|
// rtpCapabilities is set for callback
|
||||||
@ -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,6 +287,7 @@ 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}`);
|
||||||
|
|
||||||
if (kind === 'video') {
|
if (kind === 'video') {
|
||||||
if (!isInitiator(callId, socket.id)) {
|
if (!isInitiator(callId, socket.id)) {
|
||||||
videoCalls[callId].receiverVideoProducer = await videoCalls[callId].receiverProducerTransport.produce({
|
videoCalls[callId].receiverVideoProducer = await videoCalls[callId].receiverProducerTransport.produce({
|
||||||
@ -578,7 +586,7 @@ const consumeAudio = async (callId, socketId, rtpCapabilities) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const isInitiator = (callId, socketId) => {
|
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
|
// 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 => {
|
||||||
|
@ -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) {
|
||||||
|
@ -91,10 +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 }) => {
|
||||||
|
console.log(`🟢 new-producer | callId: ${callId} | Ready to consume`);
|
||||||
|
consume()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_PRODUCER === true) {
|
if (IS_PRODUCER === true) {
|
||||||
|
Loading…
Reference in New Issue
Block a user