From 0731090b0e53c4fed048572d07323aa261b8770e Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Mon, 19 Dec 2022 11:26:08 +0200 Subject: [PATCH] Update --- public/bundle.js | 42 ++++++++++++++++++++---------------------- public/index.js | 42 ++++++++++++++++++++---------------------- 2 files changed, 40 insertions(+), 44 deletions(-) diff --git a/public/bundle.js b/public/bundle.js index 0882739..4102964 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20765,31 +20765,29 @@ const connectRecvTransport = async () => { }, async ({videoParams, audioParams}) => { console.log(`[consume] videoParams ${videoParams}`); console.log(`[consume] audioParams ${audioParams}`); - // if (params.error) { - // console.log('Cannot Consume') - // return - // } + if (!audioParams) { + console.log('Cannot Consume audio') + return + } - // console.log(`[connectRecvTransport] consume params ${params}`); + // Then consume with the local consumer transport + // which creates a consumer + consumer = await consumerTransport.consume({ + id: audioParams.id, + producerId: audioParams.producerId, + kind: audioParams.kind, + rtpParameters: audioParams.rtpParameters + }) - // // Then consume with the local consumer transport - // // which creates a consumer - // consumer = await consumerTransport.consume({ - // id: params.id, - // producerId: params.producerId, - // kind: params.kind, - // rtpParameters: params.rtpParameters - // }) + // destructure and retrieve the video track from the producer + const { track } = consumer - // // destructure and retrieve the video track from the producer - // const { track } = consumer - - // let stream = new MediaStream() - // stream.addTrack(track) - // // stream.removeTrack(track) - // remoteVideo.srcObject = stream - // socket.emit('consumer-resume') - // console.log('consumer', consumer); + let stream = new MediaStream() + stream.addTrack(track) + // stream.removeTrack(track) + remoteVideo.srcObject = stream + socket.emit('consumer-resume') + console.log('consumer', consumer); }) } diff --git a/public/index.js b/public/index.js index 34ae630..bc7b573 100644 --- a/public/index.js +++ b/public/index.js @@ -407,31 +407,29 @@ const connectRecvTransport = async () => { }, async ({videoParams, audioParams}) => { console.log(`[consume] videoParams ${videoParams}`); console.log(`[consume] audioParams ${audioParams}`); - // if (params.error) { - // console.log('Cannot Consume') - // return - // } + if (!audioParams) { + console.log('Cannot Consume audio') + return + } - // console.log(`[connectRecvTransport] consume params ${params}`); + // Then consume with the local consumer transport + // which creates a consumer + consumer = await consumerTransport.consume({ + id: audioParams.id, + producerId: audioParams.producerId, + kind: audioParams.kind, + rtpParameters: audioParams.rtpParameters + }) - // // Then consume with the local consumer transport - // // which creates a consumer - // consumer = await consumerTransport.consume({ - // id: params.id, - // producerId: params.producerId, - // kind: params.kind, - // rtpParameters: params.rtpParameters - // }) + // destructure and retrieve the video track from the producer + const { track } = consumer - // // destructure and retrieve the video track from the producer - // const { track } = consumer - - // let stream = new MediaStream() - // stream.addTrack(track) - // // stream.removeTrack(track) - // remoteVideo.srcObject = stream - // socket.emit('consumer-resume') - // console.log('consumer', consumer); + let stream = new MediaStream() + stream.addTrack(track) + // stream.removeTrack(track) + remoteVideo.srcObject = stream + socket.emit('consumer-resume') + console.log('consumer', consumer); }) }