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

View File

@ -1,4 +1,4 @@
module.exports = {
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>
<div id="sharedBtns">
<button id="btnRecvSendTransport">Consume</button>
<!-- <button id="btnRecvSendTransport">Consume</button> -->
<button id="remoteSoundControl">Unmute</button>
</div>
</td>

View File

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