Kaynağa Gözat

Implements statistics module.

master
hristoterezov 10 yıl önce
ebeveyn
işleme
c6d8e34779

+ 22
- 0
Makefile Dosyayı Görüntüle

@@ -0,0 +1,22 @@
1
+BROWSERIFY = browserify
2
+GLOBAL_FLAGS = -e
3
+MODULE_DIR = modules
4
+MODULE_SUBDIRS = $(wildcard $(MODULE_DIR)/*/)
5
+MODULES = $(MODULE_SUBDIRS:$(MODULE_DIR)/%/=%)
6
+OUTPUT_DIR = .
7
+DEPLOY_DIR = libs/modules
8
+
9
+all:FLAGS = $(GLOBAL_FLAGS)
10
+all:$(MODULES)
11
+
12
+debug:FLAGS = -d $(GLOBAL_FLAGS)
13
+debug:$(MODULES)
14
+
15
+$(MODULES): *.js
16
+	$(BROWSERIFY) $(FLAGS) $(MODULE_DIR)/$@/$@.js -s $@ -o $(OUTPUT_DIR)/$@.bundle.js
17
+
18
+clean:
19
+	@rm $(OUTPUT_DIR)/*.bundle.js
20
+
21
+deploy:
22
+	@mkdir -p $(DEPLOY_DIR) && cp $(OUTPUT_DIR)/*.bundle.js $(DEPLOY_DIR)

+ 4
- 0
README.md Dosyayı Görüntüle

@@ -12,6 +12,10 @@ Installing Jitsi Meet is quite a simple experience. For Debian-based systems, we
12 12
 
13 13
 For other systems, or if you wish to install all components manually, see the [detailed installation instructions](https://github.com/jitsi/jitsi-meet/blob/master/doc/manual-install.md).
14 14
 
15
+## Development tools
16
+
17
+Jitsi Meet uses [Browserify](http://browserify.org). If you want to make changes in the code you need to [install Browserify](http://browserify.org/#install). Browserify requires [nodejs](http://nodejs.org). 
18
+
15 19
 ## Discuss
16 20
 Please use the [Jitsi dev mailing list](http://lists.jitsi.org/pipermail/dev/) to discuss feature requests before opening an issue on github. 
17 21
 

+ 10
- 74
app.js Dosyayı Görüntüle

@@ -18,18 +18,6 @@ var notReceivedSSRCs = [];
18 18
 
19 19
 var jid2Ssrc = {};
20 20
 
21
-/**
22
- * The stats collector that process stats data and triggers updates to app.js.
23
- * @type {StatsCollector}
24
- */
25
-var statsCollector = null;
26
-
27
-/**
28
- * The stats collector for the local stream.
29
- * @type {LocalStatsCollector}
30
- */
31
-var localStatsCollector = null;
32
-
33 21
 /**
34 22
  * Indicates whether ssrc is camera video or desktop stream.
35 23
  * FIXME: remove those maps
@@ -100,7 +88,7 @@ function init() {
100 88
                 videoStream.addTrack(videoTracks[i]);
101 89
             }
102 90
             VideoLayout.changeLocalAudio(audioStream);
103
-            startLocalRtpStatsCollector(audioStream);
91
+            statistics.onStreamCreated(audioStream);
104 92
 
105 93
 
106 94
             VideoLayout.changeLocalVideo(videoStream, true);
@@ -108,7 +96,7 @@ function init() {
108 96
         else
109 97
         {
110 98
             VideoLayout.changeLocalStream(stream);
111
-            startLocalRtpStatsCollector(stream);
99
+            statistics.onStreamCreated(stream);
112 100
 
113 101
         }
114 102
 
@@ -559,7 +547,7 @@ function muteVideo(pc, unmute) {
559 547
 function audioLevelUpdated(jid, audioLevel)
560 548
 {
561 549
     var resourceJid;
562
-    if(jid === LocalStatsCollector.LOCAL_JID)
550
+    if(jid === statistics.LOCAL_JID)
563 551
     {
564 552
         resourceJid = AudioLevels.LOCAL_LEVEL;
565 553
         if(isAudioMuted())
@@ -575,66 +563,13 @@ function audioLevelUpdated(jid, audioLevel)
575 563
     AudioLevels.updateAudioLevel(resourceJid, audioLevel);
576 564
 }
577 565
 
578
-/**
579
- * Starts the {@link StatsCollector} if the feature is enabled in config.js.
580
- */
581
-function startRtpStatsCollector()
582
-{
583
-    stopRTPStatsCollector();
584
-    if (config.enableRtpStats)
585
-    {
586
-        statsCollector = new StatsCollector(
587
-            getConferenceHandler().peerconnection, 200, audioLevelUpdated, 2000,
588
-            ConnectionQuality.updateLocalStats);
589
-        statsCollector.start();
590
-    }
591
-}
592
-
593
-/**
594
- * Stops the {@link StatsCollector}.
595
- */
596
-function stopRTPStatsCollector()
597
-{
598
-    if (statsCollector)
599
-    {
600
-        statsCollector.stop();
601
-        statsCollector = null;
602
-        ConnectionQuality.stopSendingStats();
603
-    }
604
-}
605
-
606
-/**
607
- * Starts the {@link LocalStatsCollector} if the feature is enabled in config.js
608
- * @param stream the stream that will be used for collecting statistics.
609
- */
610
-function startLocalRtpStatsCollector(stream)
611
-{
612
-    if(config.enableRtpStats)
613
-    {
614
-        localStatsCollector = new LocalStatsCollector(stream, 100, audioLevelUpdated);
615
-        localStatsCollector.start();
616
-    }
617
-}
618
-
619
-/**
620
- * Stops the {@link LocalStatsCollector}.
621
- */
622
-function stopLocalRtpStatsCollector()
623
-{
624
-    if(localStatsCollector)
625
-    {
626
-        localStatsCollector.stop();
627
-        localStatsCollector = null;
628
-    }
629
-}
630
-
631 566
 $(document).bind('callincoming.jingle', function (event, sid) {
632 567
     var sess = connection.jingle.sessions[sid];
633 568
 
634 569
     // TODO: do we check activecall == null?
635 570
     activecall = sess;
636 571
 
637
-    startRtpStatsCollector();
572
+    statistics.onConfereceCreated(sess);
638 573
 
639 574
     // Bind data channel listener in case we're a regular participant
640 575
     if (config.openSctp)
@@ -652,7 +587,7 @@ $(document).bind('callincoming.jingle', function (event, sid) {
652 587
 
653 588
 $(document).bind('conferenceCreated.jingle', function (event, focus)
654 589
 {
655
-    startRtpStatsCollector();
590
+    statistics.onConfereceCreated(getConferenceHandler());
656 591
 });
657 592
 
658 593
 $(document).bind('conferenceCreated.jingle', function (event, focus)
@@ -1461,6 +1396,10 @@ $(document).ready(function () {
1461 1396
         }
1462 1397
     });
1463 1398
 
1399
+    statistics.addAudioLevelListener(audioLevelUpdated);
1400
+    statistics.addConnectionStatsListener(ConnectionQuality.updateLocalStats);
1401
+    statistics.addRemoteStatsStopListener(ConnectionQuality.stopSendingStats);
1402
+    
1464 1403
     Moderator.init();
1465 1404
 
1466 1405
     // Set the defaults for prompt dialogs.
@@ -1577,10 +1516,7 @@ function disposeConference(onUnload) {
1577 1516
         }
1578 1517
         handler.peerconnection.close();
1579 1518
     }
1580
-    stopRTPStatsCollector();
1581
-    if(onUnload) {
1582
-        stopLocalRtpStatsCollector();
1583
-    }
1519
+    statistics.onDisposeConference(onUnload);
1584 1520
     activecall = null;
1585 1521
 }
1586 1522
 

+ 1
- 2
index.html Dosyayı Görüntüle

@@ -47,8 +47,6 @@
47 47
     <script src="replacement.js?v=7"></script><!-- link and smiley replacement -->
48 48
     <script src="moderatemuc.js?v=4"></script><!-- moderator plugin -->
49 49
     <script src="analytics.js?v=1"></script><!-- google analytics plugin -->
50
-    <script src="rtp_sts.js?v=5"></script><!-- RTP stats processing -->
51
-    <script src="local_sts.js?v=2"></script><!-- Local stats processing -->
52 50
     <script src="videolayout.js?v=31"></script><!-- video ui -->
53 51
     <script src="connectionquality.js?v=1"></script>
54 52
     <script src="toolbar.js?v=7"></script><!-- toolbar ui -->
@@ -66,6 +64,7 @@
66 64
     <script src="message_handler.js?v=2"></script>
67 65
     <script src="api_connector.js?v=2"></script>
68 66
     <script src="settings_menu.js?v=1"></script>
67
+    <script src="libs/modules/statistics.bundle.js"></script>
69 68
     <script src="avatar.js?v=4"></script><!-- avatars -->
70 69
     <link rel="stylesheet" href="css/font.css?v=6"/>
71 70
     <link rel="stylesheet" href="css/toastr.css?v=1">

+ 1282
- 0
libs/modules/statistics.bundle.js
Dosya farkı çok büyük olduğundan ihmal edildi
Dosyayı Görüntüle


+ 0
- 131
local_sts.js Dosyayı Görüntüle

@@ -1,131 +0,0 @@
1
-/**
2
- * Provides statistics for the local stream.
3
- */
4
-var LocalStatsCollector = (function() {
5
-    /**
6
-     * Size of the webaudio analizer buffer.
7
-     * @type {number}
8
-     */
9
-    var WEBAUDIO_ANALIZER_FFT_SIZE = 2048;
10
-
11
-    /**
12
-     * Value of the webaudio analizer smoothing time parameter.
13
-     * @type {number}
14
-     */
15
-    var WEBAUDIO_ANALIZER_SMOOTING_TIME = 0.8;
16
-
17
-    /**
18
-     * <tt>LocalStatsCollector</tt> calculates statistics for the local stream.
19
-     *
20
-     * @param stream the local stream
21
-     * @param interval stats refresh interval given in ms.
22
-     * @param {function(LocalStatsCollector)} updateCallback the callback called on stats
23
-     *                                   update.
24
-     * @constructor
25
-     */
26
-    function LocalStatsCollectorProto(stream, interval, updateCallback) {
27
-        window.AudioContext = window.AudioContext || window.webkitAudioContext;
28
-        this.stream = stream;
29
-        this.intervalId = null;
30
-        this.intervalMilis = interval;
31
-        this.audioLevelsUpdateCallback = updateCallback;
32
-        this.audioLevel = 0;
33
-    }
34
-
35
-    /**
36
-     * Starts the collecting the statistics.
37
-     */
38
-    LocalStatsCollectorProto.prototype.start = function () {
39
-        if (!window.AudioContext)
40
-            return;
41
-
42
-        var context = new AudioContext();
43
-        var analyser = context.createAnalyser();
44
-        analyser.smoothingTimeConstant = WEBAUDIO_ANALIZER_SMOOTING_TIME;
45
-        analyser.fftSize = WEBAUDIO_ANALIZER_FFT_SIZE;
46
-
47
-
48
-        var source = context.createMediaStreamSource(this.stream);
49
-        source.connect(analyser);
50
-
51
-
52
-        var self = this;
53
-
54
-        this.intervalId = setInterval(
55
-            function () {
56
-                var array = new Uint8Array(analyser.frequencyBinCount);
57
-                analyser.getByteTimeDomainData(array);
58
-                var audioLevel = TimeDomainDataToAudioLevel(array);
59
-                if(audioLevel != self.audioLevel) {
60
-                    self.audioLevel = animateLevel(audioLevel, self.audioLevel);
61
-                    self.audioLevelsUpdateCallback(LocalStatsCollectorProto.LOCAL_JID, self.audioLevel);
62
-                }
63
-            },
64
-            this.intervalMilis
65
-        );
66
-
67
-    };
68
-
69
-    /**
70
-     * Stops collecting the statistics.
71
-     */
72
-    LocalStatsCollectorProto.prototype.stop = function () {
73
-        if (this.intervalId) {
74
-            clearInterval(this.intervalId);
75
-            this.intervalId = null;
76
-        }
77
-    };
78
-
79
-    /**
80
-     * Converts time domain data array to audio level.
81
-     * @param array the time domain data array.
82
-     * @returns {number} the audio level
83
-     */
84
-    var TimeDomainDataToAudioLevel = function (samples) {
85
-
86
-        var maxVolume = 0;
87
-
88
-        var length = samples.length;
89
-
90
-        for (var i = 0; i < length; i++) {
91
-            if (maxVolume < samples[i])
92
-                maxVolume = samples[i];
93
-        }
94
-
95
-        return parseFloat(((maxVolume - 127) / 128).toFixed(3));
96
-    };
97
-
98
-    /**
99
-     * Animates audio level change
100
-     * @param newLevel the new audio level
101
-     * @param lastLevel the last audio level
102
-     * @returns {Number} the audio level to be set
103
-     */
104
-    function animateLevel(newLevel, lastLevel)
105
-    {
106
-        var value = 0;
107
-        var diff = lastLevel - newLevel;
108
-        if(diff > 0.2)
109
-        {
110
-            value = lastLevel - 0.2;
111
-        }
112
-        else if(diff < -0.4)
113
-        {
114
-            value = lastLevel + 0.4;
115
-        }
116
-        else
117
-        {
118
-            value = newLevel;
119
-        }
120
-
121
-        return parseFloat(value.toFixed(3));
122
-    }
123
-
124
-    /**
125
-     * Indicates that this audio level is for local jid.
126
-     * @type {string}
127
-     */
128
-    LocalStatsCollectorProto.LOCAL_JID = 'local';
129
-
130
-    return LocalStatsCollectorProto;
131
-})();

+ 130
- 0
modules/statistics/LocalStatsCollector.js Dosyayı Görüntüle

@@ -0,0 +1,130 @@
1
+/**
2
+ * Provides statistics for the local stream.
3
+ */
4
+
5
+
6
+/**
7
+ * Size of the webaudio analizer buffer.
8
+ * @type {number}
9
+ */
10
+var WEBAUDIO_ANALIZER_FFT_SIZE = 2048;
11
+
12
+/**
13
+ * Value of the webaudio analizer smoothing time parameter.
14
+ * @type {number}
15
+ */
16
+var WEBAUDIO_ANALIZER_SMOOTING_TIME = 0.8;
17
+
18
+/**
19
+ * Converts time domain data array to audio level.
20
+ * @param array the time domain data array.
21
+ * @returns {number} the audio level
22
+ */
23
+function timeDomainDataToAudioLevel(samples) {
24
+
25
+    var maxVolume = 0;
26
+
27
+    var length = samples.length;
28
+
29
+    for (var i = 0; i < length; i++) {
30
+        if (maxVolume < samples[i])
31
+            maxVolume = samples[i];
32
+    }
33
+
34
+    return parseFloat(((maxVolume - 127) / 128).toFixed(3));
35
+};
36
+
37
+/**
38
+ * Animates audio level change
39
+ * @param newLevel the new audio level
40
+ * @param lastLevel the last audio level
41
+ * @returns {Number} the audio level to be set
42
+ */
43
+function animateLevel(newLevel, lastLevel)
44
+{
45
+    var value = 0;
46
+    var diff = lastLevel - newLevel;
47
+    if(diff > 0.2)
48
+    {
49
+        value = lastLevel - 0.2;
50
+    }
51
+    else if(diff < -0.4)
52
+    {
53
+        value = lastLevel + 0.4;
54
+    }
55
+    else
56
+    {
57
+        value = newLevel;
58
+    }
59
+
60
+    return parseFloat(value.toFixed(3));
61
+}
62
+
63
+
64
+/**
65
+ * <tt>LocalStatsCollector</tt> calculates statistics for the local stream.
66
+ *
67
+ * @param stream the local stream
68
+ * @param interval stats refresh interval given in ms.
69
+ * @param {function(LocalStatsCollector)} updateCallback the callback called on stats
70
+ *                                   update.
71
+ * @constructor
72
+ */
73
+function LocalStatsCollector(stream, interval, statisticsService, eventEmitter) {
74
+    window.AudioContext = window.AudioContext || window.webkitAudioContext;
75
+    this.stream = stream;
76
+    this.intervalId = null;
77
+    this.intervalMilis = interval;
78
+    this.eventEmitter = eventEmitter;
79
+    this.audioLevel = 0;
80
+    this.statisticsService = statisticsService;
81
+}
82
+
83
+/**
84
+ * Starts the collecting the statistics.
85
+ */
86
+LocalStatsCollector.prototype.start = function () {
87
+    if (!window.AudioContext)
88
+        return;
89
+
90
+    var context = new AudioContext();
91
+    var analyser = context.createAnalyser();
92
+    analyser.smoothingTimeConstant = WEBAUDIO_ANALIZER_SMOOTING_TIME;
93
+    analyser.fftSize = WEBAUDIO_ANALIZER_FFT_SIZE;
94
+
95
+
96
+    var source = context.createMediaStreamSource(this.stream);
97
+    source.connect(analyser);
98
+
99
+
100
+    var self = this;
101
+
102
+    this.intervalId = setInterval(
103
+        function () {
104
+            var array = new Uint8Array(analyser.frequencyBinCount);
105
+            analyser.getByteTimeDomainData(array);
106
+            var audioLevel = timeDomainDataToAudioLevel(array);
107
+            if(audioLevel != self.audioLevel) {
108
+                self.audioLevel = animateLevel(audioLevel, self.audioLevel);
109
+                self.eventEmitter.emit(
110
+                    "statistics.audioLevel",
111
+                    self.statisticsService.LOCAL_JID,
112
+                    self.audioLevel);
113
+            }
114
+        },
115
+        this.intervalMilis
116
+    );
117
+
118
+};
119
+
120
+/**
121
+ * Stops collecting the statistics.
122
+ */
123
+LocalStatsCollector.prototype.stop = function () {
124
+    if (this.intervalId) {
125
+        clearInterval(this.intervalId);
126
+        this.intervalId = null;
127
+    }
128
+};
129
+
130
+module.exports = LocalStatsCollector;

rtp_sts.js → modules/statistics/RTPStatsCollector.js Dosyayı Görüntüle

@@ -13,6 +13,13 @@ function calculatePacketLoss(lostPackets, totalPackets) {
13 13
     return Math.round((lostPackets/totalPackets)*100);
14 14
 }
15 15
 
16
+function getStatValue(item, name) {
17
+    if(!keyMap[RTC.browser][name])
18
+        throw "The property isn't supported!";
19
+    var key = keyMap[RTC.browser][name];
20
+    return RTC.browser == "chrome"? item.stat(key) : item[key];
21
+}
22
+
16 23
 /**
17 24
  * Peer statistics data holder.
18 25
  * @constructor
@@ -124,9 +131,7 @@ PeerStats.transport = [];
124 131
  * called on stats update.
125 132
  * @constructor
126 133
  */
127
-function StatsCollector(peerconnection, audioLevelsInterval,
128
-                        audioLevelsUpdateCallback, statsInterval,
129
-                        statsUpdateCallback)
134
+function StatsCollector(peerconnection, audioLevelsInterval, statsInterval, eventEmitter)
130 135
 {
131 136
     this.peerconnection = peerconnection;
132 137
     this.baselineAudioLevelsReport = null;
@@ -134,6 +139,7 @@ function StatsCollector(peerconnection, audioLevelsInterval,
134 139
     this.currentStatsReport = null;
135 140
     this.baselineStatsReport = null;
136 141
     this.audioLevelsIntervalId = null;
142
+    this.eventEmitter = eventEmitter;
137 143
 
138 144
     /**
139 145
      * Gather PeerConnection stats once every this many milliseconds.
@@ -161,8 +167,8 @@ function StatsCollector(peerconnection, audioLevelsInterval,
161 167
      */
162 168
     this.statsToBeLogged =
163 169
     {
164
-      timestamps: [],
165
-      stats: {}
170
+        timestamps: [],
171
+        stats: {}
166 172
     };
167 173
 
168 174
     // Updates stats interval
@@ -172,11 +178,10 @@ function StatsCollector(peerconnection, audioLevelsInterval,
172 178
     this.statsIntervalMilis = statsInterval;
173 179
     // Map of jids to PeerStats
174 180
     this.jid2stats = {};
175
-
176
-    this.audioLevelsUpdateCallback = audioLevelsUpdateCallback;
177
-    this.statsUpdateCallback = statsUpdateCallback;
178 181
 }
179 182
 
183
+module.exports = StatsCollector;
184
+
180 185
 /**
181 186
  * Stops stats updates.
182 187
  */
@@ -339,7 +344,7 @@ StatsCollector.prototype.logStats = function () {
339 344
     // XEP-0337-ish
340 345
     var message = $msg({to: focusMucJid, type: 'normal'});
341 346
     message.c('log', { xmlns: 'urn:xmpp:eventlog',
342
-                       id: 'PeerConnectionStats'});
347
+        id: 'PeerConnectionStats'});
343 348
     message.c('message').t(content).up();
344 349
     if (deflate) {
345 350
         message.c('tag', {name: "deflated", value: "true"}).up();
@@ -616,13 +621,13 @@ StatsCollector.prototype.processStatsReport = function () {
616 621
     PeerStats.packetLoss = {
617 622
         total:
618 623
             calculatePacketLoss(lostPackets.download + lostPackets.upload,
619
-                totalPackets.download + totalPackets.upload),
624
+                    totalPackets.download + totalPackets.upload),
620 625
         download:
621 626
             calculatePacketLoss(lostPackets.download, totalPackets.download),
622 627
         upload:
623 628
             calculatePacketLoss(lostPackets.upload, totalPackets.upload)
624 629
     };
625
-    this.statsUpdateCallback(
630
+    this.eventEmitter.emit("statistics.connectionstats",
626 631
         {
627 632
             "bitrate": PeerStats.bitrate,
628 633
             "packetLoss": PeerStats.packetLoss,
@@ -696,17 +701,10 @@ StatsCollector.prototype.processAudioLevelReport = function ()
696 701
             audioLevel = audioLevel / 32767;
697 702
             jidStats.setSsrcAudioLevel(ssrc, audioLevel);
698 703
             if(jid != connection.emuc.myroomjid)
699
-                this.audioLevelsUpdateCallback(jid, audioLevel);
704
+                this.eventEmitter.emit("statistics.audioLevel", jid, audioLevel);
700 705
         }
701 706
 
702 707
     }
703 708
 
704 709
 
705
-};
706
-
707
-function getStatValue(item, name) {
708
-    if(!keyMap[RTC.browser][name])
709
-        throw "The property isn't supported!";
710
-    var key = keyMap[RTC.browser][name];
711
-    return RTC.browser == "chrome"? item.stat(key) : item[key];
712
-}
710
+};

+ 132
- 0
modules/statistics/statistics.js Dosyayı Görüntüle

@@ -0,0 +1,132 @@
1
+/**
2
+ * Created by hristo on 8/4/14.
3
+ */
4
+var LocalStats = require("./LocalStatsCollector.js");
5
+var RTPStats = require("./RTPStatsCollector.js");
6
+var EventEmitter = require("events");
7
+//var StreamEventTypes = require("../service/RTC/StreamEventTypes.js");
8
+//var XMPPEvents = require("../service/xmpp/XMPPEvents");
9
+
10
+var eventEmitter = new EventEmitter();
11
+
12
+var localStats = null;
13
+
14
+var rtpStats = null;
15
+
16
+var RTCService = null;
17
+
18
+function stopLocal()
19
+{
20
+    if(localStats)
21
+    {
22
+        localStats.stop();
23
+        localStats = null;
24
+    }
25
+}
26
+
27
+function stopRemote()
28
+{
29
+    if(rtpStats)
30
+    {
31
+        rtpStats.stop();
32
+        eventEmitter.emit("statistics.stop");
33
+        rtpStats = null;
34
+    }
35
+}
36
+
37
+function startRemoteStats (peerconnection) {
38
+    if (config.enableRtpStats)
39
+    {
40
+        if(rtpStats)
41
+        {
42
+            rtpStats.stop();
43
+            rtpStats = null;
44
+        }
45
+
46
+        rtpStats = new RTPStats(peerconnection, 200, 2000, eventEmitter);
47
+        rtpStats.start();
48
+    }
49
+
50
+}
51
+
52
+
53
+var statistics =
54
+{
55
+    /**
56
+     * Indicates that this audio level is for local jid.
57
+     * @type {string}
58
+     */
59
+    LOCAL_JID: 'local',
60
+
61
+    addAudioLevelListener: function(listener)
62
+    {
63
+        eventEmitter.on("statistics.audioLevel", listener);
64
+    },
65
+
66
+    removeAudioLevelListener: function(listener)
67
+    {
68
+        eventEmitter.removeListener("statistics.audioLevel", listener);
69
+    },
70
+
71
+    addConnectionStatsListener: function(listener)
72
+    {
73
+        eventEmitter.on("statistics.connectionstats", listener);
74
+    },
75
+
76
+    removeConnectionStatsListener: function(listener)
77
+    {
78
+        eventEmitter.removeListener("statistics.connectionstats", listener);
79
+    },
80
+
81
+
82
+    addRemoteStatsStopListener: function(listener)
83
+    {
84
+        eventEmitter.on("statistics.stop", listener);
85
+    },
86
+
87
+    removeRemoteStatsStopListener: function(listener)
88
+    {
89
+        eventEmitter.removeListener("statistics.stop", listener);
90
+    },
91
+
92
+    stop: function () {
93
+        stopLocal();
94
+        stopRemote();
95
+        if(eventEmitter)
96
+        {
97
+            eventEmitter.removeAllListeners();
98
+        }
99
+    },
100
+
101
+    stopRemoteStatistics: function()
102
+    {
103
+        stopRemote();
104
+    },
105
+
106
+    onConfereceCreated: function (event) {
107
+        startRemoteStats(event.peerconnection);
108
+    },
109
+
110
+    onDisposeConference: function (onUnload) {
111
+        stopRemote();
112
+        if(onUnload) {
113
+            stopLocal();
114
+            eventEmitter.removeAllListeners();
115
+        }
116
+    },
117
+
118
+    onStreamCreated: function(stream)
119
+    {
120
+        if(stream.getAudioTracks().length === 0)
121
+            return;
122
+
123
+        localStats = new LocalStats(stream, 100, this,
124
+            eventEmitter);
125
+        localStats.start();
126
+    }
127
+};
128
+
129
+
130
+
131
+
132
+module.exports = statistics;

Loading…
İptal
Kaydet