Update server
This commit is contained in:
parent
3bc15fdef1
commit
e085d22e89
37
app.js
37
app.js
@ -397,29 +397,30 @@ peers.on('connection', async socket => {
|
||||
closeCall(callId);
|
||||
});
|
||||
|
||||
videoCalls[callId].consumerAudio = await videoCalls[callId].consumerTransport.consume({
|
||||
producerId: videoCalls[callId].producerAudio.id,
|
||||
rtpCapabilities,
|
||||
paused: true,
|
||||
});
|
||||
|
||||
// https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-on-transportclose
|
||||
videoCalls[callId].consumerAudio.on('transportclose', () => {
|
||||
const callId = socketDetails[socket.id];
|
||||
console.log('transport close from consumer', callId);
|
||||
closeCall(callId);
|
||||
});
|
||||
// videoCalls[callId].consumerAudio = await videoCalls[callId].consumerTransport.consume({
|
||||
// producerId: videoCalls[callId].producerAudio.id,
|
||||
// rtpCapabilities,
|
||||
// paused: true,
|
||||
// });
|
||||
|
||||
// https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-on-producerclose
|
||||
videoCalls[callId].consumerAudio.on('producerclose', () => {
|
||||
const callId = socketDetails[socket.id];
|
||||
console.log('producer of consumer closed', callId);
|
||||
closeCall(callId);
|
||||
});
|
||||
// // https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-on-transportclose
|
||||
// videoCalls[callId].consumerAudio.on('transportclose', () => {
|
||||
// const callId = socketDetails[socket.id];
|
||||
// console.log('transport close from consumer', callId);
|
||||
// closeCall(callId);
|
||||
// });
|
||||
|
||||
// // https://mediasoup.org/documentation/v3/mediasoup/api/#consumer-on-producerclose
|
||||
// videoCalls[callId].consumerAudio.on('producerclose', () => {
|
||||
// const callId = socketDetails[socket.id];
|
||||
// console.log('producer of consumer closed', callId);
|
||||
// closeCall(callId);
|
||||
// });
|
||||
|
||||
console.log('🟠 videoCalls[callId].consumerVideo', videoCalls[callId].consumerVideo);
|
||||
console.log('🟠 videoCalls[callId].consumerAudio', videoCalls[callId].consumerAudio);
|
||||
|
||||
|
||||
// From the consumer extract the following params to send back to the Client
|
||||
const videoParams = {
|
||||
id: videoCalls[callId].consumerVideo.id,
|
||||
|
@ -20372,8 +20372,38 @@ console.log('[URL] ASSET_ID', ASSET_ID, '| ACCOUNT_ID', ACCOUNT_ID, '| callId',
|
||||
|
||||
console.log('🟩 config', config)
|
||||
|
||||
let socket, hub, having
|
||||
let socket, hub
|
||||
let doIHaveAudio = false
|
||||
let device
|
||||
let rtpCapabilities
|
||||
let producerTransport
|
||||
let consumerTransport
|
||||
let producerVideo
|
||||
let producerAudio
|
||||
let consumer
|
||||
let originAssetId
|
||||
|
||||
// https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerOptions
|
||||
// https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce
|
||||
let videoParams = {
|
||||
encodings: [
|
||||
{ scaleResolutionDownBy: 4, maxBitrate: 500000 },
|
||||
{ scaleResolutionDownBy: 2, maxBitrate: 1000000 },
|
||||
{ scaleResolutionDownBy: 1, maxBitrate: 5000000 },
|
||||
{ scalabilityMode: 'S3T3_KEY' }
|
||||
],
|
||||
codecOptions: {
|
||||
videoGoogleStartBitrate: 1000
|
||||
}
|
||||
}
|
||||
|
||||
let audioParams = {
|
||||
codecOptions :
|
||||
{
|
||||
opusStereo : true,
|
||||
opusDtx : true
|
||||
}
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
hub = io(config.hubAddress)
|
||||
@ -20449,60 +20479,6 @@ setTimeout(() => {
|
||||
|
||||
}, 1600);
|
||||
|
||||
|
||||
let device
|
||||
let rtpCapabilities
|
||||
let producerTransport
|
||||
let consumerTransport
|
||||
let producerVideo
|
||||
let producerAudio
|
||||
let consumer
|
||||
let originAssetId
|
||||
|
||||
// https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerOptions
|
||||
// https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce
|
||||
let videoParams = {
|
||||
encodings: [
|
||||
{ scaleResolutionDownBy: 4, maxBitrate: 500000 },
|
||||
{ scaleResolutionDownBy: 2, maxBitrate: 1000000 },
|
||||
{ scaleResolutionDownBy: 1, maxBitrate: 5000000 },
|
||||
{ scalabilityMode: 'S3T3_KEY' }
|
||||
],
|
||||
codecOptions: {
|
||||
videoGoogleStartBitrate: 1000
|
||||
}
|
||||
// encodings: [
|
||||
// {
|
||||
// rid: 'r0',
|
||||
// maxBitrate: 100000,
|
||||
// scalabilityMode: 'S1T3',
|
||||
// },
|
||||
// {
|
||||
// rid: 'r1',
|
||||
// maxBitrate: 300000,
|
||||
// scalabilityMode: 'S1T3',
|
||||
// },
|
||||
// {
|
||||
// rid: 'r2',
|
||||
// maxBitrate: 900000,
|
||||
// scalabilityMode: 'S1T3',
|
||||
// },
|
||||
// ],
|
||||
// // https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerCodecOptions
|
||||
// codecOptions: {
|
||||
// videoGoogleStartBitrate: 1000
|
||||
// }
|
||||
}
|
||||
|
||||
let audioParams = {
|
||||
codecOptions :
|
||||
{
|
||||
opusStereo : true,
|
||||
opusDtx : true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const streamSuccess = (stream) => {
|
||||
console.log('[streamSuccess] device', device);
|
||||
localVideo.srcObject = stream
|
||||
@ -20552,7 +20528,7 @@ const getLocalStream = () => {
|
||||
navigator.permissions.query(
|
||||
{ name: 'microphone' }
|
||||
).then(function(permissionStatus) {
|
||||
|
||||
|
||||
console.log('🟨 [PERMISSION] onchange', permissionStatus.state); // granted, denied, prompt
|
||||
|
||||
// If he has entered before, the saved access is already saved
|
||||
@ -20713,6 +20689,8 @@ const connectSendTransport = async () => {
|
||||
// close video track
|
||||
})
|
||||
|
||||
// Video is mandatory, but audio may not be included
|
||||
if (doIHaveAudio) {
|
||||
console.log('audioParams', audioParams);
|
||||
producerAudio = await producerTransport.produce(audioParams)
|
||||
console.log('producerAudio', producerAudio);
|
||||
@ -20723,14 +20701,9 @@ const connectSendTransport = async () => {
|
||||
|
||||
producerAudio.on('transportclose', () => {
|
||||
console.log('transport ended')
|
||||
|
||||
// close video track
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
const answer = {
|
||||
origin_asset_id: ASSET_ID,
|
||||
|
@ -14,8 +14,38 @@ console.log('[URL] ASSET_ID', ASSET_ID, '| ACCOUNT_ID', ACCOUNT_ID, '| callId',
|
||||
|
||||
console.log('🟩 config', config)
|
||||
|
||||
let socket, hub, having
|
||||
let socket, hub
|
||||
let doIHaveAudio = false
|
||||
let device
|
||||
let rtpCapabilities
|
||||
let producerTransport
|
||||
let consumerTransport
|
||||
let producerVideo
|
||||
let producerAudio
|
||||
let consumer
|
||||
let originAssetId
|
||||
|
||||
// https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerOptions
|
||||
// https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce
|
||||
let videoParams = {
|
||||
encodings: [
|
||||
{ scaleResolutionDownBy: 4, maxBitrate: 500000 },
|
||||
{ scaleResolutionDownBy: 2, maxBitrate: 1000000 },
|
||||
{ scaleResolutionDownBy: 1, maxBitrate: 5000000 },
|
||||
{ scalabilityMode: 'S3T3_KEY' }
|
||||
],
|
||||
codecOptions: {
|
||||
videoGoogleStartBitrate: 1000
|
||||
}
|
||||
}
|
||||
|
||||
let audioParams = {
|
||||
codecOptions :
|
||||
{
|
||||
opusStereo : true,
|
||||
opusDtx : true
|
||||
}
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
hub = io(config.hubAddress)
|
||||
@ -91,60 +121,6 @@ setTimeout(() => {
|
||||
|
||||
}, 1600);
|
||||
|
||||
|
||||
let device
|
||||
let rtpCapabilities
|
||||
let producerTransport
|
||||
let consumerTransport
|
||||
let producerVideo
|
||||
let producerAudio
|
||||
let consumer
|
||||
let originAssetId
|
||||
|
||||
// https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerOptions
|
||||
// https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce
|
||||
let videoParams = {
|
||||
encodings: [
|
||||
{ scaleResolutionDownBy: 4, maxBitrate: 500000 },
|
||||
{ scaleResolutionDownBy: 2, maxBitrate: 1000000 },
|
||||
{ scaleResolutionDownBy: 1, maxBitrate: 5000000 },
|
||||
{ scalabilityMode: 'S3T3_KEY' }
|
||||
],
|
||||
codecOptions: {
|
||||
videoGoogleStartBitrate: 1000
|
||||
}
|
||||
// encodings: [
|
||||
// {
|
||||
// rid: 'r0',
|
||||
// maxBitrate: 100000,
|
||||
// scalabilityMode: 'S1T3',
|
||||
// },
|
||||
// {
|
||||
// rid: 'r1',
|
||||
// maxBitrate: 300000,
|
||||
// scalabilityMode: 'S1T3',
|
||||
// },
|
||||
// {
|
||||
// rid: 'r2',
|
||||
// maxBitrate: 900000,
|
||||
// scalabilityMode: 'S1T3',
|
||||
// },
|
||||
// ],
|
||||
// // https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerCodecOptions
|
||||
// codecOptions: {
|
||||
// videoGoogleStartBitrate: 1000
|
||||
// }
|
||||
}
|
||||
|
||||
let audioParams = {
|
||||
codecOptions :
|
||||
{
|
||||
opusStereo : true,
|
||||
opusDtx : true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const streamSuccess = (stream) => {
|
||||
console.log('[streamSuccess] device', device);
|
||||
localVideo.srcObject = stream
|
||||
@ -194,7 +170,7 @@ const getLocalStream = () => {
|
||||
navigator.permissions.query(
|
||||
{ name: 'microphone' }
|
||||
).then(function(permissionStatus) {
|
||||
|
||||
|
||||
console.log('🟨 [PERMISSION] onchange', permissionStatus.state); // granted, denied, prompt
|
||||
|
||||
// If he has entered before, the saved access is already saved
|
||||
@ -355,6 +331,8 @@ const connectSendTransport = async () => {
|
||||
// close video track
|
||||
})
|
||||
|
||||
// Video is mandatory, but audio may not be included
|
||||
if (doIHaveAudio) {
|
||||
console.log('audioParams', audioParams);
|
||||
producerAudio = await producerTransport.produce(audioParams)
|
||||
console.log('producerAudio', producerAudio);
|
||||
@ -365,14 +343,9 @@ const connectSendTransport = async () => {
|
||||
|
||||
producerAudio.on('transportclose', () => {
|
||||
console.log('transport ended')
|
||||
|
||||
// close video track
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
const answer = {
|
||||
origin_asset_id: ASSET_ID,
|
||||
|
Loading…
Reference in New Issue
Block a user