Bladeren bron

fix one more usage of deprecated addStream method

akotynski 6 jaren geleden
bovenliggende
commit
9e2fdda0c9
3 gewijzigde bestanden met toevoegingen van 12 en 9 verwijderingen
  1. 0 0
      dist/peerjs.min.js
  2. 0 0
      dist/peerjs.min.map
  3. 12 9
      lib/negotiator.ts

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


File diff suppressed because it is too large
+ 0 - 0
dist/peerjs.min.map


+ 12 - 9
lib/negotiator.ts

@@ -27,14 +27,7 @@ Negotiator.startConnection = function(connection, options) {
   connection.pc = connection.peerConnection = pc;
 
   if (connection.type === "media" && options._stream) {
-    // Add the stream.
-    if ('addStream' in pc) {
-      pc.addStream(options._stream);
-    } else if ('addTrack' in pc) {
-      options._stream.getTracks().forEach(track => {
-        pc.addTrack(track, options._stream);
-      });
-    }
+    addStreamToConnection(options._stream, pc);
   }
 
   // What do we need to do now?
@@ -198,7 +191,7 @@ Negotiator._setupListeners = function(connection, pc, pc_id) {
     var stream = evt.streams[0];
     var connection = provider.getConnection(peerId, connectionId);
     if (connection.type === "media") {
-      connection.addStream(stream);
+      addStreamToConnection(stream, connection);
     }
   };
 };
@@ -347,3 +340,13 @@ Negotiator.handleCandidate = function(connection, ice) {
   );
   util.log("Added ICE candidate for:", connection.peer);
 };
+
+function addStreamToConnection(stream: MediaStream, connection: RTCPeerConnection) {
+  if ('addTrack' in connection) {
+    stream.getTracks().forEach(track => {
+      connection.addTrack(track, stream);
+    });
+  } else if ('addStream' in connection) {
+    (<any>connection).addStream(stream);
+  }
+}

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