浏览代码

partial audio-only focus support. lacks SRD/SLD cycle to trigger keyframe

master
Philipp Hancke 11 年前
父节点
当前提交
2f7b21588c
共有 2 个文件被更改,包括 23 次插入20 次删除
  1. 8
    4
      app.js
  2. 15
    16
      libs/colibri.js

+ 8
- 4
app.js 查看文件

249
     var localSDP = new SDP(sess.peerconnection.localDescription.sdp);
249
     var localSDP = new SDP(sess.peerconnection.localDescription.sdp);
250
     localSDP.media.forEach(function (media) {
250
     localSDP.media.forEach(function (media) {
251
         var type = SDPUtil.parse_mline(media.split('\r\n')[0]).media;
251
         var type = SDPUtil.parse_mline(media.split('\r\n')[0]).media;
252
-        var ssrc = SDPUtil.find_line(media, 'a=ssrc:').substring(7).split(' ')[0];
253
-        // assumes a single local ssrc
254
-        newssrcs[type] = ssrc;
252
+        if (SDPUtil.find_line(media, 'a=ssrc:')) {
253
+            var ssrc = SDPUtil.find_line(media, 'a=ssrc:').substring(7).split(' ')[0];
254
+            // assumes a single local ssrc
255
+            newssrcs[type] = ssrc;
256
+        }
255
     });
257
     });
256
     console.log('new ssrcs', newssrcs);
258
     console.log('new ssrcs', newssrcs);
257
 
259
 
260
         i++;
262
         i++;
261
         connection.emuc.addMediaToPresence(i, mtype, newssrcs[mtype]);
263
         connection.emuc.addMediaToPresence(i, mtype, newssrcs[mtype]);
262
     });
264
     });
263
-    connection.emuc.sendPresence();
265
+    if (i > 0) {
266
+        connection.emuc.sendPresence();
267
+    }
264
 });
268
 });
265
 
269
 
266
 $(document).bind('joined.muc', function (event, jid, info) {
270
 $(document).bind('joined.muc', function (event, jid, info) {

+ 15
- 16
libs/colibri.js 查看文件

42
 
42
 
43
     this.peerconnection = null;
43
     this.peerconnection = null;
44
 
44
 
45
+    // media types of the conference
46
+    this.media = ['audio', 'video'];
47
+
45
     this.sid = Math.random().toString(36).substr(2, 12);
48
     this.sid = Math.random().toString(36).substr(2, 12);
46
     this.connection.jingle.sessions[this.sid] = this;
49
     this.connection.jingle.sessions[this.sid] = this;
47
     this.mychannel = [];
50
     this.mychannel = [];
151
     elem.c('conference', {xmlns: 'http://jitsi.org/protocol/colibri'});
154
     elem.c('conference', {xmlns: 'http://jitsi.org/protocol/colibri'});
152
 
155
 
153
     var stream = this.connection.jingle.localStream;
156
     var stream = this.connection.jingle.localStream;
154
-    var types = [];
155
-    if (connection.jingle.localStream.getAudioTracks().length > 0) {
156
-        types.push('audio');
157
-    }
158
-    if (connection.jingle.localStream.getVideoTracks().length > 0) {
159
-        types.push('video');
160
-    }
161
-    types.forEach(function (name) {
157
+    this.media.forEach(function (name) {
162
         elem.c('content', {name: name});
158
         elem.c('content', {name: name});
163
         elem.c('channel', {initiator: 'true', expire: '15'}).up();
159
         elem.c('channel', {initiator: 'true', expire: '15'}).up();
164
         for (var j = 0; j < self.peers.length; j++) {
160
         for (var j = 0; j < self.peers.length; j++) {
652
     this.remotessrc[session.peerjid] = [];
648
     this.remotessrc[session.peerjid] = [];
653
     for (channel = 0; channel < this.channels[participant].length; channel++) {
649
     for (channel = 0; channel < this.channels[participant].length; channel++) {
654
         //if (channel == 0) continue; FIXME: does not work as intended
650
         //if (channel == 0) continue; FIXME: does not work as intended
655
-        this.remotessrc[session.peerjid][channel] = SDPUtil.find_lines(remoteSDP.media[channel], 'a=ssrc:').join('\r\n') + '\r\n';
651
+        if (SDPUtil.find_lines(remoteSDP.media[channel], 'a=ssrc:').length) {
652
+            this.remotessrc[session.peerjid][channel] = SDPUtil.find_lines(remoteSDP.media[channel], 'a=ssrc:').join('\r\n') + '\r\n';
653
+        }
656
     }
654
     }
657
 
655
 
658
     // ACT 4: add new a=ssrc lines to local remotedescription
656
     // ACT 4: add new a=ssrc lines to local remotedescription
659
     for (channel = 0; channel < this.channels[participant].length; channel++) {
657
     for (channel = 0; channel < this.channels[participant].length; channel++) {
660
         //if (channel == 0) continue; FIXME: does not work as intended
658
         //if (channel == 0) continue; FIXME: does not work as intended
661
         if (!this.addssrc[channel]) this.addssrc[channel] = '';
659
         if (!this.addssrc[channel]) this.addssrc[channel] = '';
662
-        this.addssrc[channel] += SDPUtil.find_lines(remoteSDP.media[channel], 'a=ssrc:').join('\r\n') + '\r\n';
660
+        if (SDPUtil.find_lines(remoteSDP.media[channel], 'a=ssrc:').length) {
661
+            this.addssrc[channel] += SDPUtil.find_lines(remoteSDP.media[channel], 'a=ssrc:').join('\r\n') + '\r\n';
662
+        }
663
     }
663
     }
664
     this.modifySources();
664
     this.modifySources();
665
 };
665
 };
843
             console.log('setModifiedRemoteDescription ok');
843
             console.log('setModifiedRemoteDescription ok');
844
             self.peerconnection.createAnswer(
844
             self.peerconnection.createAnswer(
845
                 function (modifiedAnswer) {
845
                 function (modifiedAnswer) {
846
-                    console.log('modifiedAnswer created', modifiedAnswer.sdp);
846
+                    console.log('modifiedAnswer created');
847
                     // FIXME: pushing down an answer while ice connection state 
847
                     // FIXME: pushing down an answer while ice connection state 
848
                     // is still checking is bad...
848
                     // is still checking is bad...
849
-                    console.log(self.peerconnection.iceConnectionState);
849
+                    //console.log(self.peerconnection.iceConnectionState);
850
 
850
 
851
                     // trying to work around another chrome bug
851
                     // trying to work around another chrome bug
852
                     //modifiedAnswer.sdp = modifiedAnswer.sdp.replace(/a=setup:active/g, 'a=setup:actpass');
852
                     //modifiedAnswer.sdp = modifiedAnswer.sdp.replace(/a=setup:active/g, 'a=setup:actpass');
856
                             $(document).trigger('setLocalDescription.jingle', [self.sid]);
856
                             $(document).trigger('setLocalDescription.jingle', [self.sid]);
857
                         },
857
                         },
858
                         function (error) {
858
                         function (error) {
859
-                            console.log('setModifiedLocalDescription failed');
859
+                            console.log('setModifiedLocalDescription failed', error);
860
                         }
860
                         }
861
                     );
861
                     );
862
                 },
862
                 },
863
                 function (error) {
863
                 function (error) {
864
-                    console.log('createModifiedAnswer failed');
864
+                    console.log('createModifiedAnswer failed', error);
865
                 }
865
                 }
866
             );
866
             );
867
         },
867
         },
868
         function (error) {
868
         function (error) {
869
-            console.log('setModifiedRemoteDescription failed');
869
+            console.log('setModifiedRemoteDescription failed', error);
870
         }
870
         }
871
     );
871
     );
872
     /*
872
     /*
900
     */
900
     */
901
 };
901
 };
902
 
902
 
903
-
904
 // A colibri session is similar to a jingle session, it just implements some things differently
903
 // A colibri session is similar to a jingle session, it just implements some things differently
905
 // FIXME: inherit jinglesession, see https://github.com/legastero/Jingle-RTCPeerConnection/blob/master/index.js
904
 // FIXME: inherit jinglesession, see https://github.com/legastero/Jingle-RTCPeerConnection/blob/master/index.js
906
 function ColibriSession(me, sid, connection) {
905
 function ColibriSession(me, sid, connection) {

正在加载...
取消
保存