LH-276: Update producer close event handler
This commit is contained in:
parent
4b9987efe8
commit
512d0f8bed
109
app.js
109
app.js
@ -227,17 +227,6 @@ peers.on('connection', async (socket) => {
|
||||
videoCalls[callId].receiverProducerTransport = await createWebRtcTransportLayer(callId, callback);
|
||||
} else if (!videoCalls[callId].initiatorProducerTransport && isInitiator(callId, socket.id)) {
|
||||
videoCalls[callId].initiatorProducerTransport = await createWebRtcTransportLayer(callId, callback);
|
||||
|
||||
videoCalls[callId].initiatorProducerTransport.observer.on("newproducer", (producer) =>
|
||||
{
|
||||
console.log(
|
||||
"------------------new producer created [worker.pid:%d, router.id:%s, transport.id:%s, producer.id:%s]", producer.id);
|
||||
|
||||
producer.observer.on("close", () => {
|
||||
console.log("-------------------producer closed [producer.id:%s]", producer.id);
|
||||
});
|
||||
});
|
||||
|
||||
} else {
|
||||
console.log(`producerTransport has already been defined | callId ${callId}`);
|
||||
callback(null);
|
||||
@ -304,9 +293,10 @@ peers.on('connection', async (socket) => {
|
||||
closeCall(callId);
|
||||
});
|
||||
|
||||
videoCalls[callId].receiverVideoProducer.on('close', () => {
|
||||
console.log('receiverVideoProducer for this producer closed', callId);
|
||||
});
|
||||
videoCalls[callId].receiverVideoProducer.observer.on("close", () => {
|
||||
console.log(`[close-producer] receiverVideoProducer | callId: ${callId} | kind: ${kind}`);
|
||||
videoCalls[callId].initiatorSocket.emit('close-producer', { callId, kind });
|
||||
})
|
||||
|
||||
// Send back to the client the Producer's id
|
||||
callback &&
|
||||
@ -328,47 +318,11 @@ peers.on('connection', async (socket) => {
|
||||
closeCall(callId);
|
||||
});
|
||||
|
||||
console.log('🟢');
|
||||
|
||||
videoCalls[callId].initiatorVideoProducer.on('close', () => {
|
||||
console.log('===================1 initiatorVideoProducer for this producer closed', callId);
|
||||
});
|
||||
videoCalls[callId].initiatorVideoProducer.observer.on("close", () => {
|
||||
console.log('====================2 initiatorVideoProducer for this producer closed', callId);
|
||||
// const socketToEmit = isInitiator(callId, socket.id)
|
||||
// ? videoCalls[callId].receiverSocket
|
||||
// : videoCalls[callId].initiatorSocket;
|
||||
|
||||
// // callId - Id of the call
|
||||
// // kind - producer type: audio/video
|
||||
// socketToEmit.emit('new-producer', { callId, kind });
|
||||
console.log(`[close-producer] initiatorVideoProducer | callId: ${callId} | kind: ${kind}`);
|
||||
videoCalls[callId].receiverSocket.emit('close-producer', { callId, kind });
|
||||
})
|
||||
|
||||
videoCalls[callId].initiatorVideoProducer.on('producerclose', () => {
|
||||
console.log('000000000000000000000000000 producerclose initiatorVideoProducer!!!!!!!!!!!');
|
||||
});
|
||||
videoCalls[callId].initiatorVideoProducer.observer.on('producerclose', () => {
|
||||
console.log('000000000000000000000000000 producerclose initiatorVideoProducer!!!!!!!!!!!');
|
||||
});
|
||||
|
||||
videoCalls[callId].initiatorVideoProducer.on('closed', () => {
|
||||
console.log('===================4 initiatorVideoProducer for this producer closed', callId);
|
||||
});
|
||||
videoCalls[callId].initiatorVideoProducer.observer.on("closed", () => {
|
||||
console.log('====================5 initiatorVideoProducer for this producer closed', callId);
|
||||
})
|
||||
|
||||
// videoCalls[callId].initiatorProducerTransport.observer.on("newproducer", (producer) =>
|
||||
// {
|
||||
// console.log(
|
||||
// "new producer created [worker.pid:%d, router.id:%s, transport.id:%s, producer.id:%s]", producer.id);
|
||||
|
||||
// producer.observer.on("close", () => {
|
||||
// console.log("producer closed [producer.id:%s]", producer.id);
|
||||
// });
|
||||
// });
|
||||
|
||||
callback &&
|
||||
callback({
|
||||
id: videoCalls[callId].initiatorVideoProducer.id,
|
||||
@ -390,9 +344,10 @@ peers.on('connection', async (socket) => {
|
||||
closeCall(callId);
|
||||
});
|
||||
|
||||
videoCalls[callId].receiverAudioProducer.on('close', () => {
|
||||
console.log('receiverAudioProducer for this producer closed', callId);
|
||||
});
|
||||
videoCalls[callId].receiverAudioProducer.observer.on("close", () => {
|
||||
console.log(`[close-producer] receiverAudioProducer | callId: ${callId} | kind: ${kind}`);
|
||||
videoCalls[callId].initiatorSocket.emit('close-producer', { callId, kind });
|
||||
})
|
||||
|
||||
// Send back to the client the Producer's id
|
||||
callback &&
|
||||
@ -414,9 +369,10 @@ peers.on('connection', async (socket) => {
|
||||
closeCall(callId);
|
||||
});
|
||||
|
||||
videoCalls[callId].initiatorAudioProducer.on('close', () => {
|
||||
console.log('initiatorAudioProducer for this producer closed', callId);
|
||||
});
|
||||
videoCalls[callId].initiatorAudioProducer.observer.on("close", () => {
|
||||
console.log(`[close-producer] initiatorAudioProducer | callId: ${callId} | kind: ${kind}`);
|
||||
videoCalls[callId].initiatorSocket.emit('close-producer', { callId, kind });
|
||||
})
|
||||
|
||||
// Send back to the client the Producer's id
|
||||
callback &&
|
||||
@ -583,15 +539,6 @@ const consumeVideo = async (callId, socketId, rtpCapabilities) => {
|
||||
closeCall(callId);
|
||||
});
|
||||
|
||||
// https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-on-producerclose
|
||||
videoCalls[callId].initiatorConsumerVideo.on('producerclose', () => {
|
||||
console.log('000000000000000000000000000 producer of consumer closed', callId);
|
||||
});
|
||||
|
||||
videoCalls[callId].initiatorConsumerTransport.on('producerclose', () => {
|
||||
console.log('000000000000000000000000000 producerclose initiatorConsumerTransport');
|
||||
});
|
||||
|
||||
return {
|
||||
id: videoCalls[callId].initiatorConsumerVideo.id,
|
||||
producerId: videoCalls[callId].receiverVideoProducer.id,
|
||||
@ -611,12 +558,6 @@ const consumeVideo = async (callId, socketId, rtpCapabilities) => {
|
||||
closeCall(callId);
|
||||
});
|
||||
|
||||
videoCalls[callId].receiverConsumerVideo.on('producerclose', () => {
|
||||
const callId = socketDetails[socket.id];
|
||||
console.log('producer of consumer closed', callId);
|
||||
closeCall(callId);
|
||||
});
|
||||
|
||||
return {
|
||||
id: videoCalls[callId].receiverConsumerVideo.id,
|
||||
producerId: videoCalls[callId].initiatorVideoProducer.id,
|
||||
@ -725,30 +666,6 @@ const createWebRtcTransportLayer = async (callId, callback) => {
|
||||
console.log(`transport | closed | calldId ${callId}`);
|
||||
});
|
||||
|
||||
transport.observer.on("newdataproducer", (dataProducer) =>
|
||||
{
|
||||
console.log(
|
||||
"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^new data producer created [worker.pid:%d, router.id:%s, transport.id:%s, dataProducer.id:%s]",
|
||||
worker.pid, router.id, transport.id, dataProducer.id);
|
||||
|
||||
dataProducer.observer.on("close", () =>
|
||||
{
|
||||
console.log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^data producer closed [dataProducer.id:%s]", dataProducer.id);
|
||||
});
|
||||
});
|
||||
|
||||
transport.observer.on("newproducer", (producer) =>
|
||||
{
|
||||
console.log(
|
||||
"$$$$$$$$$$$$$$$$$$$$$$$$$$new producer created [worker.pid:%d, router.id:%s, transport.id:%s, producer.id:%s]",
|
||||
worker.pid, router.id, transport.id, producer.id);
|
||||
|
||||
producer.observer.on("close", () =>
|
||||
{
|
||||
console.log("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$producer closed [producer.id:%s]", producer.id);
|
||||
});
|
||||
});
|
||||
|
||||
const params = {
|
||||
id: transport.id,
|
||||
iceParameters: transport.iceParameters,
|
||||
|
Loading…
Reference in New Issue
Block a user