Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('still works', () => {
const input = new RTCSessionDescription({ type: 'offer', sdp: validSdp2 });
const output = workaround(input).sdp;
assert(!output.match(/\r\n\r\n/));
});
});
before(async () => {
const constraints = { audio: true, video: true };
stream = await makeStream(constraints);
pc1 = new RTCPeerConnection({ iceServers: [] });
pc1.addStream(stream);
pc2 = new RTCPeerConnection({ iceServers: [] });
pc2.addStream(stream);
trackIdsToAttributes = new Map();
const offerOptions = { offerToReceiveAudio: true, offerToReceiveVideo: true };
const offer = await pc1.createOffer(offerOptions);
offer1 = createSdp === 'createOffer' ? new RTCSessionDescription({
type: offer.type,
sdp: setSimulcast(offer.sdp, sdpFormat, trackIdsToAttributes)
}) : offer;
await pc1.setLocalDescription(offer1);
await pc2.setRemoteDescription(offer1);
const answer = await pc2.createAnswer();
answer1 = createSdp === 'createAnswer' ? new RTCSessionDescription({
type: answer.type,
sdp: setSimulcast(answer.sdp, sdpFormat, trackIdsToAttributes)
}) : answer;
await pc2.setLocalDescription(answer1);
await pc1.setRemoteDescription(answer1);
const _offer = await pc1.createOffer(offerOptions);
pc1.addStream(stream);
trackIdsToAttributes = new Map();
const offerOptions = { offerToReceiveAudio: true, offerToReceiveVideo: true };
const offer = await pc1.createOffer(offerOptions);
offer1 = new RTCSessionDescription({
type: offer.type,
sdp: setSimulcast(offer.sdp, sdpFormat, trackIdsToAttributes)
});
await pc1.setLocalDescription(offer1);
assert.equal(pc1.signalingState, 'have-local-offer');
const _offer = await pc1.createOffer(offerOptions);
offer2 = new RTCSessionDescription({
type: _offer.type,
sdp: setSimulcast(_offer.sdp, sdpFormat, trackIdsToAttributes)
});
});
before(async () => {
const constraints = { audio: true, video: true };
stream = await makeStream(constraints);
pc1 = new RTCPeerConnection({ iceServers: [] });
pc1.addStream(stream);
trackIdsToAttributes = new Map();
const offerOptions = { offerToReceiveAudio: true, offerToReceiveVideo: true };
const offer = await pc1.createOffer(offerOptions);
offer1 = new RTCSessionDescription({
type: offer.type,
sdp: setSimulcast(offer.sdp, sdpFormat, trackIdsToAttributes)
});
await pc1.setLocalDescription(offer1);
assert.equal(pc1.signalingState, 'have-local-offer');
const _offer = await pc1.createOffer(offerOptions);
offer2 = new RTCSessionDescription({
type: _offer.type,
sdp: setSimulcast(_offer.sdp, sdpFormat, trackIdsToAttributes)
});
});
}) : offer;
await pc1.setLocalDescription(offer1);
await pc2.setRemoteDescription(offer1);
const answer = await pc2.createAnswer();
answer1 = createSdp === 'createAnswer' ? new RTCSessionDescription({
type: answer.type,
sdp: setSimulcast(answer.sdp, sdpFormat, trackIdsToAttributes)
}) : answer;
await pc2.setLocalDescription(answer1);
await pc1.setRemoteDescription(answer1);
const _offer = await pc1.createOffer(offerOptions);
offer2 = createSdp === 'createOffer' ? new RTCSessionDescription({
type: _offer.type,
sdp: setSimulcast(_offer.sdp, sdpFormat, trackIdsToAttributes)
}) : _offer;
await pc2.setRemoteDescription(offer2);
answer2 = await pc2.createAnswer();
});
pc2.addStream(stream);
trackIdsToAttributes = new Map();
const offerOptions = { offerToReceiveAudio: true, offerToReceiveVideo: true };
const offer = await pc1.createOffer(offerOptions);
offer1 = createSdp === 'createOffer' ? new RTCSessionDescription({
type: offer.type,
sdp: setSimulcast(offer.sdp, sdpFormat, trackIdsToAttributes)
}) : offer;
await pc1.setLocalDescription(offer1);
await pc2.setRemoteDescription(offer1);
const answer = await pc2.createAnswer();
answer1 = createSdp === 'createAnswer' ? new RTCSessionDescription({
type: answer.type,
sdp: setSimulcast(answer.sdp, sdpFormat, trackIdsToAttributes)
}) : answer;
await pc2.setLocalDescription(answer1);
await pc1.setRemoteDescription(answer1);
const _offer = await pc1.createOffer(offerOptions);
offer2 = createSdp === 'createOffer' ? new RTCSessionDescription({
type: _offer.type,
sdp: setSimulcast(_offer.sdp, sdpFormat, trackIdsToAttributes)
}) : _offer;
await pc2.setRemoteDescription(offer2);
answer2 = await pc2.createAnswer();
});
['RTCSessionDescription', descriptionInit => new RTCSessionDescription(descriptionInit)],
['RTCSessionDescriptionInit', descriptionInit => descriptionInit]
function workaround(description) {
const descriptionInit = { type: description.type };
if (description.type !== 'rollback') {
descriptionInit.sdp = sdpWorkaround(description.sdp);
}
return new RTCSessionDescription(descriptionInit);
}