Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 6 additions & 14 deletions src/content/insertable-streams/endtoend-encryption/js/videopipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,8 @@
'use strict';

function VideoPipe(stream, forceSend, forceReceive, handler) {
this.pc1 = new RTCPeerConnection({
encodedInsertableStreams: forceSend,
});
this.pc2 = new RTCPeerConnection({
encodedInsertableStreams: forceReceive,
});
this.pc1 = new RTCPeerConnection();
this.pc2 = new RTCPeerConnection();
this.pc2.ontrack = handler;
stream.getTracks().forEach((track) => this.pc1.addTrack(track, stream));
}
Expand All @@ -36,14 +32,10 @@ VideoPipe.prototype.negotiate = async function() {
this.pc1.onicecandidate = e => this.pc2.addIceCandidate(e.candidate);
this.pc2.onicecandidate = e => this.pc1.addIceCandidate(e.candidate);

const offer = await this.pc1.createOffer();
// Disable video/red to allow for easier inspection in Wireshark.
await this.pc2.setRemoteDescription({type: 'offer', sdp: offer.sdp.replace('red/90000', 'green/90000')});
await this.pc1.setLocalDescription(offer);

const answer = await this.pc2.createAnswer();
await this.pc1.setRemoteDescription(answer);
await this.pc2.setLocalDescription(answer);
await this.pc1.setLocalDescription();
await this.pc2.setRemoteDescription(this.pc1.localDescription);
await this.pc2.setLocalDescription();
await this.pc1.setRemoteDescription(this.pc2.localDescription);
};

VideoPipe.prototype.close = function() {
Expand Down
4 changes: 1 addition & 3 deletions src/content/insertable-streams/video-analyzer/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,7 @@ async function call() {
pc1 = new RTCPeerConnection();
console.log('Created local peer connection object pc1');
pc1.addEventListener('icecandidate', e => onIceCandidate(pc1, e));
pc2 = new RTCPeerConnection({
encodedInsertableStreams: true,
});
pc2 = new RTCPeerConnection();
console.log('Created remote peer connection object pc2');
pc2.addEventListener('icecandidate', e => onIceCandidate(pc2, e));
pc1.addEventListener('iceconnectionstatechange', e => onIceStateChange(pc1, e));
Expand Down