Home > Forum > Check connection to an IP Camera with VideoCaptureCore.IP_Camera_CheckAvailable

Check connection to an IP Camera with VideoCaptureCore.IP_Camera_CheckAvailable

Oct 01 (10 days ago)
Christa Kallenberger wrote
Hi there,
I'm trying to check the connection to an IP camera with the following code:

VideoCaptureCore videoCaptureCore = new VideoCaptureCore();
string myUri = "rtsp://<IPAddress>/axis-media/media.amp";
System.Uri uri = new Uri(myUri );
System.Net.IPAddress ipAddress = Dns.GetHostAddresses(uri.Host)[0];
int port = uri.Port;
System.Net.Sockets.ProtocolType protocol = uri.Scheme == "rtsp" ? ProtocolType.Tcp : ProtocolType.Udp;
bool result = videoCaptureCore.IP_Camera_CheckAvailable(ipAddress, port, protocol, new TimeSpan(0, 0, 10));

The result is always false and this is not correct. The camera can be accessed via vlc Media Player using the same URI.

Notes:
1. <IPAddress> must be replaced with the real address when testing.
2. The uri does not contain a port number; the default port number returned by uri.Port is -1; Could this be a problem?

How to use this function to check the connection?
Thanks in advance for your answer.

Best regards
Christa
Reply
4 Answers
Oct 01 (9 days ago)
Roman Miniailov agent wrote
Hi

Yes, you should provide the correct port and protocol. It can be a problem.
Oct 01 (9 days ago)
Christa Kallenberger wrote
But I don't have either a port, not a protocol in my URI. How to test the camera connection in this case?
Oct 01 (9 days ago)
Roman Miniailov agent wrote
RTSP default port is 554. You can add it to your URL or specify it as a "port" parameter.
Oct 02 (9 days ago)
Christa Kallenberger wrote
Thanks, it's working now with the default port 😀!