From 7d10de8546be72fc09decbb37c625703e69945db Mon Sep 17 00:00:00 2001 From: Jeff Kaufman Date: Sat, 30 Jan 2021 02:26:11 +0000 Subject: [PATCH] ui: show whether people are muted --- html/demo.js | 12 ++++++++++++ html/index.html | 3 +++ html/net.js | 7 ++++++- server.py | 15 ++++++++++----- 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/html/demo.js b/html/demo.js index 28bac1e..fe6eaa8 100644 --- a/html/demo.js +++ b/html/demo.js @@ -1092,6 +1092,7 @@ function update_active_users( const mic_volume = user_summary[i][2]; const userid = user_summary[i][3]; const rms_volume = user_summary[i][4]; + const muted = user_summary[i][5]; let est_bucket = estimateBucket(offset_s); if (!showBuckets) { @@ -1129,6 +1130,14 @@ function update_active_users( const participantDiv = participantDivs[userid]; const displayName = userid == myUserid ? (name + " (me)") : name; + if (participantDiv) { + if (muted) { + participantDiv.classList.add("muted"); + } else { + participantDiv.classList.remove("muted"); + } + } + if (participantDiv && participantDiv.name != displayName) { // First child is always participantInfo. participantDiv.children[0].innerText = displayName; @@ -1829,6 +1838,9 @@ async function start_singing() { window.bpr.value = server_bpr; last_server_bpr = server_bpr; } + if (micPaused) { + singer_client.x_send_metadata("muted", 1); + } singer_client.x_send_metadata("user_summary", 1); if (in_spectator_mode) { singer_client.x_send_metadata("spectator", 1); diff --git a/html/index.html b/html/index.html index 34c6543..6862b04 100644 --- a/html/index.html +++ b/html/index.html @@ -423,6 +423,9 @@ .dominant-speaker { border: 1px solid #0b0; } +.muted { + border: 1px solid #d00; +} .participantInfo { margin: 0.25em; } diff --git a/html/net.js b/html/net.js index ff31d5a..0619099 100644 --- a/html/net.js +++ b/html/net.js @@ -201,7 +201,12 @@ export class ServerConnection extends ServerConnectionBase { 0, /*littleEndian=*/false); pos += 2; - metadata.user_summary.push([delay, name, mic_volume, userid, rms_volume]); + const muted = + new DataView(data.slice(pos, pos + 1)).getUint8(0); + pos += 1; + + metadata.user_summary.push([ + delay, name, mic_volume, userid, rms_volume, muted]); } data = data.slice(pos); } diff --git a/server.py b/server.py index 2d11106..1475514 100755 --- a/server.py +++ b/server.py @@ -33,7 +33,8 @@ # 4 mic_volume: float32, # 4 rms_volume: float32 # 2 delay: uint16 -BINARY_USER_CONFIG_FORMAT = struct.Struct(">Q32sffH") +# 1 muted: boolean +BINARY_USER_CONFIG_FORMAT = struct.Struct(">Q32sffH?") FRAME_SIZE = 128 @@ -353,6 +354,7 @@ def __init__(self, userid, name, last_heard_server_clock, delay_samples) -> None self.client_telemetry = {} # unstructured info from client self.in_spectator_mode = False; + self.muted = False; self.mark_sent() @@ -619,7 +621,8 @@ def user_summary(requested_user_summary) -> List[Any]: user.name, user.mic_volume, user.userid, - user.rms_volume)) + user.rms_volume, + user.muted)) summary.sort() return summary @@ -638,7 +641,7 @@ def binary_user_summary(summary): compact by only sending names if they have changed. """ binary_summaries = [struct.pack(">H", len(summary))] - for delay, name, mic_volume, userid, rms_volume in summary: + for delay, name, mic_volume, userid, rms_volume, muted in summary: # delay is encoded as a uint16 if delay < 0: delay = 0 @@ -650,7 +653,8 @@ def binary_user_summary(summary): name.encode('utf8'), mic_volume, rms_volume, - delay)) + delay, + muted)) resp = np.frombuffer(b"".join(binary_summaries), dtype=np.uint8) if len(resp) != summary_length(len(summary)): @@ -1062,6 +1066,7 @@ def handle_post(in_json, in_data) -> Tuple[Any, str]: user.client_address = in_json["client_address"] user.in_spectator_mode = query_params.get("spectator", None) + user.muted = query_params.get("muted", None) == "1" client_telemetry = query_params.get("client_telemetry", None) if client_telemetry: @@ -1229,7 +1234,7 @@ def maybe_print_status() -> None: print("-"*70) for delay, name, mic_volume, userid, \ - rms_volume in user_summary(requested_user_summary=True): + rms_volume, muted in user_summary(requested_user_summary=True): print ("%s %s vol=%.2f rms=%.5f" % ( str(delay).rjust(3), name.rjust(30),