/* ██████ ██  ██ ███████ ███  ██ ████████  ██      ██  ██ ██      ████  ██    ██     ██  ██  ██ █████  ██ ██  ██  ██  ██  ██  ██ ██     ██  ██ ██  ██  ██████ ███████ ██ ███████ ██   ████  ██  MiroTalk Browser Client Copyright (C) 2021 Miroslav Pejic This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ 'use strict'; // https://www.w3schools.com/js/js_strict.asp const isHttps = false; // must be the same to server.js isHttps const signalingServerPort = 3000; // must be the same to server.js PORT const signalingServer = getSignalingServer(); const roomId = getRoomId(); const peerInfo = getPeerInfo(); const peerLoockupUrl = 'https://extreme-ip-lookup.com/json/?key=demo'; const avatarApiUrl = 'https://eu.ui-avatars.com/api'; const welcomeImg = '../images/image-placeholder.svg'; const shareUrlImg = '../images/image-placeholder.svg'; const leaveRoomImg = '../images/leave-room.png'; const confirmImg = '../images/image-placeholder.svg'; const fileSharingImg = '../images/image-placeholder.svg'; // nice free icon: https://www.iconfinder.com const roomLockedImg = '../images/locked.png'; const camOffImg = '../images/cam-off.png'; const audioOffImg = '../images/audio-off.png'; const deleteImg = '../images/delete.png'; const youtubeImg = '../images/youtube.png'; const messageImg = '../images/message.png'; const kickedOutImg = '../images/leave-room.png'; const aboutImg = '../images/about.png'; const notifyBySound = true; // turn on - off sound notifications const fileSharingInput = '*'; // allow all file extensions const isWebRTCSupported = DetectRTC.isWebRTCSupported; const isMobileDevice = DetectRTC.isMobileDevice; const myBrowserName = DetectRTC.browser.name; const wbImageInput = 'image/*'; const wbWidth = 800; const wbHeight = 600; // video cam - screen max frame rate let videoMaxFrameRate = 30; let screenMaxFrameRate = 30; let leftChatAvatar; let rightChatAvatar; let callStartTime; let callElapsedTime; let recStartTime; let recElapsedTime; let mirotalkTheme = 'neon'; // neon - dark - forest - ghost ... let mirotalkBtnsBar = 'vertical'; // vertical - horizontal let swalBackground = 'rgba(0, 0, 0, 0.7)'; // black - #16171b - transparent ... let peerGeo; let peerConnection; let myPeerName; let useAudio = true; let useVideo = true; let camera = 'user'; let roomLocked = false; let myVideoChange = false; let myHandStatus = false; let myVideoStatus = true; let myAudioStatus = true; let isScreenStreaming = false; let isChatRoomVisible = false; let isChatEmojiVisible = false; let isButtonsVisible = false; let isMySettingsVisible = false; let isVideoOnFullScreen = false; let isDocumentOnFullScreen = false; let isWhiteboardFs = false; let isVideoUrlPlayerOpen = false; let isRecScreenSream = false; let signalingSocket; // socket.io connection to our webserver let localMediaStream; // my microphone / webcam let remoteMediaStream; // peers microphone / webcam let recScreenStream; // recorded screen stream let remoteMediaControls = false; // enable - disable peers video player controls (default false) let peerConnections = {}; // keep track of our peer connections, indexed by peer_id == socket.io id let chatDataChannels = {}; // keep track of our peer chat data channels let fileDataChannels = {}; // keep track of our peer file sharing data channels let peerMediaElements = {}; // keep track of our peer