LH-276: Add close-producer event handler; Update client #30

Merged
sergiu merged 9 commits from LH-276-close-producer into develop 2023-02-23 09:46:42 +00:00
Showing only changes of commit 7842953faf - Show all commits

18
app.js
View File

@ -409,13 +409,17 @@ peers.on('connection', async (socket) => {
const callId = socketDetails[socket.id]; const callId = socketDetails[socket.id];
const isInitiatorValue = isInitiator(callId, socket.id); const isInitiatorValue = isInitiator(callId, socket.id);
console.log(`[consumer-resume] callId: ${callId} | isInitiator: ${isInitiatorValue}`); console.log(`[consumer-resume] callId: ${callId} | isInitiator: ${isInitiatorValue}`);
if (isInitiatorValue) {
videoCalls[callId].initiatorConsumerVideo && videoCalls[callId].initiatorConsumerVideo.resume(); const consumerVideo = isInitiatorValue
videoCalls[callId].initiatorConsumerAudio && videoCalls[callId].initiatorConsumerAudio.resume(); ? videoCalls[callId].initiatorConsumerVideo
} else { : videoCalls[callId].receiverConsumerVideo;
videoCalls[callId].receiverConsumerVideo && videoCalls[callId].receiverConsumerVideo.resume();
videoCalls[callId].receiverConsumerAudio && videoCalls[callId].receiverConsumerAudio.resume(); const consumerAudio = isInitiatorValue
} ? videoCalls[callId].initiatorConsumerAudio
  • we should not use the same variables for both receiver and initiator, we can improve the naming with something like canConsumeAudioReceiver and canConsumeAudioInitiator
  • the assignments for canConsumeAudio and canConsumeVideo are very similar and very hard to distinguish if something is wrong, extract it in a function and use it in all 4 places
    • something like: initCanConsume(producer, callId, rtpCapabilities)
  • not sure if !! is necessary in all places
* we should not use the same variables for both receiver and initiator, we can improve the naming with something like `canConsumeAudioReceiver` and `canConsumeAudioInitiator` * the assignments for `canConsumeAudio` and `canConsumeVideo` are very similar and very hard to distinguish if something is wrong, extract it in a function and use it in all 4 places * something like: `initCanConsume(producer, callId, rtpCapabilities)` * not sure if `!!` is necessary in all places
: videoCalls[callId].receiverConsumerAudio;
consumerVideo?.resume();
consumerAudio?.resume();
} catch (error) { } catch (error) {
console.error( console.error(
`[consumer-resume] | ERROR | callId: ${socketDetails[socket.id]} | isInitiator: ${isInitiator} | error: ${ `[consumer-resume] | ERROR | callId: ${socketDetails[socket.id]} | isInitiator: ${isInitiator} | error: ${