mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-17 10:00:46 -04:00
guh
This commit is contained in:
@@ -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) => {
|
||||
|
||||
@@ -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 });
|
||||
|
||||
Reference in New Issue
Block a user