WebGL is now default

This commit is contained in:
Milan Nikolic
2018-01-27 01:59:46 +01:00
parent 1c9dfcb84c
commit 7392d8d9b8
4 changed files with 9 additions and 9 deletions

View File

@@ -46,8 +46,8 @@ Usage of ./cam2ip:
Path to htpasswd file, if empty auth is disabled Path to htpasswd file, if empty auth is disabled
-index int -index int
Camera index Camera index
-webgl -nowebgl
Use WebGL to draw images Disable WebGL drawing of images (html handler)
``` ```
### Handlers ### Handlers

View File

@@ -21,7 +21,7 @@ func main() {
flag.IntVar(&srv.Delay, "delay", 10, "Delay between frames, in milliseconds") flag.IntVar(&srv.Delay, "delay", 10, "Delay between frames, in milliseconds")
flag.Float64Var(&srv.FrameWidth, "frame-width", 640, "Frame width") flag.Float64Var(&srv.FrameWidth, "frame-width", 640, "Frame width")
flag.Float64Var(&srv.FrameHeight, "frame-height", 480, "Frame height") flag.Float64Var(&srv.FrameHeight, "frame-height", 480, "Frame height")
flag.BoolVar(&srv.WebGL, "webgl", false, "Use WebGL to draw images") flag.BoolVar(&srv.NoWebGL, "nowebgl", false, "Disable WebGL drawing of images (html handler)")
flag.StringVar(&srv.Bind, "bind-addr", ":56000", "Bind address") flag.StringVar(&srv.Bind, "bind-addr", ":56000", "Bind address")
flag.StringVar(&srv.Htpasswd, "htpasswd-file", "", "Path to htpasswd file, if empty auth is disabled") flag.StringVar(&srv.Htpasswd, "htpasswd-file", "", "Path to htpasswd file, if empty auth is disabled")
flag.Parse() flag.Parse()

View File

@@ -13,7 +13,7 @@ type HTML struct {
} }
// NewHTML returns new HTML handler. // NewHTML returns new HTML handler.
func NewHTML(bind string, width, height float64, gl bool) *HTML { func NewHTML(bind string, width, height float64, nogl bool) *HTML {
h := &HTML{} h := &HTML{}
b := strings.Split(bind, ":") b := strings.Split(bind, ":")
@@ -21,9 +21,9 @@ func NewHTML(bind string, width, height float64, gl bool) *HTML {
bind = "127.0.0.1" + bind bind = "127.0.0.1" + bind
} }
tpl := html tpl := htmlWebGL
if gl { if nogl {
tpl = htmlWebGL tpl = html
} }
tpl = strings.Replace(tpl, "{BIND}", bind, -1) tpl = strings.Replace(tpl, "{BIND}", bind, -1)

View File

@@ -24,7 +24,7 @@ type Server struct {
Delay int Delay int
FrameWidth float64 FrameWidth float64
FrameHeight float64 FrameHeight float64
WebGL bool NoWebGL bool
Camera *camera.Camera Camera *camera.Camera
} }
@@ -43,7 +43,7 @@ func (s *Server) ListenAndServe() error {
basic = auth.NewBasicAuthenticator(realm, auth.HtpasswdFileProvider(s.Htpasswd)) basic = auth.NewBasicAuthenticator(realm, auth.HtpasswdFileProvider(s.Htpasswd))
} }
http.Handle("/html", newAuthHandler(handlers.NewHTML(s.Bind, s.FrameWidth, s.FrameHeight, s.WebGL), basic)) http.Handle("/html", newAuthHandler(handlers.NewHTML(s.Bind, s.FrameWidth, s.FrameHeight, s.NoWebGL), basic))
http.Handle("/jpeg", newAuthHandler(handlers.NewJPEG(s.Camera), basic)) http.Handle("/jpeg", newAuthHandler(handlers.NewJPEG(s.Camera), basic))
http.Handle("/mjpeg", newAuthHandler(handlers.NewMJPEG(s.Camera, s.Delay), basic)) http.Handle("/mjpeg", newAuthHandler(handlers.NewMJPEG(s.Camera, s.Delay), basic))