Browse Source

optional args

Michelle Bu 11 years ago
parent
commit
6c15549091
3 changed files with 22 additions and 12 deletions
  1. 12 7
      dist/peer.js
  2. 0 0
      dist/peer.min.js
  3. 10 5
      lib/negotiator.js

+ 12 - 7
dist/peer.js

@@ -1164,8 +1164,8 @@ var util = {
             util.supports.onnegotiationneeded = true;
           }
         };
-        // FIXME: this is not great because it doesn't work for audio-only
-        // browsers (?).
+        // FIXME: this is not great because in theory it doesn't work for
+        // av-only browsers (?).
         var dc = pc.createDataChannel('_PEERJSRELIABLETEST');
 
         pc.close();
@@ -2050,11 +2050,16 @@ Negotiator._startPeerConnection = function(connection) {
   util.log('Creating RTCPeerConnection.');
 
   var id = Negotiator._idPrefix + util.randomToken();
-  pc = new RTCPeerConnection(connection.provider.options.config, {
-    optional: [{
-      RtpDataChannels: true
-    }]
-  });
+  var optional = {};
+
+  if (connection.type === 'data' && !util.supports.reliable) {
+    optional = {optional: [{RtpDataChannels: true}]};
+  } else if (connection.type === 'media') {
+    // Interop req for chrome.
+    optional = {optional: [{DtlsSrtpKeyAgreement: true}]};
+  }
+
+  pc = new RTCPeerConnection(connection.provider.options.config, optional);
   Negotiator.pcs[connection.type][connection.peer][id] = pc;
 
   Negotiator._setupListeners(connection, pc, id);

File diff suppressed because it is too large
+ 0 - 0
dist/peer.min.js


+ 10 - 5
lib/negotiator.js

@@ -88,11 +88,16 @@ Negotiator._startPeerConnection = function(connection) {
   util.log('Creating RTCPeerConnection.');
 
   var id = Negotiator._idPrefix + util.randomToken();
-  pc = new RTCPeerConnection(connection.provider.options.config, {
-    optional: [{
-      RtpDataChannels: true
-    }]
-  });
+  var optional = {};
+
+  if (connection.type === 'data' && !util.supports.reliable) {
+    optional = {optional: [{RtpDataChannels: true}]};
+  } else if (connection.type === 'media') {
+    // Interop req for chrome.
+    optional = {optional: [{DtlsSrtpKeyAgreement: true}]};
+  }
+
+  pc = new RTCPeerConnection(connection.provider.options.config, optional);
   Negotiator.pcs[connection.type][connection.peer][id] = pc;
 
   Negotiator._setupListeners(connection, pc, id);

Some files were not shown because too many files changed in this diff