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