Przeglądaj źródła

Merge pull request #22 from jitsi/fix_torture

Fixes the sources in session-accept jingle packets. Fixes issue with not replacing unmuted SSRCs in the SDP.
dev1
damencho 10 lat temu
rodzic
commit
0d839fa055

+ 1
- 1
modules/RTC/RTC.js Wyświetl plik

123
                 }
123
                 }
124
             }
124
             }
125
             this.room.addStream(this.localStreams[i].getOriginalStream(),
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 Wyświetl plik

570
     this.session.removeStream(stream, callback, ssrcInfo);
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
     if(this.session) {
584
     if(this.session) {
575
         // FIXME: will block switchInProgress on true value in case of exception
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
     } else {
587
     } else {
578
         // We are done immediately
588
         // We are done immediately
579
         logger.warn("No conference handler or conference not started yet");
589
         logger.warn("No conference handler or conference not started yet");

+ 21
- 9
modules/xmpp/JingleSessionPC.js Wyświetl plik

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

+ 21
- 1
modules/xmpp/TraceablePeerConnection.js Wyświetl plik

172
 
172
 
173
         modded = true;
173
         modded = true;
174
         var SSRCs = this.replaceSSRCs[bLine.type].splice(0,1);
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
         //FIXME: The code expects that we have only SIM group or we
179
         //FIXME: The code expects that we have only SIM group or we
176
         // don't have any groups and we have only one SSRC per
180
         // don't have any groups and we have only one SSRC per
177
         // stream. If we add another groups (FID, etc) this code
181
         // stream. If we add another groups (FID, etc) this code
267
                             ssrc.id = ssrcMap[ssrc.id];
271
                             ssrc.id = ssrcMap[ssrc.id];
268
                         }
272
                         }
269
                     });
273
                     });
274
+                    // Storing the unmuted SSRCs.
275
+                    permSSRCs.push(ssrcOperation);
270
                     break;
276
                     break;
271
                 default:
277
                 default:
272
                 break;
278
                 break;
273
             }
279
             }
274
             SSRCs = this.replaceSSRCs[bLine.type].splice(0,1);
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
         if (!Array.isArray(bLine.ssrcs) || bLine.ssrcs.length === 0)
285
         if (!Array.isArray(bLine.ssrcs) || bLine.ssrcs.length === 0)
278
         {
286
         {
483
         // FF doesn't support this yet.
491
         // FF doesn't support this yet.
484
         if (this.peerconnection.removeStream) {
492
         if (this.peerconnection.removeStream) {
485
             this.peerconnection.removeStream(stream);
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
                 this.replaceSSRCs[ssrcInfo.mtype].push(ssrcInfo);
506
                 this.replaceSSRCs[ssrcInfo.mtype].push(ssrcInfo);
507
+            }
488
         }
508
         }
489
     } catch (e) {
509
     } catch (e) {
490
         logger.error(e);
510
         logger.error(e);

Ładowanie…
Anuluj
Zapisz