Skip to content

Commit

Permalink
Add UI for simulcast control.
Browse files Browse the repository at this point in the history
  • Loading branch information
jech committed May 8, 2021
1 parent 795a40c commit 2f44961
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
6 changes: 6 additions & 0 deletions static/galene.css
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,12 @@ h1 {
margin-right: 0.4em;
}

#simulcastselect {
width: 8em;
text-align-last: center;
margin-right: 0.4em;
}

#requestselect {
width: 8em;
text-align-last: center;
Expand Down
9 changes: 9 additions & 0 deletions static/galene.html
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,15 @@ <h2>Settings</h2>
</select>
</form>

<form id="simulcastform">
<label for="simulcastselect" class="sidenav-label-first">Simulcast:</label>
<select id="simulcastselect" class="select select-inline">
<option value="off">off</option>
<option value="auto" selected>auto</option>
<option value="on">on</option>
</select>
</form>

<form id="requestform">
<label for="requestselect" class="sidenav-label">Receive:</label>
<select id="requestselect" class="select select-inline">
Expand Down
31 changes: 27 additions & 4 deletions static/galene.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function getUserPass() {
* @property {boolean} [localMute]
* @property {string} [video]
* @property {string} [audio]
* @property {boolean} [simulcast]
* @property {string} [simulcast]
* @property {string} [send]
* @property {string} [request]
* @property {boolean} [activityDetection]
Expand Down Expand Up @@ -229,6 +229,13 @@ function reflectSettings() {
store = true;
}

if(settings.hasOwnProperty('simulcast')) {
getSelectElement('simulcastselect').value = settings.simulcast
} else {
settings.simulcast = getSelectElement('simulcastselect').value;
store = true;
}

if(settings.hasOwnProperty('blackboardMode')) {
getInputElement('blackboardbox').checked = settings.blackboardMode;
} else {
Expand Down Expand Up @@ -538,6 +545,17 @@ getSelectElement('sendselect').onchange = async function(e) {
}
};

getSelectElement('simulcastselect').onchange = async function(e) {
if(!(this instanceof HTMLSelectElement))
throw new Error('Unexpected type for this');
updateSettings({simulcast: this.value});
let t = getMaxVideoThroughput();
for(let id in serverConnection.up) {
let c = serverConnection.up[id];
await setMaxVideoThroughput(c, t);
}
};

/**
* @param {string} what
* @returns {Object<string,Array<string>>}
Expand Down Expand Up @@ -1042,10 +1060,15 @@ const simulcastRate = 100000;
* @returns {boolean}
*/
function doSimulcast() {
if(!getSettings().simulcast)
switch(getSettings().simulcast) {
case 'on':
return true;
case 'off':
return false;
let bps = getMaxVideoThroughput();
return bps <= 0 || bps >= 2 * simulcastRate;
default:
let bps = getMaxVideoThroughput();
return bps <= 0 || bps >= 2 * simulcastRate;
}
}

/**
Expand Down

0 comments on commit 2f44961

Please sign in to comment.