LINXD-2342-dispatcher-audio #29

Merged
sergiu merged 6 commits from LINXD-2342-dispatcher-audio into develop 2023-02-15 09:14:57 +00:00
5 changed files with 66 additions and 59 deletions

5
app.js
View File

@ -260,7 +260,6 @@ peers.on('connection', async (socket) => {
isInitiator(callId, socket.id) isInitiator(callId, socket.id)
? await videoCalls[callId].initiatorProducerTransport.connect({ dtlsParameters }) ? await videoCalls[callId].initiatorProducerTransport.connect({ dtlsParameters })
: await videoCalls[callId].receiverProducerTransport.connect({ dtlsParameters }); : await videoCalls[callId].receiverProducerTransport.connect({ dtlsParameters });
} 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}`);
} }
@ -370,8 +369,10 @@ peers.on('connection', async (socket) => {
const socketToEmit = isInitiator(callId, socket.id) const socketToEmit = isInitiator(callId, socket.id)
? videoCalls[callId].receiverSocket ? videoCalls[callId].receiverSocket
: videoCalls[callId].initiatorSocket; : videoCalls[callId].initiatorSocket;
socketToEmit.emit('new-producer', { callId });
// callId - Id of the call

Add a comment with param description.

Add a comment with param description.
// kind - producer type: audio/video
socketToEmit.emit('new-producer', { callId, kind });
} catch (error) { } catch (error) {
console.log(`ERROR | transport-produce | callId ${socketDetails[socket.id]} | ${error.message}`); console.log(`ERROR | transport-produce | callId ${socketDetails[socket.id]} | ${error.message}`);
} }

View File

@ -20353,7 +20353,7 @@ module.exports = yeast;
},{}],94:[function(require,module,exports){ },{}],94:[function(require,module,exports){
module.exports = { module.exports = {
hubAddress: 'https://hub.dev.linx.safemobile.com/', hubAddress: 'https://hub.dev.linx.safemobile.com/',
mediasoupAddress: 'https://video.safemobile.org', mediasoupAddress: 'https://video.safemobile.org/',
} }
},{}],95:[function(require,module,exports){ },{}],95:[function(require,module,exports){
const io = require('socket.io-client') const io = require('socket.io-client')
@ -20453,9 +20453,9 @@ setTimeout(() => {
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, kind }) => {
console.log(`🟢 new-producer | callId: ${callId} | Ready to consume`); console.log(`🟢 new-producer | callId: ${callId} | kind: ${kind} | Ready to consume`);
consume() connectRecvTransport();
}) })
} }
@ -20735,6 +20735,8 @@ const connectSendTransport = async () => {
// Enable Close call button // Enable Close call button
const closeCallBtn = document.getElementById('btnCloseCall'); const closeCallBtn = document.getElementById('btnCloseCall');
closeCallBtn.removeAttribute('disabled'); closeCallBtn.removeAttribute('disabled');
createRecvTransport();
} }
const createRecvTransport = async () => { const createRecvTransport = async () => {
@ -20774,7 +20776,8 @@ const createRecvTransport = async () => {
errback(error) errback(error)
} }
}) })
connectRecvTransport() // We call it in new-rpoducer, we don't need it here anymore
// connectRecvTransport()
}) })
} }
@ -20907,31 +20910,31 @@ const closeCall = () => {
resetCallSettings() resetCallSettings()
} }
const consume = async () => { // const consume = async (kind) => {
console.log('[consume]') // console.log(`[consume] kind: ${kind}`)
console.log('createRecvTransport Consumer') // console.log('createRecvTransport Consumer')
await socket.emit('createWebRtcTransport', { sender: false, callId, dispatcher: true }, ({ params }) => { // await socket.emit('createWebRtcTransport', { sender: false, callId, dispatcher: true }, ({ params }) => {
if (params.error) { // if (params.error) {
console.log('createRecvTransport | createWebRtcTransport | Error', params.error) // console.log('createRecvTransport | createWebRtcTransport | Error', params.error)
return // return
} // }
consumerTransport = device.createRecvTransport(params) // consumerTransport = device.createRecvTransport(params)
consumerTransport.on('connect', async ({ dtlsParameters }, callback, errback) => { // consumerTransport.on('connect', async ({ dtlsParameters }, callback, errback) => {
try { // try {
await socket.emit('transport-recv-connect', { // await socket.emit('transport-recv-connect', {
dtlsParameters, // dtlsParameters,
}) // })
callback() // callback()
} catch (error) { // } catch (error) {
errback(error) // errback(error)
} // }
}) // })
connectRecvTransport() // connectRecvTransport()
}) // })
} // }
btnLocalVideo.addEventListener('click', getLocalStream) btnLocalVideo.addEventListener('click', getLocalStream)
btnRecvSendTransport.addEventListener('click', consume) // btnRecvSendTransport.addEventListener('click', consume)
btnCloseCall.addEventListener('click', closeCall) btnCloseCall.addEventListener('click', closeCall)
},{"./config":94,"mediasoup-client":66,"socket.io-client":82}]},{},[95]); },{"./config":94,"mediasoup-client":66,"socket.io-client":82}]},{},[95]);

View File

@ -1,4 +1,4 @@
module.exports = { module.exports = {
hubAddress: 'https://hub.dev.linx.safemobile.com/', hubAddress: 'https://hub.dev.linx.safemobile.com/',
mediasoupAddress: 'https://video.safemobile.org', mediasoupAddress: 'https://video.safemobile.org/',
} }

View File

@ -75,7 +75,7 @@
</td> </td>
<td> <td>
<div id="sharedBtns"> <div id="sharedBtns">
<button id="btnRecvSendTransport">Consume</button> <!-- <button id="btnRecvSendTransport">Consume</button> -->
<button id="remoteSoundControl">Unmute</button> <button id="remoteSoundControl">Unmute</button>
</div> </div>
</td> </td>

View File

@ -95,9 +95,9 @@ setTimeout(() => {
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, kind }) => {
console.log(`🟢 new-producer | callId: ${callId} | Ready to consume`); console.log(`🟢 new-producer | callId: ${callId} | kind: ${kind} | Ready to consume`);
consume() connectRecvTransport();
}) })
} }
@ -377,6 +377,8 @@ const connectSendTransport = async () => {
// Enable Close call button // Enable Close call button
const closeCallBtn = document.getElementById('btnCloseCall'); const closeCallBtn = document.getElementById('btnCloseCall');
closeCallBtn.removeAttribute('disabled'); closeCallBtn.removeAttribute('disabled');
createRecvTransport();
} }
const createRecvTransport = async () => { const createRecvTransport = async () => {
@ -416,7 +418,8 @@ const createRecvTransport = async () => {
errback(error) errback(error)
} }
}) })
connectRecvTransport() // We call it in new-rpoducer, we don't need it here anymore
// connectRecvTransport()
}) })
} }
@ -549,30 +552,30 @@ const closeCall = () => {
resetCallSettings() resetCallSettings()
} }
const consume = async () => { // const consume = async (kind) => {
console.log('[consume]') // console.log(`[consume] kind: ${kind}`)
console.log('createRecvTransport Consumer') // console.log('createRecvTransport Consumer')
await socket.emit('createWebRtcTransport', { sender: false, callId, dispatcher: true }, ({ params }) => { // await socket.emit('createWebRtcTransport', { sender: false, callId, dispatcher: true }, ({ params }) => {
if (params.error) { // if (params.error) {
console.log('createRecvTransport | createWebRtcTransport | Error', params.error) // console.log('createRecvTransport | createWebRtcTransport | Error', params.error)
return // return
} // }
consumerTransport = device.createRecvTransport(params) // consumerTransport = device.createRecvTransport(params)
consumerTransport.on('connect', async ({ dtlsParameters }, callback, errback) => { // consumerTransport.on('connect', async ({ dtlsParameters }, callback, errback) => {
try { // try {
await socket.emit('transport-recv-connect', { // await socket.emit('transport-recv-connect', {
dtlsParameters, // dtlsParameters,
}) // })
callback() // callback()
} catch (error) { // } catch (error) {
errback(error) // errback(error)
} // }
}) // })
connectRecvTransport() // connectRecvTransport()
}) // })
} // }
btnLocalVideo.addEventListener('click', getLocalStream) btnLocalVideo.addEventListener('click', getLocalStream)
btnRecvSendTransport.addEventListener('click', consume) // btnRecvSendTransport.addEventListener('click', consume)
btnCloseCall.addEventListener('click', closeCall) btnCloseCall.addEventListener('click', closeCall)