Browse Source

colibri.js: dont add ssrcs for mixed audio

master
Philipp Hancke 11 years ago
parent
commit
668219e5ff
1 changed files with 26 additions and 14 deletions
  1. 26
    14
      libs/colibri.js

+ 26
- 14
libs/colibri.js View File

293
             sdp.removeMediaLines(i, 'a=fingerprint:');
293
             sdp.removeMediaLines(i, 'a=fingerprint:');
294
             sdp.removeMediaLines(i, 'a=setup:');
294
             sdp.removeMediaLines(i, 'a=setup:');
295
 
295
 
296
-            // re-add all remote a=ssrcs
297
-            for (var jid in this.remotessrc) {
298
-                if (jid == peer) continue;
299
-                sdp.media[i] += this.remotessrc[jid][i];
296
+            if (i > 0) { // not for audio
297
+                // re-add all remote a=ssrcs
298
+                for (var jid in this.remotessrc) {
299
+                    if (jid == peer) continue;
300
+                    sdp.media[i] += this.remotessrc[jid][i];
301
+                }
302
+                // and local a=ssrc lines
303
+                sdp.media[i] += SDPUtil.find_lines(localSDP.media[i], 'a=ssrc').join('\r\n') + '\r\n';
300
             }
304
             }
301
-            // and local a=ssrc lines
302
-            sdp.media[i] += SDPUtil.find_lines(localSDP.media[i], 'a=ssrc').join('\r\n') + '\r\n';
303
         }
305
         }
304
         sdp.raw = sdp.session + sdp.media.join('');
306
         sdp.raw = sdp.session + sdp.media.join('');
305
     } else {
307
     } else {
513
                 sid: peersess.sid
515
                 sid: peersess.sid
514
             }
516
             }
515
         );
517
         );
518
+        // FIXME: only announce video ssrcs since we mix audio and dont need 
519
+        //      the audio ssrcs therefore
520
+        var modified = false;
516
         for (channel = 0; channel < sdp.media.length; channel++) {
521
         for (channel = 0; channel < sdp.media.length; channel++) {
522
+            modified = true;
517
             tmp = SDPUtil.find_lines(sdp.media[channel], 'a=ssrc:');
523
             tmp = SDPUtil.find_lines(sdp.media[channel], 'a=ssrc:');
518
             modify.c('content', {name: SDPUtil.parse_mid(SDPUtil.find_line(sdp.media[channel], 'a=mid:'))});
524
             modify.c('content', {name: SDPUtil.parse_mid(SDPUtil.find_line(sdp.media[channel], 'a=mid:'))});
519
             modify.c('source', { xmlns: 'urn:xmpp:jingle:apps:rtp:ssma:0' });
525
             modify.c('source', { xmlns: 'urn:xmpp:jingle:apps:rtp:ssma:0' });
536
             modify.up(); // end of source
542
             modify.up(); // end of source
537
             modify.up(); // end of content
543
             modify.up(); // end of content
538
         }
544
         }
539
-        ob.connection.sendIQ(modify,
540
-            function (res) {
541
-                console.warn('got modify result');
542
-            },
543
-            function (err) {
544
-                console.warn('got modify error');
545
-            }
546
-        );
545
+        if (modified) {
546
+            ob.connection.sendIQ(modify,
547
+                function (res) {
548
+                    console.warn('got modify result');
549
+                },
550
+                function (err) {
551
+                    console.warn('got modify error');
552
+                }
553
+            );
554
+        } else {
555
+            console.log('modification not necessary');
556
+        }
547
     });
557
     });
548
 };
558
 };
549
 
559
 
565
     // ACT 3: note the SSRCs
575
     // ACT 3: note the SSRCs
566
     this.remotessrc[session.peerjid] = [];
576
     this.remotessrc[session.peerjid] = [];
567
     for (channel = 0; channel < this.channels[participant].length; channel++) {
577
     for (channel = 0; channel < this.channels[participant].length; channel++) {
578
+        if (channel == 0) continue;
568
         this.remotessrc[session.peerjid][channel] = SDPUtil.find_lines(remoteSDP.media[channel], 'a=ssrc:').join('\r\n') + '\r\n';
579
         this.remotessrc[session.peerjid][channel] = SDPUtil.find_lines(remoteSDP.media[channel], 'a=ssrc:').join('\r\n') + '\r\n';
569
     }
580
     }
570
 
581
 
571
     // ACT 4: add new a=ssrc lines to local remotedescription
582
     // ACT 4: add new a=ssrc lines to local remotedescription
572
     for (channel = 0; channel < this.channels[participant].length; channel++) {
583
     for (channel = 0; channel < this.channels[participant].length; channel++) {
584
+        if (channel == 0) continue;
573
         if (!this.addssrc[channel]) this.addssrc[channel] = '';
585
         if (!this.addssrc[channel]) this.addssrc[channel] = '';
574
         this.addssrc[channel] += SDPUtil.find_lines(remoteSDP.media[channel], 'a=ssrc:').join('\r\n') + '\r\n';
586
         this.addssrc[channel] += SDPUtil.find_lines(remoteSDP.media[channel], 'a=ssrc:').join('\r\n') + '\r\n';
575
     }
587
     }

Loading…
Cancel
Save