mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-11-14 18:58:49 -05:00
room audio
This commit is contained in:
@@ -11,6 +11,7 @@ function registerVideoAuthRoute(deps) {
|
||||
logAdminEvent,
|
||||
extractStreamInfoFromBody,
|
||||
canAccessStream,
|
||||
trackRoomAudioSession,
|
||||
} = deps;
|
||||
|
||||
app.post('/mediamtx/auth', (req, res) => {
|
||||
@@ -36,7 +37,8 @@ function registerVideoAuthRoute(deps) {
|
||||
const isLoopback = ip === '127.0.0.1' || ip === '::1';
|
||||
const isRoverForwardAudioRead = action === 'read'
|
||||
&& isRtspProtocol
|
||||
&& streamInfo?.id?.endsWith('-fwd');
|
||||
&& streamInfo?.type === 'rover'
|
||||
&& streamInfo.id.endsWith('-fwd');
|
||||
// Replay and snapshot workers read MediaMTX through loopback RTSP. They do
|
||||
// not represent a browser session. Rovers likewise read their dedicated
|
||||
// -fwd speaker feed without browser credentials; every other non-loopback
|
||||
@@ -50,7 +52,7 @@ function registerVideoAuthRoute(deps) {
|
||||
callback for RTSP, so explicitly admit that publish protocol while leaving WHEP reads
|
||||
under the existing session and role checks below.
|
||||
*/
|
||||
if (action === 'publish' && isRtspProtocol) {
|
||||
if (action === 'publish' && isRtspProtocol && (streamInfo?.type !== 'roomAudio' || isLoopback)) {
|
||||
return res.status(200).end();
|
||||
}
|
||||
|
||||
@@ -62,7 +64,9 @@ function registerVideoAuthRoute(deps) {
|
||||
const info = videoSessions.getSession(sessionId);
|
||||
const streamTypeMatches =
|
||||
info &&
|
||||
(info.sourceType === streamInfo.type || (info.sourceType === 'roverMic' && streamInfo.type === 'rover'));
|
||||
(info.sourceType === streamInfo.type
|
||||
|| (info.sourceType === 'roomMic' && streamInfo.type === 'roomAudio')
|
||||
|| (info.sourceType === 'roverMic' && streamInfo.type === 'rover'));
|
||||
if (!info || !streamTypeMatches || info.sourceId !== streamInfo.id) {
|
||||
logger.warn('invalid session %s for stream %s:%s', sessionId, streamInfo.type, streamInfo.id);
|
||||
return res.status(401).end();
|
||||
@@ -78,6 +82,7 @@ function registerVideoAuthRoute(deps) {
|
||||
return res.status(401).end();
|
||||
}
|
||||
|
||||
if (streamInfo.type === 'roomAudio' && protocol === 'webrtc') trackRoomAudioSession(body.id, sessionId);
|
||||
return res.status(200).end();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
const { app } = require('../../globals/http');
|
||||
const io = require('../../globals/io');
|
||||
const logger = require('../../globals/logger').child('videoAuth');
|
||||
const roomAudioService = require('../roomAudioService');
|
||||
const videoSessions = require('../videoSessions');
|
||||
const { getMode, MODES } = require('../modeManager');
|
||||
const { isAdmin, isLockdownAdmin, getRole } = require('../roleService');
|
||||
@@ -28,6 +29,7 @@ const { canAccessStream } = createVideoAuthPolicy({
|
||||
turnService,
|
||||
roverManager,
|
||||
ptzCameraService,
|
||||
roomAudioService,
|
||||
getSocketIp,
|
||||
isLocalNetwork,
|
||||
io,
|
||||
@@ -42,6 +44,7 @@ registerVideoAuthRoute({
|
||||
logAdminEvent,
|
||||
extractStreamInfoFromBody,
|
||||
canAccessStream,
|
||||
trackRoomAudioSession: roomAudioService.trackMediaSession,
|
||||
});
|
||||
|
||||
module.exports = {};
|
||||
|
||||
@@ -17,6 +17,7 @@ function createVideoAuthPolicy(deps) {
|
||||
turnService,
|
||||
roverManager,
|
||||
ptzCameraService,
|
||||
roomAudioService,
|
||||
getSocketIp,
|
||||
isLocalNetwork,
|
||||
io,
|
||||
@@ -58,6 +59,11 @@ function createVideoAuthPolicy(deps) {
|
||||
}
|
||||
|
||||
function canAccessStream({ socket, streamInfo, action, sourceType }) {
|
||||
if (streamInfo.type === 'roomAudio') {
|
||||
return action === 'publish'
|
||||
? sourceType === 'roomMic' && roomAudioService.canPublish(socket, streamInfo.id)
|
||||
: action === 'read' && sourceType === 'roomAudio' && roomAudioService.canListen(socket) && roomAudioService.hasStream(streamInfo.id);
|
||||
}
|
||||
if (!canView(socket)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,8 @@ function extractStreamInfo(path) {
|
||||
return { type: 'rover', id: rawId, baseId };
|
||||
}
|
||||
|
||||
if (remaining.length === 2 && remaining[0] === 'room-audio') return { type: 'roomAudio', id: remaining[1] };
|
||||
|
||||
if (remaining.length === 2 && remaining[0] === 'room') {
|
||||
return { type: 'room', id: remaining[1] || '' };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user