(stream, handler)
| 38 | |
| 39 | |
| 40 | function VideoPipe(stream, handler) { |
| 41 | let servers = null; |
| 42 | let pc1 = new RTCPeerConnection(servers); |
| 43 | let pc2 = new RTCPeerConnection(servers); |
| 44 | |
| 45 | pc1.addStream(stream); |
| 46 | pc1.onicecandidate = function(event) { |
| 47 | if (event.candidate) { |
| 48 | pc2.addIceCandidate(new RTCIceCandidate(event.candidate), |
| 49 | noAction, errorHandler('AddIceCandidate')); |
| 50 | } |
| 51 | }; |
| 52 | pc2.onicecandidate = function(event) { |
| 53 | if (event.candidate) { |
| 54 | pc1.addIceCandidate(new RTCIceCandidate(event.candidate), |
| 55 | noAction, errorHandler('AddIceCandidate')); |
| 56 | } |
| 57 | }; |
| 58 | pc2.onaddstream = function(e) { |
| 59 | handler(e.stream); |
| 60 | }; |
| 61 | pc1.createOffer(function(desc) { |
| 62 | pc1.setLocalDescription(desc); |
| 63 | pc2.setRemoteDescription(desc); |
| 64 | pc2.createAnswer(function(desc2) { |
| 65 | pc2.setLocalDescription(desc2); |
| 66 | pc1.setRemoteDescription(desc2); |
| 67 | }, errorHandler('pc2.createAnswer')); |
| 68 | }, errorHandler('pc1.createOffer')); |
| 69 | this.pc1 = pc1; |
| 70 | this.pc2 = pc2; |
| 71 | } |
| 72 | |
| 73 | VideoPipe.prototype.close = function() { |
| 74 | this.pc1.close(); |
nothing calls this directly
no test coverage detected