[mirotalk] - improvements, update dep

This commit is contained in:
Miroslav Pejic
2024-03-12 18:26:40 +01:00
parent a5518e4140
commit febc2a32eb
3 changed files with 104 additions and 20 deletions
+1 -1
View File
@@ -39,7 +39,7 @@ dependencies: {
* @license For commercial use or closed source, contact us at license.mirotalk@gmail.com or purchase directly from CodeCanyon
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-p2p-webrtc-realtime-video-conferences/38376661
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
* @version 1.2.98
* @version 1.2.99
*
*/
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "mirotalk",
"version": "1.2.98",
"version": "1.2.99",
"description": "A free WebRTC browser-based video call",
"main": "server.js",
"scripts": {
@@ -37,8 +37,8 @@
"license": "AGPL-3.0",
"homepage": "https://github.com/miroslavpejic85/mirotalk",
"dependencies": {
"@sentry/integrations": "^7.106.0",
"@sentry/node": "^7.106.0",
"@sentry/integrations": "^7.106.1",
"@sentry/node": "^7.106.1",
"axios": "^1.6.7",
"body-parser": "^1.20.2",
"colors": "^1.4.0",
+100 -16
View File
@@ -15,7 +15,7 @@
* @license For commercial use or closed source, contact us at license.mirotalk@gmail.com or purchase directly from CodeCanyon
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-p2p-webrtc-realtime-video-conferences/38376661
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
* @version 1.2.98
* @version 1.2.99
*
*/
@@ -1925,6 +1925,7 @@ async function handleOnIceCandidate(peer_id) {
break;
default:
console.warn(`[ICE candidate] unknown type: ${type}`, candidate);
break;
}
};
@@ -2042,6 +2043,8 @@ async function handleRTCDataChannels(peer_id) {
case 'micVolume':
handlePeerVolume(dataMessage);
break;
default:
break;
}
} catch (err) {
console.error('mirotalk_chat_channel', err);
@@ -2068,6 +2071,8 @@ async function handleRTCDataChannels(peer_id) {
console.error('mirotalk_file_sharing_channel', err);
}
break;
default:
break;
}
};
};
@@ -2405,7 +2410,8 @@ function setTheme() {
break;
// ...
default:
return console.log('No theme found');
console.log('No theme found');
break;
}
//setButtonsBarPosition(mainButtonsBarPosition);
}
@@ -2646,11 +2652,54 @@ async function setupLocalAudioMedia() {
/**
* Handle media access error.
* https://blog.addpipe.com/common-getusermedia-errors/
*
* @param {string} mediaType - 'video' or 'audio'
* @param {Error} err - The error object
*/
function handleMediaError(mediaType, err) {
console.error(`[Error] - Access denied for ${mediaType} device`, err);
let errMessage = '';
switch (err.name) {
case 'NotFoundError':
case 'DevicesNotFoundError':
errMessage = 'Required track is missing';
break;
case 'NotReadableError':
case 'TrackStartError':
errMessage = 'Already in use';
break;
case 'OverconstrainedError':
case 'ConstraintNotSatisfiedError':
errMessage = 'Constraints cannot be satisfied by available devices';
break;
case 'NotAllowedError':
case 'PermissionDeniedError':
errMessage = 'Permission denied in browser';
break;
case 'TypeError':
errMessage = 'Empty constraints object';
break;
default:
break;
}
// Print message to inform user
const $html = `
<ul style="text-align: left">
<li>Media type: ${mediaType}</li>
<li>Error name: ${err.name}</li>
<li>Error message: ${errMessage}</li>
<li>Common: <a href="https://blog.addpipe.com/common-getusermedia-errors" target="_blank">Common getUserMedia errors</a></li>
</ul>
`;
msgHTML(null, images.forbidden, 'Access denied', $html, 'center');
/*
it immediately stops the execution of the current function and jumps to the nearest enclosing try...catch block or,
if none exists, it interrupts the script execution and displays an error message in the console.
*/
throw new Error(`Access denied for ${mediaType} device [${err.name}]: ${errMessage} \ncheck the common getUserMedia errors: https://blog.addpipe.com/common-getusermedia-errors/`);
}
/**
@@ -3429,6 +3478,8 @@ function setPeerChatAvatarImgName(avatar, peerName) {
// console.log("Set My chat avatar image");
rightChatAvatar = avatarImg;
break;
default:
break;
}
}
@@ -3725,6 +3776,8 @@ function toggleVideoPin(position) {
videoMediaContainer.style.width = '100% !important';
videoMediaContainer.style.height = '25%';
break;
default:
break;
}
resizeVideoMedia();
}
@@ -5158,60 +5211,73 @@ async function getAudioVideoConstraints() {
*/
async function getVideoConstraints(videoQuality) {
const frameRate = videoMaxFrameRate;
let constraints = {};
switch (videoQuality) {
case 'default':
if (forceCamMaxResolutionAndFps) {
// This will make the browser use the maximum resolution available as default, `up to 4K and 60fps`.
return {
constraints = {
width: { ideal: 3840 },
height: { ideal: 2160 },
frameRate: { ideal: 60 },
}; // video cam constraints default
} else {
// This will make the browser use hdVideo and 30fps.
constraints = {
width: { exact: 1280 },
height: { exact: 720 },
frameRate: { exact: 30 },
}; // on default as hdVideo
}
// This will make the browser use hdVideo and 30fps.
return {
width: { ideal: 1280 },
height: { ideal: 720 },
frameRate: { ideal: 30 },
}; // on default as hdVideo
break;
case 'qvgaVideo':
return {
constraints = {
width: { exact: 320 },
height: { exact: 240 },
frameRate: frameRate,
}; // video cam constraints low bandwidth
break;
case 'vgaVideo':
return {
constraints = {
width: { exact: 640 },
height: { exact: 480 },
frameRate: frameRate,
}; // video cam constraints medium bandwidth
break;
case 'hdVideo':
return {
constraints = {
width: { exact: 1280 },
height: { exact: 720 },
frameRate: frameRate,
}; // video cam constraints high bandwidth
break;
case 'fhdVideo':
return {
constraints = {
width: { exact: 1920 },
height: { exact: 1080 },
frameRate: frameRate,
}; // video cam constraints very high bandwidth
break;
case '2kVideo':
return {
constraints = {
width: { exact: 2560 },
height: { exact: 1440 },
frameRate: frameRate,
}; // video cam constraints ultra high bandwidth
break;
case '4kVideo':
return {
constraints = {
width: { exact: 3840 },
height: { exact: 2160 },
frameRate: frameRate,
}; // video cam constraints ultra high bandwidth
break;
default:
break;
}
console.log('Video constraints', constraints);
return constraints;
}
/**
@@ -5240,6 +5306,7 @@ async function getAudioConstraints() {
video: false,
};
}
console.log('Audio constraints', constraints);
return constraints;
// return {
// echoCancellation: true,
@@ -7669,6 +7736,8 @@ function handlePeerStatus(config) {
case 'privacy':
setVideoPrivacyStatus(peer_id + '___video', status);
break;
default:
break;
}
}
@@ -7926,6 +7995,8 @@ function handlePeerAction(config) {
case 'ejectAll':
handleKickedOut(config);
break;
default:
break;
}
}
@@ -8095,6 +8166,8 @@ function disableAllPeers(element) {
userLog('toast', 'Hide everyone 👍');
emitPeersAction('hideVideo');
break;
default:
break;
}
}
});
@@ -8159,6 +8232,8 @@ function disablePeer(peer_id, element) {
userLog('toast', 'Hide video 👍');
emitPeerAction(peer_id, 'hideVideo');
break;
default:
break;
}
}
});
@@ -8212,6 +8287,8 @@ function handleRoomAction(config, emit = false) {
sendToServer('roomAction', thisConfig);
handleRoomStatus(thisConfig);
break;
default:
break;
}
} else {
// data coming from signaling server
@@ -8244,6 +8321,8 @@ function handleRoomStatus(config) {
isRoomLocked = true;
password == 'OK' ? joinToChannel() : handleRoomLocked();
break;
default:
break;
}
}
@@ -8941,6 +9020,8 @@ function handleWhiteboardAction(config, logMe = true) {
}
break;
//...
default:
break;
}
}
@@ -9508,6 +9589,8 @@ function handleVideoPlayer(config) {
userLog('toast', `${icons.user} ${peer_name} \n close video player`);
closeVideoUrlPlayer();
break;
default:
break;
}
}
@@ -9867,6 +9950,7 @@ function userLog(type, message, timer = 3000) {
// ......
default:
alert(message);
break;
}
}