You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

connectionquality.bundle.js 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. !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){
  2. /**
  3. * local stats
  4. * @type {{}}
  5. */
  6. var stats = {};
  7. /**
  8. * remote stats
  9. * @type {{}}
  10. */
  11. var remoteStats = {};
  12. /**
  13. * Interval for sending statistics to other participants
  14. * @type {null}
  15. */
  16. var sendIntervalId = null;
  17. /**
  18. * Start statistics sending.
  19. */
  20. function startSendingStats() {
  21. sendStats();
  22. sendIntervalId = setInterval(sendStats, 10000);
  23. }
  24. /**
  25. * Sends statistics to other participants
  26. */
  27. function sendStats() {
  28. connection.emuc.addConnectionInfoToPresence(convertToMUCStats(stats));
  29. connection.emuc.sendPresence();
  30. }
  31. /**
  32. * Converts statistics to format for sending through XMPP
  33. * @param stats the statistics
  34. * @returns {{bitrate_donwload: *, bitrate_uplpoad: *, packetLoss_total: *, packetLoss_download: *, packetLoss_upload: *}}
  35. */
  36. function convertToMUCStats(stats) {
  37. return {
  38. "bitrate_download": stats.bitrate.download,
  39. "bitrate_upload": stats.bitrate.upload,
  40. "packetLoss_total": stats.packetLoss.total,
  41. "packetLoss_download": stats.packetLoss.download,
  42. "packetLoss_upload": stats.packetLoss.upload
  43. };
  44. }
  45. /**
  46. * Converts statitistics to format used by VideoLayout
  47. * @param stats
  48. * @returns {{bitrate: {download: *, upload: *}, packetLoss: {total: *, download: *, upload: *}}}
  49. */
  50. function parseMUCStats(stats) {
  51. return {
  52. bitrate: {
  53. download: stats.bitrate_download,
  54. upload: stats.bitrate_upload
  55. },
  56. packetLoss: {
  57. total: stats.packetLoss_total,
  58. download: stats.packetLoss_download,
  59. upload: stats.packetLoss_upload
  60. }
  61. };
  62. }
  63. var ConnectionQuality = {
  64. /**
  65. * Updates the local statistics
  66. * @param data new statistics
  67. */
  68. updateLocalStats: function (data) {
  69. stats = data;
  70. UI.updateLocalConnectionStats(100 - stats.packetLoss.total, stats);
  71. if (sendIntervalId == null) {
  72. startSendingStats();
  73. }
  74. },
  75. /**
  76. * Updates remote statistics
  77. * @param jid the jid associated with the statistics
  78. * @param data the statistics
  79. */
  80. updateRemoteStats: function (jid, data) {
  81. if (data == null || data.packetLoss_total == null) {
  82. UI.updateConnectionStats(jid, null, null);
  83. return;
  84. }
  85. remoteStats[jid] = parseMUCStats(data);
  86. UI.updateConnectionStats(jid, 100 - data.packetLoss_total, remoteStats[jid]);
  87. },
  88. /**
  89. * Stops statistics sending.
  90. */
  91. stopSendingStats: function () {
  92. clearInterval(sendIntervalId);
  93. sendIntervalId = null;
  94. //notify UI about stopping statistics gathering
  95. UI.onStatsStop();
  96. },
  97. /**
  98. * Returns the local statistics.
  99. */
  100. getStats: function () {
  101. return stats;
  102. }
  103. };
  104. module.exports = ConnectionQuality;
  105. },{}]},{},[1])(1)
  106. });