Merge pull request #744 from jitsi/revert-741-dc_stats
Revert "Changes the connection quality stats to be sent by the data channels"
This commit is contained in:
commit
b0957f387e
|
@ -1133,27 +1133,27 @@ export default {
|
||||||
room.on(ConferenceEvents.CONNECTION_STATS, function (stats) {
|
room.on(ConferenceEvents.CONNECTION_STATS, function (stats) {
|
||||||
ConnectionQuality.updateLocalStats(stats);
|
ConnectionQuality.updateLocalStats(stats);
|
||||||
});
|
});
|
||||||
|
ConnectionQuality.addListener(
|
||||||
ConnectionQuality.addListener(CQEvents.LOCALSTATS_UPDATED,
|
CQEvents.LOCALSTATS_UPDATED,
|
||||||
(percent, stats) => {
|
(percent, stats) => {
|
||||||
APP.UI.updateLocalStats(percent, stats);
|
APP.UI.updateLocalStats(percent, stats);
|
||||||
room.sendDataChannelBroadcast({
|
|
||||||
type: this.commands.defaults.CONNECTION_QUALITY,
|
|
||||||
from: room.myUserId(),
|
|
||||||
values: stats });
|
|
||||||
});
|
|
||||||
|
|
||||||
room.on(ConferenceEvents.DATACHANNEL_ENDPOINT_MESSAGE_RECEIVED,
|
// send local stats to other users
|
||||||
(payload) => {
|
room.sendCommandOnce(this.commands.defaults.CONNECTION_QUALITY,
|
||||||
switch(payload.type) {
|
{
|
||||||
case this.commands.defaults.CONNECTION_QUALITY:
|
children: ConnectionQuality.convertToMUCStats(stats),
|
||||||
ConnectionQuality.updateRemoteStats(payload.from,
|
attributes: {
|
||||||
payload.values);
|
xmlns: 'http://jitsi.org/jitmeet/stats'
|
||||||
break;
|
}
|
||||||
default:
|
});
|
||||||
console.warn("Unknown datachannel message", payload);
|
}
|
||||||
}
|
);
|
||||||
});
|
|
||||||
|
// listen to remote stats
|
||||||
|
room.addCommandListener(this.commands.defaults.CONNECTION_QUALITY,
|
||||||
|
(values, from) => {
|
||||||
|
ConnectionQuality.updateRemoteStats(from, values);
|
||||||
|
});
|
||||||
|
|
||||||
ConnectionQuality.addListener(CQEvents.REMOTESTATS_UPDATED,
|
ConnectionQuality.addListener(CQEvents.REMOTESTATS_UPDATED,
|
||||||
(id, percent, stats) => {
|
(id, percent, stats) => {
|
||||||
|
|
|
@ -28,6 +28,39 @@ var localConnectionQuality = 100;
|
||||||
*/
|
*/
|
||||||
var remoteConnectionQuality = {};
|
var remoteConnectionQuality = {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts statistics to format used by VideoLayout
|
||||||
|
* @param stats
|
||||||
|
* @returns {{bitrate: {download: *, upload: *}, packetLoss: {total: *, download: *, upload: *}}}
|
||||||
|
*/
|
||||||
|
function parseMUCStats(stats) {
|
||||||
|
if(!stats || !stats.children || !stats.children.length)
|
||||||
|
return null;
|
||||||
|
var children = stats.children;
|
||||||
|
var extractedStats = {};
|
||||||
|
children.forEach((child) => {
|
||||||
|
if(child.tagName !== "stat" || !child.attributes)
|
||||||
|
return;
|
||||||
|
var attrKeys = Object.keys(child.attributes);
|
||||||
|
if(!attrKeys || !attrKeys.length)
|
||||||
|
return;
|
||||||
|
attrKeys.forEach((attr) => {
|
||||||
|
extractedStats[attr] = child.attributes[attr];
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
bitrate: {
|
||||||
|
download: extractedStats.bitrate_download,
|
||||||
|
upload: extractedStats.bitrate_upload
|
||||||
|
},
|
||||||
|
packetLoss: {
|
||||||
|
total: extractedStats.packetLoss_total,
|
||||||
|
download: extractedStats.packetLoss_download,
|
||||||
|
upload: extractedStats.packetLoss_upload
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates the quality percent based on passed new and old value.
|
* Calculates the quality percent based on passed new and old value.
|
||||||
* @param newVal the new value
|
* @param newVal the new value
|
||||||
|
@ -57,7 +90,8 @@ export default {
|
||||||
* @param data the statistics
|
* @param data the statistics
|
||||||
*/
|
*/
|
||||||
updateRemoteStats: function (id, data) {
|
updateRemoteStats: function (id, data) {
|
||||||
if (!data || !("packetLoss" in data) || !("total" in data.packetLoss)) {
|
data = parseMUCStats(data);
|
||||||
|
if (!data || !data.packetLoss || !data.packetLoss.total) {
|
||||||
eventEmitter.emit(CQEvents.REMOTESTATS_UPDATED, id, null, null);
|
eventEmitter.emit(CQEvents.REMOTESTATS_UPDATED, id, null, null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -81,5 +115,24 @@ export default {
|
||||||
|
|
||||||
addListener: function (type, listener) {
|
addListener: function (type, listener) {
|
||||||
eventEmitter.on(type, listener);
|
eventEmitter.on(type, listener);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts statistics to format for sending through XMPP
|
||||||
|
* @param stats the statistics
|
||||||
|
* @returns [{tagName: "stat", attributes: {{bitrate_donwload: *}},
|
||||||
|
* {tagName: "stat", attributes: {{ bitrate_uplpoad: *}},
|
||||||
|
* {tagName: "stat", attributes: {{ packetLoss_total: *}},
|
||||||
|
* {tagName: "stat", attributes: {{ packetLoss_download: *}},
|
||||||
|
* {tagName: "stat", attributes: {{ packetLoss_upload: *}}]
|
||||||
|
*/
|
||||||
|
convertToMUCStats: function (stats) {
|
||||||
|
return [
|
||||||
|
{tagName: "stat", attributes: {"bitrate_download": stats.bitrate.download}},
|
||||||
|
{tagName: "stat", attributes: {"bitrate_upload": stats.bitrate.upload}},
|
||||||
|
{tagName: "stat", attributes: {"packetLoss_total": stats.packetLoss.total}},
|
||||||
|
{tagName: "stat", attributes: {"packetLoss_download": stats.packetLoss.download}},
|
||||||
|
{tagName: "stat", attributes: {"packetLoss_upload": stats.packetLoss.upload}}
|
||||||
|
];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue