Browse Source

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 years ago
parent
commit
5652becace

+ 7
- 2
JitsiConference.js View File

@@ -2,6 +2,7 @@
2 2
 
3 3
 var logger = require("jitsi-meet-logger").getLogger(__filename);
4 4
 import RTC from "./modules/RTC/RTC";
5
+import * as MediaType from "./service/RTC/MediaType";
5 6
 var XMPPEvents = require("./service/xmpp/XMPPEvents");
6 7
 var EventEmitter = require("events");
7 8
 import * as JitsiConferenceErrors from "./JitsiConferenceErrors";
@@ -246,7 +247,7 @@ JitsiConference.prototype.getExternalAuthUrl = function (urlForPopup) {
246 247
 /**
247 248
  * Returns the local tracks of the given media type, or all local tracks if no
248 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 252
 JitsiConference.prototype.getLocalTracks = function (mediaType) {
252 253
     let tracks = [];
@@ -883,7 +884,7 @@ function (jingleSession, jingleOffer, now) {
883 884
     this.rtc.localTracks.forEach(function(localTrack) {
884 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 888
          *  stream in the peer connection and just set 'enabled' on the
888 889
          *  track to false (see JitsiLocalTrack::_setMute).  This means
889 890
          *  that if we generated an ssrc here and set it in the cache, it
@@ -926,6 +927,10 @@ function (jingleSession, jingleOffer, now) {
926 927
             logger.error(e);
927 928
         }
928 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 935
     jingleSession.acceptOffer(jingleOffer, null,
931 936
         function (error) {

+ 13
- 0
modules/xmpp/ChatRoom.js View File

@@ -425,6 +425,19 @@ export default class ChatRoom extends Listenable {
425 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 441
     processNode (node, from) {
429 442
         // make sure we catch all errors coming from any handler
430 443
         // otherwise we can remove the presence handler from strophe

+ 13
- 0
modules/xmpp/JingleSessionPC.js View File

@@ -287,6 +287,19 @@ JingleSessionPC.prototype.readSsrcInfo = function (contents) {
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 304
  * Does accept incoming Jingle 'session-initiate' and should send
292 305
  * 'session-accept' in result.

+ 19
- 15
modules/xmpp/SdpConsistency.js View File

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

+ 12
- 0
modules/xmpp/TraceablePeerConnection.js View File

@@ -396,6 +396,18 @@ TraceablePeerConnection.prototype.setRemoteDescription
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 411
 TraceablePeerConnection.prototype.close = function () {
400 412
     this.trace('stop');
401 413
     if (this.statsinterval !== null) {

Loading…
Cancel
Save