elsampsa / valkka-core

Valkka - Create video surveillance, management and analysis programs with PyQt
GNU Lesser General Public License v3.0
181 stars 35 forks source link

Status of camera source (LiveConnectionContext) #23

Closed acschristoph closed 3 years ago

acschristoph commented 3 years ago

Hey

First awesome libary, is there a way to get the status of rtsp Connection (LiveConnectionContext) If it connected right or, isnt get the error Message maybe a callback or similar a stdout is not enough for our case. Big thanks Happy Christmas

elsampsa commented 3 years ago

"status of rtsp connection" can get a bit complex:

  1. Is your NIC up?
  2. Is the rtsp camera online / does it exist in the first place?
  3. Did something go wrong in the rtsp negotiations: bad password, etc?
  4. Streaming started, but the network connection stalled at some moment
  5. Some firewall is messing up with the rtsp connection or sending the actual stream rtp packets
  6. etc.

Libvalkka does not take any opinion nor does it care about the origin of the error: it simply tells live555 to connect to the given rtsp address and if no data is coming through in a certain amount of time, it issues live555 to restart the connection. This happens under-the-hood & you don't need to worry about it (there's a parameter in LiveConnectionContext to control that period of time).

So, if no frames are coming through, then that's the indicator that something is wrong with "status of the rtsp connection". I suggest you do just that: if data is not coming in, say, 10 seconds, you know there is a problem & issue a callback or whatever you need to do.

If you need to "probe" the camera (see if it exists / is online, test the password, etc.), without initiating actual streaming, I suggest that you do that with OnVif (there are instructions for OnVif at valkka.fi as well).

elsampsa commented 3 years ago

There's now a new branch called "signalframe" in the repo.

This framefilter does what you are looking for:

https://github.com/elsampsa/valkka-core/blob/signalframe/include/framefilter2.h#L40

A warning: pretty untested. Maybe you can help with that.

P. S. That reconnection feature I was talking about only took effect if mstimeout is set to > 0, here: https://elsampsa.github.io/valkka-core/html/structLiveConnectionContext.html

The default was 0, so there was no reconnection by default..! Now that's been set to 10 secs. by default in that experimental branch.

acschristoph commented 3 years ago

Thx, I will test this and let u know I think thats a common task on vms systems to ask the vms server about camera metadata that includes: Camera Status: online/offline/auth error/ Decoding Status: fps/height/widht/Codec That would also a great benefit to valkka-live where u can display this data as overlay on each stream or camera like u see it in modern vms.

Example from milestone vms rtaImage

elsampsa commented 3 years ago

sending alerts downstream is now in the master branch.

However, you have to enable it manually & compile:

https://github.com/elsampsa/valkka-core/blob/master/src/livethread.cpp#L39

I tested the python callback scheme and it works

Milestone has an army of engineers doing this kind of details into their monumental software.. This is not our case. Thanks for the suggestion anyway.