webrtc-adapter
Advanced tools
Comparing version 3.3.2 to 3.3.3
{ | ||
"name": "webrtc-adapter", | ||
"version": "3.3.2", | ||
"version": "3.3.3", | ||
"description": "A shim to insulate apps from WebRTC spec changes and browser prefix differences", | ||
@@ -22,3 +22,3 @@ "license": "BSD-3-Clause", | ||
"dependencies": { | ||
"sdp": "^1.4.0" | ||
"sdp": "^1.5.0" | ||
}, | ||
@@ -25,0 +25,0 @@ "engines": { |
@@ -512,4 +512,3 @@ /* | ||
var rejected = mediaSection.split('\n', 1)[0] | ||
.split(' ', 2)[1] === '0'; | ||
var rejected = SDPUtils.isRejected(mediaSection); | ||
@@ -611,17 +610,13 @@ if (!rejected && !transceiver.isDatachannel) { | ||
var lines = SDPUtils.splitLines(mediaSection); | ||
var mline = lines[0].substr(2).split(' '); | ||
var kind = mline[0]; | ||
var rejected = mline[1] === '0'; | ||
var kind = SDPUtils.getKind(mediaSection); | ||
var rejected = SDPUtils.isRejected(mediaSection); | ||
var protocol = lines[0].substr(2).split(' ')[2]; | ||
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(); | ||
} | ||
var mid = SDPUtils.getMid(mediaSection) || SDPUtils.generateIdentifier(); | ||
// Reject datachannels which are not implemented yet. | ||
if (kind === 'application' && mline[2] === 'DTLS/SCTP') { | ||
if (kind === 'application' && protocol === 'DTLS/SCTP') { | ||
self.transceivers[sdpMLineIndex] = { | ||
@@ -817,3 +812,2 @@ mid: mid, | ||
track = rtpReceiver.track; | ||
receiverList.push([track, rtpReceiver]); | ||
if (remoteMsid) { | ||
@@ -824,2 +818,3 @@ if (!streams[remoteMsid.stream]) { | ||
streams[remoteMsid.stream].addTrack(track); | ||
receiverList.push([track, rtpReceiver, streams[remoteMsid.stream]]); | ||
} else { | ||
@@ -830,2 +825,3 @@ if (!streams.default) { | ||
streams.default.addTrack(track); | ||
receiverList.push([track, rtpReceiver, streams.default]); | ||
} | ||
@@ -1012,6 +1008,18 @@ } else { | ||
if (offerOptions.offerToReceiveAudio !== undefined) { | ||
numAudioTracks = offerOptions.offerToReceiveAudio; | ||
if (offerOptions.offerToReceiveAudio === true) { | ||
numAudioTracks = 1; | ||
} else if (offerOptions.offerToReceiveAudio === false) { | ||
numAudioTracks = 0; | ||
} else { | ||
numAudioTracks = offerOptions.offerToReceiveAudio; | ||
} | ||
} | ||
if (offerOptions.offerToReceiveVideo !== undefined) { | ||
numVideoTracks = offerOptions.offerToReceiveVideo; | ||
if (offerOptions.offerToReceiveVideo === true) { | ||
numVideoTracks = 1; | ||
} else if (offerOptions.offerToReceiveVideo === false) { | ||
numVideoTracks = 0; | ||
} else { | ||
numVideoTracks = offerOptions.offerToReceiveVideo; | ||
} | ||
} | ||
@@ -1018,0 +1026,0 @@ } |
@@ -50,4 +50,7 @@ /* | ||
}; | ||
global.RTCIceTransport = function() {}; | ||
global.RTCIceTransport = function() { | ||
this.start = function() {}; | ||
}; | ||
global.RTCDtlsTransport = function() { | ||
this.start = function() {}; | ||
this.getLocalParameters = function() { | ||
@@ -71,3 +74,3 @@ return { | ||
this.receive = function(params) {}; | ||
this.receive = function() {}; | ||
}; | ||
@@ -119,2 +122,3 @@ function getCapabilities(kind) { | ||
this.transport = transport; | ||
this.send = function() {}; | ||
}; | ||
@@ -530,2 +534,26 @@ RTCRtpSender.getCapabilities = getCapabilities; | ||
}); | ||
it('= true the generated SDP should contain one audio m-line', (done) => { | ||
pc.createOffer({offerToReceiveAudio: true}) | ||
.then((offer) => { | ||
const sections = SDPUtils.splitSections(offer.sdp); | ||
expect(sections.length).to.equal(2); | ||
expect(SDPUtils.getDirection(sections[1])).to.equal('recvonly'); | ||
done(); | ||
}); | ||
}); | ||
it('= false the generated SDP should not offer to receive ' + | ||
'audio', (done) => { | ||
const audioTrack = new MediaStreamTrack(); | ||
audioTrack.kind = 'audio'; | ||
const stream = new MediaStream([audioTrack]); | ||
pc.addStream(stream); | ||
pc.createOffer({offerToReceiveAudio: false}) | ||
.then((offer) => { | ||
const sections = SDPUtils.splitSections(offer.sdp); | ||
expect(sections.length).to.equal(2); | ||
expect(SDPUtils.getDirection(sections[1])).to.equal('sendonly'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
@@ -994,2 +1022,32 @@ | ||
describe('full cycle', () => { | ||
let pc1; | ||
let pc2; | ||
beforeEach(() => { | ||
pc1 = new RTCPeerConnection(); | ||
pc2 = new RTCPeerConnection(); | ||
}); | ||
it('completes a full createOffer-SLD-SRD-createAnswer-SLD-SRD ' + | ||
'cycle', (done) => { | ||
const audioTrack = new MediaStreamTrack(); | ||
audioTrack.kind = 'audio'; | ||
const stream = new MediaStream([audioTrack]); | ||
pc1.addStream(stream); | ||
pc2.addStream(stream); | ||
pc1.createOffer() | ||
.then((offer) => pc1.setLocalDescription(offer)) | ||
.then(() => pc2.setRemoteDescription(pc1.localDescription)) | ||
.then(() => pc2.createAnswer()) | ||
.then((answer) => pc2.setLocalDescription(answer)) | ||
.then(() => pc1.setRemoteDescription(pc2.localDescription)) | ||
.then(() => { | ||
expect(pc1.signalingState).to.equal('stable'); | ||
expect(pc2.signalingState).to.equal('stable'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
describe('bundlePolicy', () => { | ||
@@ -996,0 +1054,0 @@ it('creates an offer with a=group:BUNDLE by default', (done) => { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
552250
14669
2
Updatedsdp@^1.5.0