Dregu / visio

Ultra fast live streaming raw h264 from Raspberry Pi to multiple browser clients with Node, websockets and Broadway
MIT License
37 stars 13 forks source link

(solved) video client don't start (0 FPS but data is received) #8

Open VigibotDev opened 6 years ago

VigibotDev commented 6 years ago

This bug appear when a server side video is re-started without any client. You write the header only if there is wsServer.clients.length > 0.

I just moved the "if (headers.length < 3) headers.push(data)" outside the "if (wsServer && wsServer.clients.length > 0) {"

(root|/var/www) git diff
diff --git a/visio/serveur.js b/visio/serveur.js
index 1016c87..2fb3cb9 100644
--- a/visio/serveur.js
+++ b/visio/serveur.js
@@ -50,8 +50,8 @@ if (conf.get('tcpport')) {
     headers = []
     const NALSplitter = new Split(NALSeparator)
     NALSplitter.on('data', (data) => {
+      if (headers.length < 3) headers.push(data)
       if (wsServer && wsServer.clients.length > 0) {
-        if (headers.length < 3) headers.push(data)
         broadcast(data)
       }
     }).on('error', (e) => {

I forked your repo I can do commits + pull request if you want.