Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'sdp' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.
t.pass('answer ready to signal');
// this was fixed into Chrome 51 with https://bugs.chromium.org/p/chromium/issues/detail?id=591971
if (answerWithCandidates.sdp.indexOf('a=rtpmap:126 H264') !== -1 &&
answerWithCandidates.sdp.indexOf('a=fmtp:126') === -1) {
var sections = SDPUtils.splitSections(answerWithCandidates.sdp);
var lines = SDPUtils.splitLines(sections[2]);
var idx = lines.indexOf('a=rtpmap:126 H264/90000');
lines.splice(idx + 1, 0, 'a=fmtp:126 profile-level-id=42e01f;level-asymmetry-allowed=1;packetization-mode=1');
sections[2] = lines.join('\r\n');
answerWithCandidates.sdp = sections.join('') + '\r\n';
}
if (preferredVideoCodec) {
var sections = SDPUtils.splitSections(answerWithCandidates.sdp);
var codecs = SDPUtils.parseRtpParameters(sections[2]).codecs;
t.ok(codecs[0].name === preferredVideoCodec, 'preferredVideoCodec is used');
}
return clientA.setRemoteDescription(answerWithCandidates);
})
.then(() => // wait for the iceConnectionState to become either connected/completed
function splitSimulcast(sdp) {
const sections = SDPUtils.splitSections(sdp);
const candidates = SDPUtils.matchPrefix(sections[1], 'a=candidate:');
const dtls = SDPUtils.getDtlsParameters(sections[1], sections[0]);
const ice = SDPUtils.getIceParameters(sections[1], sections[0]);
const rtpParameters = SDPUtils.parseRtpParameters(sections[1]);
// unified plan things.
rtpParameters.headerExtensions = rtpParameters.headerExtensions.filter(ext => {
return ext.uri !== 'urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id' &&
ext.uri !== 'urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id' &&
ext.uri !== 'urn:ietf:params:rtp-hdrext:sdes:mid';
});
sdp = 'v=0\r\n' +
'o=mozilla...THIS_IS_SDPARTA-61.0 8324701712193024513 0 IN IP4 0.0.0.0\r\n' +
's=-\r\n' +
't=0 0\r\n' +
'a=fingerprint:' + dtls.fingerprints[0].algorithm + ' ' + dtls.fingerprints[0].value + '\r\n' +
'a=ice-ufrag:' + ice.usernameFragment + '\r\n' +
'a=ice-pwd:' + ice.password + '\r\n' +
'a=group:BUNDLE 0 1\r\n' +
'a=msid-semantic:WMS *\r\n';
function splitSimulcast(sdp) {
const sections = SDPUtils.splitSections(sdp);
const candidates = SDPUtils.matchPrefix(sections[1], 'a=candidate:');
const dtls = SDPUtils.getDtlsParameters(sections[1], sections[0]);
const ice = SDPUtils.getIceParameters(sections[1], sections[0]);
const rtpParameters = SDPUtils.parseRtpParameters(sections[1]);
// unified plan things.
rtpParameters.headerExtensions = rtpParameters.headerExtensions.filter(ext => {
return ext.uri !== 'urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id' &&
ext.uri !== 'urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id' &&
ext.uri !== 'urn:ietf:params:rtp-hdrext:sdes:mid';
});
sdp = 'v=0\r\n' +
'o=mozilla...THIS_IS_SDPARTA-61.0 8324701712193024513 0 IN IP4 0.0.0.0\r\n' +
's=-\r\n' +
't=0 0\r\n' +
'a=fingerprint:' + dtls.fingerprints[0].algorithm + ' ' + dtls.fingerprints[0].value + '\r\n' +
'a=ice-ufrag:' + ice.usernameFragment + '\r\n' +
'a=ice-pwd:' + ice.password + '\r\n' +
.then(answerWithCandidates => {
t.pass('answer ready to signal');
// this was fixed into Chrome 51 with https://bugs.chromium.org/p/chromium/issues/detail?id=591971
if (answerWithCandidates.sdp.indexOf('a=rtpmap:126 H264') !== -1 &&
answerWithCandidates.sdp.indexOf('a=fmtp:126') === -1) {
var sections = SDPUtils.splitSections(answerWithCandidates.sdp);
var lines = SDPUtils.splitLines(sections[2]);
var idx = lines.indexOf('a=rtpmap:126 H264/90000');
lines.splice(idx + 1, 0, 'a=fmtp:126 profile-level-id=42e01f;level-asymmetry-allowed=1;packetization-mode=1');
sections[2] = lines.join('\r\n');
answerWithCandidates.sdp = sections.join('') + '\r\n';
}
if (preferredVideoCodec) {
var sections = SDPUtils.splitSections(answerWithCandidates.sdp);
var codecs = SDPUtils.parseRtpParameters(sections[2]).codecs;
t.ok(codecs[0].name === preferredVideoCodec, 'preferredVideoCodec is used');
}
return clientA.setRemoteDescription(answerWithCandidates);
})
.then(() => // wait for the iceConnectionState to become either connected/completed
function(description) {
var self = this;
var stream = new MediaStream();
var receiverList = [];
var sections = SDPUtils.splitSections(description.sdp);
var sessionpart = sections.shift();
var isIceLite = SDPUtils.matchPrefix(sessionpart,
'a=ice-lite').length > 0;
this.usingBundle = SDPUtils.matchPrefix(sessionpart,
'a=group:BUNDLE ').length > 0;
sections.forEach(function(mediaSection, sdpMLineIndex) {
var lines = SDPUtils.splitLines(mediaSection);
var mline = lines[0].substr(2).split(' ');
var kind = mline[0];
var rejected = mline[1] === '0';
var direction = SDPUtils.getDirection(mediaSection, sessionpart);
var mid = SDPUtils.matchPrefix(mediaSection, 'a=mid:');
if (mid.length) {
mid = mid[0].substr(6);
} else {
mid = SDPUtils.generateIdentifier();
}
// Reject datachannels which are not implemented yet.
sections.forEach(function(mediaSection, sdpMLineIndex) {
var transceiver = self.transceivers[sdpMLineIndex];
var iceGatherer = transceiver.iceGatherer;
var iceTransport = transceiver.iceTransport;
var dtlsTransport = transceiver.dtlsTransport;
var localCapabilities = transceiver.localCapabilities;
var remoteCapabilities = transceiver.remoteCapabilities;
var rejected = mediaSection.split('\n', 1)[0]
.split(' ', 2)[1] === '0';
if (!rejected && !transceiver.isDatachannel) {
var remoteIceParameters = SDPUtils.getIceParameters(
mediaSection, sessionpart);
if (isIceLite) {
var cands = SDPUtils.matchPrefix(mediaSection, 'a=candidate:')
.map(function(cand) {
return SDPUtils.parseCandidate(cand);
})
.filter(function(cand) {
return cand.component === '1';
});
// ice-lite only includes host candidates in the SDP so we can
// use setRemoteCandidates (which implies an
// RTCIceCandidateComplete)
if (cands.length) {
iceTransport.setRemoteCandidates(cands);
}
}
sections.forEach(function(mediaSection, sdpMLineIndex) {
var transceiver = self.transceivers[sdpMLineIndex];
var iceGatherer = transceiver.iceGatherer;
var iceTransport = transceiver.iceTransport;
var dtlsTransport = transceiver.dtlsTransport;
var localCapabilities = transceiver.localCapabilities;
var remoteCapabilities = transceiver.remoteCapabilities;
var rejected = mediaSection.split('\n', 1)[0]
.split(' ', 2)[1] === '0';
if (!rejected && !transceiver.isDatachannel) {
var remoteIceParameters = SDPUtils.getIceParameters(
mediaSection, sessionpart);
if (isIceLite) {
var cands = SDPUtils.matchPrefix(mediaSection, 'a=candidate:')
.map(function(cand) {
return SDPUtils.parseCandidate(cand);
})
.filter(function(cand) {
return cand.component === '1';
});
// ice-lite only includes host candidates in the SDP so we can
// use setRemoteCandidates (which implies an
// RTCIceCandidateComplete)
if (cands.length) {
iceTransport.setRemoteCandidates(cands);
}
}
sections.forEach(function(mediaSection, sdpMLineIndex) {
var lines = SDPUtils.splitLines(mediaSection);
var mline = lines[0].substr(2).split(' ');
var kind = mline[0];
var rejected = mline[1] === '0';
var direction = SDPUtils.getDirection(mediaSection, sessionpart);
var remoteMsid = SDPUtils.parseMsid(mediaSection);
var mid = SDPUtils.matchPrefix(mediaSection, 'a=mid:');
if (mid.length) {
mid = mid[0].substr(6);
} else {
mid = SDPUtils.generateIdentifier();
}
// Reject datachannels which are not implemented yet.
if (kind === 'application' && mline[2] === 'DTLS/SCTP') {
self.transceivers[sdpMLineIndex] = {
mid: mid,
isDatachannel: true
};
return;
}
var transceiver;
var iceGatherer;
var iceTransport;
var dtlsTransport;
var rtpSender;
sections.forEach(function(mediaSection, sdpMLineIndex) {
var lines = SDPUtils.splitLines(mediaSection);
var mline = lines[0].substr(2).split(' ');
var kind = mline[0];
var rejected = mline[1] === '0';
var direction = SDPUtils.getDirection(mediaSection, sessionpart);
var mid = SDPUtils.matchPrefix(mediaSection, 'a=mid:');
if (mid.length) {
mid = mid[0].substr(6);
} else {
mid = SDPUtils.generateIdentifier();
}
// Reject datachannels which are not implemented yet.
if (kind === 'application' && mline[2] === 'DTLS/SCTP') {
self.transceivers[sdpMLineIndex] = {
mid: mid,
isDatachannel: true
};
return;
}
var transceiver;
var iceGatherer;
var iceTransport;
var dtlsTransport;
var rtpSender;
sections.forEach(function(mediaSection, sdpMLineIndex) {
var lines = SDPUtils.splitLines(mediaSection);
var mline = lines[0].substr(2).split(' ');
var kind = mline[0];
var rejected = mline[1] === '0';
var direction = SDPUtils.getDirection(mediaSection, sessionpart);
var remoteMsid = SDPUtils.parseMsid(mediaSection);
var mid = SDPUtils.matchPrefix(mediaSection, 'a=mid:');
if (mid.length) {
mid = mid[0].substr(6);
} else {
mid = SDPUtils.generateIdentifier();
}
// Reject datachannels which are not implemented yet.
if (kind === 'application' && mline[2] === 'DTLS/SCTP') {
self.transceivers[sdpMLineIndex] = {
mid: mid,
isDatachannel: true
};
return;
}
var transceiver;
var iceGatherer;
var iceTransport;
var dtlsTransport;
var rtpSender;