-
-
Save markandrus/7761495b9af1a319e3ddba1f44fe0e7e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const pc = new RTCPeerConnection() | |
// 1. addTrack(audioTrack1) | |
const sender1 = pc.addTrack(audioTrack1) | |
// 2. negotiate | |
const offer1 = await pc.createOffer() | |
await pc.setLocalDescription(offer1) | |
await pc.setRemoteDescription(answer1) | |
// 3. removeTrack(sender1) | |
pc.removeTrack(sender1) | |
// 4. negotiate | |
const offer2 = await pc.createOffer() | |
await pc.setLocalDescription(offer2) | |
await pc.setRemoteDescription(answer2) | |
// 5. addTrack(audioTrack2) | |
// | |
// The following does not hold, so create a new RTCRtpTransceiver: | |
// | |
// o The sender has never been used to send. More precisely, the | |
// RTCRtpTransceiver associated with the sender has never had a | |
// currentDirection of sendrecv or sendonly. | |
// | |
const sender2 = pc.addTrack(audioTrack2) | |
// 6. negotiate | |
// | |
// `offer3` contains two m= sections, and `pc.getTransceivers()` | |
// contains two RTCRtpTransceivers. | |
const offer3 = await pc.createOffer() | |
await pc.setLocalDescription(offer3) | |
await pc.setRemoteDescription(answer3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment