Add --lazy to open the camera only while clients are connected, issue #21

This commit is contained in:
Milan Nikolic
2026-06-30 16:42:40 +02:00
parent 029d0bef08
commit d09d78bc5f
4 changed files with 64 additions and 23 deletions

View File

@@ -36,7 +36,8 @@ type Server struct {
Bind string
Htpasswd string
Reader handlers.ImageReader
Lazy bool
Open func() (handlers.ImageReader, error)
}
// NewServer returns new Server.
@@ -54,7 +55,7 @@ func (s *Server) ListenAndServe() error {
basic = auth.NewBasicAuthenticator(realm, auth.HtpasswdFileProvider(s.Htpasswd))
}
stream := handlers.NewStream(s.Reader, s.Delay, s.Quality)
stream := handlers.NewStream(s.Open, s.Delay, s.Quality, s.Lazy)
mux := http.NewServeMux()