MCPcopy
hub / github.com/webrtc/samples / VideoPipe

Function VideoPipe

src/js/videopipe.js:40–71  ·  view source on GitHub ↗
(stream, handler)

Source from the content-addressed store, hash-verified

38
39
40function 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
73VideoPipe.prototype.close = function() {
74 this.pc1.close();

Callers

nothing calls this directly

Calls 5

errorHandlerFunction · 0.85
createOfferMethod · 0.80
setLocalDescriptionMethod · 0.80
setRemoteDescriptionMethod · 0.80
createAnswerMethod · 0.80

Tested by

no test coverage detected