Skip to content

Commit

Permalink
trickle-ice: Display offer creation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
rhansen committed Apr 6, 2022
1 parent eb0a255 commit 2c4bbac
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions src/content/peerconnection/trickle-ice/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,32 +155,28 @@ async function start() {
// Whether we only gather a single set of candidates for RTP and RTCP.

console.log(`Creating new PeerConnection with config=${JSON.stringify(config)}`);
document.getElementById('error').innerText = '';
pc = new RTCPeerConnection(config);
pc.onicecandidate = iceCallback;
pc.onicegatheringstatechange = gatheringStateChange;
pc.onicecandidateerror = iceCandidateError;
if (stream) {
stream.getTracks().forEach(track => pc.addTrack(track, stream));
const errDiv = document.getElementById('error');
errDiv.innerText = '';
let desc;
try {
pc = new RTCPeerConnection(config);
pc.onicecandidate = iceCallback;
pc.onicegatheringstatechange = gatheringStateChange;
pc.onicecandidateerror = iceCandidateError;
if (stream) {
stream.getTracks().forEach(track => pc.addTrack(track, stream));
}
desc = await pc.createOffer(offerOptions);
} catch (err) {
errDiv.innerText = `Error creating offer: ${err}`;
gatherButton.disabled = false;
return;
}
pc.createOffer(
offerOptions
).then(
gotDescription,
noDescription
);
}

function gotDescription(desc) {
begin = window.performance.now();
candidates = [];
pc.setLocalDescription(desc);
}

function noDescription(error) {
console.log('Error creating offer: ', error);
}

// Parse the uint32 PRIORITY field into its constituent parts from RFC 5245,
// type preference, local preference, and (256 - component ID).
// ex: 126 | 32252 | 255 (126 is host preference, 255 is component ID 1)
Expand Down

0 comments on commit 2c4bbac

Please sign in to comment.