mirror of
https://github.com/jech/galene.git
synced 2024-11-22 16:45:58 +01:00
Make stats reporting independent of the number of tracks.
This commit is contained in:
parent
23cceba7ba
commit
a8ca2e8559
1 changed files with 22 additions and 25 deletions
|
@ -44,8 +44,7 @@ function Connection(id, pc) {
|
||||||
this.labelsByMid = {};
|
this.labelsByMid = {};
|
||||||
this.iceCandidates = [];
|
this.iceCandidates = [];
|
||||||
this.timers = [];
|
this.timers = [];
|
||||||
this.audioStats = {};
|
this.stats = {};
|
||||||
this.videoStats = {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Connection.prototype.setInterval = function(f, t) {
|
Connection.prototype.setInterval = function(f, t) {
|
||||||
|
@ -214,22 +213,21 @@ document.getElementById('requestselect').onchange = function(e) {
|
||||||
};
|
};
|
||||||
|
|
||||||
async function updateStats(conn, sender) {
|
async function updateStats(conn, sender) {
|
||||||
let stats;
|
let tid = sender.track && sender.track.id;
|
||||||
if(!sender.track)
|
if(!tid)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(sender.track.kind === 'audio')
|
let stats = conn.stats[tid];
|
||||||
stats = conn.audioStats;
|
if(!stats) {
|
||||||
else if(sender.track.kind === 'video')
|
conn.stats[tid] = {};
|
||||||
stats = conn.videoStats;
|
stats = conn.stats[tid];
|
||||||
else
|
}
|
||||||
return;
|
|
||||||
|
|
||||||
let report;
|
let report;
|
||||||
try {
|
try {
|
||||||
report = await sender.getStats();
|
report = await sender.getStats();
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
delete(stats.rate);
|
delete(stats[id].rate);
|
||||||
delete(stats.timestamp);
|
delete(stats.timestamp);
|
||||||
delete(stats.bytesSent);
|
delete(stats.bytesSent);
|
||||||
return;
|
return;
|
||||||
|
@ -254,25 +252,24 @@ async function updateStats(conn, sender) {
|
||||||
|
|
||||||
function displayStats(id) {
|
function displayStats(id) {
|
||||||
let conn = up[id];
|
let conn = up[id];
|
||||||
if(!conn.audioStats.rate && !conn.videoStats.rate) {
|
if(!conn) {
|
||||||
setLabel(id);
|
setLabel(id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let a = conn.audioStats.rate;
|
|
||||||
let v = conn.videoStats.rate;
|
|
||||||
|
|
||||||
let text = '';
|
let text = '';
|
||||||
if(a)
|
|
||||||
text = text + Math.round(a / 1000) + 'kbps';
|
conn.pc.getSenders().forEach(s => {
|
||||||
if(a && v)
|
let tid = s.track && s.track.id;
|
||||||
text = text + ' + ';
|
let stats = tid && conn.stats[tid];
|
||||||
if(v)
|
if(stats && stats.rate > 0) {
|
||||||
text = text + Math.round(v / 1000) + 'kbps';
|
if(text)
|
||||||
if(text)
|
text = text + ' + ';
|
||||||
setLabel(id, text);
|
text = text + Math.round(stats.rate / 1000) + 'kbps';
|
||||||
else
|
}
|
||||||
setLabel(id);
|
});
|
||||||
|
|
||||||
|
setLabel(id, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
function mapMediaOption(value) {
|
function mapMediaOption(value) {
|
||||||
|
|
Loading…
Reference in a new issue