【问题标题】:ONVIF GetStreamURL C#ONVIF GetStreamURL C#
【发布时间】:2015-07-05 16:40:40
【问题描述】:

我正在尝试使用 ONVIF 获取流 URL,但我被卡住了。方法 GetStreamURL 总是返回 Null,但是当我在 Wireshark 中嗅探流量时,我得到了来自摄像头的正确响应。也许有人有类似的问题,可以帮助我吗?我的代码如下所示:

HttpTransportBindingElement httpBinding = new HttpTransportBindingElement();
EndpointAddress serviceAddress = new EndpointAddress(__url);
TextMessageEncodingBindingElement messegeElement = new TextMessageEncodingBindingElement();

httpBinding.AuthenticationScheme = AuthenticationSchemes.Digest;
messegeElement.MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.WSAddressing10);

CustomBinding bind = new CustomBinding(messegeElement, httpBinding);
ONVIF.onvifMedia.mediaClient mclient = new ONVIF.onvifMedia.mediaClient(bind, serviceAddress);

ONVIF.onvifMedia.StreamSetup streamSetup = new ONVIF.onvifMedia.StreamSetup();
streamSetup.Stream = ONVIF.onvifMedia.StreamType.RTPUnicast;

streamSetup.Transport = new ONVIF.onvifMedia.Transport();
streamSetup.Transport.Protocol = ONVIF.onvifMedia.TransportProtocol.RTSP;

mediaUri uri = new mediaUri();
Profile[] profiles;

log.Debug("Trying to fetch profiles");
profiles = mclient.GetProfiles();

foreach (Profile item in profiles)
{
   uri = mclient.GetStreamUri(streamSetup, item.token);
}

【问题讨论】:

  • 你能把你用Wireshark找到的相应流量粘贴过来吗?
  • 您是如何直接使用 ONVIF 课程的?我试图访问 api 以从相机中检索图像快照,但没有让它工作:stackoverflow.com/questions/32779467/…

标签: c# wsdl streaming onvif


【解决方案1】:

看起来我帮助自己解决了这个问题: 代码效果很好,但我需要删除对 wsdl 文件的所有服务引用并再次添加它们。但是,我没有发现上次在 ONVIF 网站上是否有任何 wsdls 更新 - 它帮助了我,现在上面的代码正在运行,并且我得到了正确的流 URI。

这段代码有一个问题,但在我看来,这取决于标准是如何在设备上实现的:一些相机返回带有 HTTP 前缀的流式 URI,但它们仅通过 RTSP 传输。

如果您想使用类似的代码,请不要忘记在地址中添加登录名和密码字段。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-12-23
    • 2012-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多