2016-10-25 22:57:29 +00:00
|
|
|
/* global $, APP, config */
|
2015-09-11 02:42:15 +00:00
|
|
|
/* jshint -W101 */
|
2017-04-21 21:14:14 +00:00
|
|
|
import {
|
|
|
|
setLargeVideoHDStatus
|
|
|
|
} from '../../../react/features/base/conference';
|
|
|
|
|
2015-12-14 12:26:50 +00:00
|
|
|
import JitsiPopover from "../util/JitsiPopover";
|
2016-03-15 20:26:22 +00:00
|
|
|
import VideoLayout from "./VideoLayout";
|
2016-10-26 03:05:32 +00:00
|
|
|
import UIUtil from "../util/UIUtil";
|
2015-01-07 14:54:03 +00:00
|
|
|
|
2016-10-31 20:53:08 +00:00
|
|
|
/**
|
|
|
|
* Maps a connection quality value (in percent) to the width of the "full" icon.
|
|
|
|
*/
|
|
|
|
const qualityToWidth = [
|
|
|
|
// Full (5 bars)
|
|
|
|
{percent: 80, width: "100%"},
|
|
|
|
// 4 bars
|
|
|
|
{percent: 60, width: "80%"},
|
|
|
|
// 3 bars
|
|
|
|
{percent: 40, width: "55%"},
|
|
|
|
// 2 bars
|
|
|
|
{percent: 20, width: "40%"},
|
|
|
|
// 1 bar
|
|
|
|
{percent: 0, width: "20%"}
|
|
|
|
// Note: we never show 0 bars.
|
|
|
|
];
|
|
|
|
|
2015-01-07 14:54:03 +00:00
|
|
|
/**
|
|
|
|
* Constructs new connection indicator.
|
|
|
|
* @param videoContainer the video container associated with the indicator.
|
2016-10-26 03:05:32 +00:00
|
|
|
* @param videoId the identifier of the video
|
2015-01-07 14:54:03 +00:00
|
|
|
* @constructor
|
|
|
|
*/
|
2016-10-26 03:05:32 +00:00
|
|
|
function ConnectionIndicator(videoContainer, videoId) {
|
2015-01-07 14:54:03 +00:00
|
|
|
this.videoContainer = videoContainer;
|
|
|
|
this.bandwidth = null;
|
|
|
|
this.packetLoss = null;
|
|
|
|
this.bitrate = null;
|
|
|
|
this.showMoreValue = false;
|
|
|
|
this.resolution = null;
|
2016-03-15 20:26:22 +00:00
|
|
|
this.isResolutionHD = null;
|
2015-01-07 14:54:03 +00:00
|
|
|
this.transport = [];
|
2017-03-13 20:39:40 +00:00
|
|
|
this.framerate = null;
|
2015-01-07 14:54:03 +00:00
|
|
|
this.popover = null;
|
2016-10-26 03:05:32 +00:00
|
|
|
this.id = videoId;
|
2015-01-07 14:54:03 +00:00
|
|
|
this.create();
|
|
|
|
}
|
|
|
|
|
2015-07-28 21:52:32 +00:00
|
|
|
ConnectionIndicator.getIP = function(value) {
|
2015-01-07 14:54:03 +00:00
|
|
|
return value.substring(0, value.lastIndexOf(":"));
|
|
|
|
};
|
|
|
|
|
2015-07-28 21:52:32 +00:00
|
|
|
ConnectionIndicator.getPort = function(value) {
|
2015-01-07 14:54:03 +00:00
|
|
|
return value.substring(value.lastIndexOf(":") + 1, value.length);
|
|
|
|
};
|
|
|
|
|
|
|
|
ConnectionIndicator.getStringFromArray = function (array) {
|
|
|
|
var res = "";
|
2015-07-28 21:52:32 +00:00
|
|
|
for(var i = 0; i < array.length; i++) {
|
2015-01-07 14:54:03 +00:00
|
|
|
res += (i === 0? "" : ", ") + array[i];
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generates the html content.
|
|
|
|
* @returns {string} the html content.
|
|
|
|
*/
|
|
|
|
ConnectionIndicator.prototype.generateText = function () {
|
2016-01-29 15:33:16 +00:00
|
|
|
var downloadBitrate, uploadBitrate, packetLoss, i;
|
2015-01-07 14:54:03 +00:00
|
|
|
|
2017-01-30 22:29:48 +00:00
|
|
|
if(!this.bitrate) {
|
2015-01-07 14:54:03 +00:00
|
|
|
downloadBitrate = "N/A";
|
|
|
|
uploadBitrate = "N/A";
|
|
|
|
}
|
2015-07-28 21:52:32 +00:00
|
|
|
else {
|
2015-01-07 14:54:03 +00:00
|
|
|
downloadBitrate =
|
|
|
|
this.bitrate.download? this.bitrate.download + " Kbps" : "N/A";
|
|
|
|
uploadBitrate =
|
|
|
|
this.bitrate.upload? this.bitrate.upload + " Kbps" : "N/A";
|
|
|
|
}
|
|
|
|
|
2017-01-30 22:29:48 +00:00
|
|
|
if(!this.packetLoss) {
|
2015-01-07 14:54:03 +00:00
|
|
|
packetLoss = "N/A";
|
2015-07-28 21:52:32 +00:00
|
|
|
} else {
|
2015-01-07 14:54:03 +00:00
|
|
|
|
2016-10-20 10:43:05 +00:00
|
|
|
packetLoss = "<span class='connection-info__download'>↓</span>" +
|
2015-07-28 21:52:32 +00:00
|
|
|
(this.packetLoss.download !== null ?
|
|
|
|
this.packetLoss.download : "N/A") +
|
2016-10-20 10:43:05 +00:00
|
|
|
"% <span class='connection-info__upload'>↑</span>" +
|
2015-07-28 21:52:32 +00:00
|
|
|
(this.packetLoss.upload !== null? this.packetLoss.upload : "N/A") +
|
|
|
|
"%";
|
2015-01-07 14:54:03 +00:00
|
|
|
}
|
|
|
|
|
2016-01-29 15:33:16 +00:00
|
|
|
// GENERATE RESOLUTIONS STRING
|
2017-03-13 20:39:40 +00:00
|
|
|
const resolutions = this.resolution || {};
|
|
|
|
const resolutionStr = Object.keys(resolutions).map(ssrc => {
|
2016-01-29 15:33:16 +00:00
|
|
|
let {width, height} = resolutions[ssrc];
|
|
|
|
return `${width}x${height}`;
|
|
|
|
}).join(', ') || 'N/A';
|
2015-01-07 14:54:03 +00:00
|
|
|
|
2017-03-13 20:39:40 +00:00
|
|
|
const framerates = this.framerate || {};
|
|
|
|
const frameRateStr = Object.keys(framerates).map(ssrc =>
|
|
|
|
framerates[ssrc]
|
|
|
|
).join(', ') || 'N/A';
|
|
|
|
|
2016-10-13 15:00:02 +00:00
|
|
|
let result = (
|
2016-10-19 14:57:16 +00:00
|
|
|
`<table class="connection-info__container" style='width:100%'>
|
2016-10-13 15:00:02 +00:00
|
|
|
<tr>
|
|
|
|
<td>
|
2016-10-21 18:17:17 +00:00
|
|
|
<span data-i18n='connectionindicator.bitrate'></span>
|
2016-10-13 15:00:02 +00:00
|
|
|
</td>
|
|
|
|
<td>
|
2016-10-20 10:43:05 +00:00
|
|
|
<span class='connection-info__download'>↓</span>${downloadBitrate}
|
|
|
|
<span class='connection-info__upload'>↑</span>${uploadBitrate}
|
2016-10-13 15:00:02 +00:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>
|
2016-10-21 18:17:17 +00:00
|
|
|
<span data-i18n='connectionindicator.packetloss'></span>
|
2016-10-13 15:00:02 +00:00
|
|
|
</td>
|
|
|
|
<td>${packetLoss}</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>
|
2016-10-21 18:17:17 +00:00
|
|
|
<span data-i18n='connectionindicator.resolution'></span>
|
2016-10-13 15:00:02 +00:00
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
${resolutionStr}
|
|
|
|
</td>
|
|
|
|
</tr>
|
2017-03-13 20:39:40 +00:00
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
<span data-i18n='connectionindicator.framerate'></span>
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
${frameRateStr}
|
|
|
|
</td>
|
|
|
|
</tr>
|
2016-10-13 15:00:02 +00:00
|
|
|
</table>`);
|
2015-01-07 14:54:03 +00:00
|
|
|
|
2015-06-23 08:00:46 +00:00
|
|
|
if(this.videoContainer.videoSpanId == "localVideoContainer") {
|
2016-10-13 13:16:13 +00:00
|
|
|
result += "<a class=\"jitsipopover__showmore link\" " +
|
2015-01-28 14:35:22 +00:00
|
|
|
"onclick = \"APP.UI.connectionIndicatorShowMore('" +
|
2015-12-14 12:26:50 +00:00
|
|
|
// FIXME: we do not know local id when this text is generated
|
|
|
|
//this.id + "')\" data-i18n='connectionindicator." +
|
2015-07-20 17:32:04 +00:00
|
|
|
"local')\" data-i18n='connectionindicator." +
|
2016-10-21 18:17:17 +00:00
|
|
|
(this.showMoreValue ? "less" : "more") + "'></a>";
|
2015-02-06 15:46:50 +00:00
|
|
|
}
|
2015-01-07 14:54:03 +00:00
|
|
|
|
2015-07-28 21:52:32 +00:00
|
|
|
if (this.showMoreValue) {
|
2015-01-07 14:54:03 +00:00
|
|
|
var downloadBandwidth, uploadBandwidth, transport;
|
2017-01-30 22:29:48 +00:00
|
|
|
if (!this.bandwidth) {
|
2015-01-07 14:54:03 +00:00
|
|
|
downloadBandwidth = "N/A";
|
|
|
|
uploadBandwidth = "N/A";
|
2015-07-28 21:52:32 +00:00
|
|
|
} else {
|
2015-01-07 14:54:03 +00:00
|
|
|
downloadBandwidth = this.bandwidth.download?
|
|
|
|
this.bandwidth.download + " Kbps" :
|
|
|
|
"N/A";
|
|
|
|
uploadBandwidth = this.bandwidth.upload?
|
|
|
|
this.bandwidth.upload + " Kbps" :
|
|
|
|
"N/A";
|
|
|
|
}
|
|
|
|
|
2015-07-28 21:52:32 +00:00
|
|
|
if (!this.transport || this.transport.length === 0) {
|
2015-01-07 14:54:03 +00:00
|
|
|
transport = "<tr>" +
|
2016-10-13 13:16:13 +00:00
|
|
|
"<td><span " +
|
2016-10-21 17:11:22 +00:00
|
|
|
"data-i18n='connectionindicator.address'></span></td>" +
|
2015-01-07 14:54:03 +00:00
|
|
|
"<td> N/A</td></tr>";
|
2015-07-28 21:52:32 +00:00
|
|
|
} else {
|
2017-03-13 22:13:01 +00:00
|
|
|
var data = {
|
|
|
|
remoteIP: [],
|
|
|
|
localIP:[],
|
|
|
|
remotePort:[],
|
|
|
|
localPort:[],
|
|
|
|
transportType:[]};
|
2015-07-28 21:52:32 +00:00
|
|
|
for(i = 0; i < this.transport.length; i++) {
|
2015-01-07 14:54:03 +00:00
|
|
|
var ip = ConnectionIndicator.getIP(this.transport[i].ip);
|
|
|
|
var port = ConnectionIndicator.getPort(this.transport[i].ip);
|
|
|
|
var localIP =
|
|
|
|
ConnectionIndicator.getIP(this.transport[i].localip);
|
|
|
|
var localPort =
|
|
|
|
ConnectionIndicator.getPort(this.transport[i].localip);
|
2015-07-28 21:52:32 +00:00
|
|
|
if(data.remoteIP.indexOf(ip) == -1) {
|
2015-01-07 14:54:03 +00:00
|
|
|
data.remoteIP.push(ip);
|
|
|
|
}
|
|
|
|
|
2015-07-28 21:52:32 +00:00
|
|
|
if(data.remotePort.indexOf(port) == -1) {
|
2015-01-07 14:54:03 +00:00
|
|
|
data.remotePort.push(port);
|
|
|
|
}
|
|
|
|
|
2015-07-28 21:52:32 +00:00
|
|
|
if(data.localIP.indexOf(localIP) == -1) {
|
2015-01-07 14:54:03 +00:00
|
|
|
data.localIP.push(localIP);
|
|
|
|
}
|
|
|
|
|
2015-07-28 21:52:32 +00:00
|
|
|
if(data.localPort.indexOf(localPort) == -1) {
|
2015-01-07 14:54:03 +00:00
|
|
|
data.localPort.push(localPort);
|
|
|
|
}
|
2017-03-13 22:13:01 +00:00
|
|
|
|
|
|
|
if(data.transportType.indexOf(this.transport[i].type) == -1) {
|
|
|
|
data.transportType.push(this.transport[i].type);
|
|
|
|
}
|
2015-01-07 14:54:03 +00:00
|
|
|
}
|
2015-02-06 15:46:50 +00:00
|
|
|
|
2017-02-20 18:06:35 +00:00
|
|
|
// All of the transports should be either P2P or JVB
|
|
|
|
const isP2P = this.transport.length ? this.transport[0].p2p : false;
|
|
|
|
|
2015-02-27 17:58:05 +00:00
|
|
|
var local_address_key = "connectionindicator.localaddress";
|
|
|
|
var remote_address_key = "connectionindicator.remoteaddress";
|
2015-01-07 14:54:03 +00:00
|
|
|
var localTransport =
|
2016-10-13 13:16:13 +00:00
|
|
|
"<tr><td><span data-i18n='" +
|
2015-02-27 17:58:05 +00:00
|
|
|
local_address_key +"' data-i18n-options='" +
|
2016-10-21 18:17:17 +00:00
|
|
|
JSON.stringify({count: data.localIP.length})
|
|
|
|
+ "'></span></td><td> " +
|
2015-01-07 14:54:03 +00:00
|
|
|
ConnectionIndicator.getStringFromArray(data.localIP) +
|
|
|
|
"</td></tr>";
|
|
|
|
transport =
|
2016-10-13 13:16:13 +00:00
|
|
|
"<tr><td><span data-i18n='" +
|
2015-02-27 17:58:05 +00:00
|
|
|
remote_address_key + "' data-i18n-options='" +
|
2016-10-21 18:17:17 +00:00
|
|
|
JSON.stringify({count: data.remoteIP.length})
|
|
|
|
+ "'></span></td><td> " +
|
2017-04-03 14:59:22 +00:00
|
|
|
ConnectionIndicator.getStringFromArray(data.remoteIP);
|
|
|
|
|
|
|
|
// Append (p2p) to indicate the P2P type of transport
|
|
|
|
if (isP2P) {
|
|
|
|
transport
|
|
|
|
+= "<span data-i18n='connectionindicator.peer_to_peer'>";
|
|
|
|
}
|
|
|
|
transport += "</td></tr>";
|
2015-02-06 15:46:50 +00:00
|
|
|
|
2015-02-27 17:58:05 +00:00
|
|
|
var key_remote = "connectionindicator.remoteport",
|
|
|
|
key_local = "connectionindicator.localport";
|
2015-01-07 14:54:03 +00:00
|
|
|
|
2015-02-06 15:46:50 +00:00
|
|
|
transport += "<tr>" +
|
|
|
|
"<td>" +
|
2016-10-13 13:16:13 +00:00
|
|
|
"<span data-i18n='" + key_remote +
|
2015-02-27 17:58:05 +00:00
|
|
|
"' data-i18n-options='" +
|
2016-10-21 18:17:17 +00:00
|
|
|
JSON.stringify({count: this.transport.length})
|
|
|
|
+ "'></span></td><td>";
|
2015-02-06 15:46:50 +00:00
|
|
|
localTransport += "<tr>" +
|
|
|
|
"<td>" +
|
2016-10-13 13:16:13 +00:00
|
|
|
"<span data-i18n='" + key_local +
|
2015-02-27 17:58:05 +00:00
|
|
|
"' data-i18n-options='" +
|
2016-10-21 18:17:17 +00:00
|
|
|
JSON.stringify({count: this.transport.length})
|
|
|
|
+ "'></span></td><td>";
|
2015-02-06 15:46:50 +00:00
|
|
|
|
2015-01-07 14:54:03 +00:00
|
|
|
transport +=
|
|
|
|
ConnectionIndicator.getStringFromArray(data.remotePort);
|
|
|
|
localTransport +=
|
|
|
|
ConnectionIndicator.getStringFromArray(data.localPort);
|
|
|
|
transport += "</td></tr>";
|
|
|
|
transport += localTransport + "</td></tr>";
|
|
|
|
transport +="<tr>" +
|
2017-03-13 22:13:01 +00:00
|
|
|
"<td><span data-i18n='connectionindicator.transport' "
|
|
|
|
+ " data-i18n-options='" +
|
|
|
|
JSON.stringify({count: data.transportType.length})
|
|
|
|
+ "'></span></td>" +
|
|
|
|
"<td>"
|
2017-02-20 18:06:35 +00:00
|
|
|
+ ConnectionIndicator.getStringFromArray(data.transportType);
|
2017-04-03 14:59:22 +00:00
|
|
|
+ "</td></tr>";
|
2015-01-07 14:54:03 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-10-19 14:57:16 +00:00
|
|
|
result += "<table class='connection-info__container' style='width:100%'>" +
|
2015-01-07 14:54:03 +00:00
|
|
|
"<tr>" +
|
|
|
|
"<td>" +
|
2016-10-21 18:17:17 +00:00
|
|
|
"<span data-i18n='connectionindicator.bandwidth'></span>" +
|
2015-01-07 14:54:03 +00:00
|
|
|
"</td><td>" +
|
2016-10-20 10:43:05 +00:00
|
|
|
"<span class='connection-info__download'>↓</span>" +
|
2015-01-07 14:54:03 +00:00
|
|
|
downloadBandwidth +
|
2016-10-20 10:43:05 +00:00
|
|
|
" <span class='connection-info__upload'>↑</span>" +
|
2015-01-07 14:54:03 +00:00
|
|
|
uploadBandwidth + "</td></tr>";
|
|
|
|
|
|
|
|
result += transport + "</table>";
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows or hide the additional information.
|
|
|
|
*/
|
|
|
|
ConnectionIndicator.prototype.showMore = function () {
|
|
|
|
this.showMoreValue = !this.showMoreValue;
|
|
|
|
this.updatePopoverData();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-09-16 19:52:07 +00:00
|
|
|
function createIcon(classes, iconClass) {
|
2015-01-07 14:54:03 +00:00
|
|
|
var icon = document.createElement("span");
|
2015-07-28 21:52:32 +00:00
|
|
|
for(var i in classes) {
|
2015-01-07 14:54:03 +00:00
|
|
|
icon.classList.add(classes[i]);
|
|
|
|
}
|
|
|
|
icon.appendChild(
|
2016-09-16 19:52:07 +00:00
|
|
|
document.createElement("i")).classList.add(iconClass);
|
2015-01-07 14:54:03 +00:00
|
|
|
return icon;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates the indicator
|
|
|
|
*/
|
|
|
|
ConnectionIndicator.prototype.create = function () {
|
2016-10-26 03:05:32 +00:00
|
|
|
let indicatorId = 'connectionindicator';
|
|
|
|
let element = UIUtil.getVideoThumbnailIndicatorSpan({
|
|
|
|
videoSpanId: this.videoContainer.videoSpanId,
|
|
|
|
indicatorId
|
|
|
|
});
|
2016-10-26 14:50:39 +00:00
|
|
|
element.classList.add('show');
|
2016-10-26 03:05:32 +00:00
|
|
|
this.connectionIndicatorContainer = element;
|
|
|
|
|
|
|
|
let popoverContent = (
|
|
|
|
`<div class="connection-info" data-i18n="${indicatorId}.na"></div>`
|
|
|
|
);
|
2016-10-26 12:18:48 +00:00
|
|
|
this.popover = new JitsiPopover($(element), {
|
2016-10-26 03:05:32 +00:00
|
|
|
content: popoverContent,
|
|
|
|
skin: "black",
|
|
|
|
onBeforePosition: el => APP.translation.translateElement(el)
|
|
|
|
});
|
2015-01-07 14:54:03 +00:00
|
|
|
|
2016-04-09 17:35:54 +00:00
|
|
|
// override popover show method to make sure we will update the content
|
|
|
|
// before showing the popover
|
|
|
|
var origShowFunc = this.popover.show;
|
|
|
|
this.popover.show = function () {
|
|
|
|
// update content by forcing it, to finish even if popover
|
|
|
|
// is not visible
|
|
|
|
this.updatePopoverData(true);
|
|
|
|
// call the original show, passing its actual this
|
|
|
|
origShowFunc.call(this.popover);
|
|
|
|
}.bind(this);
|
|
|
|
|
2016-10-26 14:50:39 +00:00
|
|
|
let connectionIconContainer = document.createElement('div');
|
|
|
|
connectionIconContainer.className = 'connection indicatoricon';
|
|
|
|
|
|
|
|
|
|
|
|
this.emptyIcon = connectionIconContainer.appendChild(
|
|
|
|
createIcon(["connection_empty"], "icon-connection"));
|
|
|
|
this.fullIcon = connectionIconContainer.appendChild(
|
|
|
|
createIcon(["connection_full"], "icon-connection"));
|
|
|
|
this.interruptedIndicator = connectionIconContainer.appendChild(
|
|
|
|
createIcon(["connection_lost"],"icon-connection-lost"));
|
|
|
|
|
2016-09-16 20:33:22 +00:00
|
|
|
$(this.interruptedIndicator).hide();
|
2016-10-26 14:50:39 +00:00
|
|
|
this.connectionIndicatorContainer.appendChild(connectionIconContainer);
|
2015-01-07 14:54:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes the indicator
|
|
|
|
*/
|
2015-07-28 21:52:32 +00:00
|
|
|
ConnectionIndicator.prototype.remove = function() {
|
2015-07-10 09:57:20 +00:00
|
|
|
if (this.connectionIndicatorContainer.parentNode) {
|
|
|
|
this.connectionIndicatorContainer.parentNode.removeChild(
|
|
|
|
this.connectionIndicatorContainer);
|
|
|
|
}
|
2015-01-07 14:54:03 +00:00
|
|
|
this.popover.forceHide();
|
|
|
|
};
|
|
|
|
|
2016-09-16 20:33:22 +00:00
|
|
|
/**
|
|
|
|
* Updates the UI which displays warning about user's connectivity problems.
|
|
|
|
*
|
|
|
|
* @param {boolean} isActive true if the connection is working fine or false if
|
|
|
|
* the user is having connectivity issues.
|
|
|
|
*/
|
|
|
|
ConnectionIndicator.prototype.updateConnectionStatusIndicator
|
2017-03-21 17:14:13 +00:00
|
|
|
= function (isActive) {
|
|
|
|
this.isConnectionActive = isActive;
|
|
|
|
if (this.isConnectionActive) {
|
|
|
|
$(this.interruptedIndicator).hide();
|
|
|
|
$(this.emptyIcon).show();
|
|
|
|
$(this.fullIcon).show();
|
|
|
|
} else {
|
|
|
|
$(this.interruptedIndicator).show();
|
|
|
|
$(this.emptyIcon).hide();
|
|
|
|
$(this.fullIcon).hide();
|
|
|
|
}
|
2016-09-16 20:33:22 +00:00
|
|
|
};
|
|
|
|
|
2015-01-07 14:54:03 +00:00
|
|
|
/**
|
|
|
|
* Updates the data of the indicator
|
|
|
|
* @param percent the percent of connection quality
|
|
|
|
* @param object the statistics data.
|
|
|
|
*/
|
|
|
|
ConnectionIndicator.prototype.updateConnectionQuality =
|
2015-07-28 21:52:32 +00:00
|
|
|
function (percent, object) {
|
2017-01-30 22:29:48 +00:00
|
|
|
if (!percent) {
|
2015-01-07 14:54:03 +00:00
|
|
|
this.connectionIndicatorContainer.style.display = "none";
|
|
|
|
this.popover.forceHide();
|
|
|
|
return;
|
2015-07-28 21:52:32 +00:00
|
|
|
} else {
|
2015-01-07 14:54:03 +00:00
|
|
|
if(this.connectionIndicatorContainer.style.display == "none") {
|
|
|
|
this.connectionIndicatorContainer.style.display = "block";
|
|
|
|
}
|
|
|
|
}
|
2016-09-16 19:57:56 +00:00
|
|
|
if (object) {
|
|
|
|
this.bandwidth = object.bandwidth;
|
|
|
|
this.bitrate = object.bitrate;
|
|
|
|
this.packetLoss = object.packetLoss;
|
|
|
|
this.transport = object.transport;
|
|
|
|
if (object.resolution) {
|
|
|
|
this.resolution = object.resolution;
|
|
|
|
}
|
2017-03-13 20:39:40 +00:00
|
|
|
if (object.framerate)
|
|
|
|
this.framerate = object.framerate;
|
2015-01-07 14:54:03 +00:00
|
|
|
}
|
2016-10-31 20:53:08 +00:00
|
|
|
|
|
|
|
let width = qualityToWidth.find(x => percent >= x.percent);
|
|
|
|
this.fullIcon.style.width = width.width;
|
|
|
|
|
2016-09-16 19:57:56 +00:00
|
|
|
if (object && typeof object.isResolutionHD === 'boolean') {
|
2016-03-15 20:26:22 +00:00
|
|
|
this.isResolutionHD = object.isResolutionHD;
|
|
|
|
}
|
|
|
|
this.updateResolutionIndicator();
|
2015-01-07 14:54:03 +00:00
|
|
|
this.updatePopoverData();
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates the resolution
|
|
|
|
* @param resolution the new resolution
|
|
|
|
*/
|
|
|
|
ConnectionIndicator.prototype.updateResolution = function (resolution) {
|
|
|
|
this.resolution = resolution;
|
2016-03-15 20:26:22 +00:00
|
|
|
this.updateResolutionIndicator();
|
2015-01-07 14:54:03 +00:00
|
|
|
this.updatePopoverData();
|
|
|
|
};
|
|
|
|
|
2017-03-17 21:10:45 +00:00
|
|
|
/**
|
|
|
|
* Updates the framerate
|
|
|
|
* @param framerate the new resolution
|
|
|
|
*/
|
|
|
|
ConnectionIndicator.prototype.updateFramerate = function (framerate) {
|
|
|
|
this.framerate = framerate;
|
|
|
|
this.updatePopoverData();
|
|
|
|
};
|
|
|
|
|
2015-01-07 14:54:03 +00:00
|
|
|
/**
|
2016-04-09 17:35:54 +00:00
|
|
|
* Updates the content of the popover if its visible
|
|
|
|
* @param force to work even if popover is not visible
|
2015-01-07 14:54:03 +00:00
|
|
|
*/
|
2016-04-09 17:35:54 +00:00
|
|
|
ConnectionIndicator.prototype.updatePopoverData = function (force) {
|
|
|
|
// generate content, translate it and add it to document only if
|
|
|
|
// popover is visible or we force to do so.
|
|
|
|
if(this.popover.popoverShown || force) {
|
|
|
|
this.popover.updateContent(
|
2016-10-19 14:57:16 +00:00
|
|
|
`<div class="connection-info">${this.generateText()}</div>`
|
2016-04-09 17:35:54 +00:00
|
|
|
);
|
|
|
|
}
|
2015-01-07 14:54:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Hides the popover
|
|
|
|
*/
|
|
|
|
ConnectionIndicator.prototype.hide = function () {
|
|
|
|
this.popover.forceHide();
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Hides the indicator
|
|
|
|
*/
|
|
|
|
ConnectionIndicator.prototype.hideIndicator = function () {
|
|
|
|
this.connectionIndicatorContainer.style.display = "none";
|
|
|
|
if(this.popover)
|
|
|
|
this.popover.forceHide();
|
|
|
|
};
|
|
|
|
|
2016-03-15 20:26:22 +00:00
|
|
|
/**
|
|
|
|
* Updates the resolution indicator.
|
|
|
|
*/
|
|
|
|
ConnectionIndicator.prototype.updateResolutionIndicator = function () {
|
|
|
|
|
|
|
|
if (this.id !== null
|
|
|
|
&& VideoLayout.isCurrentlyOnLarge(this.id)) {
|
|
|
|
|
|
|
|
let showResolutionLabel = false;
|
|
|
|
|
|
|
|
if (this.isResolutionHD !== null)
|
|
|
|
showResolutionLabel = this.isResolutionHD;
|
|
|
|
else if (this.resolution !== null) {
|
|
|
|
let resolutions = this.resolution || {};
|
|
|
|
Object.keys(resolutions).map(function (ssrc) {
|
2016-10-03 16:12:04 +00:00
|
|
|
const { height } = resolutions[ssrc];
|
2016-03-24 17:17:58 +00:00
|
|
|
if (height >= config.minHDHeight)
|
2016-03-15 20:26:22 +00:00
|
|
|
showResolutionLabel = true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-04-21 21:14:14 +00:00
|
|
|
APP.store.dispatch(setLargeVideoHDStatus(showResolutionLabel));
|
2016-03-15 20:26:22 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-10-27 18:17:17 +00:00
|
|
|
/**
|
|
|
|
* Adds a hover listener to the popover.
|
|
|
|
*/
|
|
|
|
ConnectionIndicator.prototype.addPopoverHoverListener = function (listener) {
|
|
|
|
this.popover.addOnHoverPopover(listener);
|
|
|
|
};
|
|
|
|
|
2015-12-14 12:26:50 +00:00
|
|
|
export default ConnectionIndicator;
|