Update server
This commit is contained in:
parent
fc745a5879
commit
4bb23def42
@ -20527,23 +20527,9 @@ const getLocalStream = () => {
|
||||
|
||||
navigator.permissions.query(
|
||||
{ name: 'microphone' }
|
||||
).then(function(permissionStatus) {
|
||||
|
||||
console.log('🟨 [PERMISSION] onchange1', permissionStatus.state); // granted, denied, prompt
|
||||
|
||||
// If he has entered before, the saved access is already saved
|
||||
if (permissionStatus === 'grated') {
|
||||
doIHaveAudio = true;
|
||||
}
|
||||
|
||||
// If it is the first time client enter and give permission
|
||||
permissionStatus.onchange = function() {
|
||||
console.log('🟨 [PERMISSION] onchange2', this.state);
|
||||
if (this.state === 'grated') {
|
||||
// doIHaveAudio = true;
|
||||
}
|
||||
}
|
||||
|
||||
).then((permissionStatus) =>{
|
||||
console.log('🟨 [PERMISSION] permissionStatus', permissionStatus); // granted, denied, prompt
|
||||
// It will block the code from execution and display "Permission denied" if we don't have microphone permissions
|
||||
})
|
||||
|
||||
}
|
||||
@ -20645,7 +20631,7 @@ const createSendTransport = () => {
|
||||
console.log('[produce] parameters', parameters)
|
||||
|
||||
try {
|
||||
// tell the server to create a Producer
|
||||
// Tell the server to create a Producer
|
||||
// with the following parameters and produce
|
||||
// and expect back a server side producer id
|
||||
// see server's socket.on('transport-produce', ...)
|
||||
@ -20671,14 +20657,16 @@ const connectSendTransport = async () => {
|
||||
|
||||
console.log('[connectSendTransport] producerTransport');
|
||||
|
||||
// we now call produce() to instruct the producer transport
|
||||
// We now call produce() to instruct the producer transport
|
||||
// to send media to the Router
|
||||
// https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce
|
||||
// this action will trigger the 'connect' and 'produce' events above
|
||||
|
||||
console.log('videoParams', videoParams);
|
||||
// Produce video
|
||||
producerVideo = await producerTransport.produce(videoParams)
|
||||
console.log('videoParams', videoParams);
|
||||
console.log('producerVideo', producerVideo);
|
||||
|
||||
producerVideo.on('trackended', () => {
|
||||
console.log('track ended')
|
||||
// close video track
|
||||
@ -20689,21 +20677,20 @@ const connectSendTransport = async () => {
|
||||
// close video track
|
||||
})
|
||||
|
||||
// Video is mandatory, but audio may not be included
|
||||
// if (doIHaveAudio) {
|
||||
console.log('audioParams', audioParams);
|
||||
// Produce audio
|
||||
producerAudio = await producerTransport.produce(audioParams)
|
||||
console.log('audioParams', audioParams);
|
||||
console.log('producerAudio', producerAudio);
|
||||
|
||||
producerAudio.on('trackended', () => {
|
||||
console.log('track ended')
|
||||
// close video track
|
||||
// close audio track
|
||||
})
|
||||
|
||||
producerAudio.on('transportclose', () => {
|
||||
console.log('transport ended')
|
||||
// close video track
|
||||
// close audio track
|
||||
})
|
||||
// }
|
||||
|
||||
const answer = {
|
||||
origin_asset_id: ASSET_ID,
|
||||
@ -20713,7 +20700,7 @@ const connectSendTransport = async () => {
|
||||
origin_asset_type_name: ASSET_TYPE,
|
||||
origin_asset_name: ASSET_NAME,
|
||||
video_call_id: callId,
|
||||
answer: 'accepted', // answer: 'rejected'
|
||||
answer: 'accepted', // answer: accepted/rejected
|
||||
};
|
||||
console.log('SEND answer', answer);
|
||||
|
||||
@ -20729,7 +20716,7 @@ const connectSendTransport = async () => {
|
||||
|
||||
const createRecvTransport = async () => {
|
||||
console.log('createRecvTransport');
|
||||
// see server's socket.on('consume', sender?, ...)
|
||||
// See server's socket.on('consume', sender?, ...)
|
||||
// this is a call from Consumer, so sender = false
|
||||
await socket.emit('createWebRtcTransport', { sender: false, callId }, ({ params }) => {
|
||||
// The server sends back params needed
|
||||
@ -20741,13 +20728,13 @@ const createRecvTransport = async () => {
|
||||
|
||||
console.log('[createRecvTransport] params', params)
|
||||
|
||||
// creates a new WebRTC Transport to receive media
|
||||
// Creates a new WebRTC Transport to receive media
|
||||
// based on server's consumer transport params
|
||||
// https://mediasoup.org/documentation/v3/mediasoup-client/api/#device-createRecvTransport
|
||||
consumerTransport = device.createRecvTransport(params)
|
||||
|
||||
// https://mediasoup.org/documentation/v3/communication-between-client-and-server/#producing-media
|
||||
// this event is raised when a first call to transport.produce() is made
|
||||
// This event is raised when a first call to transport.produce() is made
|
||||
// see connectRecvTransport() below
|
||||
consumerTransport.on('connect', async ({ dtlsParameters }, callback, errback) => {
|
||||
try {
|
||||
@ -20781,7 +20768,7 @@ const resetCallSettings = () => {
|
||||
|
||||
const connectRecvTransport = async () => {
|
||||
console.log('connectRecvTransport');
|
||||
// for consumer, we need to tell the server first
|
||||
// For consumer, we need to tell the server first
|
||||
// to create a consumer based on the rtpCapabilities and consume
|
||||
// if the router can consume, it will send back a set of params as below
|
||||
await socket.emit('consume', {
|
||||
@ -20793,7 +20780,7 @@ const connectRecvTransport = async () => {
|
||||
return
|
||||
}
|
||||
|
||||
// then consume with the local consumer transport
|
||||
// Then consume with the local consumer transport
|
||||
// which creates a consumer
|
||||
consumer = await consumerTransport.consume({
|
||||
id: params.id,
|
||||
|
@ -169,23 +169,9 @@ const getLocalStream = () => {
|
||||
|
||||
navigator.permissions.query(
|
||||
{ name: 'microphone' }
|
||||
).then(function(permissionStatus) {
|
||||
|
||||
console.log('🟨 [PERMISSION] onchange1', permissionStatus.state); // granted, denied, prompt
|
||||
|
||||
// If he has entered before, the saved access is already saved
|
||||
if (permissionStatus === 'grated') {
|
||||
doIHaveAudio = true;
|
||||
}
|
||||
|
||||
// If it is the first time client enter and give permission
|
||||
permissionStatus.onchange = function() {
|
||||
console.log('🟨 [PERMISSION] onchange2', this.state);
|
||||
if (this.state === 'grated') {
|
||||
// doIHaveAudio = true;
|
||||
}
|
||||
}
|
||||
|
||||
).then((permissionStatus) =>{
|
||||
console.log('🟨 [PERMISSION] permissionStatus', permissionStatus); // granted, denied, prompt
|
||||
// It will block the code from execution and display "Permission denied" if we don't have microphone permissions
|
||||
})
|
||||
|
||||
}
|
||||
@ -287,7 +273,7 @@ const createSendTransport = () => {
|
||||
console.log('[produce] parameters', parameters)
|
||||
|
||||
try {
|
||||
// tell the server to create a Producer
|
||||
// Tell the server to create a Producer
|
||||
// with the following parameters and produce
|
||||
// and expect back a server side producer id
|
||||
// see server's socket.on('transport-produce', ...)
|
||||
@ -313,14 +299,16 @@ const connectSendTransport = async () => {
|
||||
|
||||
console.log('[connectSendTransport] producerTransport');
|
||||
|
||||
// we now call produce() to instruct the producer transport
|
||||
// We now call produce() to instruct the producer transport
|
||||
// to send media to the Router
|
||||
// https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce
|
||||
// this action will trigger the 'connect' and 'produce' events above
|
||||
|
||||
console.log('videoParams', videoParams);
|
||||
// Produce video
|
||||
producerVideo = await producerTransport.produce(videoParams)
|
||||
console.log('videoParams', videoParams);
|
||||
console.log('producerVideo', producerVideo);
|
||||
|
||||
producerVideo.on('trackended', () => {
|
||||
console.log('track ended')
|
||||
// close video track
|
||||
@ -331,21 +319,20 @@ const connectSendTransport = async () => {
|
||||
// close video track
|
||||
})
|
||||
|
||||
// Video is mandatory, but audio may not be included
|
||||
// if (doIHaveAudio) {
|
||||
console.log('audioParams', audioParams);
|
||||
// Produce audio
|
||||
producerAudio = await producerTransport.produce(audioParams)
|
||||
console.log('audioParams', audioParams);
|
||||
console.log('producerAudio', producerAudio);
|
||||
|
||||
producerAudio.on('trackended', () => {
|
||||
console.log('track ended')
|
||||
// close video track
|
||||
// close audio track
|
||||
})
|
||||
|
||||
producerAudio.on('transportclose', () => {
|
||||
console.log('transport ended')
|
||||
// close video track
|
||||
// close audio track
|
||||
})
|
||||
// }
|
||||
|
||||
const answer = {
|
||||
origin_asset_id: ASSET_ID,
|
||||
@ -355,7 +342,7 @@ const connectSendTransport = async () => {
|
||||
origin_asset_type_name: ASSET_TYPE,
|
||||
origin_asset_name: ASSET_NAME,
|
||||
video_call_id: callId,
|
||||
answer: 'accepted', // answer: 'rejected'
|
||||
answer: 'accepted', // answer: accepted/rejected
|
||||
};
|
||||
console.log('SEND answer', answer);
|
||||
|
||||
@ -371,7 +358,7 @@ const connectSendTransport = async () => {
|
||||
|
||||
const createRecvTransport = async () => {
|
||||
console.log('createRecvTransport');
|
||||
// see server's socket.on('consume', sender?, ...)
|
||||
// See server's socket.on('consume', sender?, ...)
|
||||
// this is a call from Consumer, so sender = false
|
||||
await socket.emit('createWebRtcTransport', { sender: false, callId }, ({ params }) => {
|
||||
// The server sends back params needed
|
||||
@ -383,13 +370,13 @@ const createRecvTransport = async () => {
|
||||
|
||||
console.log('[createRecvTransport] params', params)
|
||||
|
||||
// creates a new WebRTC Transport to receive media
|
||||
// Creates a new WebRTC Transport to receive media
|
||||
// based on server's consumer transport params
|
||||
// https://mediasoup.org/documentation/v3/mediasoup-client/api/#device-createRecvTransport
|
||||
consumerTransport = device.createRecvTransport(params)
|
||||
|
||||
// https://mediasoup.org/documentation/v3/communication-between-client-and-server/#producing-media
|
||||
// this event is raised when a first call to transport.produce() is made
|
||||
// This event is raised when a first call to transport.produce() is made
|
||||
// see connectRecvTransport() below
|
||||
consumerTransport.on('connect', async ({ dtlsParameters }, callback, errback) => {
|
||||
try {
|
||||
@ -423,7 +410,7 @@ const resetCallSettings = () => {
|
||||
|
||||
const connectRecvTransport = async () => {
|
||||
console.log('connectRecvTransport');
|
||||
// for consumer, we need to tell the server first
|
||||
// For consumer, we need to tell the server first
|
||||
// to create a consumer based on the rtpCapabilities and consume
|
||||
// if the router can consume, it will send back a set of params as below
|
||||
await socket.emit('consume', {
|
||||
@ -435,7 +422,7 @@ const connectRecvTransport = async () => {
|
||||
return
|
||||
}
|
||||
|
||||
// then consume with the local consumer transport
|
||||
// Then consume with the local consumer transport
|
||||
// which creates a consumer
|
||||
consumer = await consumerTransport.consume({
|
||||
id: params.id,
|
||||
|
Loading…
Reference in New Issue
Block a user