Comments (7)
There is already notification for close here https://github.com/gen2brain/cam2ip/blob/master/handlers/mjpeg.go#L41 and for HTML on socket close can close the camera. My point is that if there is a need for e.g. many mjpeg clients, one can put some mjpeg-proxy in front of cam2ip, there are many of them, if lazy option doesn't work for many clients, user can disable it etc.
Just trying to not further complicate the code, for now everything is clear and simple, but I will consider also your hint when I start to work on this.
from cam2ip.
It seems like a nice addition. This should be done by handlers, not Read(), and if option enabled main should not initialize the camera. I think it should not be a big job but need to check first, not sure when. What do you think option should be called, lazy
sounds ok?
from cam2ip.
"Deferred camera initialization" is the most descriptive way, but that doesn't fit well into a short CLI option, so "lazy" works. Kind of fun.
from cam2ip.
One thing to think about is, what happens when multiple clients are accessing the camera at once.
Would need to maintain a client counter and only release the camera when the client counter reaches zero.
from cam2ip.
Every handler will anyway check if camera is nil/null on every request and will initialize it if it is not, so one client closes tab/connection and it closes the camera, the other client on the next request will again initialize the camera. Needs to be tested but I would not want to complicate this much.
from cam2ip.
If somebody is viewing MJPEG stream they would not want to have the camera turned off underneath them by somebody capturing a single JPEG... This would result in a glitch in the video stream as the camera has to be reinitialized for the next MJPEG frame. I guess that's not the end of the world, but not perfect. Or is that not an issue for some other reason I'm not seeing? Oh well! It's your project, your call!
Thanks again for this project and thanks for being so responsive!
from cam2ip.
Maybe initialize as you suggest, and handle closing the camera by a ConnState hook ( https://golang.org/pkg/net/http/#ConnState ) that increments a counter on StateNew, decrements on StateClosed (maybe StateHijacked too) and closes the camera whenever the counter transitions to zero.
Again not a Go expert, just reading the docs...
from cam2ip.
Related Issues (20)
- camera: no camera at index 0 HOT 1
- Password? HOT 1
- read: camera: can not grab frame: device or resource busy HOT 2
- audio HOT 1
- Goost lib? HOT 2
- Add ability to choose camera by ID HOT 2
- jpeglib.h: No such file or directory HOT 2
- delete pls
- Can't get higher than 5FPS HOT 7
- ERROR: SampleCB() - buffer sizes do not match HOT 1
- Cannot install using go get HOT 6
- cannot retreive frame : eof HOT 1
- Timestamp Scaling? HOT 2
- fatal error: jpeglib.h: No such file or directory - Windows 10 - How to install libjpeg-turbo HOT 11
- How to change index camera HOT 1
- fails to build on some architectures.. HOT 11
- socket: read: camera: invalid JPEG format: uninitialized Huffman table HOT 1
- New Builds on Releases? HOT 1
- How to let multiple clients access the same camera at the same time HOT 4
- Changing resolution Windows HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cam2ip.