Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
Creates connection quality module.
hristoterezove20274c2f7e9
diff --git a/app.js b/app.jsindex af66b3de34..23cf7daed9 100644--- a/app.js+++ b/app.js@@ -834,8 +834,6 @@ $(document).ready(function () {APIConnector.init();UI.start();- statistics.addConnectionStatsListener(ConnectionQuality.updateLocalStats);- statistics.addRemoteStatsStopListener(ConnectionQuality.stopSendingStats);statistics.start();Moderator.init();diff --git a/connectionquality.js b/connectionquality.jsdeleted file mode 100644index 73390a7d0a..0000000000--- a/connectionquality.js+++ /dev/null@@ -1,127 +0,0 @@-var ConnectionQuality = (function () {-- /**- * Constructs new ConnectionQuality object- * @constructor- */- function ConnectionQuality() {-- }-- /**- * local stats- * @type {{}}- */- var stats = {};-- /**- * remote stats- * @type {{}}- */- var remoteStats = {};-- /**- * Interval for sending statistics to other participants- * @type {null}- */- var sendIntervalId = null;-- /**- * Updates the local statistics- * @param data new statistics- */- ConnectionQuality.updateLocalStats = function (data) {- stats = data;- UI.updateLocalConnectionStats(100 - stats.packetLoss.total,stats);- if(sendIntervalId == null)- {- startSendingStats();- }- };-- /**- * Start statistics sending.- */- function startSendingStats() {- sendStats();- sendIntervalId = setInterval(sendStats, 10000);- }-- /**- * Sends statistics to other participants- */- function sendStats() {- connection.emuc.addConnectionInfoToPresence(convertToMUCStats(stats));- connection.emuc.sendPresence();- }-- /**- * Converts statistics to format for sending through XMPP- * @param stats the statistics- * @returns {{bitrate_donwload: *, bitrate_uplpoad: *, packetLoss_total: *, packetLoss_download: *, packetLoss_upload: *}}- */- function convertToMUCStats(stats) {- return {- "bitrate_download": stats.bitrate.download,- "bitrate_upload": stats.bitrate.upload,- "packetLoss_total": stats.packetLoss.total,- "packetLoss_download": stats.packetLoss.download,- "packetLoss_upload": stats.packetLoss.upload- };- }-- /**- * Converts statitistics to format used by VideoLayout- * @param stats- * @returns {{bitrate: {download: *, upload: *}, packetLoss: {total: *, download: *, upload: *}}}- */- function parseMUCStats(stats) {- return {- bitrate: {- download: stats.bitrate_download,- upload: stats.bitrate_upload- },- packetLoss: {- total: stats.packetLoss_total,- download: stats.packetLoss_download,- upload: stats.packetLoss_upload- }- };- }-- /**- * Updates remote statistics- * @param jid the jid associated with the statistics- * @param data the statistics- */- ConnectionQuality.updateRemoteStats = function (jid, data) {- if(data == null || data.packetLoss_total == null)- {- UI.updateConnectionStats(jid, null, null);- return;- }- remoteStats[jid] = parseMUCStats(data);-- UI.updateConnectionStats(jid, 100 - data.packetLoss_total,remoteStats[jid]);-- };-- /**- * Stops statistics sending.- */- ConnectionQuality.stopSendingStats = function () {- clearInterval(sendIntervalId);- sendIntervalId = null;- //notify UI about stopping statistics gathering- UI.onStatsStop();- };-- /**- * Returns the local statistics.- */- ConnectionQuality.getStats = function () {- return stats;- }-- return ConnectionQuality;-})();\ No newline at end of filediff --git a/index.html b/index.htmlindex 33207ec8fc..a8cbeb8a49 100644--- a/index.html+++ b/index.html@@ -30,6 +30,7 @@<script src="service/RTC/RTCBrowserType.js?v=1"></script><script src="service/RTC/StreamEventTypes.js?v=1"></script><script src="service/RTC/MediaStreamTypes.js?v=1"></script>+ <script src="libs/modules/connectionquality.bundle.js?v=1"></script><script src="libs/modules/UI.bundle.js?v=1"></script><script src="libs/modules/statistics.bundle.js?v=1"></script><script src="libs/modules/RTC.bundle.js?v=1"></script>@@ -40,7 +41,6 @@<script src="util.js?v=7"></script><!-- utility functions --><script src="moderatemuc.js?v=4"></script><!-- moderator plugin --><script src="analytics.js?v=1"></script><!-- google analytics plugin -->- <script src="connectionquality.js?v=1"></script><script src="moderator.js?v=2"></script><!-- media stream --><script src="tracking.js?v=1"></script><!-- tracking --><script src="api_connector.js?v=2"></script>diff --git a/libs/modules/UI.bundle.js b/libs/modules/UI.bundle.jsindex b744242077..3485701dbf 100644--- a/libs/modules/UI.bundle.js+++ b/libs/modules/UI.bundle.js@@ -3782,7 +3782,7 @@ ConnectionIndicator.prototype.generateText = function () {}var resolutionValue = null;- if(this.resolution)+ if(this.resolution && this.jid != null){var keys = Object.keys(this.resolution);if(keys.length == 1)diff --git a/libs/modules/connection_quality.bundle.js b/libs/modules/connection_quality.bundle.jsnew file mode 100644index 0000000000..50b92a66d3--- /dev/null+++ b/libs/modules/connection_quality.bundle.js@@ -0,0 +1,122 @@+!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n;"undefined"!=typeof window?n=window:"undefined"!=typeof global?n=global:"undefined"!=typeof self&&(n=self),n.connectionquality=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){+/**+ * local stats+ * @type {{}}+ */+var stats = {};++/**+ * remote stats+ * @type {{}}+ */+var remoteStats = {};++/**+ * Interval for sending statistics to other participants+ * @type {null}+ */+var sendIntervalId = null;+++/**+ * Start statistics sending.+ */+function startSendingStats() {+ sendStats();+ sendIntervalId = setInterval(sendStats, 10000);+}++/**+ * Sends statistics to other participants+ */+function sendStats() {+ connection.emuc.addConnectionInfoToPresence(convertToMUCStats(stats));+ connection.emuc.sendPresence();+}++/**+ * Converts statistics to format for sending through XMPP+ * @param stats the statistics+ * @returns {{bitrate_donwload: *, bitrate_uplpoad: *, packetLoss_total: *, packetLoss_download: *, packetLoss_upload: *}}+ */+function convertToMUCStats(stats) {+ return {+ "bitrate_download": stats.bitrate.download,+ "bitrate_upload": stats.bitrate.upload,+ "packetLoss_total": stats.packetLoss.total,+ "packetLoss_download": stats.packetLoss.download,+ "packetLoss_upload": stats.packetLoss.upload+ };+}++/**+ * Converts statitistics to format used by VideoLayout+ * @param stats+ * @returns {{bitrate: {download: *, upload: *}, packetLoss: {total: *, download: *, upload: *}}}+ */+function parseMUCStats(stats) {+ return {+ bitrate: {+ download: stats.bitrate_download,+ upload: stats.bitrate_upload+ },+ packetLoss: {+ total: stats.packetLoss_total,+ download: stats.packetLoss_download,+ upload: stats.packetLoss_upload+ }+ };+}+++var ConnectionQuality = {+ /**+ * Updates the local statistics+ * @param data new statistics+ */+ updateLocalStats: function (data) {+ stats = data;+ UI.updateLocalConnectionStats(100 - stats.packetLoss.total, stats);+ if (sendIntervalId == null) {+ startSendingStats();+ }+ },++ /**+ * Updates remote statistics+ * @param jid the jid associated with the statistics+ * @param data the statistics+ */+ updateRemoteStats: function (jid, data) {+ if (data == null || data.packetLoss_total == null) {+ UI.updateConnectionStats(jid, null, null);+ return;+ }+ remoteStats[jid] = parseMUCStats(data);++ UI.updateConnectionStats(jid, 100 - data.packetLoss_total, remoteStats[jid]);++ },++ /**+ * Stops statistics sending.+ */+ stopSendingStats: function () {+ clearInterval(sendIntervalId);+ sendIntervalId = null;+ //notify UI about stopping statistics gathering+ UI.onStatsStop();+ },++ /**+ * Returns the local statistics.+ */+ getStats: function () {+ return stats;+ }++};++module.exports = ConnectionQuality;+},{}]},{},[1])(1)+});\ No newline at end of filediff --git a/libs/modules/statistics.bundle.js b/libs/modules/statistics.bundle.jsindex 77fde862d0..e27474b5ec 100644--- a/libs/modules/statistics.bundle.js+++ b/libs/modules/statistics.bundle.js@@ -969,6 +969,8 @@ var statistics =},start: function () {+ this.addConnectionStatsListener(connection_quality.updateLocalStats);+ this.addRemoteStatsStopListener(connection_quality.stopSendingStats);RTC.addStreamListener(onStreamCreated,StreamEventTypes.EVENT_TYPE_LOCAL_CREATED);}diff --git a/modules/connection_quality/connection_quality.js b/modules/connection_quality/connection_quality.jsnew file mode 100644index 0000000000..4a668a0021--- /dev/null+++ b/modules/connection_quality/connection_quality.js@@ -0,0 +1,119 @@+/**+ * local stats+ * @type {{}}+ */+var stats = {};++/**+ * remote stats+ * @type {{}}+ */+var remoteStats = {};++/**+ * Interval for sending statistics to other participants+ * @type {null}+ */+var sendIntervalId = null;+++/**+ * Start statistics sending.+ */+function startSendingStats() {+ sendStats();+ sendIntervalId = setInterval(sendStats, 10000);+}++/**+ * Sends statistics to other participants+ */+function sendStats() {+ connection.emuc.addConnectionInfoToPresence(convertToMUCStats(stats));+ connection.emuc.sendPresence();+}++/**+ * Converts statistics to format for sending through XMPP+ * @param stats the statistics+ * @returns {{bitrate_donwload: *, bitrate_uplpoad: *, packetLoss_total: *, packetLoss_download: *, packetLoss_upload: *}}+ */+function convertToMUCStats(stats) {+ return {+ "bitrate_download": stats.bitrate.download,+ "bitrate_upload": stats.bitrate.upload,+ "packetLoss_total": stats.packetLoss.total,+ "packetLoss_download": stats.packetLoss.download,+ "packetLoss_upload": stats.packetLoss.upload+ };+}++/**+ * Converts statitistics to format used by VideoLayout+ * @param stats+ * @returns {{bitrate: {download: *, upload: *}, packetLoss: {total: *, download: *, upload: *}}}+ */+function parseMUCStats(stats) {+ return {+ bitrate: {+ download: stats.bitrate_download,+ upload: stats.bitrate_upload+ },+ packetLoss: {+ total: stats.packetLoss_total,+ download: stats.packetLoss_download,+ upload: stats.packetLoss_upload+ }+ };+}+++var ConnectionQuality = {+ /**+ * Updates the local statistics+ * @param data new statistics+ */+ updateLocalStats: function (data) {+ stats = data;+ UI.updateLocalConnectionStats(100 - stats.packetLoss.total, stats);+ if (sendIntervalId == null) {+ startSendingStats();+ }+ },++ /**+ * Updates remote statistics+ * @param jid the jid associated with the statistics+ * @param data the statistics+ */+ updateRemoteStats: function (jid, data) {+ if (data == null || data.packetLoss_total == null) {+ UI.updateConnectionStats(jid, null, null);+ return;+ }+ remoteStats[jid] = parseMUCStats(data);++ UI.updateConnectionStats(jid, 100 - data.packetLoss_total, remoteStats[jid]);++ },++ /**+ * Stops statistics sending.+ */+ stopSendingStats: function () {+ clearInterval(sendIntervalId);+ sendIntervalId = null;+ //notify UI about stopping statistics gathering+ UI.onStatsStop();+ },++ /**+ * Returns the local statistics.+ */+ getStats: function () {+ return stats;+ }++};++module.exports = ConnectionQuality;\ No newline at end of filediff --git a/modules/statistics/statistics.js b/modules/statistics/statistics.jsindex fb4cb055de..64bc2fd7cf 100644--- a/modules/statistics/statistics.js+++ b/modules/statistics/statistics.js@@ -126,6 +126,8 @@ var statistics =},start: function () {+ this.addConnectionStatsListener(connection_quality.updateLocalStats);+ this.addRemoteStatsStopListener(connection_quality.stopSendingStats);RTC.addStreamListener(onStreamCreated,StreamEventTypes.EVENT_TYPE_LOCAL_CREATED);}diff --git a/muc.js b/muc.jsindex 693713d9f9..2b7286d071 100644--- a/muc.js+++ b/muc.js@@ -140,7 +140,7 @@ Strophe.addConnectionPlugin('emuc', {Strophe.forEachChild(stats[0], "stat", function (el) {statsObj[el.getAttribute("name")] = el.getAttribute("value");});- ConnectionQuality.updateRemoteStats(from, statsObj);+ connection_quality.updateRemoteStats(from, statsObj);}// Parse status.