Skip to content

Commit

Permalink
feat: Trackを受け取れるように
Browse files Browse the repository at this point in the history
  • Loading branch information
sevenc-nanashi committed Feb 7, 2025
1 parent c18f483 commit 110e2e2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/backend/vst/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ export async function rtcSdp(sdp: RTCSessionDescriptionInit) {
};
}

export async function rtcIce(nonce: string, ice: RTCIceCandidateInit) {
export async function rtcIce(nonce: string, ice: RTCIceCandidateInit | null) {
await ipcRtcIce({ nonce, ice });
}

Expand Down
12 changes: 5 additions & 7 deletions src/backend/vst/vstPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,15 +315,13 @@ export const vstPlugin: Plugin = {
const { promise: noncePromise, resolve: resolveNonce } =
Promise.withResolvers<string>();

rtcPeerConnection.onicecandidate = (event) => {
rtcPeerConnection.addEventListener("icecandidate", async (event) => {
const candidate = event.candidate;
if (candidate) {
void noncePromise.then((nonce) => rtcIce(nonce, candidate));
}
};
rtcPeerConnection.onconnectionstatechange = () => {
void noncePromise.then((nonce) => rtcIce(nonce, candidate));
});
rtcPeerConnection.addEventListener("connectionstatechange", () => {
log.info(`connection state: ${rtcPeerConnection.connectionState}`);
};
});
const offer = await rtcPeerConnection.createOffer();
await rtcPeerConnection.setLocalDescription(offer);
log.info("Local description set");
Expand Down

0 comments on commit 110e2e2

Please sign in to comment.