Permalink
Browse files

ref(ssrc info): get rid of 'ssrc' and 'group' roots

Removes 'ssrc' and 'group' root Objects from "ssrc info" structure.
Also removed redundant 'primarySSRC' from the group.
Do not split and join back and forth the SSRCs, but store them as
numbers.
  • Loading branch information...
paweldomas committed Jan 25, 2017
1 parent d68829f commit 76229eb4e4c8e40cca08ff6dc069b39ead2bf671
Showing with 51 additions and 53 deletions.
  1. +3 −2 JitsiConference.js
  2. +5 −3 modules/RTC/JitsiLocalTrack.js
  3. +21 −25 modules/RTC/TraceablePeerConnection.js
  4. +22 −23 modules/xmpp/JingleSessionPC.js
View
@@ -1037,7 +1037,7 @@ function (jingleSession, jingleOffer, now) {
this.rtc.initializeDataChannels(jingleSession.peerconnection);
// Add local Tracks to the ChatRoom
this.getLocalTracks().forEach(function(localTrack) {
var ssrcInfo = null;
let ssrcInfo = null;
/**
* We don't do this for Firefox because, on Firefox, we keep the
* stream in the peer connection and just set 'enabled' on the
@@ -1068,7 +1068,8 @@ function (jingleSession, jingleOffer, now) {
ssrcInfo = {
mtype: localTrack.getType(),
type: "addMuted",
ssrc: localTrack.ssrc,
ssrcs: localTrack.ssrc.ssrcs,
groups: localTrack.ssrc.groups,
msid: localTrack.initialMSID
};
}
@@ -377,7 +377,8 @@ JitsiLocalTrack.prototype._addStreamToConferenceAsUnmute = function () {
{
mtype: self.type,
type: "unmute",
ssrc: self.ssrc,
ssrcs: self.ssrc ? self.ssrc.ssrcs : undefined,
groups: self.ssrc ? self.ssrc.groups: undefined,
msid: self.getMSID()
});
});
@@ -403,7 +404,8 @@ function (successCallback, errorCallback) {
{
mtype: this.type,
type: "mute",
ssrc: this.ssrc
ssrcs: this.ssrc ? this.ssrc.ssrcs : undefined,
groups: this.ssrc ? this.ssrc.groups : undefined
});
};
@@ -518,7 +520,7 @@ JitsiLocalTrack.prototype._setConference = function(conference) {
*/
JitsiLocalTrack.prototype.getSSRC = function () {
if(this.ssrc && this.ssrc.groups && this.ssrc.groups.length)
return this.ssrc.groups[0].primarySSRC;
return this.ssrc.groups[0].ssrcs[0];
else if(this.ssrc && this.ssrc.ssrcs && this.ssrc.ssrcs.length)
return this.ssrc.ssrcs[0];
else
@@ -740,7 +740,12 @@ function extractSSRCMap(desc) {
mLine.ssrcGroups.forEach(function (group) {
if (typeof group.semantics !== 'undefined' &&
typeof group.ssrcs !== 'undefined') {
var primarySSRC = Number(group.ssrcs.split(' ')[0]);
// Parse SSRCs and store as numbers
const groupSSRCs
= group.ssrcs.split(' ').map(
(ssrcStr) => { return Number(ssrcStr); });
const primarySSRC = groupSSRCs[0];
group.ssrcs = groupSSRCs;
ssrcGroups[primarySSRC] = ssrcGroups[primarySSRC] || [];
ssrcGroups[primarySSRC].push(group);
}
@@ -749,13 +754,12 @@ function extractSSRCMap(desc) {
mLine.ssrcs.forEach(function (ssrc) {
if(ssrc.attribute !== 'msid')
return;
ssrcList[ssrc.value] = ssrcList[ssrc.value] ||
{groups: [], ssrcs: []};
ssrcList[ssrc.value]
= ssrcList[ssrc.value] || { groups: [], ssrcs: [] };
ssrcList[ssrc.value].ssrcs.push(ssrc.id);
if(ssrcGroups[ssrc.id]){
ssrcGroups[ssrc.id].forEach(function (group) {
ssrcList[ssrc.value].groups.push(
{primarySSRC: ssrc.id, group: group});
ssrcList[ssrc.value].groups.push(group);
});
}
});
@@ -881,26 +885,23 @@ TraceablePeerConnection.prototype.addStream = function (stream, ssrcInfo) {
if (stream)
this.peerconnection.addStream(stream);
if (ssrcInfo && ssrcInfo.type === "addMuted") {
this.sdpConsistency.setPrimarySsrc(ssrcInfo.ssrc.ssrcs[0]);
this.sdpConsistency.setPrimarySsrc(ssrcInfo.ssrcs[0]);
const simGroup =
ssrcInfo.ssrc.groups.find(groupInfo => {
return groupInfo.group.semantics === "SIM";
ssrcInfo.groups.find(groupInfo => {
return groupInfo.semantics === "SIM";
});
if (simGroup) {
const simSsrcs = SDPUtil.parseGroupSsrcs(simGroup.group);
this.simulcast.setSsrcCache(simSsrcs);
this.simulcast.setSsrcCache(simGroup.ssrcs);
}
const fidGroups =
ssrcInfo.ssrc.groups.filter(groupInfo => {
return groupInfo.group.semantics === "FID";
ssrcInfo.groups.filter(groupInfo => {
return groupInfo.semantics === "FID";
});
if (fidGroups) {
const rtxSsrcMapping = new Map();
fidGroups.forEach(fidGroup => {
const fidGroupSsrcs =
SDPUtil.parseGroupSsrcs(fidGroup.group);
const primarySsrc = fidGroupSsrcs[0];
const rtxSsrc = fidGroupSsrcs[1];
const primarySsrc = fidGroup.ssrcs[0];
const rtxSsrc = fidGroup.ssrcs[1];
rtxSsrcMapping.set(primarySsrc, rtxSsrc);
});
this.rtxModifier.setSsrcCache(rtxSsrcMapping);
@@ -1211,10 +1212,8 @@ TraceablePeerConnection.prototype.generateNewStreamSSRCInfo = function () {
for (let i = 0; i < SIMULCAST_LAYERS; i++) {
ssrcInfo.ssrcs.push(SDPUtil.generateSsrc());
}
ssrcInfo.groups.push({
primarySSRC: ssrcInfo.ssrcs[0],
group: {ssrcs: ssrcInfo.ssrcs.join(" "), semantics: "SIM"}});
ssrcInfo;
ssrcInfo.groups.push(
{ ssrcs: ssrcInfo.ssrcs.slice(), semantics: "SIM" });
} else {
ssrcInfo = {ssrcs: [SDPUtil.generateSsrc()], groups: []};
}
@@ -1229,11 +1228,8 @@ TraceablePeerConnection.prototype.generateNewStreamSSRCInfo = function () {
const rtxSsrc = SDPUtil.generateSsrc();
ssrcInfo.ssrcs.push(rtxSsrc);
ssrcInfo.groups.push({
primarySSRC: primarySsrc,
group: {
ssrcs: primarySsrc + " " + rtxSsrc,
semantics: "FID"
}
ssrcs: [primarySsrc, rtxSsrc],
semantics: "FID"
});
}
}
@@ -1363,16 +1363,15 @@ export default class JingleSessionPC extends JingleSession {
ssrcObj.mtype + "\"]>description");
if (!desc || !desc.length)
return;
ssrcObj.ssrc.ssrcs.forEach(function (ssrc) {
ssrcObj.ssrcs.forEach(function (ssrc) {
const sourceNode = desc.find(">source[ssrc=\"" +
ssrc + "\"]");
sourceNode.remove();
});
ssrcObj.ssrc.groups.forEach(function (group) {
ssrcObj.groups.forEach(function (group) {
const groupNode = desc.find(">ssrc-group[semantics=\"" +
group.group.semantics + "\"]:has(source[ssrc=\"" +
group.primarySSRC +
"\"])");
group.semantics + "\"]:has(source[ssrc=\"" +
group.ssrcs[0] + "\"])");
groupNode.remove();
});
});
@@ -1386,7 +1385,7 @@ export default class JingleSessionPC extends JingleSession {
= JingleSessionPC.createDescriptionNode(
jingle, ssrcObj.mtype);
const cname = Math.random().toString(36).substring(2);
ssrcObj.ssrc.ssrcs.forEach(function (ssrc) {
ssrcObj.ssrcs.forEach(function (ssrc) {
const sourceNode
= desc.find(">source[ssrc=\"" + ssrc + "\"]");
sourceNode.remove();
@@ -1399,18 +1398,18 @@ export default class JingleSessionPC extends JingleSession {
" value=\"" + cname + "\" name=\"cname\" />" + "</source>";
desc.append(sourceXML);
});
ssrcObj.ssrc.groups.forEach(function (group) {
ssrcObj.groups.forEach(function (group) {
const groupNode
= desc.find(">ssrc-group[semantics=\"" +
group.group.semantics + "\"]:has(source[ssrc=\""
+ group.primarySSRC + "\"])");
group.semantics + "\"]:has(source[ssrc=\""
+ group.ssrcs[0] + "\"])");
groupNode.remove();
desc.append(
"<ssrc-group semantics=\"" + group.group.semantics +
"<ssrc-group semantics=\"" + group.semantics +
"\" xmlns=\"urn:xmpp:jingle:apps:rtp:ssma:0\">" +
"<source ssrc=\"" +
group.group.ssrcs.split(" ")
.join("\"/>" + "<source ssrc=\"") + "\"/>" +
group.ssrcs.join("\"/>" + "<source ssrc=\"") +
"\"/>" +
"</ssrc-group>");
});
});
@@ -1428,20 +1427,20 @@ export default class JingleSessionPC extends JingleSession {
this.modifiedSSRCs["mute"] = [];
if (ssrcs && ssrcs.length)
ssrcs.forEach(function (ssrcObj) {
ssrcObj.ssrc.ssrcs.forEach(function (ssrc) {
ssrcObj.ssrcs.forEach(function (ssrc) {
const sourceNode
= $(jingle.tree()).find(">jingle>content[name=\"" +
ssrcObj.mtype + "\"]>description>source[ssrc=\"" +
ssrc + "\"]");
sourceNode.remove();
});
ssrcObj.ssrc.groups.forEach(function (group) {
ssrcObj.groups.forEach(function (group) {
const groupNode
= $(jingle.tree()).find(
">jingle>content[name=\"" + ssrcObj.mtype +
"\"]>description>ssrc-group[semantics=\"" +
group.group.semantics + "\"]:has(source[ssrc=\"" +
group.primarySSRC + "\"])");
group.semantics + "\"]:has(source[ssrc=\"" +
group.ssrcs[0] + "\"])");
groupNode.remove();
});
});
@@ -1453,7 +1452,7 @@ export default class JingleSessionPC extends JingleSession {
const desc
= JingleSessionPC.createDescriptionNode(
jingle, ssrcObj.mtype);
ssrcObj.ssrc.ssrcs.forEach(function (ssrc) {
ssrcObj.ssrcs.forEach(function (ssrc) {
const sourceNode
= desc.find(">source[ssrc=\"" + ssrc + "\"]");
if (!sourceNode || !sourceNode.length) {
@@ -1464,18 +1463,18 @@ export default class JingleSessionPC extends JingleSession {
"ssrc=\"" + ssrc + "\"></source>");
}
});
ssrcObj.ssrc.groups.forEach(function (group) {
ssrcObj.groups.forEach(function (group) {
const groupNode
= desc.find(">ssrc-group[semantics=\"" +
group.group.semantics + "\"]:has(source[ssrc=\"" +
group.primarySSRC + "\"])");
group.semantics + "\"]:has(source[ssrc=\"" +
group.ssrcs[0] + "\"])");
if (!groupNode || !groupNode.length) {
desc.append("<ssrc-group semantics=\"" +
group.group.semantics +
group.semantics +
"\" xmlns=\"urn:xmpp:jingle:apps:rtp:ssma:0\">" +
"<source ssrc=\"" +
group.group.ssrcs.split(" ")
.join("\"/><source ssrc=\"") + "\"/>" +
group.ssrcs.join("\"/><source ssrc=\"") +
"\"/>" +
"</ssrc-group>");
}
});

0 comments on commit 76229eb

Please sign in to comment.