|
@@ -28,39 +28,6 @@ var localConnectionQuality = 100;
|
28
|
28
|
*/
|
29
|
29
|
var remoteConnectionQuality = {};
|
30
|
30
|
|
31
|
|
-/**
|
32
|
|
- * Converts statistics to format used by VideoLayout
|
33
|
|
- * @param stats
|
34
|
|
- * @returns {{bitrate: {download: *, upload: *}, packetLoss: {total: *, download: *, upload: *}}}
|
35
|
|
- */
|
36
|
|
-function parseMUCStats(stats) {
|
37
|
|
- if(!stats || !stats.children || !stats.children.length)
|
38
|
|
- return null;
|
39
|
|
- var children = stats.children;
|
40
|
|
- var extractedStats = {};
|
41
|
|
- children.forEach((child) => {
|
42
|
|
- if(child.tagName !== "stat" || !child.attributes)
|
43
|
|
- return;
|
44
|
|
- var attrKeys = Object.keys(child.attributes);
|
45
|
|
- if(!attrKeys || !attrKeys.length)
|
46
|
|
- return;
|
47
|
|
- attrKeys.forEach((attr) => {
|
48
|
|
- extractedStats[attr] = child.attributes[attr];
|
49
|
|
- });
|
50
|
|
- });
|
51
|
|
- return {
|
52
|
|
- bitrate: {
|
53
|
|
- download: extractedStats.bitrate_download,
|
54
|
|
- upload: extractedStats.bitrate_upload
|
55
|
|
- },
|
56
|
|
- packetLoss: {
|
57
|
|
- total: extractedStats.packetLoss_total,
|
58
|
|
- download: extractedStats.packetLoss_download,
|
59
|
|
- upload: extractedStats.packetLoss_upload
|
60
|
|
- }
|
61
|
|
- };
|
62
|
|
-}
|
63
|
|
-
|
64
|
31
|
/**
|
65
|
32
|
* Calculates the quality percent based on passed new and old value.
|
66
|
33
|
* @param newVal the new value
|
|
@@ -90,8 +57,7 @@ export default {
|
90
|
57
|
* @param data the statistics
|
91
|
58
|
*/
|
92
|
59
|
updateRemoteStats: function (id, data) {
|
93
|
|
- data = parseMUCStats(data);
|
94
|
|
- if (!data || !data.packetLoss || !data.packetLoss.total) {
|
|
60
|
+ if (!data || !("packetLoss" in data) || !("total" in data.packetLoss)) {
|
95
|
61
|
eventEmitter.emit(CQEvents.REMOTESTATS_UPDATED, id, null, null);
|
96
|
62
|
return;
|
97
|
63
|
}
|
|
@@ -115,24 +81,5 @@ export default {
|
115
|
81
|
|
116
|
82
|
addListener: function (type, listener) {
|
117
|
83
|
eventEmitter.on(type, listener);
|
118
|
|
- },
|
119
|
|
-
|
120
|
|
- /**
|
121
|
|
- * Converts statistics to format for sending through XMPP
|
122
|
|
- * @param stats the statistics
|
123
|
|
- * @returns [{tagName: "stat", attributes: {{bitrate_donwload: *}},
|
124
|
|
- * {tagName: "stat", attributes: {{ bitrate_uplpoad: *}},
|
125
|
|
- * {tagName: "stat", attributes: {{ packetLoss_total: *}},
|
126
|
|
- * {tagName: "stat", attributes: {{ packetLoss_download: *}},
|
127
|
|
- * {tagName: "stat", attributes: {{ packetLoss_upload: *}}]
|
128
|
|
- */
|
129
|
|
- convertToMUCStats: function (stats) {
|
130
|
|
- return [
|
131
|
|
- {tagName: "stat", attributes: {"bitrate_download": stats.bitrate.download}},
|
132
|
|
- {tagName: "stat", attributes: {"bitrate_upload": stats.bitrate.upload}},
|
133
|
|
- {tagName: "stat", attributes: {"packetLoss_total": stats.packetLoss.total}},
|
134
|
|
- {tagName: "stat", attributes: {"packetLoss_download": stats.packetLoss.download}},
|
135
|
|
- {tagName: "stat", attributes: {"packetLoss_upload": stats.packetLoss.upload}}
|
136
|
|
- ];
|
137
|
84
|
}
|
138
|
85
|
};
|