|
|
@@ -146,7 +146,6 @@ function StatsCollector(peerconnection, audioLevelsInterval, statsInterval, even
|
|
146
|
146
|
{
|
|
147
|
147
|
this.peerconnection = peerconnection;
|
|
148
|
148
|
this.baselineAudioLevelsReport = null;
|
|
149
|
|
- this.currentAudioLevelsReport = null;
|
|
150
|
149
|
this.currentStatsReport = null;
|
|
151
|
150
|
this.baselineStatsReport = null;
|
|
152
|
151
|
this.audioLevelsIntervalId = null;
|
|
|
@@ -252,10 +251,7 @@ StatsCollector.prototype.start = function ()
|
|
252
|
251
|
results = report.result();
|
|
253
|
252
|
}
|
|
254
|
253
|
//console.error("Got interval report", results);
|
|
255
|
|
- self.currentAudioLevelsReport = results;
|
|
256
|
|
- self.processAudioLevelReport();
|
|
257
|
|
- self.baselineAudioLevelsReport =
|
|
258
|
|
- self.currentAudioLevelsReport;
|
|
|
254
|
+ self.baselineAudioLevelsReport = results;
|
|
259
|
255
|
},
|
|
260
|
256
|
self.errorCallback
|
|
261
|
257
|
);
|
|
|
@@ -666,65 +662,3 @@ StatsCollector.prototype.processStatsReport = function () {
|
|
666
|
662
|
PeerStats.transport = [];
|
|
667
|
663
|
|
|
668
|
664
|
};
|
|
669
|
|
-
|
|
670
|
|
-/**
|
|
671
|
|
- * Stats processing logic.
|
|
672
|
|
- */
|
|
673
|
|
-StatsCollector.prototype.processAudioLevelReport = function () {
|
|
674
|
|
- if (!this.baselineAudioLevelsReport) {
|
|
675
|
|
- return;
|
|
676
|
|
- }
|
|
677
|
|
-
|
|
678
|
|
- for (var idx in this.currentAudioLevelsReport) {
|
|
679
|
|
- var now = this.currentAudioLevelsReport[idx];
|
|
680
|
|
-
|
|
681
|
|
- if (now.type != 'ssrc') {
|
|
682
|
|
- continue;
|
|
683
|
|
- }
|
|
684
|
|
-
|
|
685
|
|
- var before = this.baselineAudioLevelsReport[idx];
|
|
686
|
|
- if (!before) {
|
|
687
|
|
- console.warn(getStatValue(now, 'ssrc') + ' not enough data');
|
|
688
|
|
- continue;
|
|
689
|
|
- }
|
|
690
|
|
-
|
|
691
|
|
- var ssrc = getStatValue(now, 'ssrc');
|
|
692
|
|
- var jid = APP.conference._room.room.getJidBySSRC(ssrc);
|
|
693
|
|
- if (!jid) {
|
|
694
|
|
- if((Date.now() - now.timestamp) < 3000)
|
|
695
|
|
- console.warn("No jid for ssrc: " + ssrc);
|
|
696
|
|
- continue;
|
|
697
|
|
- }
|
|
698
|
|
-
|
|
699
|
|
- var jidStats = this.jid2stats[jid];
|
|
700
|
|
- if (!jidStats) {
|
|
701
|
|
- jidStats = new PeerStats();
|
|
702
|
|
- this.jid2stats[jid] = jidStats;
|
|
703
|
|
- }
|
|
704
|
|
-
|
|
705
|
|
- // Audio level
|
|
706
|
|
- var audioLevel = null;
|
|
707
|
|
-
|
|
708
|
|
- try {
|
|
709
|
|
- audioLevel = getStatValue(now, 'audioInputLevel');
|
|
710
|
|
- if (!audioLevel)
|
|
711
|
|
- audioLevel = getStatValue(now, 'audioOutputLevel');
|
|
712
|
|
- }
|
|
713
|
|
- catch(e) {/*not supported*/
|
|
714
|
|
- console.warn("Audio Levels are not available in the statistics.");
|
|
715
|
|
- clearInterval(this.audioLevelsIntervalId);
|
|
716
|
|
- return;
|
|
717
|
|
- }
|
|
718
|
|
-
|
|
719
|
|
- if (audioLevel) {
|
|
720
|
|
- // TODO: can't find specs about what this value really is,
|
|
721
|
|
- // but it seems to vary between 0 and around 32k.
|
|
722
|
|
- audioLevel = audioLevel / 32767;
|
|
723
|
|
- jidStats.setSsrcAudioLevel(ssrc, audioLevel);
|
|
724
|
|
- if (jid != APP.conference._room.room.myroomjid) {
|
|
725
|
|
- this.eventEmitter.emit(
|
|
726
|
|
- StatisticsEvents.AUDIO_LEVEL, jid, audioLevel);
|
|
727
|
|
- }
|
|
728
|
|
- }
|
|
729
|
|
- }
|
|
730
|
|
-};
|