Pārlūkot izejas kodu

Exposes methods for obtaining stream SSRCs and audio levels.

dev1
paweldomas 9 gadus atpakaļ
vecāks
revīzija
022940eb13

+ 18
- 1
modules/statistics/statistics.js Parādīt failu

@@ -84,7 +84,24 @@ Statistics.prototype.stopRemote = function () {
84 84
         this.eventEmitter.emit(StatisticsEvents.STOP);
85 85
         this.rtpStats = null;
86 86
     }
87
-}
87
+};
88
+
89
+/**
90
+ * Obtains audio level reported in the stats for specified peer.
91
+ * @param peerJid full MUC jid of the user for whom we want to obtain last
92
+ *        audio level.
93
+ * @param ssrc the SSRC of audio stream for which we want to obtain audio
94
+ *        level.
95
+ * @returns {*} a float form 0 to 1 that represents current audio level or
96
+ *              <tt>null</tt> if for any reason the value is not available
97
+ *              at this time.
98
+ */
99
+Statistics.prototype.getPeerSSRCAudioLevel = function (peerJid, ssrc) {
100
+
101
+    var peerStats = this.rtpStats.jid2stats[peerJid];
102
+
103
+    return peerStats ? peerStats.ssrc2AudioLevel[ssrc] : null;
104
+};
88 105
 
89 106
 Statistics.LOCAL_JID = require("../../service/statistics/constants").LOCAL_JID;
90 107
 

+ 16
- 0
modules/xmpp/JingleSessionPC.js Parādīt failu

@@ -42,6 +42,11 @@ function JingleSessionPC(me, sid, connection, service) {
42 42
     this.addingStreams = false;
43 43
 
44 44
     this.wait = true;
45
+    /**
46
+     * A map that stores SSRCs of local streams
47
+     * @type {{}} maps media type('audio' or 'video') to SSRC number
48
+     */
49
+    this.localStreamsSSRC = {};
45 50
     this.ssrcOwners = {};
46 51
     this.ssrcVideoTypes = {};
47 52
 
@@ -550,6 +555,15 @@ JingleSessionPC.prototype.readSsrcInfo = function (contents) {
550 555
     });
551 556
 };
552 557
 
558
+/**
559
+ * Returns the SSRC of local audio stream.
560
+ * @param mediaType 'audio' or 'video' media type
561
+ * @returns {*} the SSRC number of local audio or video stream.
562
+ */
563
+JingleSessionPC.prototype.getLocalSSRC = function (mediaType) {
564
+    return this.localStreamsSSRC[mediaType];
565
+};
566
+
553 567
 JingleSessionPC.prototype.getSsrcOwner = function (ssrc) {
554 568
     return this.ssrcOwners[ssrc];
555 569
 };
@@ -1505,6 +1519,8 @@ JingleSessionPC.prototype.setLocalDescription = function () {
1505 1519
                     'ssrc': ssrc.id,
1506 1520
                     'type': media.type
1507 1521
                 });
1522
+                // FIXME allows for only one SSRC per media type
1523
+                self.localStreamsSSRC[media.type] = ssrc.id;
1508 1524
             });
1509 1525
         }
1510 1526
 

+ 15
- 0
modules/xmpp/xmpp.js Parādīt failu

@@ -299,5 +299,20 @@ XMPP.prototype.disconnect = function () {
299 299
     this.connection.disconnect();
300 300
 };
301 301
 
302
+/**
303
+ * Gets the SSRC of local media stream.
304
+ * @param mediaType the media type that tells whether we want to get
305
+ *        the SSRC of local audio or video stream.
306
+ * @returns {*} the SSRC number for local media stream or <tt>null</tt> if
307
+ *              not available.
308
+ */
309
+XMPP.prototype.getLocalSSRC = function (mediaType) {
310
+    if (this.connection.jingle.activecall &&
311
+        this.connection.jingle.activecall.peerconnection) {
312
+        return this.connection.jingle.activecall.getLocalSSRC(mediaType);
313
+    } else {
314
+        return null;
315
+    }
316
+};
302 317
 
303 318
 module.exports = XMPP;

Notiek ielāde…
Atcelt
Saglabāt