Pārlūkot izejas kodu

Fixes reporting local resolution when simulcast is enabled. Removes storing localSSRCs in JingleSessionPC and use the available ssrcs from the local tracks.

master
damencho 9 gadus atpakaļ
vecāks
revīzija
16fb903b09

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

208
  * Gets the SSRC of this local track if it's available already or <tt>null</tt>
208
  * Gets the SSRC of this local track if it's available already or <tt>null</tt>
209
  * otherwise. That's because we don't know the SSRC until local description is
209
  * otherwise. That's because we don't know the SSRC until local description is
210
  * created.
210
  * created.
211
+ * In case of video and simulcast returns the the primarySSRC.
211
  * @returns {string} or {null}
212
  * @returns {string} or {null}
212
  */
213
  */
213
 JitsiLocalTrack.prototype.getSSRC = function () {
214
 JitsiLocalTrack.prototype.getSSRC = function () {
214
-    if (!this.rtc.room.session)
215
+    if(this.ssrc && this.ssrc.groups && this.ssrc.groups.length)
216
+        return this.ssrc.groups[0].primarySSRC;
217
+    else if(this.ssrc && this.ssrc.ssrcs && this.ssrc.ssrcs.length)
218
+        return this.ssrc.ssrcs[0];
219
+    else
215
         return null;
220
         return null;
216
-    if (this.isAudioTrack()) {
217
-        return this.rtc.room.session.localStreamsSSRC.audio;
218
-    } else {
219
-        return this.rtc.room.session.localStreamsSSRC.video;
220
-    }
221
 };
221
 };
222
 
222
 
223
 /**
223
 /**

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

291
  * @param ssrc the ssrc to check.
291
  * @param ssrc the ssrc to check.
292
  */
292
  */
293
 RTC.prototype.getResourceBySSRC = function (ssrc) {
293
 RTC.prototype.getResourceBySSRC = function (ssrc) {
294
-    if(ssrc == this.room.session.localStreamsSSRC.video
295
-        || ssrc == this.room.session.localStreamsSSRC.audio) {
294
+    if(ssrc == this.localVideo.getSSRC()
295
+        || ssrc == this.localAudio.getSSRC()) {
296
         return Strophe.getResourceFromJid(this.room.myroomjid);
296
         return Strophe.getResourceFromJid(this.room.myroomjid);
297
     }
297
     }
298
 
298
 

+ 2
- 50
modules/xmpp/JingleSessionPC.js Parādīt failu

7
 var SDPUtil = require("./SDPUtil");
7
 var SDPUtil = require("./SDPUtil");
8
 var SDP = require("./SDP");
8
 var SDP = require("./SDP");
9
 var async = require("async");
9
 var async = require("async");
10
-var transform = require("sdp-transform");
11
 var XMPPEvents = require("../../service/xmpp/XMPPEvents");
10
 var XMPPEvents = require("../../service/xmpp/XMPPEvents");
12
 var RTCBrowserType = require("../RTC/RTCBrowserType");
11
 var RTCBrowserType = require("../RTC/RTCBrowserType");
13
 var RTC = require("../RTC/RTC");
12
 var RTC = require("../RTC/RTC");
39
     this.modifyingLocalStreams = false;
38
     this.modifyingLocalStreams = false;
40
     this.modifiedSSRCs = {};
39
     this.modifiedSSRCs = {};
41
 
40
 
42
-    /**
43
-     * A map that stores SSRCs of local streams
44
-     * @type {{}} maps media type('audio' or 'video') to SSRC number
45
-     */
46
-    this.localStreamsSSRC = {};
47
     /**
41
     /**
48
      * A map that stores SSRCs of remote streams. And is used only locally
42
      * A map that stores SSRCs of remote streams. And is used only locally
49
      * We store the mapping when jingle is received, and later is used
43
      * We store the mapping when jingle is received, and later is used
271
     var self = this;
265
     var self = this;
272
     this.peerconnection.setLocalDescription(new RTCSessionDescription({type: 'answer', sdp: sdp}),
266
     this.peerconnection.setLocalDescription(new RTCSessionDescription({type: 'answer', sdp: sdp}),
273
         function () {
267
         function () {
274
-            //logger.log('setLocalDescription success');
275
-            self.setLocalDescription();
276
-
277
             self.connection.sendIQ(accept,
268
             self.connection.sendIQ(accept,
278
                 function () {
269
                 function () {
279
                     var ack = {};
270
                     var ack = {};
474
     });
465
     });
475
 };
466
 };
476
 
467
 
477
-/**
478
- * Returns the SSRC of local audio stream.
479
- * @param mediaType 'audio' or 'video' media type
480
- * @returns {*} the SSRC number of local audio or video stream.
481
- */
482
-JingleSessionPC.prototype.getLocalSSRC = function (mediaType) {
483
-    return this.localStreamsSSRC[mediaType];
484
-};
485
-
486
 JingleSessionPC.prototype.setRemoteDescription = function (elem, desctype) {
468
 JingleSessionPC.prototype.setRemoteDescription = function (elem, desctype) {
487
     //logger.log('setting remote description... ', desctype);
469
     //logger.log('setting remote description... ', desctype);
488
     this.remoteSDP = new SDP('');
470
     this.remoteSDP = new SDP('');
732
             if (self.usetrickle && !self.usepranswer) {
714
             if (self.usetrickle && !self.usepranswer) {
733
                 sendJingle();
715
                 sendJingle();
734
             }
716
             }
735
-            self.setLocalDescription();
736
         },
717
         },
737
         function (e) {
718
         function (e) {
738
             logger.error('setLocalDescription failed', e);
719
             logger.error('setLocalDescription failed', e);
953
     if (this.peerconnection.signalingState == 'closed') return;
934
     if (this.peerconnection.signalingState == 'closed') return;
954
     if (!(this.addssrc.length || this.removessrc.length || this.pendingop !== null
935
     if (!(this.addssrc.length || this.removessrc.length || this.pendingop !== null
955
         || this.modifyingLocalStreams)){
936
         || this.modifyingLocalStreams)){
956
-        // There is nothing to do since scheduled job might have been executed by another succeeding call
957
-        this.setLocalDescription();
937
+        // There is nothing to do since scheduled job might have been
938
+        // executed by another succeeding call
958
         if(successCallback){
939
         if(successCallback){
959
             successCallback();
940
             successCallback();
960
         }
941
         }
1021
                     //modifiedAnswer.sdp = modifiedAnswer.sdp.replace(/a=setup:active/g, 'a=setup:actpass');
1002
                     //modifiedAnswer.sdp = modifiedAnswer.sdp.replace(/a=setup:active/g, 'a=setup:actpass');
1022
                     self.peerconnection.setLocalDescription(modifiedAnswer,
1003
                     self.peerconnection.setLocalDescription(modifiedAnswer,
1023
                         function() {
1004
                         function() {
1024
-                            //logger.log('modified setLocalDescription ok');
1025
-                            self.setLocalDescription();
1026
                             if(successCallback){
1005
                             if(successCallback){
1027
                                 successCallback();
1006
                                 successCallback();
1028
                             }
1007
                             }
1291
     this.room.eventEmitter.emit(XMPPEvents.JINGLE_FATAL_ERROR, session, error);
1270
     this.room.eventEmitter.emit(XMPPEvents.JINGLE_FATAL_ERROR, session, error);
1292
 }
1271
 }
1293
 
1272
 
1294
-JingleSessionPC.prototype.setLocalDescription = function () {
1295
-    var self = this;
1296
-    var newssrcs = [];
1297
-    if(!this.peerconnection.localDescription)
1298
-        return;
1299
-    var session = transform.parse(this.peerconnection.localDescription.sdp);
1300
-    var i;
1301
-    session.media.forEach(function (media) {
1302
-
1303
-        if (media.ssrcs && media.ssrcs.length > 0) {
1304
-            // TODO(gp) maybe exclude FID streams?
1305
-            media.ssrcs.forEach(function (ssrc) {
1306
-                if (ssrc.attribute !== 'cname') {
1307
-                    return;
1308
-                }
1309
-                newssrcs.push({
1310
-                    'ssrc': ssrc.id,
1311
-                    'type': media.type
1312
-                });
1313
-                // FIXME allows for only one SSRC per media type
1314
-                self.localStreamsSSRC[media.type] = ssrc.id;
1315
-            });
1316
-        }
1317
-
1318
-    });
1319
-}
1320
-
1321
 // an attempt to work around https://github.com/jitsi/jitmeet/issues/32
1273
 // an attempt to work around https://github.com/jitsi/jitmeet/issues/32
1322
 JingleSessionPC.prototype.sendKeyframe = function () {
1274
 JingleSessionPC.prototype.sendKeyframe = function () {
1323
     var pc = this.peerconnection;
1275
     var pc = this.peerconnection;

Notiek ielāde…
Atcelt
Saglabāt