diff --git a/Protocol.md b/Protocol.md index e79610e..2b68b83 100644 --- a/Protocol.md +++ b/Protocol.md @@ -40,7 +40,7 @@ VideoFlag: { Active: 1 << 0, // or 00000001 in binary NSFW: 1 << 1, // or 00000010 Muted: 1 << 2, // or 00000100, etc. - IsTalking: 1 << 3, + NonExplicit: 1 << 3, MutualRequired: 1 << 4, MutualOpen: 1 << 5, } diff --git a/pkg/messages/messages.go b/pkg/messages/messages.go index ab9a897..d5862ac 100644 --- a/pkg/messages/messages.go +++ b/pkg/messages/messages.go @@ -126,7 +126,7 @@ const ( VideoFlagActive int = 1 << iota // user's camera is enabled/broadcasting VideoFlagNSFW // viewer's camera is marked as NSFW VideoFlagMuted // user source microphone is muted - VideoFlagIsTalking // broadcaster seems to be talking + VideoFlagNonExplicit // viewer prefers not to see NSFW cameras (don't auto-open red cams/auto-close blue cams going red) VideoFlagMutualRequired // video wants viewers to share their camera too VideoFlagMutualOpen // viewer wants to auto-open viewers' cameras VideoFlagOnlyVIP // can only shows as active to VIP members diff --git a/src/App.vue b/src/App.vue index a8bb7f9..0293763 100644 --- a/src/App.vue +++ b/src/App.vue @@ -162,7 +162,9 @@ export default { nsfw: false, // user has flagged their camera to be NSFW mutual: false, // user wants viewers to share their own videos mutualOpen: false, // user wants to open video mutually + nonExplicit: false, // user prefers not to see explicit cameras vipOnly: false, // only show camera to fellow VIP users + rememberExpresslyClosed: true, // remember cams we expressly closed // Who all is watching me? map of users. watching: {}, @@ -422,6 +424,12 @@ export default { this.sendMe(); } }, + "webcam.nonExplicit": function () { + LocalStorage.set('videoNonExplicit', this.webcam.nonExplicit); + if (this.webcam.active) { + this.sendMe(); + } + }, "webcam.vipOnly": function () { LocalStorage.set('videoVipOnly', this.webcam.vipOnly); if (this.webcam.active) { @@ -437,6 +445,9 @@ export default { } } }, + "webcam.rememberExpresslyClosed": function() { + LocalStorage.set('rememberExpresslyClosed', this.webcam.rememberExpresslyClosed); + }, // Misc preference watches "prefs.joinMessages": function () { @@ -559,6 +570,7 @@ export default { if (this.webcam.nsfw) status |= this.VideoFlag.NSFW; if (this.webcam.mutual) status |= this.VideoFlag.MutualRequired; if (this.webcam.mutualOpen) status |= this.VideoFlag.MutualOpen; + if (this.webcam.nonExplicit) status |= this.VideoFlag.NonExplicit; if (this.webcam.vipOnly && this.isVIP) status |= this.VideoFlag.VipOnly; return status; }, @@ -749,6 +761,12 @@ export default { if (settings.videoExplicit === true) { this.webcam.nsfw = true; } + if (settings.videoNonExplicit === true) { + this.webcam.nonExplicit = true; + } + if (settings.rememberExpresslyClosed === false) { + this.webcam.rememberExpresslyClosed = false; + } // Misc preferences if (settings.joinMessages != undefined) { @@ -976,6 +994,15 @@ export default { } for (let row of this.whoList) { + // If we were watching this user's (blue) camera and we prefer non-Explicit, + // and their camera is now becoming explicit (red), close it now. + if (this.webcam.nonExplicit && this.WebRTC.streams[row.username] != undefined) { + if (!(this.whoMap[row.username].video & this.VideoFlag.NSFW) + && (row.video & this.VideoFlag.NSFW)) { + this.closeVideo(row.username, "offerer"); + } + } + this.whoMap[row.username] = row; this.whoOnline[row.username] = true; @@ -996,6 +1023,17 @@ export default { // are already watching them. this.unMutualVideo(); + // If we have any webcams open with users who are no longer in the Who List + // (e.g.: can happen during a server reboot when the Who List goes empty), + // close those video connections. Note: during normal room exit events this + // is done on the onUserExited function - this is an extra safety check especially + // in case of unexpected disconnect. + for (let username of Object.keys(this.WebRTC.pc)) { + if (this.whoOnline[username] == undefined) { + this.closeVideo(username); + } + } + // Has the back-end server forgotten we are on video? This can // happen if we disconnect/reconnect while we were streaming. if (this.webcam.active && !(this.whoMap[this.username]?.video & this.VideoFlag.Active)) { @@ -1418,7 +1456,7 @@ export default { // video enabled, and we 'X' out, and they reopen ours - we may be receiving their // video right now. If we had expressly closed it, do not accept their video // and hang up the connection. - if (this.WebRTC.expresslyClosed[username]) { + if (this.WebRTC.expresslyClosed[username] && this.webcam.rememberExpresslyClosed) { if (!isOfferer) { return; } @@ -1496,6 +1534,10 @@ export default { && this.webcam.active // Our camera is active (to add it) && !this.isBooted(username) // We had not booted them off ours before && !this.isMutedUser(username) // We had not muted them before + + // If our webcam is NSFW and the viewer prefers not to see explicit, + // do not send our camera on this offer. + && (!this.webcam.nsfw || !(this.whoMap[username].video & this.VideoFlag.NonExplicit)) ) { let stream = this.webcam.stream; stream.getTracks().forEach(track => { @@ -3185,40 +3227,63 @@ export default {

-
-