LH-276: Update producer close event handler
This commit is contained in:
parent
f99a4d9849
commit
2afdf8b0ca
28
app.js
28
app.js
@ -188,22 +188,21 @@ peers.on('connection', async (socket) => {
|
|||||||
console.log(`[createRoom] socket.id ${socket.id} callId ${callId}`);
|
console.log(`[createRoom] socket.id ${socket.id} callId ${callId}`);
|
||||||
if (!videoCalls[callId]) {
|
if (!videoCalls[callId]) {
|
||||||
videoCalls[callId] = { router: await worker.createRouter({ mediaCodecs }) };
|
videoCalls[callId] = { router: await worker.createRouter({ mediaCodecs }) };
|
||||||
console.log(`[createRoom] Router ID: ${videoCalls[callId].router.id}`);
|
console.log(`[createRoom] Generate Router ID: ${videoCalls[callId].router.id}`);
|
||||||
videoCalls[callId].receiverSocket = socket;
|
videoCalls[callId].receiverSocket = socket;
|
||||||
} else {
|
} else {
|
||||||
videoCalls[callId].initiatorSocket = socket;
|
videoCalls[callId].initiatorSocket = socket;
|
||||||
}
|
}
|
||||||
socketDetails[socket.id] = callId;
|
socketDetails[socket.id] = callId;
|
||||||
// rtpCapabilities is set for callback
|
// rtpCapabilities is set for callback
|
||||||
console.log('[getRtpCapabilities] callId', callId);
|
|
||||||
callbackResponse = {
|
callbackResponse = {
|
||||||
rtpCapabilities: videoCalls[callId].router.rtpCapabilities,
|
rtpCapabilities: videoCalls[callId].router.rtpCapabilities,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
console.log(`[createRoom] missing callId ${callId}`);
|
console.log(`[createRoom] missing callId: ${callId}`);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`[createRoom] | ERROR | callId ${callId} | error: ${error.message}`);
|
console.error(`[createRoom] | ERROR | callId: ${callId} | error: ${error.message}`);
|
||||||
} finally {
|
} finally {
|
||||||
callback(callbackResponse);
|
callback(callbackResponse);
|
||||||
}
|
}
|
||||||
@ -272,7 +271,7 @@ peers.on('connection', async (socket) => {
|
|||||||
const callId = socketDetails[socket.id];
|
const callId = socketDetails[socket.id];
|
||||||
if (typeof rtpParameters === 'string') rtpParameters = JSON.parse(rtpParameters);
|
if (typeof rtpParameters === 'string') rtpParameters = JSON.parse(rtpParameters);
|
||||||
|
|
||||||
console.log(`[transport-produce] kind: ${kind} | socket: ${socket.id} | callId: ${callId}`);
|
console.log(`[transport-produce] callId: ${callId} | kind: ${kind} | socket: ${socket.id}`);
|
||||||
|
|
||||||
if (kind === 'video') {
|
if (kind === 'video') {
|
||||||
if (!isInitiator(callId, socket.id)) {
|
if (!isInitiator(callId, socket.id)) {
|
||||||
@ -281,10 +280,6 @@ peers.on('connection', async (socket) => {
|
|||||||
rtpParameters,
|
rtpParameters,
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(
|
|
||||||
`[transport-produce] receiverVideoProducer Producer ID: ${videoCalls[callId].receiverVideoProducer.id} | kind: ${videoCalls[callId].receiverVideoProducer.kind}`
|
|
||||||
);
|
|
||||||
|
|
||||||
videoCalls[callId].receiverVideoProducer.on('transportclose', () => {
|
videoCalls[callId].receiverVideoProducer.on('transportclose', () => {
|
||||||
console.log('transport for this producer closed', callId);
|
console.log('transport for this producer closed', callId);
|
||||||
closeCall(callId);
|
closeCall(callId);
|
||||||
@ -301,10 +296,6 @@ peers.on('connection', async (socket) => {
|
|||||||
rtpParameters,
|
rtpParameters,
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(
|
|
||||||
`[transport-produce] initiatorVideoProducer Producer ID: ${videoCalls[callId].initiatorVideoProducer.id} | kind: ${videoCalls[callId].initiatorVideoProducer.kind}`
|
|
||||||
);
|
|
||||||
|
|
||||||
videoCalls[callId].initiatorVideoProducer.on('transportclose', () => {
|
videoCalls[callId].initiatorVideoProducer.on('transportclose', () => {
|
||||||
console.log('transport for this producer closed', callId);
|
console.log('transport for this producer closed', callId);
|
||||||
closeCall(callId);
|
closeCall(callId);
|
||||||
@ -322,10 +313,6 @@ peers.on('connection', async (socket) => {
|
|||||||
rtpParameters,
|
rtpParameters,
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(
|
|
||||||
`[transport-produce] receiverAudioProducer Producer ID: ${videoCalls[callId].receiverAudioProducer.id} | kind: ${videoCalls[callId].receiverAudioProducer.kind}`
|
|
||||||
);
|
|
||||||
|
|
||||||
videoCalls[callId].receiverAudioProducer.on('transportclose', () => {
|
videoCalls[callId].receiverAudioProducer.on('transportclose', () => {
|
||||||
console.log('transport for this producer closed', callId);
|
console.log('transport for this producer closed', callId);
|
||||||
closeCall(callId);
|
closeCall(callId);
|
||||||
@ -342,10 +329,6 @@ peers.on('connection', async (socket) => {
|
|||||||
rtpParameters,
|
rtpParameters,
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(
|
|
||||||
`[transport-produce] initiatorAudioProducer Producer ID: ${videoCalls[callId].initiatorAudioProducer.id} | kind: ${videoCalls[callId].initiatorAudioProducer.kind}`
|
|
||||||
);
|
|
||||||
|
|
||||||
videoCalls[callId].initiatorAudioProducer.on('transportclose', () => {
|
videoCalls[callId].initiatorAudioProducer.on('transportclose', () => {
|
||||||
console.log('transport for this producer closed', callId);
|
console.log('transport for this producer closed', callId);
|
||||||
closeCall(callId);
|
closeCall(callId);
|
||||||
@ -485,7 +468,6 @@ peers.on('connection', async (socket) => {
|
|||||||
|
|
||||||
socket.on('close-producer', ({ callId, kind}) => {
|
socket.on('close-producer', ({ callId, kind}) => {
|
||||||
try {
|
try {
|
||||||
console.log(`[close-producer] callId: ${callId} | kind: ${kind}`);
|
|
||||||
if (isInitiator(callId, socket.id)) {
|
if (isInitiator(callId, socket.id)) {
|
||||||
console.log(`[close-producer] initiator --EMIT--> receiver | callId: ${callId} | kind: ${kind}`);
|
console.log(`[close-producer] initiator --EMIT--> receiver | callId: ${callId} | kind: ${kind}`);
|
||||||
videoCalls[callId].receiverSocket.emit('close-producer', { callId, kind });
|
videoCalls[callId].receiverSocket.emit('close-producer', { callId, kind });
|
||||||
@ -574,7 +556,7 @@ const isInitiator = (callId, socketId) => {
|
|||||||
*/
|
*/
|
||||||
const createWebRtcTransportLayer = async (callId, callback) => {
|
const createWebRtcTransportLayer = async (callId, callback) => {
|
||||||
try {
|
try {
|
||||||
console.log('[createWebRtcTransportLayer] callId', callId);
|
console.log(`[createWebRtcTransportLayer] callId: ${callId}`);
|
||||||
// https://mediasoup.org/documentation/v3/mediasoup/api/#WebRtcTransportOptions
|
// https://mediasoup.org/documentation/v3/mediasoup/api/#WebRtcTransportOptions
|
||||||
const webRtcTransport_options = {
|
const webRtcTransport_options = {
|
||||||
listenIps: [
|
listenIps: [
|
||||||
|
Loading…
Reference in New Issue
Block a user