Add socket info
This commit is contained in:
parent
8a9c370f02
commit
d633eec92f
48
app.js
48
app.js
@ -15,19 +15,21 @@ const mediasoup = require('mediasoup');
|
||||
|
||||
let worker
|
||||
/**
|
||||
* videoCalls
|
||||
* |-> Router
|
||||
* |-> Producer
|
||||
* |-> Consumer
|
||||
* |-> Producer Transport
|
||||
* |-> Consumer Transport
|
||||
*
|
||||
* videoCalls - Dictionary of Object(s)
|
||||
* '<callId>': {
|
||||
* router: Router,
|
||||
* producer: Producer,
|
||||
* producerTransport: Producer Transport,
|
||||
* consumer: Consumer,
|
||||
* consumerTransport: Consumer Transport
|
||||
* router: Router, router
|
||||
* initiatorAudioProducer: Producer,
|
||||
* initiatorVideoProducer: Producer,
|
||||
* receiverVideoProducer: Producer, producerVideo
|
||||
* receiverAudioProducer: Producer, producerAudio
|
||||
* initiatorProducerTransport: Producer Transport,
|
||||
* receiverProducerTransport: Producer Transport, producerTransport
|
||||
* initiatorConsumerVideo: Consumer, consumerVideo
|
||||
* initiatorConsumerAudio: Consumer, consumerAudio
|
||||
* initiatorConsumerTransport: Consumer Transport consumerTransport
|
||||
* initiatorSockerId
|
||||
* receiverSocketId
|
||||
* }
|
||||
*
|
||||
**/
|
||||
@ -141,20 +143,6 @@ const mediaCodecs = [
|
||||
'x-google-start-bitrate' : 1000
|
||||
}
|
||||
}
|
||||
// {
|
||||
// kind: 'audio',
|
||||
// mimeType: 'audio/opus',
|
||||
// clockRate: 48000,
|
||||
// channels: 2,
|
||||
// },
|
||||
// {
|
||||
// kind: 'video',
|
||||
// mimeType: 'video/VP8',
|
||||
// clockRate: 90000,
|
||||
// parameters: {
|
||||
// 'x-google-start-bitrate': 1000,
|
||||
// },
|
||||
// },
|
||||
];
|
||||
|
||||
const closeCall = (callId) => {
|
||||
@ -212,9 +200,11 @@ peers.on('connection', async socket => {
|
||||
console.log('[createRoom] callId', callId);
|
||||
videoCalls[callId] = { router: await worker.createRouter({ mediaCodecs }) }
|
||||
console.log(`[createRoom] Router ID: ${videoCalls[callId].router.id}`);
|
||||
videoCalls[callId].initiatorSockerId = socket.id
|
||||
} else {
|
||||
videoCalls[callId].receiverSocketId = socket.id
|
||||
}
|
||||
socketDetails[socket.id] = callId;
|
||||
|
||||
// rtpCapabilities is set for callback
|
||||
console.log('[getRtpCapabilities] callId', callId);
|
||||
callbackResponse = {
|
||||
@ -223,6 +213,7 @@ peers.on('connection', async socket => {
|
||||
} else {
|
||||
console.log(`[createRoom] missing callId ${callId}`);
|
||||
}
|
||||
console.log('🔴 isInitiator(callId, socket.id)', isInitiator(callId, socket.id));
|
||||
} catch (error) {
|
||||
console.log(`ERROR | createRoom | callId ${callId} | ${error.message}`);
|
||||
} finally {
|
||||
@ -470,6 +461,11 @@ const consumeAudio = async (callId, rtpCapabilities) => {
|
||||
}
|
||||
}
|
||||
|
||||
const isInitiator = async (callId, socketId) => {
|
||||
if (videoCalls[callId].initiatorSockerId === socketId) return true;
|
||||
else return false
|
||||
}
|
||||
|
||||
/*
|
||||
- Called from at event 'createWebRtcTransport' and assigned to the consumer or producer transport
|
||||
- It will return parameters, these are required for the client to create the RecvTransport
|
||||
|
Loading…
Reference in New Issue
Block a user