feat(sfu): add mediasoup runtime and router capabilities endpoint
This commit is contained in:
@@ -503,6 +503,44 @@ router.get('/:streamSessionId/sfu/session', requireDeviceAuth, async (req, res)
|
||||
});
|
||||
});
|
||||
|
||||
router.get('/:streamSessionId/sfu/router-rtp-capabilities', requireDeviceAuth, async (req, res) => {
|
||||
const parsedParams = streamParamSchema.safeParse(req.params);
|
||||
if (!parsedParams.success) {
|
||||
res.status(400).json({ message: 'Invalid streamSessionId', errors: parsedParams.error.flatten() });
|
||||
return;
|
||||
}
|
||||
|
||||
const deviceAuth = ensureDeviceAuth(req, res);
|
||||
if (!deviceAuth) return;
|
||||
|
||||
const sfu = ensureSfuEnabled(res);
|
||||
if (!sfu) return;
|
||||
|
||||
const session = await getOwnedStreamSession(parsedParams.data.streamSessionId, deviceAuth.userId);
|
||||
if (!session) {
|
||||
res.status(404).json({ message: 'Stream session not found' });
|
||||
return;
|
||||
}
|
||||
|
||||
const isParticipant = session.requesterDeviceId === deviceAuth.deviceId || session.cameraDeviceId === deviceAuth.deviceId;
|
||||
if (!isParticipant) {
|
||||
res.status(403).json({ message: 'Device cannot access SFU router capabilities for this stream' });
|
||||
return;
|
||||
}
|
||||
|
||||
const routerRtpCapabilities = await sfu.getRouterRtpCapabilities(session.id);
|
||||
if (!routerRtpCapabilities) {
|
||||
res.status(409).json({ message: 'SFU session is not initialized for this stream' });
|
||||
return;
|
||||
}
|
||||
|
||||
res.json({
|
||||
streamSessionId: session.id,
|
||||
mediaMode,
|
||||
routerRtpCapabilities,
|
||||
});
|
||||
});
|
||||
|
||||
router.post('/:streamSessionId/sfu/publish-transport', requireDeviceAuth, async (req, res) => {
|
||||
const parsedParams = streamParamSchema.safeParse(req.params);
|
||||
if (!parsedParams.success) {
|
||||
|
||||
Reference in New Issue
Block a user