mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 01:21:20 -04:00
whipwhep
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -11,7 +11,7 @@
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
||||
<meta name="apple-mobile-web-app-title" content="Multi Roomba Rover" />
|
||||
<title>Multi Roomba Rover</title>
|
||||
<script type="module" crossorigin src="/assets/index-BjEIiAR_.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-CR--WtYL.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-WqYsCIRI.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -49,6 +49,43 @@ function waitForIceGatheringComplete(pc, timeoutMs = 1500) {
|
||||
});
|
||||
}
|
||||
|
||||
function waitForPeerConnected(pc, timeoutMs = 4000) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!pc) {
|
||||
reject(new Error('Peer connection missing'));
|
||||
return;
|
||||
}
|
||||
const state = pc.connectionState;
|
||||
if (state === 'connected') {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
if (state === 'failed' || state === 'closed') {
|
||||
reject(new Error(`Peer connection ${state}`));
|
||||
return;
|
||||
}
|
||||
const timer = setTimeout(() => {
|
||||
cleanup();
|
||||
reject(new Error('Peer connection timeout'));
|
||||
}, timeoutMs);
|
||||
const onState = () => {
|
||||
const next = pc.connectionState;
|
||||
if (next === 'connected') {
|
||||
cleanup();
|
||||
resolve();
|
||||
} else if (next === 'failed' || next === 'closed') {
|
||||
cleanup();
|
||||
reject(new Error(`Peer connection ${next}`));
|
||||
}
|
||||
};
|
||||
function cleanup() {
|
||||
clearTimeout(timer);
|
||||
pc.removeEventListener('connectionstatechange', onState);
|
||||
}
|
||||
pc.addEventListener('connectionstatechange', onState);
|
||||
});
|
||||
}
|
||||
|
||||
function resampleTo16k(input, sampleRate) {
|
||||
if (!input || !input.length) return new Float32Array(0);
|
||||
if (sampleRate === TARGET_SAMPLE_RATE) return input;
|
||||
@@ -368,6 +405,7 @@ export default function VipAudioForwardingCard({
|
||||
}
|
||||
const answerSdp = await response.text();
|
||||
await pc.setRemoteDescription({ type: 'answer', sdp: answerSdp });
|
||||
await waitForPeerConnected(pc, 4500);
|
||||
await readyMicWhip?.(target);
|
||||
setMicState('live');
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user