arkhipenko/esp32-cam-mjpeg-multiclient

Race hazard accessing camera between motion/static stream threads

Opened this issue · 1 comments

There is, I think, a race hazard if you have clients using the MPJEG stream and static picture URL at the same time in that that that it is possible for both threads to be accessing the camera object at the same time. This can then result in bad things happening with regard to the memory buffer pointer returned from the camera class. I can very quickly crash the board under these conditions.

I think you need a semaphore around the camera object accesses - the attached patch seems to work for me.

Cheers,

Jon.

cam_race_hazard.diff.gz

I actually did not care about static picture taking in this code at all. It is kind of a leftover from the example it was built upon.
The goal of this POC was to make multi-client video streaming work on VLC, Blynk App video feed and browsers.
So yeah, please go ahead and improve!
Thank you.