Compare commits

..

63 Commits

Author SHA1 Message Date
451fff0a6b Update 2022-12-23 11:39:49 +02:00
a568e542a7 Update 2022-12-22 09:34:31 +02:00
14af825eab Update 2022-12-22 09:26:37 +02:00
f3ba6d37c2 Update 2022-12-22 09:22:23 +02:00
a4356f06be Update 2022-12-22 09:16:52 +02:00
c4d6cdd209 Merge branch 'LINXD-2270-p2' of https://git.safemobile.org/Safemobile/mediasoup into LINXD-2270-p2 2022-12-19 19:08:53 +02:00
1520fb88ae Update server and web client so support full duplex 2022-12-19 19:07:08 +02:00
da906ed4ba Update 2022-12-19 18:35:02 +02:00
2dd9eb5eaf Update 2022-12-19 14:05:44 +02:00
b4fccc4d4c Update 2022-12-19 13:57:17 +02:00
88da70731f Update 2022-12-19 13:40:43 +02:00
68c80d563f Update 2022-12-19 13:32:56 +02:00
eb668e2500 Update 2022-12-19 13:29:24 +02:00
e3536e87cd Update 2022-12-19 13:19:58 +02:00
8634cb4b6e Update 2022-12-19 13:18:33 +02:00
2a6f24b2bb Update 2022-12-19 13:17:11 +02:00
381e665062 Update 2022-12-19 13:14:34 +02:00
33e30339f2 Update 2022-12-19 13:12:49 +02:00
968da6ea98 Update 2022-12-19 12:40:54 +02:00
2ada7b66db Update 2022-12-19 12:39:22 +02:00
28059144cf Update 2022-12-19 12:33:19 +02:00
714fe0ec5e Update 2022-12-19 12:31:39 +02:00
898cc0cbf2 Update 2022-12-19 12:30:25 +02:00
6379e1ae34 Update 2022-12-19 12:27:24 +02:00
dd264e39ea Update 2022-12-19 12:25:42 +02:00
72136132ba Update 2022-12-19 12:25:14 +02:00
4978e8d51f Update 2022-12-19 12:22:21 +02:00
825ded83c2 Update 2022-12-19 12:13:48 +02:00
b15357d089 Update 2022-12-19 12:01:21 +02:00
bb4cd756f3 Update 2022-12-19 11:29:24 +02:00
0731090b0e Update 2022-12-19 11:26:08 +02:00
782683c3e2 Update 2022-12-19 11:24:19 +02:00
dfa175d0c7 Update 2022-12-19 11:22:28 +02:00
2c375c01ea Update 2022-12-19 11:21:02 +02:00
2fbb355fea Update 2022-12-19 11:19:51 +02:00
2ddeb4baaa Update 2022-12-16 14:13:11 +02:00
a31e646e2b Update 2022-12-16 14:10:26 +02:00
fe792f93b6 Update 2022-12-16 14:10:07 +02:00
dafbc486ad Update 2022-12-16 14:00:16 +02:00
b606a72030 Update 2022-12-16 13:43:55 +02:00
c174e92e3c Update 2022-12-16 13:33:13 +02:00
449724537e Update 2022-12-16 12:01:20 +02:00
9634aac153 Update 2022-12-16 11:59:10 +02:00
e0bc4642cb Update 2022-12-16 11:31:26 +02:00
f950142188 Update 2022-12-16 11:28:57 +02:00
5ba1f76585 Update 2022-12-16 11:23:10 +02:00
dc9c91fccc Update 2022-12-16 11:10:30 +02:00
5abcddc115 Update 2022-12-16 11:02:08 +02:00
bf65221664 Update 2022-12-16 10:54:25 +02:00
5687569bc1 Update 2022-12-16 10:47:13 +02:00
44c8d9b8ee Update 2022-12-16 02:15:26 +02:00
0a6985f9b9 Update 2022-12-16 02:12:22 +02:00
d29def364c Update 2022-12-16 02:10:10 +02:00
acd6025f59 Update 2022-12-16 02:07:01 +02:00
4b0c06e0b0 Added socket id to createWebRtcTransport 2022-12-16 02:02:38 +02:00
c1fe524ec7 LINXD-2270: Remove commented code; Update comments/logs 2022-12-14 11:57:19 +02:00
f8fcfb3165 Fix isInitiator in transport-produce 2022-12-14 11:33:16 +02:00
d324528d52 Added logs on transport-produce 2022-12-14 11:05:40 +02:00
d1eb7afc3a Added logs on createRoom on videoCalls 2022-12-14 10:15:34 +02:00
695964d342 Refactor code to use initiator/receiver 2022-12-14 09:55:45 +02:00
3ca555ef9e Set initiatorSocketId to be dispatcher 2022-12-13 13:23:15 +02:00
92fbecc36a Set initiatorSocketId to be dispatcher 2022-12-13 13:04:43 +02:00
d633eec92f Add socket info 2022-12-13 10:28:45 +02:00
13 changed files with 81 additions and 51 deletions

30
app.js
View File

@ -13,40 +13,40 @@ try {
} }
const mediasoup = require('mediasoup'); const mediasoup = require('mediasoup');
let worker; let worker
/** /**
* *
* videoCalls - Dictionary of Object(s) * videoCalls - Dictionary of Object(s)
* '<callId>': { * '<callId>': {
* router: Router, * router: Router, router
* initiatorAudioProducer: Producer, * initiatorAudioProducer: Producer,
* initiatorVideoProducer: Producer, * initiatorVideoProducer: Producer,
* receiverVideoProducer: Producer, * receiverVideoProducer: Producer, producerVideo
* receiverAudioProducer: Producer, * receiverAudioProducer: Producer, producerAudio
* initiatorProducerTransport: Producer Transport, * initiatorProducerTransport: Producer Transport,
* receiverProducerTransport: Producer Transport, * receiverProducerTransport: Producer Transport, producerTransport
* initiatorConsumerVideo: Consumer, * initiatorConsumerVideo: Consumer, consumerVideo
* initiatorConsumerAudio: Consumer, * initiatorConsumerAudio: Consumer, consumerAudio
* initiatorConsumerTransport: Consumer Transport * initiatorConsumerTransport: Consumer Transport consumerTransport
* initiatorSockerId * initiatorSockerId
* receiverSocketId * receiverSocketId
* } * }
* *
**/ **/
let videoCalls = {}; let videoCalls = {}
let socketDetails = {}; let socketDetails = {}
app.get('/', (_req, res) => { app.get('/', (_req, res) => {
res.send('Hello from mediasoup app!') res.send('Hello from mediasoup app!')
}); })
app.use('/sfu', express.static(path.join(__dirname, 'public'))); app.use('/sfu', express.static(path.join(__dirname, 'public')))
// SSL cert for HTTPS access // SSL cert for HTTPS access
const options = { const options = {
key: fs.readFileSync(process.env.SERVER_KEY, 'utf-8'), key: fs.readFileSync(process.env.SERVER_KEY, 'utf-8'),
cert: fs.readFileSync(process.env.SERVER_CERT, 'utf-8'), cert: fs.readFileSync(process.env.SERVER_CERT, 'utf-8'),
}; }
const httpsServer = https.createServer(options, app); const httpsServer = https.createServer(options, app);
@ -225,6 +225,7 @@ peers.on('connection', async socket => {
*/ */
socket.on('createWebRtcTransport', async ({ sender }, callback) => { socket.on('createWebRtcTransport', async ({ sender }, callback) => {
try { try {
console.log('🟥', socket.id, JSON.stringify(sender));
const callId = socketDetails[socket.id]; const callId = socketDetails[socket.id];
console.log(`[createWebRtcTransport] socket ${socket.id} | sender ${sender} | callId ${callId}`); console.log(`[createWebRtcTransport] socket ${socket.id} | sender ${sender} | callId ${callId}`);
if (sender) { if (sender) {
@ -428,6 +429,7 @@ peers.on('connection', async socket => {
} else if (!canConsumeVideo && canConsumeAudio) { } else if (!canConsumeVideo && canConsumeAudio) {
const audioParams = await consumeAudio(callId, socket.id, rtpCapabilities) const audioParams = await consumeAudio(callId, socket.id, rtpCapabilities)
const data = { videoParams: null, audioParams }; const data = { videoParams: null, audioParams };
console.log('-----------======= data', data);
callback(data); callback(data);
} else { } else {
console.log(`[consume] Can't consume | callId ${callId}`); console.log(`[consume] Can't consume | callId ${callId}`);
@ -457,6 +459,8 @@ peers.on('connection', async socket => {
(videoCalls[callId].receiverConsumerVideo) && await videoCalls[callId].receiverConsumerVideo.resume(); (videoCalls[callId].receiverConsumerVideo) && await videoCalls[callId].receiverConsumerVideo.resume();
(videoCalls[callId].receiverConsumerVideo) && await videoCalls[callId].receiverConsumerAudio.resume(); (videoCalls[callId].receiverConsumerVideo) && await videoCalls[callId].receiverConsumerAudio.resume();
} }
// await videoCalls[callId].consumerVideo.resume();
// await videoCalls[callId].consumerAudio.resume();
} catch (error) { } catch (error) {
console.log(`ERROR | consumer-resume | callId ${socketDetails[socket.id]} | ${error.message}`); console.log(`ERROR | consumer-resume | callId ${socketDetails[socket.id]} | ${error.message}`);
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 614 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 354 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 462 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 252 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 346 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 407 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 439 KiB

View File

@ -20811,15 +20811,28 @@ const connectRecvTransport = async () => {
if (audioParams) { if (audioParams) {
console.log('❗ Have AUDIO stream to consume'); console.log('❗ Have AUDIO stream to consume');
let audioTrack = await getAudioTrask(audioParams) let audioTrack = await getAudioTrask(audioParams)
console.log('audioTrack', audioTrack);
stream.addTrack(audioTrack) stream.addTrack(audioTrack)
} else { } else {
console.log('❗ Don\'t have AUDIO stream to consume'); console.log('❗ Don\'t have AUDIO stream to consume');
} }
console.log('----------stream', stream);
console.log('stream.getAudioTracks()', stream.getAudioTracks());
socket.emit('consumer-resume') socket.emit('consumer-resume')
remoteVideo.srcObject = stream remoteVideo.srcObject = stream
remoteVideo.setAttribute('autoplay', true) // remoteVideo.autoplay = true
remoteVideo.controls = true;
remoteVideo.muted = true;
remoteVideo.loop = true;
remoteVideo.setAttribute('playsinline', '');
remoteVideo.src = stream;
remoteVideo.volume = 1.0;
// window.localStream = stream; // A
// window.localAudio.srcObject = stream; // B
// window.localAudio.autoplay = true; // C
remoteVideo.play() remoteVideo.play()
.then(() => { .then(() => {
@ -20860,24 +20873,24 @@ const getAudioTrask = async (audioParams) => {
const audioTrack = consumerAudio.track const audioTrack = consumerAudio.track
audioTrack.applyConstraints({ // audioTrack.applyConstraints({
audio: { // audio: {
advanced: [ // advanced: [
{ // {
echoCancellation: {exact: true} // echoCancellation: {exact: true}
}, // },
{ // {
autoGainControl: {exact: true} // autoGainControl: {exact: true}
}, // },
{ // {
noiseSuppression: {exact: true} // noiseSuppression: {exact: true}
}, // },
{ // {
highpassFilter: {exact: true} // highpassFilter: {exact: true}
} // }
] // ]
} // }
}) // })
return audioTrack return audioTrack
} }

BIN
public/images/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 493 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 418 B

View File

@ -453,15 +453,28 @@ const connectRecvTransport = async () => {
if (audioParams) { if (audioParams) {
console.log('❗ Have AUDIO stream to consume'); console.log('❗ Have AUDIO stream to consume');
let audioTrack = await getAudioTrask(audioParams) let audioTrack = await getAudioTrask(audioParams)
console.log('audioTrack', audioTrack);
stream.addTrack(audioTrack) stream.addTrack(audioTrack)
} else { } else {
console.log('❗ Don\'t have AUDIO stream to consume'); console.log('❗ Don\'t have AUDIO stream to consume');
} }
console.log('----------stream', stream);
console.log('stream.getAudioTracks()', stream.getAudioTracks());
socket.emit('consumer-resume') socket.emit('consumer-resume')
remoteVideo.srcObject = stream remoteVideo.srcObject = stream
remoteVideo.setAttribute('autoplay', true) // remoteVideo.autoplay = true
remoteVideo.controls = true;
remoteVideo.muted = true;
remoteVideo.loop = true;
remoteVideo.setAttribute('playsinline', '');
remoteVideo.src = stream;
remoteVideo.volume = 1.0;
// window.localStream = stream; // A
// window.localAudio.srcObject = stream; // B
// window.localAudio.autoplay = true; // C
remoteVideo.play() remoteVideo.play()
.then(() => { .then(() => {
@ -502,24 +515,24 @@ const getAudioTrask = async (audioParams) => {
const audioTrack = consumerAudio.track const audioTrack = consumerAudio.track
audioTrack.applyConstraints({ // audioTrack.applyConstraints({
audio: { // audio: {
advanced: [ // advanced: [
{ // {
echoCancellation: {exact: true} // echoCancellation: {exact: true}
}, // },
{ // {
autoGainControl: {exact: true} // autoGainControl: {exact: true}
}, // },
{ // {
noiseSuppression: {exact: true} // noiseSuppression: {exact: true}
}, // },
{ // {
highpassFilter: {exact: true} // highpassFilter: {exact: true}
} // }
] // ]
} // }
}) // })
return audioTrack return audioTrack
} }