Pārlūkot izejas kodu

Fixes the sources in session-accept jingle packets. Fixes issue with not replacing unmuted SSRCs in the SDP.

master
hristoterezov 9 gadus atpakaļ
vecāks
revīzija
43c1d3f38f

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

@@ -123,7 +123,7 @@ RTC.prototype.onIncommingCall = function(event) {
123 123
                 }
124 124
             }
125 125
             this.room.addStream(this.localStreams[i].getOriginalStream(),
126
-                function () {}, ssrcInfo);
126
+                function () {}, ssrcInfo, true);
127 127
         }
128 128
 }
129 129
 

+ 12
- 2
modules/xmpp/ChatRoom.js Parādīt failu

@@ -570,10 +570,20 @@ ChatRoom.prototype.removeStream = function (stream, callback, ssrcInfo) {
570 570
     this.session.removeStream(stream, callback, ssrcInfo);
571 571
 };
572 572
 
573
-ChatRoom.prototype.addStream = function (stream, callback, ssrcInfo) {
573
+/**
574
+ * Adds stream.
575
+ * @param stream new stream that will be added.
576
+ * @param callback callback executed after successful stream addition.
577
+ * @param ssrcInfo object with information about the SSRCs associated with the
578
+ * stream.
579
+ * @param dontModifySources {boolean} if true _modifySources won't be called.
580
+ * Used for streams added before the call start.
581
+ */
582
+ChatRoom.prototype.addStream = function (stream, callback, ssrcInfo,
583
+    dontModifySources) {
574 584
     if(this.session) {
575 585
         // FIXME: will block switchInProgress on true value in case of exception
576
-        this.session.addStream(stream, callback, ssrcInfo);
586
+        this.session.addStream(stream, callback, ssrcInfo, dontModifySources);
577 587
     } else {
578 588
         // We are done immediately
579 589
         logger.warn("No conference handler or conference not started yet");

+ 21
- 9
modules/xmpp/JingleSessionPC.js Parādīt failu

@@ -361,7 +361,6 @@ JingleSessionPC.prototype.sendIceCandidate = function (candidate) {
361 361
                     init,
362 362
                     self.initiator == self.me ? 'initiator' : 'responder',
363 363
                     ssrc);
364
-
365 364
                 self.connection.sendIQ(init,
366 365
                     function () {
367 366
                         //logger.log('session initiate ack');
@@ -689,7 +688,7 @@ JingleSessionPC.prototype.createdAnswer = function (sdp, provisional) {
689 688
                     accept,
690 689
                     self.initiator == self.me ? 'initiator' : 'responder',
691 690
                     ssrcs);
692
-
691
+                self.fixJingle(accept);
693 692
                 self.connection.sendIQ(accept,
694 693
                     function () {
695 694
                         var ack = {};
@@ -1027,11 +1026,16 @@ JingleSessionPC.prototype._modifySources = function (successCallback, queueCallb
1027 1026
 };
1028 1027
 
1029 1028
 /**
1030
- * Adds streams.
1029
+ * Adds stream.
1031 1030
  * @param stream new stream that will be added.
1032 1031
  * @param success_callback callback executed after successful stream addition.
1032
+ * @param ssrcInfo object with information about the SSRCs associated with the
1033
+ * stream.
1034
+ * @param dontModifySources {boolean} if true _modifySources won't be called.
1035
+ * Used for streams added before the call start.
1033 1036
  */
1034
-JingleSessionPC.prototype.addStream = function (stream, callback, ssrcInfo) {
1037
+JingleSessionPC.prototype.addStream = function (stream, callback, ssrcInfo,
1038
+    dontModifySources) {
1035 1039
     // Remember SDP to figure out added/removed SSRCs
1036 1040
     var oldSdp = null;
1037 1041
     if(this.peerconnection) {
@@ -1045,7 +1049,13 @@ JingleSessionPC.prototype.addStream = function (stream, callback, ssrcInfo) {
1045 1049
     }
1046 1050
 
1047 1051
     // Conference is not active
1048
-    if(!oldSdp || !this.peerconnection) {
1052
+    if(!oldSdp || !this.peerconnection || dontModifySources) {
1053
+        if(ssrcInfo) {
1054
+            //available only on video unmute or when adding muted stream
1055
+            this.modifiedSSRCs[ssrcInfo.type] =
1056
+                this.modifiedSSRCs[ssrcInfo.type] || [];
1057
+            this.modifiedSSRCs[ssrcInfo.type].push(ssrcInfo);
1058
+        }
1049 1059
         callback();
1050 1060
         return;
1051 1061
     }
@@ -1054,14 +1064,13 @@ JingleSessionPC.prototype.addStream = function (stream, callback, ssrcInfo) {
1054 1064
     var self = this;
1055 1065
     this.modifySourcesQueue.push(function() {
1056 1066
         logger.log('modify sources done');
1057
-
1058
-        callback();
1059 1067
         if(ssrcInfo) {
1060 1068
             //available only on video unmute or when adding muted stream
1061 1069
             self.modifiedSSRCs[ssrcInfo.type] =
1062 1070
                 self.modifiedSSRCs[ssrcInfo.type] || [];
1063 1071
             self.modifiedSSRCs[ssrcInfo.type].push(ssrcInfo);
1064 1072
         }
1073
+        callback();
1065 1074
         var newSdp = new SDP(self.peerconnection.localDescription.sdp);
1066 1075
         logger.log("SDPs", oldSdp, newSdp);
1067 1076
         self.notifyMySSRCUpdate(oldSdp, newSdp);
@@ -1081,6 +1090,8 @@ JingleSessionPC.prototype.generateNewStreamSSRCInfo = function () {
1081 1090
  * Remove streams.
1082 1091
  * @param stream stream that will be removed.
1083 1092
  * @param success_callback callback executed after successful stream addition.
1093
+ * @param ssrcInfo object with information about the SSRCs associated with the
1094
+ * stream.
1084 1095
  */
1085 1096
 JingleSessionPC.prototype.removeStream = function (stream, callback, ssrcInfo) {
1086 1097
     // Remember SDP to figure out added/removed SSRCs
@@ -1183,7 +1194,7 @@ JingleSessionPC.prototype.notifyMySSRCUpdate = function (old_sdp, new_sdp) {
1183 1194
     var removed = this.fixJingle(remove);
1184 1195
 
1185 1196
     if (removed && remove) {
1186
-        logger.info("Sending source-remove", remove);
1197
+        logger.info("Sending source-remove", remove.tree());
1187 1198
         this.connection.sendIQ(remove,
1188 1199
             function (res) {
1189 1200
                 logger.info('got remove result', res);
@@ -1211,7 +1222,7 @@ JingleSessionPC.prototype.notifyMySSRCUpdate = function (old_sdp, new_sdp) {
1211 1222
     var added = this.fixJingle(add);
1212 1223
 
1213 1224
     if (added && add) {
1214
-        logger.info("Sending source-add", add);
1225
+        logger.info("Sending source-add", add.tree());
1215 1226
         this.connection.sendIQ(add,
1216 1227
             function (res) {
1217 1228
                 logger.info('got add result', res);
@@ -1389,6 +1400,7 @@ JingleSessionPC.prototype.fixJingle = function(jingle) {
1389 1400
     var action = $(jingle.nodeTree).find("jingle").attr("action");
1390 1401
     switch (action) {
1391 1402
         case "source-add":
1403
+        case "session-accept":
1392 1404
             this.fixSourceAddJingle(jingle);
1393 1405
             break;
1394 1406
         case "source-remove":

+ 21
- 1
modules/xmpp/TraceablePeerConnection.js Parādīt failu

@@ -172,6 +172,10 @@ TraceablePeerConnection.prototype.ssrcReplacement = function (desc) {
172 172
 
173 173
         modded = true;
174 174
         var SSRCs = this.replaceSSRCs[bLine.type].splice(0,1);
175
+        // Stores all SSRCs that should be used on other SRD/SDL operations.
176
+        // For every stream that is unmuted we need to replace it SSRC
177
+        // otherwise we are going to send jingle packet.
178
+        var permSSRCs = [];
175 179
         //FIXME: The code expects that we have only SIM group or we
176 180
         // don't have any groups and we have only one SSRC per
177 181
         // stream. If we add another groups (FID, etc) this code
@@ -267,12 +271,16 @@ TraceablePeerConnection.prototype.ssrcReplacement = function (desc) {
267 271
                             ssrc.id = ssrcMap[ssrc.id];
268 272
                         }
269 273
                     });
274
+                    // Storing the unmuted SSRCs.
275
+                    permSSRCs.push(ssrcOperation);
270 276
                     break;
271 277
                 default:
272 278
                 break;
273 279
             }
274 280
             SSRCs = this.replaceSSRCs[bLine.type].splice(0,1);
275 281
         }
282
+        // Restoring the unmuted SSRCs.
283
+        this.replaceSSRCs[bLine.type] = permSSRCs;
276 284
 
277 285
         if (!Array.isArray(bLine.ssrcs) || bLine.ssrcs.length === 0)
278 286
         {
@@ -483,8 +491,20 @@ ssrcInfo) {
483 491
         // FF doesn't support this yet.
484 492
         if (this.peerconnection.removeStream) {
485 493
             this.peerconnection.removeStream(stream);
486
-            if(ssrcInfo && this.replaceSSRCs[ssrcInfo.mtype])
494
+            // Removing all cached ssrcs for the streams that are removed or
495
+            // muted.
496
+            if(ssrcInfo && this.replaceSSRCs[ssrcInfo.mtype]) {
497
+                for(i = 0; i < this.replaceSSRCs[ssrcInfo.mtype].length; i++) {
498
+                    var op = this.replaceSSRCs[ssrcInfo.mtype][i];
499
+                    if(op.type === "unmute" &&
500
+                        op.ssrc.ssrcs.join("_") ===
501
+                        ssrcInfo.ssrc.ssrcs.join("_")) {
502
+                        this.replaceSSRCs[ssrcInfo.mtype].splice(i, 1);
503
+                        break;
504
+                    }
505
+                }
487 506
                 this.replaceSSRCs[ssrcInfo.mtype].push(ssrcInfo);
507
+            }
488 508
         }
489 509
     } catch (e) {
490 510
         logger.error(e);

Notiek ielāde…
Atcelt
Saglabāt