浏览代码

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 年前
父节点
当前提交
16fb903b09
共有 3 个文件被更改,包括 10 次插入58 次删除
  1. 6
    6
      modules/RTC/JitsiLocalTrack.js
  2. 2
    2
      modules/RTC/RTC.js
  3. 2
    50
      modules/xmpp/JingleSessionPC.js

+ 6
- 6
modules/RTC/JitsiLocalTrack.js 查看文件

@@ -208,16 +208,16 @@ JitsiLocalTrack.prototype._setConference = function(conference) {
208 208
  * Gets the SSRC of this local track if it's available already or <tt>null</tt>
209 209
  * otherwise. That's because we don't know the SSRC until local description is
210 210
  * created.
211
+ * In case of video and simulcast returns the the primarySSRC.
211 212
  * @returns {string} or {null}
212 213
  */
213 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 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 查看文件

@@ -291,8 +291,8 @@ RTC.prototype.setAudioLevel = function (resource, audioLevel) {
291 291
  * @param ssrc the ssrc to check.
292 292
  */
293 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 296
         return Strophe.getResourceFromJid(this.room.myroomjid);
297 297
     }
298 298
 

+ 2
- 50
modules/xmpp/JingleSessionPC.js 查看文件

@@ -7,7 +7,6 @@ var SDPDiffer = require("./SDPDiffer");
7 7
 var SDPUtil = require("./SDPUtil");
8 8
 var SDP = require("./SDP");
9 9
 var async = require("async");
10
-var transform = require("sdp-transform");
11 10
 var XMPPEvents = require("../../service/xmpp/XMPPEvents");
12 11
 var RTCBrowserType = require("../RTC/RTCBrowserType");
13 12
 var RTC = require("../RTC/RTC");
@@ -39,11 +38,6 @@ function JingleSessionPC(me, sid, connection, service) {
39 38
     this.modifyingLocalStreams = false;
40 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 42
      * A map that stores SSRCs of remote streams. And is used only locally
49 43
      * We store the mapping when jingle is received, and later is used
@@ -271,9 +265,6 @@ JingleSessionPC.prototype.accept = function () {
271 265
     var self = this;
272 266
     this.peerconnection.setLocalDescription(new RTCSessionDescription({type: 'answer', sdp: sdp}),
273 267
         function () {
274
-            //logger.log('setLocalDescription success');
275
-            self.setLocalDescription();
276
-
277 268
             self.connection.sendIQ(accept,
278 269
                 function () {
279 270
                     var ack = {};
@@ -474,15 +465,6 @@ JingleSessionPC.prototype.readSsrcInfo = function (contents) {
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 468
 JingleSessionPC.prototype.setRemoteDescription = function (elem, desctype) {
487 469
     //logger.log('setting remote description... ', desctype);
488 470
     this.remoteSDP = new SDP('');
@@ -732,7 +714,6 @@ JingleSessionPC.prototype.createdAnswer = function (sdp, provisional) {
732 714
             if (self.usetrickle && !self.usepranswer) {
733 715
                 sendJingle();
734 716
             }
735
-            self.setLocalDescription();
736 717
         },
737 718
         function (e) {
738 719
             logger.error('setLocalDescription failed', e);
@@ -953,8 +934,8 @@ JingleSessionPC.prototype._modifySources = function (successCallback, queueCallb
953 934
     if (this.peerconnection.signalingState == 'closed') return;
954 935
     if (!(this.addssrc.length || this.removessrc.length || this.pendingop !== null
955 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 939
         if(successCallback){
959 940
             successCallback();
960 941
         }
@@ -1021,8 +1002,6 @@ JingleSessionPC.prototype._modifySources = function (successCallback, queueCallb
1021 1002
                     //modifiedAnswer.sdp = modifiedAnswer.sdp.replace(/a=setup:active/g, 'a=setup:actpass');
1022 1003
                     self.peerconnection.setLocalDescription(modifiedAnswer,
1023 1004
                         function() {
1024
-                            //logger.log('modified setLocalDescription ok');
1025
-                            self.setLocalDescription();
1026 1005
                             if(successCallback){
1027 1006
                                 successCallback();
1028 1007
                             }
@@ -1291,33 +1270,6 @@ JingleSessionPC.onJingleFatalError = function (session, error)
1291 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 1273
 // an attempt to work around https://github.com/jitsi/jitmeet/issues/32
1322 1274
 JingleSessionPC.prototype.sendKeyframe = function () {
1323 1275
     var pc = this.peerconnection;

正在加载...
取消
保存