Exposes methods for obtaining stream SSRCs and audio levels.

This commit is contained in:
paweldomas 2015-11-25 16:05:58 -06:00
parent 286225e81e
commit 0a7cea26b3
3 changed files with 45 additions and 0 deletions

View File

@ -137,6 +137,22 @@ var statistics = {
CallStats.sendAddIceCandidateFailed(e, pc);
}
);
},
/**
* Obtains audio level reported in the stats for specified peer.
* @param peerJid full MUC jid of the user for whom we want to obtain last
* audio level.
* @param ssrc the SSRC of audio stream for which we want to obtain audio
* level.
* @returns {*} a float form 0 to 1 that represents current audio level or
* <tt>null</tt> if for any reason the value is not available
* at this time.
*/
getPeerSSRCAudioLevel: function (peerJid, ssrc) {
var peerStats = rtpStats.jid2stats[peerJid];
return peerStats ? peerStats.ssrc2AudioLevel[ssrc] : null;
}
};

View File

@ -40,6 +40,11 @@ function JingleSessionPC(me, sid, connection, service, eventEmitter) {
this.switchstreams = false;
this.wait = true;
/**
* A map that stores SSRCs of local streams
* @type {{}} maps media type('audio' or 'video') to SSRC number
*/
this.localStreamsSSRC = {};
this.ssrcOwners = {};
this.ssrcVideoTypes = {};
this.eventEmitter = eventEmitter;
@ -552,6 +557,15 @@ JingleSessionPC.prototype.getSsrcOwner = function (ssrc) {
return this.ssrcOwners[ssrc];
};
/**
* Returns the SSRC of local audio stream.
* @param mediaType 'audio' or 'video' media type
* @returns {*} the SSRC number of local audio or video stream.
*/
JingleSessionPC.prototype.getLocalSSRC = function (mediaType) {
return this.localStreamsSSRC[mediaType];
};
JingleSessionPC.prototype.setRemoteDescription = function (elem, desctype) {
this.remoteSDP = new SDP('');
if (config.webrtcIceTcpDisable) {
@ -1424,6 +1438,8 @@ JingleSessionPC.prototype.setLocalDescription = function () {
'ssrc': ssrc.id,
'type': media.type
});
// FIXME allows for only one SSRC per media type
self.localStreamsSSRC[media.type] = ssrc.id;
});
}

View File

@ -596,6 +596,19 @@ var XMPP = {
return null;
return connection.jingle.activecall.getSsrcOwner(ssrc);
},
/**
* Gets the SSRC of local media stream.
* @param mediaType the media type that tells whether we want to get
* the SSRC of local audio or video stream.
* @returns {*} the SSRC number for local media stream or <tt>null</tt> if
* not available.
*/
getLocalSSRC: function (mediaType) {
if (!this.isConferenceInProgress()) {
return null;
}
return connection.jingle.activecall.getLocalSSRC(mediaType);
},
// Returns true iff we have joined the MUC.
isMUCJoined: function () {
return connection === null ? false : connection.emuc.joined;