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
21 changed files with 802 additions and 797 deletions

View File

@ -1,2 +0,0 @@
node_modules
doc

View File

@ -1,25 +1,11 @@
FROM ubuntu:22.04
WORKDIR /app
FROM ubuntu
RUN apt-get update && \
apt-get install -y build-essential pip net-tools iputils-ping iproute2 curl
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash -
RUN apt-get install -y nodejs
RUN npm install -g watchify
COPY . /app/
RUN npm install
EXPOSE 3000/tcp
EXPOSE 2000-2200/udp
CMD node app.js
#docker build -t linx-video .
# docker run -it -d --restart always -p 3000:3000/tcp -p 2000-2200:2000-2200/udp linx-video
#Run under host network
# docker run -it -d --network host --restart always -p 3000:3000/tcp -p 2000-2200:2000-2200/udp linx-video
#https://docs.docker.com/config/containers/resource_constraints/
#docker run -it -d --network host --cpus="0.25" --memory="512m" --restart always -p 3000:3000/tcp -p 2000-2200:2000-2200/udp linx-video
EXPOSE 3000
EXPOSE 2000-2020
EXPOSE 10000-10100

1242
app.js

File diff suppressed because it is too large Load Diff

View File

@ -1,40 +1,4 @@
#/!bin/bash
## FUNCTIONS
function getGitVersion(){
version=$(git describe)
count=$(echo ${version%%-*} | grep -o "\." | wc -l)
if (( $count > 1 )); then
version=${version%%-*}
elif (( $count == 0 ));then
echo -e "Error: Git version \"${version%%-*}\" not respecting Safemobile standard.\n Must be like 4.xx or 4.xx.xx"
version="0.0.0"
else
if [[ "$1" == "dev" ]];then
cleanprefix=${version#*-} # remove everything before `-` including `-`
cleansuffix=${cleanprefix%-*} # remove everything after `-` including `-`
version="${version%%-*}.${cleansuffix}"
else
version="${version%%-*}.0" # one `%` remove everything after last `-`, two `%%` remove everything after all `-`
fi
fi
}
function addVersionPm2(){
file_pkg="package.json"
key=" \"version\": \""
if [ -f "$file_pkg" ] && [ ! -z "$version" ]; then
versionApp=" \"version\": \"$version\","
sed -i "s|^.*$key.*|${versionApp//\//\\/}|g" $file_pkg
text=$(cat $file_pkg | grep -c "$version")
if [ $text -eq 0 ]; then
echo "Version couldn't be set"
else
echo "Version $version successfully applied to App"
fi
fi
}
## PREBUILD PROCESS
# check dist dir to be present and empty
if [ ! -d "dist" ]; then
@ -45,31 +9,38 @@ else
## CLEANUP
rm -fr dist/*
fi
if [ -d "node_modules" ]; then
rm -fr node_modules
fi
# Install dependencies
#npm install
## PROJECT NEEDS
echo "Building app... from $(git rev-parse --abbrev-ref HEAD)"
#npm run-script build
cp -r {.env,app.js,package.json,server,public,doc,Dockerfile} dist/
#cp -r ./* dist/
cp -r {.env,app.js,package.json,server,public} dist/
# Generate Git log
dateString=$(date +"%Y%m%d-%H%M%S")
git log --pretty=format:"%ad%x09%an%x09%s" --no-merges -20 > "dist/git-$dateString.log"
# Get Git version control
getGitVersion $1
# Add version control for pm2
#Add version control for pm2
cd dist
addVersionPm2
#Add version control for pm2
version=$(git describe)
file_pkg="package.json"
key=" \"version\": \""
count=$(echo ${version%%-*} | grep -o "\." | wc -l)
if (( $count > 1 )); then
version=${version%%-*}
else
version="${version%%-*}.0"
fi
if [ -f "$file_pkg" ] && [ ! -z "$version" ]; then
version=" \"version\": \"$version\","
sed -i "s|^.*$key.*|${version//\//\\/}|g" $file_pkg
text=$(cat $file_pkg | grep -c "$version")
if [ $text -eq 0 ]; then
echo "Version couldn't be set"
else
echo "Version $version successfully applied to App"
fi
fi
## POST BUILD
cd -
cd -

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 419 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 606 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 349 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 412 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 421 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 567 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 660 KiB

BIN
doc/[video] Workflow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 571 KiB

View File

@ -20353,7 +20353,7 @@ module.exports = yeast;
},{}],94:[function(require,module,exports){
module.exports = {
hubAddress: 'https://hub.dev.linx.safemobile.com/',
mediasoupAddress: 'https://testing.video.safemobile.org/',
mediasoupAddress: 'https://testing.video.safemobile.org',
}
},{}],95:[function(require,module,exports){
const io = require('socket.io-client')
@ -20449,23 +20449,10 @@ setTimeout(() => {
console.log(`[MEDIA] ${config.mediasoupAddress} | connected: ${socket.connected} | existsProducer: ${existsProducer}`)
if (!IS_PRODUCER && existsProducer && consumer === undefined) {
goConnect()
// document.getElementById('btnRecvSendTransport').click();
}
if (IS_PRODUCER && urlParams.get('testing') === 'true') { getLocalStream() }
})
socket.on('new-producer', ({ callId, kind }) => {
console.log(`🟢 new-producer | callId: ${callId} | kind: ${kind} | Ready to consume`);
connectRecvTransport();
})
socket.on('close-producer', ({ callId, kind }) => {
console.log(`🔴 close-producer | callId: ${callId} | kind: ${kind}`);
if (kind === 'video') {
consumerVideo.close()
remoteVideo.srcObject = null
}
else if (kind === 'audio') consumerAudio.close()
})
}
if (IS_PRODUCER === true) {
@ -20744,8 +20731,6 @@ const connectSendTransport = async () => {
// Enable Close call button
const closeCallBtn = document.getElementById('btnCloseCall');
closeCallBtn.removeAttribute('disabled');
createRecvTransport();
}
const createRecvTransport = async () => {
@ -20785,8 +20770,7 @@ const createRecvTransport = async () => {
errback(error)
}
})
// We call it in new-rpoducer, we don't need it here anymore
// connectRecvTransport()
connectRecvTransport()
})
}
@ -20827,22 +20811,35 @@ const connectRecvTransport = async () => {
if (audioParams) {
console.log('❗ Have AUDIO stream to consume');
let audioTrack = await getAudioTrask(audioParams)
console.log('audioTrack', audioTrack);
stream.addTrack(audioTrack)
} else {
console.log('❗ Don\'t have AUDIO stream to consume');
}
console.log('----------stream', stream);
console.log('stream.getAudioTracks()', stream.getAudioTracks());
socket.emit('consumer-resume')
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()
.then(() => {
console.log('remoteVideo PLAY')
})
.catch((error) => {
console.error(`remoteVideo PLAY ERROR | ${error.message}`)
displayError(`remoteVideo PLAY ERROR | ${error.message}`)
})
})
}
@ -20855,6 +20852,10 @@ const getVideoTrask = async (videoParams) => {
rtpParameters: videoParams.rtpParameters
})
consumerVideo.on('transportclose', () => {
console.log('transport closed so consumer closed')
})
return consumerVideo.track
}
@ -20872,24 +20873,24 @@ const getAudioTrask = async (audioParams) => {
const audioTrack = consumerAudio.track
audioTrack.applyConstraints({
audio: {
advanced: [
{
echoCancellation: {exact: true}
},
{
autoGainControl: {exact: true}
},
{
noiseSuppression: {exact: true}
},
{
highpassFilter: {exact: true}
}
]
}
})
// audioTrack.applyConstraints({
// audio: {
// advanced: [
// {
// echoCancellation: {exact: true}
// },
// {
// autoGainControl: {exact: true}
// },
// {
// noiseSuppression: {exact: true}
// },
// {
// highpassFilter: {exact: true}
// }
// ]
// }
// })
return audioTrack
}
@ -20915,31 +20916,31 @@ const closeCall = () => {
resetCallSettings()
}
// const consume = async (kind) => {
// console.log(`[consume] kind: ${kind}`)
// console.log('createRecvTransport Consumer')
// await socket.emit('createWebRtcTransport', { sender: false, callId, dispatcher: true }, ({ params }) => {
// if (params.error) {
// console.log('createRecvTransport | createWebRtcTransport | Error', params.error)
// return
// }
// consumerTransport = device.createRecvTransport(params)
// consumerTransport.on('connect', async ({ dtlsParameters }, callback, errback) => {
// try {
// await socket.emit('transport-recv-connect', {
// dtlsParameters,
// })
// callback()
// } catch (error) {
// errback(error)
// }
// })
const consume = async () => {
console.log('[consume]')
console.log('createRecvTransport Consumer')
await socket.emit('createWebRtcTransport', { sender: false, callId, dispatcher: true }, ({ params }) => {
if (params.error) {
console.log('createRecvTransport | createWebRtcTransport | Error', params.error)
return
}
consumerTransport = device.createRecvTransport(params)
consumerTransport.on('connect', async ({ dtlsParameters }, callback, errback) => {
try {
await socket.emit('transport-recv-connect', {
dtlsParameters,
})
callback()
} catch (error) {
errback(error)
}
})
// connectRecvTransport()
// })
// }
connectRecvTransport()
})
}
btnLocalVideo.addEventListener('click', getLocalStream)
// btnRecvSendTransport.addEventListener('click', consume)
btnRecvSendTransport.addEventListener('click', consume)
btnCloseCall.addEventListener('click', closeCall)
},{"./config":94,"mediasoup-client":66,"socket.io-client":82}]},{},[95]);

View File

@ -1,4 +1,4 @@
module.exports = {
hubAddress: 'https://hub.dev.linx.safemobile.com/',
mediasoupAddress: 'https://testing.video.safemobile.org/',
mediasoupAddress: 'https://testing.video.safemobile.org',
}

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

@ -75,7 +75,7 @@
</td>
<td>
<div id="sharedBtns">
<!-- <button id="btnRecvSendTransport">Consume</button> -->
<button id="btnRecvSendTransport">Consume</button>
<button id="remoteSoundControl">Unmute</button>
</div>
</td>

View File

@ -91,23 +91,10 @@ setTimeout(() => {
console.log(`[MEDIA] ${config.mediasoupAddress} | connected: ${socket.connected} | existsProducer: ${existsProducer}`)
if (!IS_PRODUCER && existsProducer && consumer === undefined) {
goConnect()
// document.getElementById('btnRecvSendTransport').click();
}
if (IS_PRODUCER && urlParams.get('testing') === 'true') { getLocalStream() }
})
socket.on('new-producer', ({ callId, kind }) => {
console.log(`🟢 new-producer | callId: ${callId} | kind: ${kind} | Ready to consume`);
connectRecvTransport();
})
socket.on('close-producer', ({ callId, kind }) => {
console.log(`🔴 close-producer | callId: ${callId} | kind: ${kind}`);
if (kind === 'video') {
consumerVideo.close()
remoteVideo.srcObject = null
}
else if (kind === 'audio') consumerAudio.close()
})
}
if (IS_PRODUCER === true) {
@ -386,8 +373,6 @@ const connectSendTransport = async () => {
// Enable Close call button
const closeCallBtn = document.getElementById('btnCloseCall');
closeCallBtn.removeAttribute('disabled');
createRecvTransport();
}
const createRecvTransport = async () => {
@ -427,8 +412,7 @@ const createRecvTransport = async () => {
errback(error)
}
})
// We call it in new-rpoducer, we don't need it here anymore
// connectRecvTransport()
connectRecvTransport()
})
}
@ -469,22 +453,35 @@ const connectRecvTransport = async () => {
if (audioParams) {
console.log('❗ Have AUDIO stream to consume');
let audioTrack = await getAudioTrask(audioParams)
console.log('audioTrack', audioTrack);
stream.addTrack(audioTrack)
} else {
console.log('❗ Don\'t have AUDIO stream to consume');
}
console.log('----------stream', stream);
console.log('stream.getAudioTracks()', stream.getAudioTracks());
socket.emit('consumer-resume')
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()
.then(() => {
console.log('remoteVideo PLAY')
})
.catch((error) => {
console.error(`remoteVideo PLAY ERROR | ${error.message}`)
displayError(`remoteVideo PLAY ERROR | ${error.message}`)
})
})
}
@ -497,6 +494,10 @@ const getVideoTrask = async (videoParams) => {
rtpParameters: videoParams.rtpParameters
})
consumerVideo.on('transportclose', () => {
console.log('transport closed so consumer closed')
})
return consumerVideo.track
}
@ -514,24 +515,24 @@ const getAudioTrask = async (audioParams) => {
const audioTrack = consumerAudio.track
audioTrack.applyConstraints({
audio: {
advanced: [
{
echoCancellation: {exact: true}
},
{
autoGainControl: {exact: true}
},
{
noiseSuppression: {exact: true}
},
{
highpassFilter: {exact: true}
}
]
}
})
// audioTrack.applyConstraints({
// audio: {
// advanced: [
// {
// echoCancellation: {exact: true}
// },
// {
// autoGainControl: {exact: true}
// },
// {
// noiseSuppression: {exact: true}
// },
// {
// highpassFilter: {exact: true}
// }
// ]
// }
// })
return audioTrack
}
@ -557,30 +558,30 @@ const closeCall = () => {
resetCallSettings()
}
// const consume = async (kind) => {
// console.log(`[consume] kind: ${kind}`)
// console.log('createRecvTransport Consumer')
// await socket.emit('createWebRtcTransport', { sender: false, callId, dispatcher: true }, ({ params }) => {
// if (params.error) {
// console.log('createRecvTransport | createWebRtcTransport | Error', params.error)
// return
// }
// consumerTransport = device.createRecvTransport(params)
// consumerTransport.on('connect', async ({ dtlsParameters }, callback, errback) => {
// try {
// await socket.emit('transport-recv-connect', {
// dtlsParameters,
// })
// callback()
// } catch (error) {
// errback(error)
// }
// })
const consume = async () => {
console.log('[consume]')
console.log('createRecvTransport Consumer')
await socket.emit('createWebRtcTransport', { sender: false, callId, dispatcher: true }, ({ params }) => {
if (params.error) {
console.log('createRecvTransport | createWebRtcTransport | Error', params.error)
return
}
consumerTransport = device.createRecvTransport(params)
consumerTransport.on('connect', async ({ dtlsParameters }, callback, errback) => {
try {
await socket.emit('transport-recv-connect', {
dtlsParameters,
})
callback()
} catch (error) {
errback(error)
}
})
// connectRecvTransport()
// })
// }
connectRecvTransport()
})
}
btnLocalVideo.addEventListener('click', getLocalStream)
// btnRecvSendTransport.addEventListener('click', consume)
btnRecvSendTransport.addEventListener('click', consume)
btnCloseCall.addEventListener('click', closeCall)