ONVIF GetStreamURL C#
ONVIF GetStreamURL C#
我正在尝试使用 ONVIF 获取流 URL,但我被卡住了。方法 GetStreamURL 总是 returns 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);
}
看来我已经帮助自己解决了这个问题:
代码运行良好,但我需要删除对 wsdl 文件的所有服务引用并重新添加它们。我上次在 ONVIF 网站上没有找到 wsdls 是否有任何更新,但是 - 它帮助了我,现在上面的代码正在运行,我得到了正确的流媒体 URI。
此代码中存在一个问题,但我认为这取决于标准在设备上的实施方式:一些相机 returns 带有 HTTP 前缀的流式 URI,但它们仅通过 RTSP 传输。
如果您想使用类似的代码,请不要忘记在地址中添加登录名和密码字段。
我正在尝试使用 ONVIF 获取流 URL,但我被卡住了。方法 GetStreamURL 总是 returns 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);
}
看来我已经帮助自己解决了这个问题: 代码运行良好,但我需要删除对 wsdl 文件的所有服务引用并重新添加它们。我上次在 ONVIF 网站上没有找到 wsdls 是否有任何更新,但是 - 它帮助了我,现在上面的代码正在运行,我得到了正确的流媒体 URI。
此代码中存在一个问题,但我认为这取决于标准在设备上的实施方式:一些相机 returns 带有 HTTP 前缀的流式 URI,但它们仅通过 RTSP 传输。
如果您想使用类似的代码,请不要忘记在地址中添加登录名和密码字段。