From c80265fe25d28138926f0715ca3341d62f8e5a5b Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 22 Feb 2023 18:36:50 +0200 Subject: [PATCH] LH-276: Format code --- app.js | 72 +++++++++++++++++++++++++++++++--------------------------- 1 file changed, 39 insertions(+), 33 deletions(-) diff --git a/app.js b/app.js index 3482956..583c79f 100644 --- a/app.js +++ b/app.js @@ -498,39 +498,45 @@ const consumeVideo = async ({ callId, socketId, rtpCapabilities }) => { }; const consumeAudio = async ({ callId, socketId, rtpCapabilities }) => { - // Handlers for consumer transport https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-on-transportclose - if (isInitiator(callId, socketId)) { - const producerId = videoCalls[callId].receiverAudioProducer.id; - if (!canConsume({ callId, producerId, rtpCapabilities })) return null; - - videoCalls[callId].initiatorConsumerAudio = await videoCalls[callId].initiatorConsumerTransport.consume({ - producerId, - rtpCapabilities, - paused: true, - }); - - return { - id: videoCalls[callId].initiatorConsumerAudio.id, - producerId, - kind: 'audio', - rtpParameters: videoCalls[callId].initiatorConsumerAudio.rtpParameters, - }; - } else { - const producerId = videoCalls[callId].initiatorAudioProducer.id; - if (!canConsume({ callId, producerId, rtpCapabilities })) return null; - - videoCalls[callId].receiverConsumerAudio = await videoCalls[callId].receiverConsumerTransport.consume({ - producerId, - rtpCapabilities, - paused: true, - }); - - return { - id: videoCalls[callId].receiverConsumerAudio.id, - producerId, - kind: 'audio', - rtpParameters: videoCalls[callId].receiverConsumerAudio.rtpParameters, - }; + try { + // Handlers for consumer transport https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-on-transportclose + if (isInitiator(callId, socketId)) { + const producerId = videoCalls[callId].receiverAudioProducer.id; + if (!canConsume({ callId, producerId, rtpCapabilities })) return null; + + videoCalls[callId].initiatorConsumerAudio = await videoCalls[callId].initiatorConsumerTransport.consume({ + producerId, + rtpCapabilities, + paused: true, + }); + const returnData = { + id: videoCalls[callId].initiatorConsumerAudio.id, + producerId, + kind: 'audio', + rtpParameters: videoCalls[callId].initiatorConsumerAudio.rtpParameters, + }; + console.log('audio returnData', returnData); + return returnData; + } else { + const producerId = videoCalls[callId].initiatorAudioProducer.id; + if (!canConsume({ callId, producerId, rtpCapabilities })) return null; + + videoCalls[callId].receiverConsumerAudio = await videoCalls[callId].receiverConsumerTransport.consume({ + producerId, + rtpCapabilities, + paused: true, + }); + const returnData = { + id: videoCalls[callId].receiverConsumerAudio.id, + producerId, + kind: 'audio', + rtpParameters: videoCalls[callId].receiverConsumerAudio.rtpParameters, + }; + console.log('audio returnData', returnData); + return returnData; + } + } catch (error) { + console.error(`[consumeAudio] | ERROR | error: ${error.message}`) } };