mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 17:40:46 -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-status-bar-style" content="black-translucent" />
|
||||||
<meta name="apple-mobile-web-app-title" content="Multi Roomba Rover" />
|
<meta name="apple-mobile-web-app-title" content="Multi Roomba Rover" />
|
||||||
<title>Multi Roomba Rover</title>
|
<title>Multi Roomba Rover</title>
|
||||||
<script type="module" crossorigin src="/assets/index-CR--WtYL.js"></script>
|
<script type="module" crossorigin src="/assets/index-D2iMrx7r.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="/assets/index-WqYsCIRI.css">
|
<link rel="stylesheet" crossorigin href="/assets/index-WqYsCIRI.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@@ -49,19 +49,31 @@ function waitForIceGatheringComplete(pc, timeoutMs = 1500) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function waitForPeerConnected(pc, timeoutMs = 4000) {
|
function isPeerTransportReady(pc) {
|
||||||
|
if (!pc) return false;
|
||||||
|
const conn = pc.connectionState;
|
||||||
|
const ice = pc.iceConnectionState;
|
||||||
|
if (conn === 'connected') return true;
|
||||||
|
if (ice === 'connected' || ice === 'completed') return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function waitForPeerConnected(pc, timeoutMs = 10000) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (!pc) {
|
if (!pc) {
|
||||||
reject(new Error('Peer connection missing'));
|
reject(new Error('Peer connection missing'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const state = pc.connectionState;
|
if (isPeerTransportReady(pc)) {
|
||||||
if (state === 'connected') {
|
|
||||||
resolve();
|
resolve();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (state === 'failed' || state === 'closed') {
|
if (
|
||||||
reject(new Error(`Peer connection ${state}`));
|
pc.connectionState === 'failed' ||
|
||||||
|
pc.connectionState === 'closed' ||
|
||||||
|
pc.iceConnectionState === 'failed'
|
||||||
|
) {
|
||||||
|
reject(new Error(`Peer connection ${pc.connectionState || pc.iceConnectionState}`));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const timer = setTimeout(() => {
|
const timer = setTimeout(() => {
|
||||||
@@ -69,20 +81,25 @@ function waitForPeerConnected(pc, timeoutMs = 4000) {
|
|||||||
reject(new Error('Peer connection timeout'));
|
reject(new Error('Peer connection timeout'));
|
||||||
}, timeoutMs);
|
}, timeoutMs);
|
||||||
const onState = () => {
|
const onState = () => {
|
||||||
const next = pc.connectionState;
|
if (isPeerTransportReady(pc)) {
|
||||||
if (next === 'connected') {
|
|
||||||
cleanup();
|
cleanup();
|
||||||
resolve();
|
resolve();
|
||||||
} else if (next === 'failed' || next === 'closed') {
|
} else if (
|
||||||
|
pc.connectionState === 'failed' ||
|
||||||
|
pc.connectionState === 'closed' ||
|
||||||
|
pc.iceConnectionState === 'failed'
|
||||||
|
) {
|
||||||
cleanup();
|
cleanup();
|
||||||
reject(new Error(`Peer connection ${next}`));
|
reject(new Error(`Peer connection ${pc.connectionState || pc.iceConnectionState}`));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
function cleanup() {
|
function cleanup() {
|
||||||
clearTimeout(timer);
|
clearTimeout(timer);
|
||||||
pc.removeEventListener('connectionstatechange', onState);
|
pc.removeEventListener('connectionstatechange', onState);
|
||||||
|
pc.removeEventListener('iceconnectionstatechange', onState);
|
||||||
}
|
}
|
||||||
pc.addEventListener('connectionstatechange', onState);
|
pc.addEventListener('connectionstatechange', onState);
|
||||||
|
pc.addEventListener('iceconnectionstatechange', onState);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -405,7 +422,7 @@ export default function VipAudioForwardingCard({
|
|||||||
}
|
}
|
||||||
const answerSdp = await response.text();
|
const answerSdp = await response.text();
|
||||||
await pc.setRemoteDescription({ type: 'answer', sdp: answerSdp });
|
await pc.setRemoteDescription({ type: 'answer', sdp: answerSdp });
|
||||||
await waitForPeerConnected(pc, 4500);
|
await waitForPeerConnected(pc, 10000);
|
||||||
await readyMicWhip?.(target);
|
await readyMicWhip?.(target);
|
||||||
setMicState('live');
|
setMicState('live');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user