This commit is contained in:
legop3
2025-11-14 02:29:11 -05:00
parent 588c7aa571
commit 440325296c
10 changed files with 56 additions and 19 deletions
+1
View File
@@ -82,6 +82,7 @@ registerModule('spectator/main', (require, exports) => {
videoPlayer
.startStream(playerId, {
url: resp.url,
token: resp.token,
mount: wrap,
onStatus: (state, detail) => {
if (state === 'playing') {
+2 -1
View File
@@ -152,10 +152,11 @@ registerModule('services/roverUI', (require, exports) => {
videoPlayer.stopStream('driver');
return;
}
const { url } = resp;
const { url, token } = resp;
videoPlayer
.startStream('driver', {
url,
token,
mount: videoContainer,
videoEl: driverVideo,
onStatus: (state, detail) => {
+2 -12
View File
@@ -70,8 +70,7 @@ registerModule('services/videoPlayer', (require, exports) => {
};
this.attachAutoPlayLoop();
const credential = token || extractSessionToken(url);
if (!credential) {
if (!token) {
throw new Error('Missing video session token');
}
const offer = await this.pc.createOffer();
@@ -80,7 +79,7 @@ registerModule('services/videoPlayer', (require, exports) => {
method: 'POST',
headers: {
'Content-Type': 'application/sdp',
Authorization: `Basic ${btoa(`${credential}:${credential}`)}`,
Authorization: `Basic ${btoa(`${token}:${token}`)}`,
},
body: offer.sdp,
});
@@ -120,15 +119,6 @@ registerModule('services/videoPlayer', (require, exports) => {
}
}
function extractSessionToken(url) {
try {
const parsed = new URL(url, window.location.origin);
return parsed.searchParams.get('session');
} catch (err) {
return null;
}
}
async function startStream(id, { url, token, mount, videoEl, onStatus } = {}) {
stopStream(id);
const player = new Player(id, { mount, videoEl, onStatus });