Skip to content

Commit

Permalink
Fix PR-answer sample (#1347)
Browse files Browse the repository at this point in the history
* Add tracks to stream

* add missing semi-colon
  • Loading branch information
KaptenJansson authored Aug 26, 2020
1 parent 694ee29 commit 5033b81
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/content/peerconnection/pr-answer/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ hangUpButton.disabled = true;

let pc1 = null;
let pc2 = null;
let localstream;
let localStream;
const remoteStream = new MediaStream();

const offerOptions = {
offerToReceiveAudio: 1,
offerToReceiveVideo: 1
Expand All @@ -33,7 +35,7 @@ const offerOptions = {
function gotStream(stream) {
console.log('Received local stream');
vid1.srcObject = stream;
localstream = stream;
localStream = stream;
callButton.disabled = false;
}

Expand All @@ -50,8 +52,8 @@ function start() {
acceptButton.disabled = false;
hangUpButton.disabled = false;
console.log('Starting Call');
const videoTracks = localstream.getVideoTracks();
const audioTracks = localstream.getAudioTracks();
const videoTracks = localStream.getVideoTracks();
const audioTracks = localStream.getAudioTracks();
if (videoTracks.length > 0) {
console.log(`Using Video device: ${videoTracks[0].label}`);
}
Expand All @@ -68,7 +70,7 @@ function start() {
pc2.onicecandidate = e => onIceCandidate(pc2, e);
pc2.ontrack = gotRemoteStream;

localstream.getTracks().forEach(track => pc1.addTrack(track, localstream));
localStream.getTracks().forEach(track => pc1.addTrack(track, localStream));
console.log('Adding Local Stream to peer connection');

pc1.createOffer(offerOptions).then(gotDescription1, onCreateSessionDescriptionError);
Expand Down Expand Up @@ -142,10 +144,8 @@ function stop() {
}

function gotRemoteStream(e) {
if (vid2.srcObject !== e.streams[0]) {
vid2.srcObject = e.streams[0];
console.log('Received remote stream');
}
vid2.srcObject = remoteStream;
remoteStream.addTrack(e.track, remoteStream);
}

function getOtherPc(pc) {
Expand Down

0 comments on commit 5033b81

Please sign in to comment.