Compare commits
117 Commits
4.05
...
fc745a5879
Author | SHA1 | Date | |
---|---|---|---|
fc745a5879 | |||
742d67f2e3 | |||
e22093d97e | |||
7634a18465 | |||
d17b035526 | |||
a21451e46d | |||
df0cb81a8e | |||
ac8c651a9d | |||
9111c4e245 | |||
7a2d02dcda | |||
39efdd12b7 | |||
0bdc6fac3a | |||
ae7a8ed9ce | |||
9feaebf8a7 | |||
85110b7f5c | |||
d047cdf7d1 | |||
753b476462 | |||
359c7c784e | |||
5169d0d49f | |||
a3b083fe24 | |||
46d3499e3d | |||
38b95d5246 | |||
984b2b892e | |||
e085d22e89 | |||
3bc15fdef1 | |||
67042185c4 | |||
c92dff9bfe | |||
3605ca0468 | |||
1edbcb2179 | |||
adbcf6c2bc | |||
c862224ead | |||
c02a7c7380 | |||
3387a362a6 | |||
21dffefa8c | |||
1369491529 | |||
56bdbca537 | |||
8444809910 | |||
cd84c534ce | |||
038bdb99bc | |||
d94ea12a40 | |||
1148532a9b | |||
3561bb13a6 | |||
22ead926b0 | |||
c6edb2947d | |||
e59f134a68 | |||
aad96b72f2 | |||
3e4c0a32bc | |||
2a7bd42247 | |||
f2c0794bf4 | |||
950298c4f6 | |||
6e74083733 | |||
8ef6c2abb0 | |||
2a86042c80 | |||
56b8e2ea74 | |||
6c42814229 | |||
e65b7e0d7c | |||
aa7c2aea90 | |||
458342c0d2 | |||
fa5a1a5ae7 | |||
9fbe01ae1d | |||
e5bcc6262b | |||
c758a9106c | |||
fcbc28c801 | |||
ba63fb20bf | |||
e8bd6837cf | |||
d386915ff2 | |||
2479f58e21 | |||
d49b8e42ff | |||
a3ae874f8e | |||
c2dbef1918 | |||
b41b8f2d64 | |||
c089e91fba | |||
c63aee83a1 | |||
a97ec24148 | |||
3c23c6791d | |||
1a7b44807d | |||
daa2c556e4 | |||
22656722e8 | |||
f5b9067b7e | |||
0b3a45ae45 | |||
dfe4630839 | |||
d18041cadd | |||
fa42caeeb2 | |||
4dbb7ad554 | |||
d1063803b9 | |||
3cbd31b49c | |||
a39e0eaa17 | |||
b63fb39fd4 | |||
0dfbd296a7 | |||
233f49a998 | |||
127f17cd97 | |||
d1ad8b4d3a | |||
f20e1ad260 | |||
27151a26d1 | |||
544e9e59ab | |||
4e4cd6f893 | |||
e9ff060544 | |||
7d677f4a34 | |||
8f96b8c98b | |||
1084a808c7 | |||
3838f774bf | |||
06bb275f0d | |||
a05f7cc987 | |||
c5c8bc5bb3 | |||
d6bc4e51e5 | |||
4ae02f70d6 | |||
d593d6dc83 | |||
1a1fa9450e | |||
0d24604f2a | |||
1d7c994036 | |||
bc2bf24a65 | |||
cdbfc7891d | |||
c730341674 | |||
b621b76e37 | |||
39ad9cad27 | |||
8860423e21 | |||
9179a67f64 |
10
README.md
10
README.md
@ -22,20 +22,18 @@
|
|||||||
2. Run the `npm start:prod` command to start the server in production mode.
|
2. Run the `npm start:prod` command to start the server in production mode.
|
||||||
(To connect to the terminal, use `pm2 log video-server`)
|
(To connect to the terminal, use `pm2 log video-server`)
|
||||||
|
|
||||||
|
---
|
||||||
### Web client
|
|
||||||
|
|
||||||
- The server will start by default on port 3000, and the ssl certificates will have to be configured
|
- The server will start by default on port 3000, and the ssl certificates will have to be configured
|
||||||
- The web client can be accessed using the /sfu path
|
- The web client can be accessed using the /sfu path
|
||||||
ex: https://HOST/sfu/?assetId=1&&accountId=1&producer=true&dest_asset_id=75&assetName=Adi
|
ex: http://localhost:3000/sfu/?assetId=1&&accountId=1&producer=true&assetName=Adi&assetType=linx
|
||||||
assetId = asset id of the unit on which you are doing the test
|
assetId = asset id of the unit on which you are doing the test
|
||||||
accountId = account id of the unit on which you are doing the test
|
accountId = account id of the unit on which you are doing the test
|
||||||
producer = it will always be true because you are the producer
|
producer = it will always be true because you are the producer
|
||||||
(it's possible to put false, but then you have to have another client with producer true)
|
(it's possible to put false, but then you have to have another client with producer true)
|
||||||
assetName = asset name of the unit on which you are doing the test
|
assetName = asset name of the unit on which you are doing the test
|
||||||
dest_asset_id= the addressee with whom the call is made
|
assetType = asset type of the unit on which you are doing the test
|
||||||
- To make a call using this client, you need a microphone and permission to use it
|
|
||||||
- For any changes related to the client, the command `npm run watch' will have to be used to generate the bundle.js used by the web client
|
|
||||||
|
|
||||||
### Demo project
|
### Demo project
|
||||||
The demo project used initially and then modified for our needs `https://github.com/jamalag/mediasoup2`
|
The demo project used initially and then modified for our needs `https://github.com/jamalag/mediasoup2`
|
||||||
|
|
||||||
|
@ -20373,6 +20373,7 @@ console.log('[URL] ASSET_ID', ASSET_ID, '| ACCOUNT_ID', ACCOUNT_ID, '| callId',
|
|||||||
console.log('🟩 config', config)
|
console.log('🟩 config', config)
|
||||||
|
|
||||||
let socket, hub
|
let socket, hub
|
||||||
|
let doIHaveAudio = false
|
||||||
let device
|
let device
|
||||||
let rtpCapabilities
|
let rtpCapabilities
|
||||||
let producerTransport
|
let producerTransport
|
||||||
@ -20487,6 +20488,8 @@ const streamSuccess = (stream) => {
|
|||||||
|
|
||||||
videoParams = {
|
videoParams = {
|
||||||
track: videoTrack,
|
track: videoTrack,
|
||||||
|
// codec : device.rtpCapabilities.codecs.find((codec) => codec.mimeType.toLowerCase() === 'video/vp9'),
|
||||||
|
// codec : 'video/vp9',
|
||||||
...videoParams
|
...videoParams
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -20497,6 +20500,14 @@ const streamSuccess = (stream) => {
|
|||||||
|
|
||||||
console.log('[streamSuccess] videoParams', videoParams, ' | audioParams', audioParams);
|
console.log('[streamSuccess] videoParams', videoParams, ' | audioParams', audioParams);
|
||||||
goConnect()
|
goConnect()
|
||||||
|
// console.log('[streamSuccess]');
|
||||||
|
// localVideo.srcObject = stream
|
||||||
|
// const track = stream.getVideoTracks()[0]
|
||||||
|
// videoParams = {
|
||||||
|
// track,
|
||||||
|
// ...videoParams
|
||||||
|
// }
|
||||||
|
// goConnect()
|
||||||
}
|
}
|
||||||
|
|
||||||
const getLocalStream = () => {
|
const getLocalStream = () => {
|
||||||
@ -20516,9 +20527,23 @@ const getLocalStream = () => {
|
|||||||
|
|
||||||
navigator.permissions.query(
|
navigator.permissions.query(
|
||||||
{ name: 'microphone' }
|
{ name: 'microphone' }
|
||||||
).then((permissionStatus) =>{
|
).then(function(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
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -20537,6 +20562,7 @@ const goCreateTransport = () => {
|
|||||||
// server side to send/recive media
|
// server side to send/recive media
|
||||||
const createDevice = async () => {
|
const createDevice = async () => {
|
||||||
try {
|
try {
|
||||||
|
console.log('[createDevice] 1 device', device);
|
||||||
device = new mediasoupClient.Device()
|
device = new mediasoupClient.Device()
|
||||||
|
|
||||||
// https://mediasoup.org/documentation/v3/mediasoup-client/api/#device-load
|
// https://mediasoup.org/documentation/v3/mediasoup-client/api/#device-load
|
||||||
@ -20547,7 +20573,7 @@ const createDevice = async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
console.log('Device RTP Capabilities', device.rtpCapabilities)
|
console.log('Device RTP Capabilities', device.rtpCapabilities)
|
||||||
console.log('[createDevice] device', device);
|
console.log('[createDevice] 2 device', device);
|
||||||
|
|
||||||
// once the device loads, create transport
|
// once the device loads, create transport
|
||||||
goCreateTransport()
|
goCreateTransport()
|
||||||
@ -20619,7 +20645,7 @@ const createSendTransport = () => {
|
|||||||
console.log('[produce] parameters', parameters)
|
console.log('[produce] parameters', parameters)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Tell the server to create a Producer
|
// tell the server to create a Producer
|
||||||
// with the following parameters and produce
|
// with the following parameters and produce
|
||||||
// and expect back a server side producer id
|
// and expect back a server side producer id
|
||||||
// see server's socket.on('transport-produce', ...)
|
// see server's socket.on('transport-produce', ...)
|
||||||
@ -20645,16 +20671,14 @@ const connectSendTransport = async () => {
|
|||||||
|
|
||||||
console.log('[connectSendTransport] producerTransport');
|
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
|
// to send media to the Router
|
||||||
// https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce
|
// https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce
|
||||||
// this action will trigger the 'connect' and 'produce' events above
|
// this action will trigger the 'connect' and 'produce' events above
|
||||||
|
|
||||||
// Produce video
|
|
||||||
producerVideo = await producerTransport.produce(videoParams)
|
|
||||||
console.log('videoParams', videoParams);
|
console.log('videoParams', videoParams);
|
||||||
|
producerVideo = await producerTransport.produce(videoParams)
|
||||||
console.log('producerVideo', producerVideo);
|
console.log('producerVideo', producerVideo);
|
||||||
|
|
||||||
producerVideo.on('trackended', () => {
|
producerVideo.on('trackended', () => {
|
||||||
console.log('track ended')
|
console.log('track ended')
|
||||||
// close video track
|
// close video track
|
||||||
@ -20665,20 +20689,21 @@ const connectSendTransport = async () => {
|
|||||||
// close video track
|
// close video track
|
||||||
})
|
})
|
||||||
|
|
||||||
// Produce audio
|
// Video is mandatory, but audio may not be included
|
||||||
producerAudio = await producerTransport.produce(audioParams)
|
// if (doIHaveAudio) {
|
||||||
console.log('audioParams', audioParams);
|
console.log('audioParams', audioParams);
|
||||||
console.log('producerAudio', producerAudio);
|
producerAudio = await producerTransport.produce(audioParams)
|
||||||
|
console.log('producerAudio', producerAudio);
|
||||||
|
producerAudio.on('trackended', () => {
|
||||||
|
console.log('track ended')
|
||||||
|
// close video track
|
||||||
|
})
|
||||||
|
|
||||||
producerAudio.on('trackended', () => {
|
producerAudio.on('transportclose', () => {
|
||||||
console.log('track ended')
|
console.log('transport ended')
|
||||||
// close audio track
|
// close video track
|
||||||
})
|
})
|
||||||
|
// }
|
||||||
producerAudio.on('transportclose', () => {
|
|
||||||
console.log('transport ended')
|
|
||||||
// close audio track
|
|
||||||
})
|
|
||||||
|
|
||||||
const answer = {
|
const answer = {
|
||||||
origin_asset_id: ASSET_ID,
|
origin_asset_id: ASSET_ID,
|
||||||
@ -20688,7 +20713,7 @@ const connectSendTransport = async () => {
|
|||||||
origin_asset_type_name: ASSET_TYPE,
|
origin_asset_type_name: ASSET_TYPE,
|
||||||
origin_asset_name: ASSET_NAME,
|
origin_asset_name: ASSET_NAME,
|
||||||
video_call_id: callId,
|
video_call_id: callId,
|
||||||
answer: 'accepted', // answer: accepted/rejected
|
answer: 'accepted', // answer: 'rejected'
|
||||||
};
|
};
|
||||||
console.log('SEND answer', answer);
|
console.log('SEND answer', answer);
|
||||||
|
|
||||||
@ -20704,7 +20729,7 @@ const connectSendTransport = async () => {
|
|||||||
|
|
||||||
const createRecvTransport = async () => {
|
const createRecvTransport = async () => {
|
||||||
console.log('createRecvTransport');
|
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
|
// this is a call from Consumer, so sender = false
|
||||||
await socket.emit('createWebRtcTransport', { sender: false, callId }, ({ params }) => {
|
await socket.emit('createWebRtcTransport', { sender: false, callId }, ({ params }) => {
|
||||||
// The server sends back params needed
|
// The server sends back params needed
|
||||||
@ -20716,13 +20741,13 @@ const createRecvTransport = async () => {
|
|||||||
|
|
||||||
console.log('[createRecvTransport] params', params)
|
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
|
// based on server's consumer transport params
|
||||||
// https://mediasoup.org/documentation/v3/mediasoup-client/api/#device-createRecvTransport
|
// https://mediasoup.org/documentation/v3/mediasoup-client/api/#device-createRecvTransport
|
||||||
consumerTransport = device.createRecvTransport(params)
|
consumerTransport = device.createRecvTransport(params)
|
||||||
|
|
||||||
// https://mediasoup.org/documentation/v3/communication-between-client-and-server/#producing-media
|
// 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
|
// see connectRecvTransport() below
|
||||||
consumerTransport.on('connect', async ({ dtlsParameters }, callback, errback) => {
|
consumerTransport.on('connect', async ({ dtlsParameters }, callback, errback) => {
|
||||||
try {
|
try {
|
||||||
@ -20756,7 +20781,7 @@ const resetCallSettings = () => {
|
|||||||
|
|
||||||
const connectRecvTransport = async () => {
|
const connectRecvTransport = async () => {
|
||||||
console.log('connectRecvTransport');
|
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
|
// 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
|
// if the router can consume, it will send back a set of params as below
|
||||||
await socket.emit('consume', {
|
await socket.emit('consume', {
|
||||||
@ -20768,7 +20793,7 @@ const connectRecvTransport = async () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then consume with the local consumer transport
|
// then consume with the local consumer transport
|
||||||
// which creates a consumer
|
// which creates a consumer
|
||||||
consumer = await consumerTransport.consume({
|
consumer = await consumerTransport.consume({
|
||||||
id: params.id,
|
id: params.id,
|
||||||
|
@ -15,6 +15,7 @@ console.log('[URL] ASSET_ID', ASSET_ID, '| ACCOUNT_ID', ACCOUNT_ID, '| callId',
|
|||||||
console.log('🟩 config', config)
|
console.log('🟩 config', config)
|
||||||
|
|
||||||
let socket, hub
|
let socket, hub
|
||||||
|
let doIHaveAudio = false
|
||||||
let device
|
let device
|
||||||
let rtpCapabilities
|
let rtpCapabilities
|
||||||
let producerTransport
|
let producerTransport
|
||||||
@ -129,6 +130,8 @@ const streamSuccess = (stream) => {
|
|||||||
|
|
||||||
videoParams = {
|
videoParams = {
|
||||||
track: videoTrack,
|
track: videoTrack,
|
||||||
|
// codec : device.rtpCapabilities.codecs.find((codec) => codec.mimeType.toLowerCase() === 'video/vp9'),
|
||||||
|
// codec : 'video/vp9',
|
||||||
...videoParams
|
...videoParams
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,6 +142,14 @@ const streamSuccess = (stream) => {
|
|||||||
|
|
||||||
console.log('[streamSuccess] videoParams', videoParams, ' | audioParams', audioParams);
|
console.log('[streamSuccess] videoParams', videoParams, ' | audioParams', audioParams);
|
||||||
goConnect()
|
goConnect()
|
||||||
|
// console.log('[streamSuccess]');
|
||||||
|
// localVideo.srcObject = stream
|
||||||
|
// const track = stream.getVideoTracks()[0]
|
||||||
|
// videoParams = {
|
||||||
|
// track,
|
||||||
|
// ...videoParams
|
||||||
|
// }
|
||||||
|
// goConnect()
|
||||||
}
|
}
|
||||||
|
|
||||||
const getLocalStream = () => {
|
const getLocalStream = () => {
|
||||||
@ -158,9 +169,23 @@ const getLocalStream = () => {
|
|||||||
|
|
||||||
navigator.permissions.query(
|
navigator.permissions.query(
|
||||||
{ name: 'microphone' }
|
{ name: 'microphone' }
|
||||||
).then((permissionStatus) =>{
|
).then(function(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
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -179,6 +204,7 @@ const goCreateTransport = () => {
|
|||||||
// server side to send/recive media
|
// server side to send/recive media
|
||||||
const createDevice = async () => {
|
const createDevice = async () => {
|
||||||
try {
|
try {
|
||||||
|
console.log('[createDevice] 1 device', device);
|
||||||
device = new mediasoupClient.Device()
|
device = new mediasoupClient.Device()
|
||||||
|
|
||||||
// https://mediasoup.org/documentation/v3/mediasoup-client/api/#device-load
|
// https://mediasoup.org/documentation/v3/mediasoup-client/api/#device-load
|
||||||
@ -189,7 +215,7 @@ const createDevice = async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
console.log('Device RTP Capabilities', device.rtpCapabilities)
|
console.log('Device RTP Capabilities', device.rtpCapabilities)
|
||||||
console.log('[createDevice] device', device);
|
console.log('[createDevice] 2 device', device);
|
||||||
|
|
||||||
// once the device loads, create transport
|
// once the device loads, create transport
|
||||||
goCreateTransport()
|
goCreateTransport()
|
||||||
@ -261,7 +287,7 @@ const createSendTransport = () => {
|
|||||||
console.log('[produce] parameters', parameters)
|
console.log('[produce] parameters', parameters)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Tell the server to create a Producer
|
// tell the server to create a Producer
|
||||||
// with the following parameters and produce
|
// with the following parameters and produce
|
||||||
// and expect back a server side producer id
|
// and expect back a server side producer id
|
||||||
// see server's socket.on('transport-produce', ...)
|
// see server's socket.on('transport-produce', ...)
|
||||||
@ -287,16 +313,14 @@ const connectSendTransport = async () => {
|
|||||||
|
|
||||||
console.log('[connectSendTransport] producerTransport');
|
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
|
// to send media to the Router
|
||||||
// https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce
|
// https://mediasoup.org/documentation/v3/mediasoup-client/api/#transport-produce
|
||||||
// this action will trigger the 'connect' and 'produce' events above
|
// this action will trigger the 'connect' and 'produce' events above
|
||||||
|
|
||||||
// Produce video
|
|
||||||
producerVideo = await producerTransport.produce(videoParams)
|
|
||||||
console.log('videoParams', videoParams);
|
console.log('videoParams', videoParams);
|
||||||
|
producerVideo = await producerTransport.produce(videoParams)
|
||||||
console.log('producerVideo', producerVideo);
|
console.log('producerVideo', producerVideo);
|
||||||
|
|
||||||
producerVideo.on('trackended', () => {
|
producerVideo.on('trackended', () => {
|
||||||
console.log('track ended')
|
console.log('track ended')
|
||||||
// close video track
|
// close video track
|
||||||
@ -307,20 +331,21 @@ const connectSendTransport = async () => {
|
|||||||
// close video track
|
// close video track
|
||||||
})
|
})
|
||||||
|
|
||||||
// Produce audio
|
// Video is mandatory, but audio may not be included
|
||||||
producerAudio = await producerTransport.produce(audioParams)
|
// if (doIHaveAudio) {
|
||||||
console.log('audioParams', audioParams);
|
console.log('audioParams', audioParams);
|
||||||
console.log('producerAudio', producerAudio);
|
producerAudio = await producerTransport.produce(audioParams)
|
||||||
|
console.log('producerAudio', producerAudio);
|
||||||
|
producerAudio.on('trackended', () => {
|
||||||
|
console.log('track ended')
|
||||||
|
// close video track
|
||||||
|
})
|
||||||
|
|
||||||
producerAudio.on('trackended', () => {
|
producerAudio.on('transportclose', () => {
|
||||||
console.log('track ended')
|
console.log('transport ended')
|
||||||
// close audio track
|
// close video track
|
||||||
})
|
})
|
||||||
|
// }
|
||||||
producerAudio.on('transportclose', () => {
|
|
||||||
console.log('transport ended')
|
|
||||||
// close audio track
|
|
||||||
})
|
|
||||||
|
|
||||||
const answer = {
|
const answer = {
|
||||||
origin_asset_id: ASSET_ID,
|
origin_asset_id: ASSET_ID,
|
||||||
@ -330,7 +355,7 @@ const connectSendTransport = async () => {
|
|||||||
origin_asset_type_name: ASSET_TYPE,
|
origin_asset_type_name: ASSET_TYPE,
|
||||||
origin_asset_name: ASSET_NAME,
|
origin_asset_name: ASSET_NAME,
|
||||||
video_call_id: callId,
|
video_call_id: callId,
|
||||||
answer: 'accepted', // answer: accepted/rejected
|
answer: 'accepted', // answer: 'rejected'
|
||||||
};
|
};
|
||||||
console.log('SEND answer', answer);
|
console.log('SEND answer', answer);
|
||||||
|
|
||||||
@ -346,7 +371,7 @@ const connectSendTransport = async () => {
|
|||||||
|
|
||||||
const createRecvTransport = async () => {
|
const createRecvTransport = async () => {
|
||||||
console.log('createRecvTransport');
|
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
|
// this is a call from Consumer, so sender = false
|
||||||
await socket.emit('createWebRtcTransport', { sender: false, callId }, ({ params }) => {
|
await socket.emit('createWebRtcTransport', { sender: false, callId }, ({ params }) => {
|
||||||
// The server sends back params needed
|
// The server sends back params needed
|
||||||
@ -358,13 +383,13 @@ const createRecvTransport = async () => {
|
|||||||
|
|
||||||
console.log('[createRecvTransport] params', params)
|
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
|
// based on server's consumer transport params
|
||||||
// https://mediasoup.org/documentation/v3/mediasoup-client/api/#device-createRecvTransport
|
// https://mediasoup.org/documentation/v3/mediasoup-client/api/#device-createRecvTransport
|
||||||
consumerTransport = device.createRecvTransport(params)
|
consumerTransport = device.createRecvTransport(params)
|
||||||
|
|
||||||
// https://mediasoup.org/documentation/v3/communication-between-client-and-server/#producing-media
|
// 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
|
// see connectRecvTransport() below
|
||||||
consumerTransport.on('connect', async ({ dtlsParameters }, callback, errback) => {
|
consumerTransport.on('connect', async ({ dtlsParameters }, callback, errback) => {
|
||||||
try {
|
try {
|
||||||
@ -398,7 +423,7 @@ const resetCallSettings = () => {
|
|||||||
|
|
||||||
const connectRecvTransport = async () => {
|
const connectRecvTransport = async () => {
|
||||||
console.log('connectRecvTransport');
|
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
|
// 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
|
// if the router can consume, it will send back a set of params as below
|
||||||
await socket.emit('consume', {
|
await socket.emit('consume', {
|
||||||
@ -410,7 +435,7 @@ const connectRecvTransport = async () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then consume with the local consumer transport
|
// then consume with the local consumer transport
|
||||||
// which creates a consumer
|
// which creates a consumer
|
||||||
consumer = await consumerTransport.consume({
|
consumer = await consumerTransport.consume({
|
||||||
id: params.id,
|
id: params.id,
|
||||||
|
Reference in New Issue
Block a user