把海康摄像机设置为H265模式,显示反序列化失败。设置成H264模式,可以成功,
通过研究发现 ,我使用的soap协议的wsdl是如下版本:
https://www.onvif.org/onvif/ver10/media/wsdl/media.wsdl
但是这个版本只支持:
并不支持H265的格式
然后,我就开始找啊找,终于找到了新版的wsdl,地址如下:
https://www.onvif.org/ver20/media/wsdl/media.wsdl
这个版本是支持H265格式的。
另外想要保存wsdl的话,直接右键链接地址下载即可。
想要查看怎么使用可以参考下面代码:
https://github.com/AlexBrochu/CameraManager
调用流程如下:
获取设备能力:
var deviceUri = new UriBuilder("http:/onvif/device_service")
{
Host = ip,
Port = port
};
Binding binding;
HttpTransportBindingElement httpTransport = new HttpTransportBindingElement();
httpTransport.AuthenticationScheme = AuthenticationSchemes.Digest;
binding = new CustomBinding(new TextMessageEncodingBindingElement(MessageVersion.Soap12WSAddressing10, Encoding.UTF8), httpTransport);
DeviceClient device = new DeviceClient(binding, new EndpointAddress(deviceUri.ToString()));
Service[] services = device.GetServices(false);
查找需要的服务地址,主要通过Namespace
Service xmedia2 = services.FirstOrDefault(s => s.Namespace == "http://www.onvif.org/ver20/media/wsdl");
查找到服务之后,在拿这个服务的地址获取想要的数据:
var media = new Media2Client(binding, new EndpointAddress(xmedia2.XAddr));
media.ClientCredentials.HttpDigest.ClientCredential.UserName = username;
media.ClientCredentials.HttpDigest.ClientCredential.Password = password;
media.ClientCredentials.HttpDigest.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
var profiles = media.GetProfiles(null, null);
string strRtspUrl = media.GetStreamUri("RTSP", profiles[0].token);