瀏覽代碼

Merge pull request #350 from jitsi/fix_no_video_device2

Fix conference being broken after someone without any video device joins (ver 2)
dev1
bbaldino 8 年之前
父節點
當前提交
5652becace
共有 5 個檔案被更改,包括 64 行新增17 行删除
  1. 7
    2
      JitsiConference.js
  2. 13
    0
      modules/xmpp/ChatRoom.js
  3. 13
    0
      modules/xmpp/JingleSessionPC.js
  4. 19
    15
      modules/xmpp/SdpConsistency.js
  5. 12
    0
      modules/xmpp/TraceablePeerConnection.js

+ 7
- 2
JitsiConference.js 查看文件

2
 
2
 
3
 var logger = require("jitsi-meet-logger").getLogger(__filename);
3
 var logger = require("jitsi-meet-logger").getLogger(__filename);
4
 import RTC from "./modules/RTC/RTC";
4
 import RTC from "./modules/RTC/RTC";
5
+import * as MediaType from "./service/RTC/MediaType";
5
 var XMPPEvents = require("./service/xmpp/XMPPEvents");
6
 var XMPPEvents = require("./service/xmpp/XMPPEvents");
6
 var EventEmitter = require("events");
7
 var EventEmitter = require("events");
7
 import * as JitsiConferenceErrors from "./JitsiConferenceErrors";
8
 import * as JitsiConferenceErrors from "./JitsiConferenceErrors";
246
 /**
247
 /**
247
  * Returns the local tracks of the given media type, or all local tracks if no
248
  * Returns the local tracks of the given media type, or all local tracks if no
248
  * specific type is given.
249
  * specific type is given.
249
- * @param mediaType {MediaType} Optional media type (audio or video).
250
+ * @param {MediaType} [mediaType] Optional media type (audio or video).
250
  */
251
  */
251
 JitsiConference.prototype.getLocalTracks = function (mediaType) {
252
 JitsiConference.prototype.getLocalTracks = function (mediaType) {
252
     let tracks = [];
253
     let tracks = [];
883
     this.rtc.localTracks.forEach(function(localTrack) {
884
     this.rtc.localTracks.forEach(function(localTrack) {
884
         var ssrcInfo = null;
885
         var ssrcInfo = null;
885
         /**
886
         /**
886
-         * We don't do this for Firefox because, on Firefox, we keep the 
887
+         * We don't do this for Firefox because, on Firefox, we keep the
887
          *  stream in the peer connection and just set 'enabled' on the
888
          *  stream in the peer connection and just set 'enabled' on the
888
          *  track to false (see JitsiLocalTrack::_setMute).  This means
889
          *  track to false (see JitsiLocalTrack::_setMute).  This means
889
          *  that if we generated an ssrc here and set it in the cache, it
890
          *  that if we generated an ssrc here and set it in the cache, it
926
             logger.error(e);
927
             logger.error(e);
927
         }
928
         }
928
     }.bind(this));
929
     }.bind(this));
930
+    // Generate the 'recvonly' SSRC in case there are no video tracks
931
+    if (!this.getLocalTracks(MediaType.VIDEO).length) {
932
+        this.room.generateRecvonlySsrc();
933
+    }
929
 
934
 
930
     jingleSession.acceptOffer(jingleOffer, null,
935
     jingleSession.acceptOffer(jingleOffer, null,
931
         function (error) {
936
         function (error) {

+ 13
- 0
modules/xmpp/ChatRoom.js 查看文件

425
         this.participantPropertyListener = listener;
425
         this.participantPropertyListener = listener;
426
     }
426
     }
427
 
427
 
428
+    /**
429
+     * Makes the underlying JingleSession generate new SSRC for the recvonly
430
+     * video stream.
431
+     * @deprecated
432
+     */
433
+    generateRecvonlySsrc() {
434
+        if (this.session) {
435
+            this.session.generateRecvonlySsrc();
436
+        } else {
437
+            logger.warn("Unable to generate recvonly SSRC - no session");
438
+        }
439
+    }
440
+
428
     processNode (node, from) {
441
     processNode (node, from) {
429
         // make sure we catch all errors coming from any handler
442
         // make sure we catch all errors coming from any handler
430
         // otherwise we can remove the presence handler from strophe
443
         // otherwise we can remove the presence handler from strophe

+ 13
- 0
modules/xmpp/JingleSessionPC.js 查看文件

287
     });
287
     });
288
 };
288
 };
289
 
289
 
290
+/**
291
+ * Makes the underlying TraceablePeerConnection generate new SSRC for
292
+ * the recvonly video stream.
293
+ * @deprecated
294
+ */
295
+JingleSessionPC.prototype.generateRecvonlySsrc = function() {
296
+    if (this.peerconnection) {
297
+        this.peerconnection.generateRecvonlySsrc();
298
+    } else {
299
+        logger.error("Unable to generate recvonly SSRC - no peerconnection");
300
+    }
301
+};
302
+
290
 /**
303
 /**
291
  * Does accept incoming Jingle 'session-initiate' and should send
304
  * Does accept incoming Jingle 'session-initiate' and should send
292
  * 'session-accept' in result.
305
  * 'session-accept' in result.

+ 19
- 15
modules/xmpp/SdpConsistency.js 查看文件

115
      */
115
      */
116
     makeVideoPrimarySsrcsConsistent (sdpStr) {
116
     makeVideoPrimarySsrcsConsistent (sdpStr) {
117
         let parsedSdp = transform.parse(sdpStr);
117
         let parsedSdp = transform.parse(sdpStr);
118
-        let videoMLine = 
118
+        let videoMLine =
119
             parsedSdp.media.find(mLine => mLine.type === "video");
119
             parsedSdp.media.find(mLine => mLine.type === "video");
120
         if (videoMLine.direction === "inactive") {
120
         if (videoMLine.direction === "inactive") {
121
             console.log("Sdp-consistency doing nothing, " +
121
             console.log("Sdp-consistency doing nothing, " +
126
             // If the mline is recvonly, we'll add the primary
126
             // If the mline is recvonly, we'll add the primary
127
             //  ssrc as a recvonly ssrc
127
             //  ssrc as a recvonly ssrc
128
             videoMLine.ssrcs = videoMLine.ssrcs || [];
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
         } else {
138
         } else {
135
             let newPrimarySsrc = getPrimarySsrc(videoMLine);
139
             let newPrimarySsrc = getPrimarySsrc(videoMLine);
136
             if (!newPrimarySsrc) {
140
             if (!newPrimarySsrc) {
137
                 console.log("Sdp-consistency couldn't parse new primary ssrc");
141
                 console.log("Sdp-consistency couldn't parse new primary ssrc");
138
                 return sdpStr;
142
                 return sdpStr;
139
             }
143
             }
140
-            let newPrimaryRtxSsrc = 
144
+            let newPrimaryRtxSsrc =
141
                 getRtxSsrc(videoMLine, newPrimarySsrc);
145
                 getRtxSsrc(videoMLine, newPrimarySsrc);
142
             if (!this.cachedPrimarySsrc) {
146
             if (!this.cachedPrimarySsrc) {
143
                 this.cachedPrimarySsrc = newPrimarySsrc;
147
                 this.cachedPrimarySsrc = newPrimarySsrc;
144
                 this.cachedPrimaryRtxSsrc = newPrimaryRtxSsrc;
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
                     this.cachedPrimaryRtxSsrc);
151
                     this.cachedPrimaryRtxSsrc);
148
             } else {
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
                     this.cachedPrimaryRtxSsrc);
156
                     this.cachedPrimaryRtxSsrc);
153
                 let self = this;
157
                 let self = this;
154
                 videoMLine.ssrcs.forEach(ssrcInfo => {
158
                 videoMLine.ssrcs.forEach(ssrcInfo => {
161
                 if (videoMLine.ssrcGroups) {
165
                 if (videoMLine.ssrcGroups) {
162
                     videoMLine.ssrcGroups.forEach(group => {
166
                     videoMLine.ssrcGroups.forEach(group => {
163
                         if (group.semantics === "FID") {
167
                         if (group.semantics === "FID") {
164
-                            let primarySsrc = 
168
+                            let primarySsrc =
165
                                 parseInt(group.ssrcs.split(" ")[0]);
169
                                 parseInt(group.ssrcs.split(" ")[0]);
166
                             if (primarySsrc == self.cachedPrimarySsrc) {
170
                             if (primarySsrc == self.cachedPrimarySsrc) {
167
-                                group.ssrcs = 
168
-                                    self.cachedPrimarySsrc + " " + 
171
+                                group.ssrcs =
172
+                                    self.cachedPrimarySsrc + " " +
169
                                         self.cachedPrimaryRtxSsrc;
173
                                         self.cachedPrimaryRtxSsrc;
170
                             }
174
                             }
171
                         }
175
                         }

+ 12
- 0
modules/xmpp/TraceablePeerConnection.js 查看文件

396
      */
396
      */
397
 };
397
 };
398
 
398
 
399
+/**
400
+ * Makes the underlying TraceablePeerConnection generate new SSRC for
401
+ * the recvonly video stream.
402
+ * @deprecated
403
+ */
404
+TraceablePeerConnection.prototype.generateRecvonlySsrc = function() {
405
+    // FIXME replace with SDPUtil.generateSsrc (when it's added)
406
+    const newSSRC = this.generateNewStreamSSRCInfo().ssrcs[0];
407
+    logger.info("Generated new recvonly SSRC: " + newSSRC);
408
+    this.sdpConsistency.setPrimarySsrc(newSSRC);
409
+};
410
+
399
 TraceablePeerConnection.prototype.close = function () {
411
 TraceablePeerConnection.prototype.close = function () {
400
     this.trace('stop');
412
     this.trace('stop');
401
     if (this.statsinterval !== null) {
413
     if (this.statsinterval !== null) {

Loading…
取消
儲存