Compare commits
7 Commits
LINXD-2180
...
523945271e
Author | SHA1 | Date | |
---|---|---|---|
523945271e | |||
0af7ddd786 | |||
ba5add489d | |||
d5cb144799 | |||
4e92f6cdd3 | |||
aaa1c5cea4 | |||
4f302570a2 |
20
app.js
20
app.js
@ -149,13 +149,12 @@ peers.on('connection', async socket => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// see client's socket.emit('transport-produce', ...)
|
// see client's socket.emit('transport-produce', ...)
|
||||||
socket.on('transport-produce', async ({ kind, rtpParameters, appData }, callback) => {
|
socket.on('transport-produce', async ({ kind, rtpParameters, appData }) => {
|
||||||
// call produce based on the prameters from the client
|
// call produce based on the prameters from the client
|
||||||
producer = await producerTransport.produce({
|
producer = await producerTransport.produce({
|
||||||
kind,
|
kind,
|
||||||
rtpParameters,
|
rtpParameters,
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log(`[transport-produce] Producer ID: ${producer.id} | kind: ${producer.kind}`)
|
console.log(`[transport-produce] Producer ID: ${producer.id} | kind: ${producer.kind}`)
|
||||||
|
|
||||||
producer.on('transportclose', () => {
|
producer.on('transportclose', () => {
|
||||||
@ -168,11 +167,6 @@ peers.on('connection', async socket => {
|
|||||||
router[callId].close()
|
router[callId].close()
|
||||||
delete router[callId]
|
delete router[callId]
|
||||||
})
|
})
|
||||||
|
|
||||||
// Send back to the client the Producer's id
|
|
||||||
callback({
|
|
||||||
id: producer.id
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// see client's socket.emit('transport-recv-connect', ...)
|
// see client's socket.emit('transport-recv-connect', ...)
|
||||||
@ -183,7 +177,7 @@ peers.on('connection', async socket => {
|
|||||||
|
|
||||||
socket.on('consume', async ({ rtpCapabilities, callId }, callback) => {
|
socket.on('consume', async ({ rtpCapabilities, callId }, callback) => {
|
||||||
try {
|
try {
|
||||||
console.log('consume', rtpCapabilities, callId);
|
// console.log('consume', rtpCapabilities, callId);
|
||||||
// check if the router can consume the specified producer
|
// check if the router can consume the specified producer
|
||||||
if (router[callId].canConsume({
|
if (router[callId].canConsume({
|
||||||
producerId: producer.id,
|
producerId: producer.id,
|
||||||
@ -198,8 +192,12 @@ peers.on('connection', async socket => {
|
|||||||
|
|
||||||
consumer.on('transportclose', () => {
|
consumer.on('transportclose', () => {
|
||||||
console.log('transport close from consumer', callId)
|
console.log('transport close from consumer', callId)
|
||||||
// closeRoom(callId)
|
|
||||||
|
// https://mediasoup.org/documentation/v3/mediasoup/api/#router-close
|
||||||
|
router[callId].close()
|
||||||
delete router[callId]
|
delete router[callId]
|
||||||
|
producer.close()
|
||||||
|
consumer.close()
|
||||||
})
|
})
|
||||||
|
|
||||||
consumer.on('producerclose', () => {
|
consumer.on('producerclose', () => {
|
||||||
@ -208,6 +206,8 @@ peers.on('connection', async socket => {
|
|||||||
// https://mediasoup.org/documentation/v3/mediasoup/api/#router-close
|
// https://mediasoup.org/documentation/v3/mediasoup/api/#router-close
|
||||||
router[callId].close()
|
router[callId].close()
|
||||||
delete router[callId]
|
delete router[callId]
|
||||||
|
producer.close()
|
||||||
|
consumer.close()
|
||||||
})
|
})
|
||||||
|
|
||||||
// from the consumer extract the following params
|
// from the consumer extract the following params
|
||||||
@ -278,7 +278,7 @@ const createWebRtcTransportLayer = async (callId, callback) => {
|
|||||||
dtlsParameters: transport.dtlsParameters,
|
dtlsParameters: transport.dtlsParameters,
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('params', params);
|
// console.log('params', params);
|
||||||
|
|
||||||
// send back to the client the following prameters
|
// send back to the client the following prameters
|
||||||
callback({
|
callback({
|
||||||
|
Reference in New Issue
Block a user