From 825ded83c2056d9a06d30662354dd1606d60c042 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Mon, 19 Dec 2022 12:13:48 +0200 Subject: [PATCH] Update --- public/bundle.js | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ public/index.js | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+) diff --git a/public/bundle.js b/public/bundle.js index 2e91197..3e37dea 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20381,6 +20381,8 @@ let producerVideo let producerAudio let consumer let originAssetId +let consumerVideo // local consumer video(consumer not transport) +let consumerAudio // local consumer audio(consumer not transport) // https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerOptions // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce @@ -20802,6 +20804,57 @@ const connectRecvTransport = async () => { }) } +const getVideoTrask = async (videoParams) => { + consumerVideo = await consumerTransport.consume({ + id: videoParams.id, + producerId: videoParams.producerId, + kind: videoParams.kind, + rtpParameters: videoParams.rtpParameters + }) + + consumerVideo.on('transportclose', () => { + console.log('transport closed so consumer closed') + }) + + return consumerVideo.track +} + +const getAudioTrask = async (audioParams) => { + consumerAudio = await consumerTransport.consume({ + id: audioParams.id, + producerId: audioParams.producerId, + kind: audioParams.kind, + rtpParameters: audioParams.rtpParameters + }) + + consumerAudio.on('transportclose', () => { + console.log('transport closed so consumer closed') + }) + + const audioTrack = consumerAudio.track + + audioTrack.applyConstraints({ + audio: { + advanced: [ + { + echoCancellation: {exact: true} + }, + { + autoGainControl: {exact: true} + }, + { + noiseSuppression: {exact: true} + }, + { + highpassFilter: {exact: true} + } + ] + } + }) + + return audioTrack +} + const closeCall = () => { console.log('closeCall'); diff --git a/public/index.js b/public/index.js index 027a149..f8d888e 100644 --- a/public/index.js +++ b/public/index.js @@ -23,6 +23,8 @@ let producerVideo let producerAudio let consumer let originAssetId +let consumerVideo // local consumer video(consumer not transport) +let consumerAudio // local consumer audio(consumer not transport) // https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerOptions // https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce @@ -444,6 +446,57 @@ const connectRecvTransport = async () => { }) } +const getVideoTrask = async (videoParams) => { + consumerVideo = await consumerTransport.consume({ + id: videoParams.id, + producerId: videoParams.producerId, + kind: videoParams.kind, + rtpParameters: videoParams.rtpParameters + }) + + consumerVideo.on('transportclose', () => { + console.log('transport closed so consumer closed') + }) + + return consumerVideo.track +} + +const getAudioTrask = async (audioParams) => { + consumerAudio = await consumerTransport.consume({ + id: audioParams.id, + producerId: audioParams.producerId, + kind: audioParams.kind, + rtpParameters: audioParams.rtpParameters + }) + + consumerAudio.on('transportclose', () => { + console.log('transport closed so consumer closed') + }) + + const audioTrack = consumerAudio.track + + audioTrack.applyConstraints({ + audio: { + advanced: [ + { + echoCancellation: {exact: true} + }, + { + autoGainControl: {exact: true} + }, + { + noiseSuppression: {exact: true} + }, + { + highpassFilter: {exact: true} + } + ] + } + }) + + return audioTrack +} + const closeCall = () => { console.log('closeCall');