victor-david / camera-eye

.Net Core 3.1 WPF Windows application to view and manipulate multiple IP cameras. Handles RTSP and MJPEG streams. Provides ability to pan and tilt the cameras. Uses plugins to deal with specific camera makes / models.
GNU General Public License v3.0
22 stars 3 forks source link

Motion latency on first movement #12

Closed victor-david closed 3 years ago

victor-david commented 3 years ago

Depending on the camera setup, there can be noticeable latency (about 1.5 seconds) when first attempting to move the camera, either via a left/right/up/down or by going to a preset.

The problem occurs the first time an HTTP request is made when the HttpClientHandler has its UseProxy property set to true (the default)

https://github.com/victor-david/camera-eye/blob/ca99d81edbf13b42c7643b212ca9c9f73b09db2a/src/Restless.Plugin.Framework/Base/HttpPluginBase.cs#L38

If the UseProxy property is set to false, the latency does not occur.

var clientHandler = new HttpClientHandler()
            {
                UseProxy = false
            };

Some cameras (Foscam) make an HTTP request during initialization to obtain values from the camera. Therefore, the latency is "hidden" in startup. Other cameras (Amcrest) do not obtain values from the camera during initialization.

If only Amcrest cameras are mounted on the camera wall, the latency occurs for the first camera to be moved. After that, the underlying .NET doesn't attempt the proxy lookup again and the second camera suffers no latency.

Same if an Amcrest and a Foscam are mounted. The Foscam performs its HTTP request during initialization ("hiding" the latency in startup) and the Amcrest suffers no latency.

Not sure this can be called a "bug" exactly and it may be something particular to my machine. But it is annoying. To fix, I propose to add a camera flag that conditionally sets the UseProxy property according to the flag. This would be an "advanced" config item and involves modifying the camera management window.

victor-david commented 3 years ago

ae85a9a1f63c906aff3f92c583e731b64e39ea79 and 8cbed724aa9beb6731b1b59835e2b0e4c69c5406

add the ability to disable proxy detection. This is handled by an application setting and is likely only needed in certain cases. If experiencing latency, you can try changing this setting, and then restart the app. If you're not having a problem, or you really are using a proxy, leave this setting as is, that is: unchecked.