LH-276: Add close-producer event handler; Update client #30
68
app.js
68
app.js
@ -498,39 +498,45 @@ const consumeVideo = async ({ callId, socketId, rtpCapabilities }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const consumeAudio = async ({ callId, socketId, rtpCapabilities }) => {
|
const consumeAudio = async ({ callId, socketId, rtpCapabilities }) => {
|
||||||
// Handlers for consumer transport https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-on-transportclose
|
try {
|
||||||
if (isInitiator(callId, socketId)) {
|
// Handlers for consumer transport https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-on-transportclose
|
||||||
const producerId = videoCalls[callId].receiverAudioProducer.id;
|
if (isInitiator(callId, socketId)) {
|
||||||
if (!canConsume({ callId, producerId, rtpCapabilities })) return null;
|
const producerId = videoCalls[callId].receiverAudioProducer.id;
|
||||||
|
if (!canConsume({ callId, producerId, rtpCapabilities })) return null;
|
||||||
|
|
||||||
videoCalls[callId].initiatorConsumerAudio = await videoCalls[callId].initiatorConsumerTransport.consume({
|
videoCalls[callId].initiatorConsumerAudio = await videoCalls[callId].initiatorConsumerTransport.consume({
|
||||||
producerId,
|
producerId,
|
||||||
rtpCapabilities,
|
rtpCapabilities,
|
||||||
paused: true,
|
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;
|
||||||
|
|
||||||
return {
|
videoCalls[callId].receiverConsumerAudio = await videoCalls[callId].receiverConsumerTransport.consume({
|
||||||
id: videoCalls[callId].initiatorConsumerAudio.id,
|
producerId,
|
||||||
producerId,
|
rtpCapabilities,
|
||||||
kind: 'audio',
|
paused: true,
|
||||||
rtpParameters: videoCalls[callId].initiatorConsumerAudio.rtpParameters,
|
});
|
||||||
};
|
const returnData = {
|
||||||
} else {
|
id: videoCalls[callId].receiverConsumerAudio.id,
|
||||||
const producerId = videoCalls[callId].initiatorAudioProducer.id;
|
producerId,
|
||||||
if (!canConsume({ callId, producerId, rtpCapabilities })) return null;
|
kind: 'audio',
|
||||||
|
rtpParameters: videoCalls[callId].receiverConsumerAudio.rtpParameters,
|
||||||
videoCalls[callId].receiverConsumerAudio = await videoCalls[callId].receiverConsumerTransport.consume({
|
};
|
||||||
producerId,
|
console.log('audio returnData', returnData);
|
||||||
rtpCapabilities,
|
return returnData;
|
||||||
paused: true,
|
}
|
||||||
});
|
} catch (error) {
|
||||||
|
console.error(`[consumeAudio] | ERROR | error: ${error.message}`)
|
||||||
return {
|
|
||||||
id: videoCalls[callId].receiverConsumerAudio.id,
|
|
||||||
producerId,
|
|
||||||
kind: 'audio',
|
|
||||||
rtpParameters: videoCalls[callId].receiverConsumerAudio.rtpParameters,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user