Skip to content

Commit

Permalink
Clean up RTCPeerConnection creation
Browse files Browse the repository at this point in the history
Now that we don't need the empty track anymore this can be made a little
easier by directly instantiating the RTCPeerConnection
  • Loading branch information
third774 committed Aug 21, 2024
1 parent 4e5bbe8 commit 9ce8b1a
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions app/utils/rxjs/RxjsPeer.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ export class RxjsPeer {
let peerConnection: RTCPeerConnection
const setup = () => {
peerConnection?.close()
peerConnection = createPeerConnection({
peerConnection = new RTCPeerConnection({
iceServers: config.iceServers,
bundlePolicy: 'max-bundle',
})
peerConnection.addEventListener('connectionstatechange', () => {
if (
Expand Down Expand Up @@ -526,17 +527,6 @@ export class RxjsPeer {
}
}

function createPeerConnection(
configuration: RTCConfiguration = {
iceServers: [{ urls: 'stun:stun.cloudflare.com:3478' }],
bundlePolicy: 'max-bundle',
}
) {
const pc = new RTCPeerConnection(configuration)

return pc
}

async function resolveTrack(
peerConnection: RTCPeerConnection,
compare: (t: RTCRtpTransceiver) => boolean,
Expand Down

0 comments on commit 9ce8b1a

Please sign in to comment.