有这样的RTSP Ping吗? [英] Is there such a RTSP Ping?

查看:22
本文介绍了有这样的RTSP Ping吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发一个 WinForm 应用程序,以使用 C# 中的 RTSP 协议从 IP 摄像机流式传输视频.一切正常.该应用程序的部分要求包括检查网络摄像机是否在线的功能.

所以我使用 System.Net.NetworkInformation.Ping 类执行了一个 ping 函数来 ping IP 摄像机.假设摄像机的RTSP url如下rtsp://[CAMERA IP]:554/Master0-RTSP/1.0,我只需要提取[CAMERA IP] 部分并使用 Ping 类通过使用其 IP 来查看相机是否在线.

最初,它一直有效,直到出现问题,例如,如果输入的 IP 可能不是预期的 IP 摄像机(例如计算机的 IP),如果输入的设备的输入 IP 是 ping 功能仍然有效在线.

我尝试搜索类似 RTSP ping 的内容,但找不到.希望对此事有任何建议或意见.非常感谢 C# 中的任何示例.感谢您的关注.

解决方案

OPTIONS 可能可行,但标准规定正确的方法是使用GET_PARAMETER.p>

RFC2326 概述清楚

http://www.ietf.org/rfc/rfc2326.txt

10.8 GET_PARAMETER

GET_PARAMETER 请求检索一个参数的值URI 中指定的表示或流.回复内容响应留给实施.GET_PARAMETER 没有实体主体可用于测试客户端或服务器的活跃度(ping").

虽然服务器可能不支持 GET_PARAMETER,但无法判断服务器将如何响应甚至不需要 sessionID 的 OPTIONS 请求.因此,不能保证它会使您现有的会话保持活动状态.

从阅读关于 OPTIONS 请求的相同 RFC 可以清楚地看出这一点

10.1 选项

该行为等同于 [H9.2] 中描述的行为.一个选项可以随时发出请求,例如,如果客户即将尝试非标准请求.它不会影响服务器状态.

例子:

 C->S: 选项 * RTSP/1.0序列号:1要求:隐式播放代理要求:gzipped-messagesS->C:RTSP/1.0 200 OK序列号:1公共:描述、设置、拆卸、播放、暂停

请注意,这些必须是虚构的功能(人们希望我们不会故意忽略一个真正有用的功能这样我们就可以在本节中有一个强有力的例子).

如果 GET_PARAMETER 不受支持,那么您将使用要保持活动状态的会话的 SessionId 发出 PLAY 请求.

即使 OPTIONS 不支持 Session ID 并且您已经在玩游戏,这也应该可以工作.

对于 C# RtspClient,请参阅我的项目@https://net7mma.codeplex.com/

还有关于 CodeProject 的文章@http://www.codeproject.com/Articles/507218/Managed-Media-Aggregation-using-Rtsp-and-Rtp

I am currently working on a WinForm app to stream videos from IP camera using the RTSP protocol in C#. Everything worked fine. Part of the requirement for the app includes a function to check whether the IP camera is online or not.

So I did a ping function using the System.Net.NetworkInformation.Ping class to ping the IP camera. Say if the RTSP url of the camera is as follows rtsp://[CAMERA IP]:554/Master0-RTSP/1.0, I would only need to extract the [CAMERA IP] part and use the Ping class to see if the camera is online or not by using its IP.

Initially, it works until an issue came, say if one to enter an IP which may not be the intended IP Camera (say an IP of a computer) the ping function would still work if the entered IP of the entered device is online.

I tried to search for something like a RTSP ping but could not find one. Was hoping for any advices or opinions on this matter. Any example in C# are greatly appreciated. Thank you for your kind attention.

解决方案

OPTIONS can possibly work but the standard specifies the correct way is through using theGET_PARAMETER.

RFC2326 outlines that clearly

http://www.ietf.org/rfc/rfc2326.txt

10.8 GET_PARAMETER

The GET_PARAMETER request retrieves the value of a parameter of a presentation or stream specified in the URI. The content of the reply and response is left to the implementation. GET_PARAMETER with no entity body may be used to test client or server liveness ("ping").

While GET_PARAMETER may not be supported by the server there is no way to tell how that server will react to the OPTIONS request which does not even require a sessionID. Therefor it cannot be guaranteed it will keep your existing session alive.

This is clear from reading the same RFC about the OPTIONS request

10.1 OPTIONS

The behavior is equivalent to that described in [H9.2]. An OPTIONS request may be issued at any time, e.g., if the client is about to try a nonstandard request. It does not influence server state.

Example:

 C->S:  OPTIONS * RTSP/1.0
        CSeq: 1
        Require: implicit-play
        Proxy-Require: gzipped-messages

 S->C:  RTSP/1.0 200 OK
        CSeq: 1
        Public: DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE

Note that these are necessarily fictional features (one would hope that we would not purposefully overlook a truly useful feature just so that we could have a strong example in this section).

If GET_PARAMETER is not supported then you would issue a PLAY request with the SessionId of the session you want to keep alive.

This should work even if OPTIONS doesn't as PLAY honors the Session ID and if you are already playing there is no adverse effect.

For the C# RtspClient see my project @ https://net7mma.codeplex.com/

And the article on CodeProject @ http://www.codeproject.com/Articles/507218/Managed-Media-Aggregation-using-Rtsp-and-Rtp

这篇关于有这样的RTSP Ping吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆