From e9ef3d18003ef263076260265e66700785956fd3 Mon Sep 17 00:00:00 2001 From: Miroslav Pejic Date: Thu, 23 Nov 2023 18:34:14 +0100 Subject: [PATCH] [mirotalksfu] - add hide myself in URL param (hide=0/1) --- README.md | 5 +++-- app/api/join/join.js | 1 + app/api/join/join.php | 1 + app/api/join/join.py | 1 + app/api/join/join.sh | 2 +- app/src/Server.js | 8 +++++--- public/js/Room.js | 19 ++++++++++++++----- public/js/RoomClient.js | 7 ++++++- 8 files changed, 32 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index d8201237..a50e5d7b 100644 --- a/README.md +++ b/README.md @@ -91,8 +91,9 @@ | video | boolean | Video stream | | screen | boolean | Screen stream | | notify | boolean | Welcome message | - | username | string | auth username | - | password | string | auth password | + | hide | boolean | Hide myself | + | username | string | Auth username | + | password | string | Auth password | > **Note** > diff --git a/app/api/join/join.js b/app/api/join/join.js index c9cf48f2..e3985b04 100644 --- a/app/api/join/join.js +++ b/app/api/join/join.js @@ -22,6 +22,7 @@ async function getJoin() { audio: true, video: true, screen: true, + hide: false, notify: true, }), }); diff --git a/app/api/join/join.php b/app/api/join/join.php index beac30c5..2b024647 100644 --- a/app/api/join/join.php +++ b/app/api/join/join.php @@ -23,6 +23,7 @@ $data = array( "audio" => true, "video" => true, "screen" => true, + "hide" => false, "notify" => true, ); $data_string = json_encode($data); diff --git a/app/api/join/join.py b/app/api/join/join.py index c331334f..75cf812b 100644 --- a/app/api/join/join.py +++ b/app/api/join/join.py @@ -18,6 +18,7 @@ data = { "audio": "true", "video": "true", "screen": "true", + "hide": "false", "notify": "true", } diff --git a/app/api/join/join.sh b/app/api/join/join.sh index fd1d8534..5a0bb33e 100755 --- a/app/api/join/join.sh +++ b/app/api/join/join.sh @@ -7,5 +7,5 @@ MIROTALK_URL="https://sfu.mirotalk.com/api/v1/join" curl $MIROTALK_URL \ --header "authorization: $API_KEY_SECRET" \ --header "Content-Type: application/json" \ - --data '{"room":"test","roomPassword":"false","name":"mirotalksfu","audio":"true","video":"true","screen":"false","notify":"true"}' \ + --data '{"room":"test","roomPassword":"false","name":"mirotalksfu","audio":"true","video":"true","screen":"false","hide":"false","notify":"true"}' \ --request POST \ No newline at end of file diff --git a/app/src/Server.js b/app/src/Server.js index a661792e..eff2807f 100644 --- a/app/src/Server.js +++ b/app/src/Server.js @@ -272,9 +272,11 @@ function startServer() { app.get('/join/', (req, res) => { if (Object.keys(req.query).length > 0) { log.debug('Direct Join', req.query); - // http://localhost:3010/join?room=test&roomPassword=0&name=mirotalksfu&audio=1&video=1&screen=0¬ify=1 - // http://localhost:3010/join?room=test&roomPassword=0&name=mirotalksfu&audio=1&video=1&screen=0¬ify=0&username=username&password=password - const { room, roomPassword, name, audio, video, screen, notify, username, password, isPresenter } = + + // http://localhost:3010/join?room=test&roomPassword=0&name=mirotalksfu&audio=1&video=1&screen=0&hide=0¬ify=1 + // http://localhost:3010/join?room=test&roomPassword=0&name=mirotalksfu&audio=1&video=1&screen=0&hide=0¬ify=0&username=username&password=password + + const { room, roomPassword, name, audio, video, screen, hide, notify, username, password, isPresenter } = checkXSS(req.query); const isPeerValid = isAuthPeer(username, password); diff --git a/public/js/Room.js b/public/js/Room.js index a77dfbe3..fb00797d 100644 --- a/public/js/Room.js +++ b/public/js/Room.js @@ -89,12 +89,12 @@ let peer_uuid = getPeerUUID(); let peer_username = getPeerUsername(); let peer_password = getPeerPassword(); let isScreenAllowed = getScreen(); +let isHideMeActive = getHideMeActive(); let notify = getNotify(); isPresenter = isPeerPresenter(); let peer_info = null; -let isHideMeActive = false; let isPushToTalkActive = false; let isSpaceDown = false; let isPitchBarEnabled = true; @@ -535,6 +535,18 @@ function getNotify() { return notify; } +function getHideMeActive() { + let qs = new URLSearchParams(window.location.search); + let hide = filterXSS(qs.get('hide')); + let queryHideMe = false; + if (hide) { + hide = hide.toLowerCase(); + queryHideMe = hide === '1' || hide === 'true'; + } + console.log('Direct join', { hide: queryHideMe }); + return queryHideMe; +} + function isPeerPresenter() { let qs = new URLSearchParams(window.location.search); let presenter = filterXSS(qs.get('isPresenter')); @@ -1160,6 +1172,7 @@ function handleButtons() { shareRoom(true); }; hideMeButton.onclick = (e) => { + isHideMeActive = !isHideMeActive; rc.handleHideMe(); }; settingsButton.onclick = () => { @@ -1352,13 +1365,11 @@ function handleButtons() { } setVideoButtonsDisabled(true); if (!isEnumerateVideoDevices) initEnumerateVideoDevices(); - if (isHideMeActive) rc.handleHideMe(); rc.produce(RoomClient.mediaType.video, videoSelect.value); // rc.resumeProducer(RoomClient.mediaType.video); }; stopVideoButton.onclick = () => { setVideoButtonsDisabled(true); - if (isHideMeActive) rc.handleHideMe(); rc.closeProducer(RoomClient.mediaType.video); // rc.pauseProducer(RoomClient.mediaType.video); }; @@ -1367,11 +1378,9 @@ function handleButtons() { if (moderator.screen_cant_share) { return userLog('warning', 'The moderator does not allow you to share the screen', 'top-end', 6000); } - if (isHideMeActive) rc.handleHideMe(); rc.produce(RoomClient.mediaType.screen); }; stopScreenButton.onclick = () => { - if (isHideMeActive) rc.handleHideMe(); rc.closeProducer(RoomClient.mediaType.screen); }; fileShareButton.onclick = () => { diff --git a/public/js/RoomClient.js b/public/js/RoomClient.js index 009444b1..585be1da 100644 --- a/public/js/RoomClient.js +++ b/public/js/RoomClient.js @@ -1013,6 +1013,10 @@ class RoomClient { getMicrophoneVolumeIndicator(stream); } + if (type == mediaType.video) { + this.handleHideMe(); + } + producer.on('trackended', () => { this.closeProducer(type); }); @@ -1418,7 +1422,6 @@ class RoomClient { // #################################################### handleHideMe() { - isHideMeActive = !isHideMeActive; //const myScreenWrap = this.getId(this.screenProducerId + '__video'); const myVideoWrap = this.getId(this.videoProducerId + '__video'); const myVideoWrapOff = this.getId(this.peer_id + '__videoOff'); @@ -2104,6 +2107,8 @@ class RoomClient { console.log('[setVideoOff] Video-element-count', this.videoMediaContainer.childElementCount); // wbUpdate(); + + this.handleHideMe(); } removeVideoOff(peer_id) {