no delay broker option check"
This commit is contained in:
@@ -16,26 +16,6 @@
|
||||
const wsUrl = `${location.protocol === 'https:' ? 'wss' : 'ws'}://${location.host}/ws/${cameraId}`;
|
||||
const player = mpegts.createPlayer(
|
||||
{ type: 'mpegts', isLive: true, url: wsUrl, hasAudio: false },
|
||||
{
|
||||
enableWorker: true, // transmuxing в отдельном треде
|
||||
enableStashBuffer: true, // включить stash
|
||||
stashInitialSize: 384,
|
||||
|
||||
autoCleanupSourceBuffer: true, // не копить старые буферы в MSE
|
||||
autoCleanupMaxBackwardDuration: 10,
|
||||
autoCleanupMinBackwardDuration: 5,
|
||||
|
||||
// liveSync — плавное догоняние через playbackRate, а не жёсткий seek
|
||||
liveSync: true,
|
||||
liveSyncTargetLatency: 4.0, // target после выравнивания ← дать буферу вырасти
|
||||
liveSyncMaxLatency: 10.0, // при плохом интернете даём 10с ← не трогать буфер до 10s
|
||||
liveSyncPlaybackRate: 1.05, // ускорение не более 1.2x ← очень мягкое догоняние
|
||||
|
||||
liveBufferLatencyChasing: false, // включить stash ← убрать конфликтующий механизм
|
||||
|
||||
lazyLoad: false,
|
||||
deferLoadAfterSourceOpen: false,
|
||||
}
|
||||
);
|
||||
player.attachMediaElement(document.getElementById('v'))
|
||||
player.load()
|
||||
|
||||
@@ -6,7 +6,12 @@ import { routeMessage } from './router.js'
|
||||
|
||||
const mqttUrl = process.env.MQTT_URL as string
|
||||
|
||||
export const mqttClient = mqtt.connect(mqttUrl)
|
||||
export const mqttClient = mqtt.connect(mqttUrl, {
|
||||
clean: true,
|
||||
queueQoSZero: false,
|
||||
reconnectPeriod: 1000,
|
||||
connectTimeout: 10000,
|
||||
});
|
||||
|
||||
mqttClient.on('connect', () => {
|
||||
log('mqtt.connected', { url: mqttUrl })
|
||||
|
||||
@@ -21,6 +21,7 @@ function getClients(cameraId: string): Set<WebSocket> {
|
||||
|
||||
wss.on('connection', (ws: WebSocket, req: IncomingMessage) => {
|
||||
log(`ws.connection ${req.url}`);
|
||||
req.socket.setNoDelay(true)
|
||||
const cameraId = req.url ? lastTopicSegment(req.url) : 'v1';
|
||||
|
||||
const clients = getClients(cameraId);
|
||||
|
||||
@@ -87,6 +87,7 @@ function handleViewer(ws: WebSocket, channel: string, path: string): void {
|
||||
|
||||
wss.on('connection', (ws: WebSocket, req: IncomingMessage) => {
|
||||
const path = req.url?.split('?')[0] ?? ''
|
||||
req.socket.setNoDelay(true);
|
||||
|
||||
if (path.startsWith('/out/')) {
|
||||
handleViewer(ws, lastTopicSegment(path), path)
|
||||
|
||||
Reference in New Issue
Block a user