LH-276: Update producer close event handler

This commit is contained in:
Sergiu Toma 2023-02-21 01:09:35 +02:00
parent 1060293980
commit cb14061b94

15
app.js
View File

@ -424,14 +424,11 @@ peers.on('connection', async (socket) => {
socket.on('consume', async ({ rtpCapabilities }, callback) => { socket.on('consume', async ({ rtpCapabilities }, callback) => {
try { try {
const callId = socketDetails[socket.id]; const callId = socketDetails[socket.id];
console.log(
`[consume] socket ${socket.id} | callId ${callId} | rtpCapabilities: ${JSON.stringify(rtpCapabilities)}`
);
if (typeof rtpCapabilities === 'string') rtpCapabilities = JSON.parse(rtpCapabilities); if (typeof rtpCapabilities === 'string') rtpCapabilities = JSON.parse(rtpCapabilities);
console.log('[consume] callId', callId);
let canConsumeVideo, canConsumeAudio; let canConsumeVideo, canConsumeAudio;
try {
if (isInitiator(callId, socket.id)) { if (isInitiator(callId, socket.id)) {
canConsumeVideo = canConsumeVideo =
!!videoCalls[callId].receiverVideoProducer && !!videoCalls[callId].receiverVideoProducer &&
@ -460,8 +457,11 @@ peers.on('connection', async (socket) => {
rtpCapabilities, rtpCapabilities,
}); });
} }
console.log('[consume] canConsumeVideo', canConsumeVideo); } catch (error) {
console.log('[consume] canConsumeAudio', canConsumeAudio); console.error(`[consume] ERROR | callId: ${callId} | error: ${error.message}`)
}
console.log(`[consume] socket ${socket.id} | callId: ${callId} | canConsumeVideo: ${canConsumeVideo} | canConsumeAudio: ${canConsumeAudio}`);
if (canConsumeVideo && !canConsumeAudio) { if (canConsumeVideo && !canConsumeAudio) {
const videoParams = await consumeVideo(callId, socket.id, rtpCapabilities); const videoParams = await consumeVideo(callId, socket.id, rtpCapabilities);
@ -479,7 +479,7 @@ peers.on('connection', async (socket) => {
callback(null); callback(null);
} }
} catch (error) { } catch (error) {
console.log(`ERROR | consume | callId ${socketDetails[socket.id]} | ${error.message}`); console.error(`[consume] ERROR | callId: ${socketDetails[socket.id]} | error: ${error.message}`);
callback({ params: { error } }); callback({ params: { error } });
} }
}); });
@ -673,7 +673,6 @@ const createWebRtcTransportLayer = async (callId, callback) => {
dtlsParameters: transport.dtlsParameters, dtlsParameters: transport.dtlsParameters,
}; };
console.log('[createWebRtcTransportLayer] callback params', params);
// Send back to the client the params // Send back to the client the params
callback({ params }); callback({ params });