|
|
@@ -115,7 +115,7 @@ export default class SdpConsistency {
|
|
115
|
115
|
*/
|
|
116
|
116
|
makeVideoPrimarySsrcsConsistent (sdpStr) {
|
|
117
|
117
|
let parsedSdp = transform.parse(sdpStr);
|
|
118
|
|
- let videoMLine =
|
|
|
118
|
+ let videoMLine =
|
|
119
|
119
|
parsedSdp.media.find(mLine => mLine.type === "video");
|
|
120
|
120
|
if (videoMLine.direction === "inactive") {
|
|
121
|
121
|
console.log("Sdp-consistency doing nothing, " +
|
|
|
@@ -126,29 +126,33 @@ export default class SdpConsistency {
|
|
126
|
126
|
// If the mline is recvonly, we'll add the primary
|
|
127
|
127
|
// ssrc as a recvonly ssrc
|
|
128
|
128
|
videoMLine.ssrcs = videoMLine.ssrcs || [];
|
|
129
|
|
- videoMLine.ssrcs.push({
|
|
130
|
|
- id: this.cachedPrimarySsrc,
|
|
131
|
|
- attribute: "cname",
|
|
132
|
|
- value: "recvonly-" + this.cachedPrimarySsrc
|
|
133
|
|
- });
|
|
|
129
|
+ if (this.cachedPrimarySsrc) {
|
|
|
130
|
+ videoMLine.ssrcs.push({
|
|
|
131
|
+ id: this.cachedPrimarySsrc,
|
|
|
132
|
+ attribute: "cname",
|
|
|
133
|
+ value: "recvonly-" + this.cachedPrimarySsrc
|
|
|
134
|
+ });
|
|
|
135
|
+ } else {
|
|
|
136
|
+ console.error("No SSRC found for the recvonly video stream!");
|
|
|
137
|
+ }
|
|
134
|
138
|
} else {
|
|
135
|
139
|
let newPrimarySsrc = getPrimarySsrc(videoMLine);
|
|
136
|
140
|
if (!newPrimarySsrc) {
|
|
137
|
141
|
console.log("Sdp-consistency couldn't parse new primary ssrc");
|
|
138
|
142
|
return sdpStr;
|
|
139
|
143
|
}
|
|
140
|
|
- let newPrimaryRtxSsrc =
|
|
|
144
|
+ let newPrimaryRtxSsrc =
|
|
141
|
145
|
getRtxSsrc(videoMLine, newPrimarySsrc);
|
|
142
|
146
|
if (!this.cachedPrimarySsrc) {
|
|
143
|
147
|
this.cachedPrimarySsrc = newPrimarySsrc;
|
|
144
|
148
|
this.cachedPrimaryRtxSsrc = newPrimaryRtxSsrc;
|
|
145
|
|
- console.log("Sdp-consistency caching primary ssrc " +
|
|
146
|
|
- this.cachedPrimarySsrc + " and rtx " +
|
|
|
149
|
+ console.log("Sdp-consistency caching primary ssrc " +
|
|
|
150
|
+ this.cachedPrimarySsrc + " and rtx " +
|
|
147
|
151
|
this.cachedPrimaryRtxSsrc);
|
|
148
|
152
|
} else {
|
|
149
|
|
- console.log("Sdp-consistency replacing new ssrc " +
|
|
150
|
|
- newPrimarySsrc + " with cached " + this.cachedPrimarySsrc +
|
|
151
|
|
- " and new rtx " + newPrimaryRtxSsrc + " with cached " +
|
|
|
153
|
+ console.log("Sdp-consistency replacing new ssrc " +
|
|
|
154
|
+ newPrimarySsrc + " with cached " + this.cachedPrimarySsrc +
|
|
|
155
|
+ " and new rtx " + newPrimaryRtxSsrc + " with cached " +
|
|
152
|
156
|
this.cachedPrimaryRtxSsrc);
|
|
153
|
157
|
let self = this;
|
|
154
|
158
|
videoMLine.ssrcs.forEach(ssrcInfo => {
|
|
|
@@ -161,11 +165,11 @@ export default class SdpConsistency {
|
|
161
|
165
|
if (videoMLine.ssrcGroups) {
|
|
162
|
166
|
videoMLine.ssrcGroups.forEach(group => {
|
|
163
|
167
|
if (group.semantics === "FID") {
|
|
164
|
|
- let primarySsrc =
|
|
|
168
|
+ let primarySsrc =
|
|
165
|
169
|
parseInt(group.ssrcs.split(" ")[0]);
|
|
166
|
170
|
if (primarySsrc == self.cachedPrimarySsrc) {
|
|
167
|
|
- group.ssrcs =
|
|
168
|
|
- self.cachedPrimarySsrc + " " +
|
|
|
171
|
+ group.ssrcs =
|
|
|
172
|
+ self.cachedPrimarySsrc + " " +
|
|
169
|
173
|
self.cachedPrimaryRtxSsrc;
|
|
170
|
174
|
}
|
|
171
|
175
|
}
|