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 wsUrl = `${location.protocol === 'https:' ? 'wss' : 'ws'}://${location.host}/ws/${cameraId}`;
|
||||||
const player = mpegts.createPlayer(
|
const player = mpegts.createPlayer(
|
||||||
{ type: 'mpegts', isLive: true, url: wsUrl, hasAudio: false },
|
{ 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.attachMediaElement(document.getElementById('v'))
|
||||||
player.load()
|
player.load()
|
||||||
|
|||||||
@@ -6,7 +6,12 @@ import { routeMessage } from './router.js'
|
|||||||
|
|
||||||
const mqttUrl = process.env.MQTT_URL as string
|
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', () => {
|
mqttClient.on('connect', () => {
|
||||||
log('mqtt.connected', { url: mqttUrl })
|
log('mqtt.connected', { url: mqttUrl })
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ function getClients(cameraId: string): Set<WebSocket> {
|
|||||||
|
|
||||||
wss.on('connection', (ws: WebSocket, req: IncomingMessage) => {
|
wss.on('connection', (ws: WebSocket, req: IncomingMessage) => {
|
||||||
log(`ws.connection ${req.url}`);
|
log(`ws.connection ${req.url}`);
|
||||||
|
req.socket.setNoDelay(true)
|
||||||
const cameraId = req.url ? lastTopicSegment(req.url) : 'v1';
|
const cameraId = req.url ? lastTopicSegment(req.url) : 'v1';
|
||||||
|
|
||||||
const clients = getClients(cameraId);
|
const clients = getClients(cameraId);
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ function handleViewer(ws: WebSocket, channel: string, path: string): void {
|
|||||||
|
|
||||||
wss.on('connection', (ws: WebSocket, req: IncomingMessage) => {
|
wss.on('connection', (ws: WebSocket, req: IncomingMessage) => {
|
||||||
const path = req.url?.split('?')[0] ?? ''
|
const path = req.url?.split('?')[0] ?? ''
|
||||||
|
req.socket.setNoDelay(true);
|
||||||
|
|
||||||
if (path.startsWith('/out/')) {
|
if (path.startsWith('/out/')) {
|
||||||
handleViewer(ws, lastTopicSegment(path), path)
|
handleViewer(ws, lastTopicSegment(path), path)
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
listener 1883
|
listener 1883
|
||||||
allow_anonymous true
|
allow_anonymous true
|
||||||
|
|
||||||
|
set_tcp_nodelay true # выключает Nagle на всех сокетах брокера
|
||||||
|
|
||||||
persistence true
|
persistence true
|
||||||
persistence_location /mosquitto/data/
|
persistence_location /mosquitto/data/
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user