Browse Source

first commit

pull/1/head
fajiao 3 years ago
parent
commit
a924c1fa02
  1. 11
      BaseModule/EC.App/Core/ApiController.cs
  2. 6
      BaseModule/EC.App/Core/BLL.cs
  3. 6
      BaseModule/EC.App/Core/IBLL.cs
  4. 6
      BaseModule/EC.App/Core/IService.cs
  5. 6
      BaseModule/EC.App/Core/Service.cs
  6. 11
      BaseModule/EC.App/EC.App.csproj
  7. 47
      BaseModule/EC.Onvif/Camera/Camera.cs
  8. 41
      BaseModule/EC.Onvif/Camera/CameraManager.cs
  9. 22862
      BaseModule/EC.Onvif/Common/DataTypes.cs
  10. 1736
      BaseModule/EC.Onvif/Device/DataTypes.cs
  11. 2934
      BaseModule/EC.Onvif/Device/DeviceClient.cs
  12. 12
      BaseModule/EC.Onvif/EC.Onvif.csproj
  13. 144
      BaseModule/EC.Onvif/Imaging/DataTypes.cs
  14. 186
      BaseModule/EC.Onvif/Imaging/ImagingClient.cs
  15. 663
      BaseModule/EC.Onvif/Media/DataTypes.cs
  16. 2126
      BaseModule/EC.Onvif/Media/MediaClient.cs
  17. 191
      BaseModule/EC.Onvif/OnvifClient.cs
  18. 117
      BaseModule/EC.Onvif/OnvifClientFactory.cs
  19. 185
      BaseModule/EC.Onvif/PTZ/DataTypes.cs
  20. 662
      BaseModule/EC.Onvif/PTZ/PTZClient.cs
  21. 27
      BaseModule/EC.Onvif/RemoteDiscovery/Constants.cs
  22. 187
      BaseModule/EC.Onvif/RemoteDiscovery/Discovery.cs
  23. 33
      BaseModule/EC.Onvif/RemoteDiscovery/DiscoveryDevice.cs
  24. 25
      BaseModule/EC.Onvif/RemoteDiscovery/ExtensionMethods.cs
  25. 140
      BaseModule/EC.Onvif/RemoteDiscovery/OnvifUdpClient.cs
  26. 113
      BaseModule/EC.Onvif/RemoteDiscovery/XmlProbeReponse.cs
  27. 82
      BaseModule/EC.Onvif/Security/SoapSecurityHeader.cs
  28. 42
      BaseModule/EC.Onvif/Security/SoapSecurityHeaderBehavior.cs
  29. 32
      BaseModule/EC.Onvif/Security/SoapSecurityHeaderInspector.cs
  30. 42
      BusinessModule/EC.App.Entity/Base/DictBase.cs
  31. 11
      BusinessModule/EC.App.Entity/EC.App.Entity.csproj
  32. 9
      BusinessModule/EC.App.Entity/Onvif/OnvifClientDict.cs
  33. 13
      BusinessModule/EC.App.ThatBLL/EC.App.ThatBLL.csproj
  34. 50
      BusinessModule/EC.App.ThatBLL/Onvif/CurdBLL.cs
  35. 27
      BusinessModule/EC.App.ThatBLL/Onvif/DeviceBLL.cs
  36. 27
      BusinessModule/EC.App.ThatBLL/Onvif/ImagingBLL.cs
  37. 21
      BusinessModule/EC.App.ThatBLL/Onvif/Impl/ICurdBLL.cs
  38. 19
      BusinessModule/EC.App.ThatBLL/Onvif/Impl/IDeviceBLL.cs
  39. 19
      BusinessModule/EC.App.ThatBLL/Onvif/Impl/IImagingBLL.cs
  40. 19
      BusinessModule/EC.App.ThatBLL/Onvif/Impl/IMediaBLL.cs
  41. 61
      BusinessModule/EC.App.ThatBLL/Onvif/Impl/IPTZBLL.cs
  42. 27
      BusinessModule/EC.App.ThatBLL/Onvif/MediaBLL.cs
  43. 64
      BusinessModule/EC.App.ThatBLL/Onvif/PTZBLL.cs
  44. 13
      BusinessModule/EC.App.ThatService/EC.App.ThatService.csproj
  45. 9
      BusinessModule/EC.App.ThatService/Onvif/Impl/IOnvifClientService.cs
  46. 44
      BusinessModule/EC.App.ThatService/Onvif/OnvifClientService.cs
  47. 72
      OnvifServer-CSharp.sln
  48. 8
      OnvifSocketServer/OnvifSocketServer.csproj
  49. 12
      OnvifSocketServer/Program.cs
  50. 90
      OnvifWebServer/Controllers/Onvif/CurdController.cs
  51. 44
      OnvifWebServer/Controllers/Onvif/DeviceController.cs
  52. 44
      OnvifWebServer/Controllers/Onvif/ImagingController.cs
  53. 44
      OnvifWebServer/Controllers/Onvif/MediaController.cs
  54. 110
      OnvifWebServer/Controllers/Onvif/PTZController.cs
  55. 40
      OnvifWebServer/Controllers/Onvif/TestController.cs
  56. 103
      OnvifWebServer/Extensions/RESTfulResultProvider.cs
  57. 19
      OnvifWebServer/OnvifWebServer.csproj
  58. 22
      OnvifWebServer/Program.cs
  59. 29
      OnvifWebServer/Properties/launchSettings.json
  60. 48
      OnvifWebServer/Startup.cs
  61. 9
      OnvifWebServer/appsettings.Development.json
  62. 20
      OnvifWebServer/appsettings.json

11
BaseModule/EC.App/Core/ApiController.cs

@ -0,0 +1,11 @@
using Furion.DynamicApiController;
using Microsoft.AspNetCore.Mvc;
namespace EC.App.Core
{
[ApiDescriptionSettings(false)]
[NonController]
public class ApiController : IDynamicApiController
{
}
}

6
BaseModule/EC.App/Core/BLL.cs

@ -0,0 +1,6 @@
namespace EC.App.Core
{
public class BLL : IBLL
{
}
}

6
BaseModule/EC.App/Core/IBLL.cs

@ -0,0 +1,6 @@
namespace EC.App.Core
{
public interface IBLL
{
}
}

6
BaseModule/EC.App/Core/IService.cs

@ -0,0 +1,6 @@
namespace EC.App.Core
{
public interface IService
{
}
}

6
BaseModule/EC.App/Core/Service.cs

@ -0,0 +1,6 @@
namespace EC.App.Core
{
public class Service : IService
{
}
}

11
BaseModule/EC.App/EC.App.csproj

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Furion" Version="2.20.7" />
</ItemGroup>
</Project>

47
BaseModule/EC.Onvif/Camera/Camera.cs

@ -0,0 +1,47 @@
namespace EC.Onvif.Camera
{
public class Camera
{
public Camera()
{
}
public Camera(string cameraIp, int port, string userName, string passWord)
{
CameraCode = cameraIp;
CameraIp = cameraIp;
Port = port;
UserName = userName;
PassWord = passWord;
}
public string CameraCode { get; set; }
public string CameraIp { get; set; }
public int Port { get; set; }
public string UserName { get; set; }
public string PassWord { get; set; }
public int CameraType { get; set; }
public bool IsPtz { get; set; }
public string PTZUrl { get; set; }
/// <summary>
/// 是否登录
/// </summary>
public bool logined { get; set; }
public bool isConnected { get; set; }
public bool dataLoaded { get; set; }
public object device { get; set; }
public object media { get; set; }
public object ptz { get; set; }
public object imaging { get; set; }
public object caps { get; set; }
public bool absolute_move { get; set; }
public bool relative_move { get; set; }
public bool continuous_move { get; set; }
public bool focus { get; set; }
}
}

41
BaseModule/EC.Onvif/Camera/CameraManager.cs

@ -0,0 +1,41 @@
using System.Collections.Generic;
namespace EC.Onvif.Camera
{
public class CameraManager
{
private Dictionary<string, Camera> CameraList = new Dictionary<string, Camera>();
public bool Add(Camera camera)
{
if (CameraList.ContainsKey(camera.CameraCode))
{
return false;
}
else
{
CameraList.Add(camera.CameraCode, camera);
return true;
}
}
public Camera GetCameraByCode(string cameraCode)
{
if (CameraList.ContainsKey(cameraCode))
{
return CameraList[cameraCode];
}
return null;
}
public void Remove(Camera camera)
{
CameraList.Remove(camera.CameraCode);
}
public void Remove(string cameraCode)
{
CameraList.Remove(cameraCode);
}
}
}

22862
BaseModule/EC.Onvif/Common/DataTypes.cs

File diff suppressed because it is too large

1736
BaseModule/EC.Onvif/Device/DataTypes.cs

File diff suppressed because it is too large

2934
BaseModule/EC.Onvif/Device/DeviceClient.cs

File diff suppressed because it is too large

12
BaseModule/EC.Onvif/EC.Onvif.csproj

@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.ServiceModel.Http" Version="4.8.1" />
<PackageReference Include="System.ServiceModel.Security" Version="4.8.1" />
</ItemGroup>
</Project>

144
BaseModule/EC.Onvif/Imaging/DataTypes.cs

@ -0,0 +1,144 @@
namespace EC.Onvif.Imaging
{
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.3")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://www.onvif.org/ver20/imaging/wsdl")]
public partial class Capabilities
{
private System.Xml.Linq.XElement[] anyField;
private bool imageStabilizationField;
private bool imageStabilizationFieldSpecified;
private bool presetsField;
private bool presetsFieldSpecified;
/// <remarks/>
[System.Xml.Serialization.XmlAnyElementAttribute(Order = 0)]
public System.Xml.Linq.XElement[] Any
{
get
{
return this.anyField;
}
set
{
this.anyField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public bool ImageStabilization
{
get
{
return this.imageStabilizationField;
}
set
{
this.imageStabilizationField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool ImageStabilizationSpecified
{
get
{
return this.imageStabilizationFieldSpecified;
}
set
{
this.imageStabilizationFieldSpecified = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public bool Presets
{
get
{
return this.presetsField;
}
set
{
this.presetsField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool PresetsSpecified
{
get
{
return this.presetsFieldSpecified;
}
set
{
this.presetsFieldSpecified = value;
}
}
}
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.3")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://www.onvif.org/ver20/imaging/wsdl")]
public partial class ImagingPreset
{
private string nameField;
private string tokenField;
private string typeField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Order = 0)]
public string Name
{
get
{
return this.nameField;
}
set
{
this.nameField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string token
{
get
{
return this.tokenField;
}
set
{
this.tokenField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string type
{
get
{
return this.typeField;
}
set
{
this.typeField = value;
}
}
}
}

186
BaseModule/EC.Onvif/Imaging/ImagingClient.cs

@ -0,0 +1,186 @@
using EC.Onvif.Common;
namespace EC.Onvif.Imaging
{
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.3")]
[System.ServiceModel.ServiceContractAttribute(Namespace = "http://www.onvif.org/ver20/imaging/wsdl", ConfigurationName = "EC.Onvif.Imaging.Imaging")]
public interface Imaging
{
[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver20/imaging/wsdl/GetServiceCapabilities", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
[return: System.ServiceModel.MessageParameterAttribute(Name = "Capabilities")]
System.Threading.Tasks.Task<Common.Capabilities> GetServiceCapabilitiesAsync();
[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver20/imaging/wsdl/GetImagingSettings", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
[return: System.ServiceModel.MessageParameterAttribute(Name = "ImagingSettings")]
System.Threading.Tasks.Task<ImagingSettings20> GetImagingSettingsAsync(string VideoSourceToken);
[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver20/imaging/wsdl/SetImagingSettings", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
System.Threading.Tasks.Task SetImagingSettingsAsync(string VideoSourceToken, ImagingSettings20 ImagingSettings, bool ForcePersistence);
[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver20/imaging/wsdl/GetOptions", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
[return: System.ServiceModel.MessageParameterAttribute(Name = "ImagingOptions")]
System.Threading.Tasks.Task<ImagingOptions20> GetOptionsAsync(string VideoSourceToken);
[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver20/imaging/wsdl/Move", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
System.Threading.Tasks.Task MoveAsync(string VideoSourceToken, FocusMove Focus);
[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver20/imaging/wsdl/GetMoveOptions", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
[return: System.ServiceModel.MessageParameterAttribute(Name = "MoveOptions")]
System.Threading.Tasks.Task<MoveOptions20> GetMoveOptionsAsync(string VideoSourceToken);
[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver20/imaging/wsdl/FocusStop", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
System.Threading.Tasks.Task StopAsync(string VideoSourceToken);
[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver20/imaging/wsdl/GetStatus", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
[return: System.ServiceModel.MessageParameterAttribute(Name = "Status")]
System.Threading.Tasks.Task<ImagingStatus20> GetStatusAsync(string VideoSourceToken);
[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver20/imaging/wsdl/GetPresets", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
System.Threading.Tasks.Task<GetPresetsResponse> GetPresetsAsync(GetPresetsRequest request);
[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver20/imaging/wsdl/GetCurrentPreset", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
[return: System.ServiceModel.MessageParameterAttribute(Name = "Preset")]
System.Threading.Tasks.Task<ImagingPreset> GetCurrentPresetAsync(string VideoSourceToken);
[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver20/imaging/wsdl/SetCurrentPreset", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
System.Threading.Tasks.Task SetCurrentPresetAsync(string VideoSourceToken, string PresetToken);
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.3")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(WrapperName = "GetPresets", WrapperNamespace = "http://www.onvif.org/ver20/imaging/wsdl", IsWrapped = true)]
public partial class GetPresetsRequest
{
[System.ServiceModel.MessageBodyMemberAttribute(Namespace = "http://www.onvif.org/ver20/imaging/wsdl", Order = 0)]
public string VideoSourceToken;
public GetPresetsRequest()
{
}
public GetPresetsRequest(string VideoSourceToken)
{
this.VideoSourceToken = VideoSourceToken;
}
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.3")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(WrapperName = "GetPresetsResponse", WrapperNamespace = "http://www.onvif.org/ver20/imaging/wsdl", IsWrapped = true)]
public partial class GetPresetsResponse
{
[System.ServiceModel.MessageBodyMemberAttribute(Namespace = "http://www.onvif.org/ver20/imaging/wsdl", Order = 0)]
[System.Xml.Serialization.XmlElementAttribute("Preset")]
public ImagingPreset[] Preset;
public GetPresetsResponse()
{
}
public GetPresetsResponse(ImagingPreset[] Preset)
{
this.Preset = Preset;
}
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.3")]
public interface ImagingChannel : Imaging, System.ServiceModel.IClientChannel
{
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.3")]
public partial class ImagingClient : System.ServiceModel.ClientBase<Imaging>, Imaging
{
internal ImagingClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
base(binding, remoteAddress)
{
}
public System.Threading.Tasks.Task<Common.Capabilities> GetServiceCapabilitiesAsync()
{
return base.Channel.GetServiceCapabilitiesAsync();
}
public System.Threading.Tasks.Task<ImagingSettings20> GetImagingSettingsAsync(string VideoSourceToken)
{
return base.Channel.GetImagingSettingsAsync(VideoSourceToken);
}
public System.Threading.Tasks.Task SetImagingSettingsAsync(string VideoSourceToken, ImagingSettings20 ImagingSettings, bool ForcePersistence)
{
return base.Channel.SetImagingSettingsAsync(VideoSourceToken, ImagingSettings, ForcePersistence);
}
public System.Threading.Tasks.Task<ImagingOptions20> GetOptionsAsync(string VideoSourceToken)
{
return base.Channel.GetOptionsAsync(VideoSourceToken);
}
public System.Threading.Tasks.Task MoveAsync(string VideoSourceToken, FocusMove Focus)
{
return base.Channel.MoveAsync(VideoSourceToken, Focus);
}
public System.Threading.Tasks.Task<MoveOptions20> GetMoveOptionsAsync(string VideoSourceToken)
{
return base.Channel.GetMoveOptionsAsync(VideoSourceToken);
}
public System.Threading.Tasks.Task StopAsync(string VideoSourceToken)
{
return base.Channel.StopAsync(VideoSourceToken);
}
public System.Threading.Tasks.Task<ImagingStatus20> GetStatusAsync(string VideoSourceToken)
{
return base.Channel.GetStatusAsync(VideoSourceToken);
}
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
System.Threading.Tasks.Task<GetPresetsResponse> Imaging.GetPresetsAsync(GetPresetsRequest request)
{
return base.Channel.GetPresetsAsync(request);
}
public System.Threading.Tasks.Task<GetPresetsResponse> GetPresetsAsync(string VideoSourceToken)
{
GetPresetsRequest inValue = new GetPresetsRequest();
inValue.VideoSourceToken = VideoSourceToken;
return ((Imaging)(this)).GetPresetsAsync(inValue);
}
public System.Threading.Tasks.Task<ImagingPreset> GetCurrentPresetAsync(string VideoSourceToken)
{
return base.Channel.GetCurrentPresetAsync(VideoSourceToken);
}
public System.Threading.Tasks.Task SetCurrentPresetAsync(string VideoSourceToken, string PresetToken)
{
return base.Channel.SetCurrentPresetAsync(VideoSourceToken, PresetToken);
}
public virtual System.Threading.Tasks.Task OpenAsync()
{
return System.Threading.Tasks.Task.Factory.FromAsync(((System.ServiceModel.ICommunicationObject)(this)).BeginOpen(null, null), new System.Action<System.IAsyncResult>(((System.ServiceModel.ICommunicationObject)(this)).EndOpen));
}
public virtual System.Threading.Tasks.Task CloseAsync()
{
return System.Threading.Tasks.Task.Factory.FromAsync(((System.ServiceModel.ICommunicationObject)(this)).BeginClose(null, null), new System.Action<System.IAsyncResult>(((System.ServiceModel.ICommunicationObject)(this)).EndClose));
}
}
}

663
BaseModule/EC.Onvif/Media/DataTypes.cs

@ -0,0 +1,663 @@
using EC.Onvif.Common;
namespace EC.Onvif.Media
{
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.3")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://www.onvif.org/ver10/media/wsdl")]
public partial class Capabilities
{
private ProfileCapabilities profileCapabilitiesField;
private StreamingCapabilities streamingCapabilitiesField;
private System.Xml.Linq.XElement[] anyField;
private bool snapshotUriField;
private bool snapshotUriFieldSpecified;
private bool rotationField;
private bool rotationFieldSpecified;
private bool videoSourceModeField;
private bool videoSourceModeFieldSpecified;
private bool oSDField;
private bool oSDFieldSpecified;
private bool temporaryOSDTextField;
private bool temporaryOSDTextFieldSpecified;
private bool eXICompressionField;
private bool eXICompressionFieldSpecified;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Order = 0)]
public ProfileCapabilities ProfileCapabilities
{
get
{
return this.profileCapabilitiesField;
}
set
{
this.profileCapabilitiesField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Order = 1)]
public StreamingCapabilities StreamingCapabilities
{
get
{
return this.streamingCapabilitiesField;
}
set
{
this.streamingCapabilitiesField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAnyElementAttribute(Order = 2)]
public System.Xml.Linq.XElement[] Any
{
get
{
return this.anyField;
}
set
{
this.anyField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public bool SnapshotUri
{
get
{
return this.snapshotUriField;
}
set
{
this.snapshotUriField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool SnapshotUriSpecified
{
get
{
return this.snapshotUriFieldSpecified;
}
set
{
this.snapshotUriFieldSpecified = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public bool Rotation
{
get
{
return this.rotationField;
}
set
{
this.rotationField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool RotationSpecified
{
get
{
return this.rotationFieldSpecified;
}
set
{
this.rotationFieldSpecified = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public bool VideoSourceMode
{
get
{
return this.videoSourceModeField;
}
set
{
this.videoSourceModeField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool VideoSourceModeSpecified
{
get
{
return this.videoSourceModeFieldSpecified;
}
set
{
this.videoSourceModeFieldSpecified = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public bool OSD
{
get
{
return this.oSDField;
}
set
{
this.oSDField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool OSDSpecified
{
get
{
return this.oSDFieldSpecified;
}
set
{
this.oSDFieldSpecified = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public bool TemporaryOSDText
{
get
{
return this.temporaryOSDTextField;
}
set
{
this.temporaryOSDTextField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool TemporaryOSDTextSpecified
{
get
{
return this.temporaryOSDTextFieldSpecified;
}
set
{
this.temporaryOSDTextFieldSpecified = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public bool EXICompression
{
get
{
return this.eXICompressionField;
}
set
{
this.eXICompressionField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool EXICompressionSpecified
{
get
{
return this.eXICompressionFieldSpecified;
}
set
{
this.eXICompressionFieldSpecified = value;
}
}
}
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.3")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://www.onvif.org/ver10/media/wsdl")]
public partial class ProfileCapabilities
{
private System.Xml.Linq.XElement[] anyField;
private int maximumNumberOfProfilesField;
private bool maximumNumberOfProfilesFieldSpecified;
/// <remarks/>
[System.Xml.Serialization.XmlAnyElementAttribute(Order = 0)]
public System.Xml.Linq.XElement[] Any
{
get
{
return this.anyField;
}
set
{
this.anyField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public int MaximumNumberOfProfiles
{
get
{
return this.maximumNumberOfProfilesField;
}
set
{
this.maximumNumberOfProfilesField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool MaximumNumberOfProfilesSpecified
{
get
{
return this.maximumNumberOfProfilesFieldSpecified;
}
set
{
this.maximumNumberOfProfilesFieldSpecified = value;
}
}
}
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.3")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://www.onvif.org/ver10/media/wsdl")]
public partial class VideoSourceModeExtension
{
private System.Xml.Linq.XElement[] anyField;
/// <remarks/>
[System.Xml.Serialization.XmlAnyElementAttribute(Order = 0)]
public System.Xml.Linq.XElement[] Any
{
get
{
return this.anyField;
}
set
{
this.anyField = value;
}
}
}
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.3")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://www.onvif.org/ver10/media/wsdl")]
public partial class VideoSourceMode
{
private float maxFramerateField;
private VideoResolution maxResolutionField;
private string encodingsField;
private bool rebootField;
private string descriptionField;
private VideoSourceModeExtension extensionField;
private string tokenField;
private bool enabledField;
private bool enabledFieldSpecified;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Order = 0)]
public float MaxFramerate
{
get
{
return this.maxFramerateField;
}
set
{
this.maxFramerateField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Order = 1)]
public VideoResolution MaxResolution
{
get
{
return this.maxResolutionField;
}
set
{
this.maxResolutionField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Order = 2)]
public string Encodings
{
get
{
return this.encodingsField;
}
set
{
this.encodingsField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Order = 3)]
public bool Reboot
{
get
{
return this.rebootField;
}
set
{
this.rebootField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Order = 4)]
public string Description
{
get
{
return this.descriptionField;
}
set
{
this.descriptionField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Order = 5)]
public VideoSourceModeExtension Extension
{
get
{
return this.extensionField;
}
set
{
this.extensionField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string token
{
get
{
return this.tokenField;
}
set
{
this.tokenField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public bool Enabled
{
get
{
return this.enabledField;
}
set
{
this.enabledField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool EnabledSpecified
{
get
{
return this.enabledFieldSpecified;
}
set
{
this.enabledFieldSpecified = value;
}
}
}
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.3")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://www.onvif.org/ver10/media/wsdl")]
public partial class StreamingCapabilities
{
private System.Xml.Linq.XElement[] anyField;
private bool rTPMulticastField;
private bool rTPMulticastFieldSpecified;
private bool rTP_TCPField;
private bool rTP_TCPFieldSpecified;
private bool rTP_RTSP_TCPField;
private bool rTP_RTSP_TCPFieldSpecified;
private bool nonAggregateControlField;
private bool nonAggregateControlFieldSpecified;
private bool noRTSPStreamingField;
private bool noRTSPStreamingFieldSpecified;
/// <remarks/>
[System.Xml.Serialization.XmlAnyElementAttribute(Order = 0)]
public System.Xml.Linq.XElement[] Any
{
get
{
return this.anyField;
}
set
{
this.anyField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public bool RTPMulticast
{
get
{
return this.rTPMulticastField;
}
set
{
this.rTPMulticastField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool RTPMulticastSpecified
{
get
{
return this.rTPMulticastFieldSpecified;
}
set
{
this.rTPMulticastFieldSpecified = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public bool RTP_TCP
{
get
{
return this.rTP_TCPField;
}
set
{
this.rTP_TCPField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool RTP_TCPSpecified
{
get
{
return this.rTP_TCPFieldSpecified;
}
set
{
this.rTP_TCPFieldSpecified = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public bool RTP_RTSP_TCP
{
get
{
return this.rTP_RTSP_TCPField;
}
set
{
this.rTP_RTSP_TCPField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool RTP_RTSP_TCPSpecified
{
get
{
return this.rTP_RTSP_TCPFieldSpecified;
}
set
{
this.rTP_RTSP_TCPFieldSpecified = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public bool NonAggregateControl
{
get
{
return this.nonAggregateControlField;
}
set
{
this.nonAggregateControlField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool NonAggregateControlSpecified
{
get
{
return this.nonAggregateControlFieldSpecified;
}
set
{
this.nonAggregateControlFieldSpecified = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public bool NoRTSPStreaming
{
get
{
return this.noRTSPStreamingField;
}
set
{
this.noRTSPStreamingField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool NoRTSPStreamingSpecified
{
get
{
return this.noRTSPStreamingFieldSpecified;
}
set
{
this.noRTSPStreamingFieldSpecified = value;
}
}
}
}

2126
BaseModule/EC.Onvif/Media/MediaClient.cs

File diff suppressed because it is too large

191
BaseModule/EC.Onvif/OnvifClient.cs

@ -0,0 +1,191 @@
using EC.Onvif.Common;
using EC.Onvif.Device;
using EC.Onvif.Imaging;
using EC.Onvif.Media;
using EC.Onvif.PTZ;
using System;
using System.Threading.Tasks;
using Capabilities = EC.Onvif.Common.Capabilities;
namespace EC.Onvif
{
public class OnvifClient
{
#region Attr
private string Hostname { get; set; }
private string Username { get; set; }
private string Password { get; set; }
public static float atomDist { get; set; } = 0.01f;
public static float atomSpeed { get; set; } = 0.1f;
#endregion Attr
#region Client Attr
private DeviceClient Device { get; set; }
private MediaClient Media { get; set; }
private PTZClient PTZ { get; set; }
private ImagingClient Imaging { get; set; }
private Capabilities Caps { get; set; }
private string profileToken { get; set; }
#endregion Client Attr
public OnvifClient(string hostname, string username, string password)
{
Hostname = hostname;
Username = username;
Password = password;
}
public async Task InitAsync()
{
try
{
Device = await OnvifClientFactory.CreateDeviceClientAsync(Hostname, Username, Password);
Media = await OnvifClientFactory.CreateMediaClientAsync(Hostname, Username, Password);
PTZ = await OnvifClientFactory.CreatePTZClientAsync(Hostname, Username, Password);
var profiles = await Media.GetProfilesAsync();
foreach (var profile in profiles.Profiles)
{
if (string.IsNullOrEmpty(profileToken))
{
profileToken = profile.token;
break;
}
}
Caps = (await Device.GetCapabilitiesAsync(new CapabilityCategory[] { CapabilityCategory.All })).Capabilities;
}
catch (Exception)
{
throw;
}
}
#region DeviceClient
public bool IsDeviceContected()
{
return Device != null;
}
#endregion DeviceClient
#region MediaClient
public bool IsMediaContected()
{
var r = IsDeviceContected();
return r;
}
#endregion MediaClient
#region PTZClient
public bool IsPTZContected()
{
var r = IsDeviceContected() && (PTZ != null) && !string.IsNullOrEmpty(profileToken);
return r;
}
/// <summary>
/// 绝对移动
/// </summary>
/// <param name="pan"></param>
/// <param name="tilt"></param>
/// <param name="zoom"></param>
/// <returns></returns>
public async Task AbsoluteMoveAsync(float pan, float tilt, float zoom)
{
await PTZ.AbsoluteMoveAsync(profileToken, new PTZVector
{
PanTilt = new Vector2D
{
x = pan,
y = tilt
},
Zoom = new Vector1D
{
x = zoom
}
}, null);
}
/// <summary>
/// 相对移动
/// </summary>
/// <param name="pan"></param>
/// <param name="tilt"></param>
/// <param name="zoom"></param>
public async Task RelativeMoveAsync(float pan, float tilt, float zoom)
{
await PTZ.RelativeMoveAsync(profileToken, new PTZVector
{
PanTilt = new Vector2D
{
x = pan,
y = tilt
},
Zoom = new Vector1D
{
x = zoom
}
}, null);
}
/// <summary>
/// 持续移动
/// </summary>
/// <param name="pan">0~100</param>
/// <param name="tilt">0~100</param>
/// <param name="zoom">0~100</param>
public async Task ContinuousMoveAsync(float pan, float tilt, float zoom)
{
await PTZ.ContinuousMoveAsync(profileToken, new PTZSpeed
{
PanTilt = new Vector2D
{
x = pan,
y = tilt
},
Zoom = new Vector1D
{
x = zoom
}
}, null);
}
public async Task StopMoveAsync()
{
await PTZ.StopAsync(profileToken, true, true);
}
public async Task<PTZStatus> GetStatusAsync()
{
return await PTZ.GetStatusAsync(profileToken);
}
#endregion PTZClient
#region ImagingClient
public bool IsImagingContected()
{
var r = IsDeviceContected();
return r;
}
#endregion ImagingClient
}
}

117
BaseModule/EC.Onvif/OnvifClientFactory.cs

@ -0,0 +1,117 @@
using EC.Onvif.Common;
using EC.Onvif.Device;
using EC.Onvif.Imaging;
using EC.Onvif.Media;
using EC.Onvif.PTZ;
using EC.Onvif.Security;
using System;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.Threading.Tasks;
namespace EC.Onvif
{
public static class OnvifClientFactory
{
private static Binding CreateBinding()
{
var binding = new CustomBinding();
var textBindingElement = new TextMessageEncodingBindingElement
{
MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.None)
};
var httpBindingElement = new HttpTransportBindingElement
{
AllowCookies = true,
MaxBufferSize = int.MaxValue,
MaxReceivedMessageSize = int.MaxValue
};
binding.Elements.Add(textBindingElement);
binding.Elements.Add(httpBindingElement);
return binding;
}
public static async Task<DeviceClient> CreateDeviceClientAsync(string host, string username, string password)
{
return await CreateDeviceClientAsync(new Uri($"http://{host}/onvif/device_service"), username, password);
}
public static async Task<DeviceClient> CreateDeviceClientAsync(Uri uri, string username, string password)
{
var binding = CreateBinding();
var endpoint = new EndpointAddress(uri);
var device = new DeviceClient(binding, endpoint);
var time_shift = await GetDeviceTimeShift(device);
device = new DeviceClient(binding, endpoint);
device.ChannelFactory.Endpoint.EndpointBehaviors.Clear();
device.ChannelFactory.Endpoint.EndpointBehaviors.Add(new SoapSecurityHeaderBehavior(username, password, time_shift));
// Connectivity Test
await device.OpenAsync();
return device;
}
public static async Task<MediaClient> CreateMediaClientAsync(string host, string username, string password)
{
var binding = CreateBinding();
var device = await CreateDeviceClientAsync(host, username, password);
var caps = await device.GetCapabilitiesAsync(new CapabilityCategory[] { CapabilityCategory.Media });
var media = new MediaClient(binding, new EndpointAddress(new Uri(caps.Capabilities.Media.XAddr)));
var time_shift = await GetDeviceTimeShift(device);
media.ChannelFactory.Endpoint.EndpointBehaviors.Clear();
media.ChannelFactory.Endpoint.EndpointBehaviors.Add(new SoapSecurityHeaderBehavior(username, password, time_shift));
// Connectivity Test
await media.OpenAsync();
return media;
}
public static async Task<PTZClient> CreatePTZClientAsync(string host, string username, string password)
{
var binding = CreateBinding();
var device = await CreateDeviceClientAsync(host, username, password);
var caps = await device.GetCapabilitiesAsync(new CapabilityCategory[] { CapabilityCategory.PTZ });
var ptz = new PTZClient(binding, new EndpointAddress(new Uri(caps.Capabilities.PTZ.XAddr)));
var time_shift = await GetDeviceTimeShift(device);
ptz.ChannelFactory.Endpoint.EndpointBehaviors.Clear();
ptz.ChannelFactory.Endpoint.EndpointBehaviors.Add(new SoapSecurityHeaderBehavior(username, password, time_shift));
// Connectivity Test
await ptz.OpenAsync();
return ptz;
}
public static async Task<ImagingClient> CreateImagingClientAsync(string host, string username, string password)
{
var binding = CreateBinding();
var device = await CreateDeviceClientAsync(host, username, password);
var caps = await device.GetCapabilitiesAsync(new CapabilityCategory[] { CapabilityCategory.Imaging });
var imaging = new ImagingClient(binding, new EndpointAddress(new Uri(caps.Capabilities.Imaging.XAddr)));
var time_shift = await GetDeviceTimeShift(device);
imaging.ChannelFactory.Endpoint.EndpointBehaviors.Clear();
imaging.ChannelFactory.Endpoint.EndpointBehaviors.Add(new SoapSecurityHeaderBehavior(username, password, time_shift));
// Connectivity Test
await imaging.OpenAsync();
return imaging;
}
private static async Task<TimeSpan> GetDeviceTimeShift(DeviceClient device)
{
var utc = (await device.GetSystemDateAndTimeAsync()).UTCDateTime;
var dt = new System.DateTime(utc.Date.Year, utc.Date.Month, utc.Date.Day,
utc.Time.Hour, utc.Time.Minute, utc.Time.Second);
return dt - System.DateTime.UtcNow;
}
}
}

185
BaseModule/EC.Onvif/PTZ/DataTypes.cs

@ -0,0 +1,185 @@
namespace EC.Onvif.PTZ
{
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.3")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://www.onvif.org/ver20/ptz/wsdl")]
public partial class Capabilities
{
private System.Xml.Linq.XElement[] anyField;
private bool eFlipField;
private bool eFlipFieldSpecified;
private bool reverseField;
private bool reverseFieldSpecified;
private bool getCompatibleConfigurationsField;
private bool getCompatibleConfigurationsFieldSpecified;
private bool moveStatusField;
private bool moveStatusFieldSpecified;
private bool statusPositionField;
private bool statusPositionFieldSpecified;
/// <remarks/>
[System.Xml.Serialization.XmlAnyElementAttribute(Order = 0)]
public System.Xml.Linq.XElement[] Any
{
get
{
return this.anyField;
}
set
{
this.anyField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public bool EFlip
{
get
{
return this.eFlipField;
}
set
{
this.eFlipField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool EFlipSpecified
{
get
{
return this.eFlipFieldSpecified;
}
set
{
this.eFlipFieldSpecified = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public bool Reverse
{
get
{
return this.reverseField;
}
set
{
this.reverseField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool ReverseSpecified
{
get
{
return this.reverseFieldSpecified;
}
set
{
this.reverseFieldSpecified = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public bool GetCompatibleConfigurations
{
get
{
return this.getCompatibleConfigurationsField;
}
set
{
this.getCompatibleConfigurationsField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool GetCompatibleConfigurationsSpecified
{
get
{
return this.getCompatibleConfigurationsFieldSpecified;
}
set
{
this.getCompatibleConfigurationsFieldSpecified = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public bool MoveStatus
{
get
{
return this.moveStatusField;
}
set
{
this.moveStatusField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool MoveStatusSpecified
{
get
{
return this.moveStatusFieldSpecified;
}
set
{
this.moveStatusFieldSpecified = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public bool StatusPosition
{
get
{
return this.statusPositionField;
}
set
{
this.statusPositionField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool StatusPositionSpecified
{
get
{
return this.statusPositionFieldSpecified;
}
set
{
this.statusPositionFieldSpecified = value;
}
}
}
}

662
BaseModule/EC.Onvif/PTZ/PTZClient.cs

@ -0,0 +1,662 @@
using EC.Onvif.Common;
namespace EC.Onvif.PTZ
{
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.3")]
[System.ServiceModel.ServiceContractAttribute(Namespace = "http://www.onvif.org/ver20/ptz/wsdl", ConfigurationName = "EC.Onvif.PTZ.PTZ")]
public interface PTZ
{
[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver20/ptz/wsdl/GetServiceCapabilities", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(ConfigurationEntity))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(DeviceEntity))]
[return: System.ServiceModel.MessageParameterAttribute(Name = "Capabilities")]
System.Threading.Tasks.Task<Capabilities> GetServiceCapabilitiesAsync();
[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver20/ptz/wsdl/GetNodes", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(ConfigurationEntity))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(DeviceEntity))]
System.Threading.Tasks.Task<GetNodesResponse> GetNodesAsync(GetNodesRequest request);
[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver20/ptz/wsdl/GetNode", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(ConfigurationEntity))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(DeviceEntity))]
[return: System.ServiceModel.MessageParameterAttribute(Name = "PTZNode")]
System.Threading.Tasks.Task<PTZNode> GetNodeAsync(string NodeToken);
[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver20/ptz/wsdl/GetConfiguration", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(ConfigurationEntity))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(DeviceEntity))]
[return: System.ServiceModel.MessageParameterAttribute(Name = "PTZConfiguration")]
System.Threading.Tasks.Task<PTZConfiguration> GetConfigurationAsync(string PTZConfigurationToken);
[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver20/ptz/wsdl/GetConfigurations", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(ConfigurationEntity))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(DeviceEntity))]
System.Threading.Tasks.Task<GetConfigurationsResponse> GetConfigurationsAsync(GetConfigurationsRequest request);
[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver20/ptz/wsdl/SetConfiguration", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(ConfigurationEntity))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(DeviceEntity))]
System.Threading.Tasks.Task SetConfigurationAsync(PTZConfiguration PTZConfiguration, bool ForcePersistence);
[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver20/ptz/wsdl/GetConfigurationOptions", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(ConfigurationEntity))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(DeviceEntity))]
[return: System.ServiceModel.MessageParameterAttribute(Name = "PTZConfigurationOptions")]
System.Threading.Tasks.Task<PTZConfigurationOptions> GetConfigurationOptionsAsync(string ConfigurationToken);
[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver20/ptz/wsdl/SendAuxiliaryCommand", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(ConfigurationEntity))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(DeviceEntity))]
[return: System.ServiceModel.MessageParameterAttribute(Name = "AuxiliaryResponse")]
System.Threading.Tasks.Task<string> SendAuxiliaryCommandAsync(string ProfileToken, string AuxiliaryData);
[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver20/ptz/wsdl/GetPresets", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(ConfigurationEntity))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(DeviceEntity))]
System.Threading.Tasks.Task<GetPresetsResponse> GetPresetsAsync(GetPresetsRequest request);
// CODEGEN: Generating message contract since the operation has multiple return values.
[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver20/ptz/wsdl/SetPreset", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(ConfigurationEntity))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(DeviceEntity))]
System.Threading.Tasks.Task<SetPresetResponse> SetPresetAsync(SetPresetRequest request);
[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver20/ptz/wsdl/RemovePreset", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(ConfigurationEntity))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(DeviceEntity))]
System.Threading.Tasks.Task RemovePresetAsync(string ProfileToken, string PresetToken);
[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver20/ptz/wsdl/GotoPreset", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(ConfigurationEntity))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(DeviceEntity))]
System.Threading.Tasks.Task GotoPresetAsync(string ProfileToken, string PresetToken, PTZSpeed Speed);
[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver20/ptz/wsdl/GotoHomePosition", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(ConfigurationEntity))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(DeviceEntity))]
System.Threading.Tasks.Task GotoHomePositionAsync(string ProfileToken, PTZSpeed Speed);
[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver20/ptz/wsdl/SetHomePosition", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(ConfigurationEntity))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(DeviceEntity))]
System.Threading.Tasks.Task SetHomePositionAsync(string ProfileToken);
[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver20/ptz/wsdl/ContinuousMove", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(ConfigurationEntity))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(DeviceEntity))]
System.Threading.Tasks.Task<ContinuousMoveResponse> ContinuousMoveAsync(ContinuousMoveRequest request);
[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver20/ptz/wsdl/RelativeMove", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(ConfigurationEntity))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(DeviceEntity))]
System.Threading.Tasks.Task RelativeMoveAsync(string ProfileToken, PTZVector Translation, PTZSpeed Speed);
[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver20/ptz/wsdl/GetStatus", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(ConfigurationEntity))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(DeviceEntity))]
[return: System.ServiceModel.MessageParameterAttribute(Name = "PTZStatus")]
System.Threading.Tasks.Task<PTZStatus> GetStatusAsync(string ProfileToken);
[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver20/ptz/wsdl/AbsoluteMove", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(ConfigurationEntity))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(DeviceEntity))]
System.Threading.Tasks.Task AbsoluteMoveAsync(string ProfileToken, PTZVector Position, PTZSpeed Speed);
[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver20/ptz/wsdl/GeoMove", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(ConfigurationEntity))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(DeviceEntity))]
System.Threading.Tasks.Task GeoMoveAsync(string ProfileToken, GeoLocation Target, PTZSpeed Speed, float AreaHeight, float AreaWidth);
[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver20/ptz/wsdl/Stop", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(ConfigurationEntity))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(DeviceEntity))]
System.Threading.Tasks.Task StopAsync(string ProfileToken, bool PanTilt, bool Zoom);
[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver20/ptz/wsdl/GetPresetTours", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(ConfigurationEntity))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(DeviceEntity))]
System.Threading.Tasks.Task<GetPresetToursResponse> GetPresetToursAsync(GetPresetToursRequest request);
[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver20/ptz/wsdl/GetPresetTour", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(ConfigurationEntity))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(DeviceEntity))]
[return: System.ServiceModel.MessageParameterAttribute(Name = "PresetTour")]
System.Threading.Tasks.Task<PresetTour> GetPresetTourAsync(string ProfileToken, string PresetTourToken);
[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver20/ptz/wsdl/GetPresetTourOptions", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(ConfigurationEntity))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(DeviceEntity))]
[return: System.ServiceModel.MessageParameterAttribute(Name = "Options")]
System.Threading.Tasks.Task<PTZPresetTourOptions> GetPresetTourOptionsAsync(string ProfileToken, string PresetTourToken);
[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver20/ptz/wsdl/CreatePresetTour", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(ConfigurationEntity))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(DeviceEntity))]
[return: System.ServiceModel.MessageParameterAttribute(Name = "PresetTourToken")]
System.Threading.Tasks.Task<string> CreatePresetTourAsync(string ProfileToken);
[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver20/ptz/wsdl/ModifyPresetTour", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(ConfigurationEntity))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(DeviceEntity))]
System.Threading.Tasks.Task ModifyPresetTourAsync(string ProfileToken, PresetTour PresetTour);
[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver20/ptz/wsdl/OperatePresetTour", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(ConfigurationEntity))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(DeviceEntity))]
System.Threading.Tasks.Task OperatePresetTourAsync(string ProfileToken, string PresetTourToken, PTZPresetTourOperation Operation);
[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver20/ptz/wsdl/RemovePresetTour", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(ConfigurationEntity))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(DeviceEntity))]
System.Threading.Tasks.Task RemovePresetTourAsync(string ProfileToken, string PresetTourToken);
[System.ServiceModel.OperationContractAttribute(Action = "http://www.onvif.org/ver20/ptz/wsdl/GetCompatibleConfigurations", ReplyAction = "*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(ConfigurationEntity))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(DeviceEntity))]
System.Threading.Tasks.Task<GetCompatibleConfigurationsResponse> GetCompatibleConfigurationsAsync(GetCompatibleConfigurationsRequest request);
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.3")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(WrapperName = "GetNodes", WrapperNamespace = "http://www.onvif.org/ver20/ptz/wsdl", IsWrapped = true)]
public partial class GetNodesRequest
{
public GetNodesRequest()
{
}
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.3")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(WrapperName = "GetNodesResponse", WrapperNamespace = "http://www.onvif.org/ver20/ptz/wsdl", IsWrapped = true)]
public partial class GetNodesResponse
{
[System.ServiceModel.MessageBodyMemberAttribute(Namespace = "http://www.onvif.org/ver20/ptz/wsdl", Order = 0)]
[System.Xml.Serialization.XmlElementAttribute("PTZNode")]
public PTZNode[] PTZNode;
public GetNodesResponse()
{
}
public GetNodesResponse(PTZNode[] PTZNode)
{
this.PTZNode = PTZNode;
}
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.3")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(WrapperName = "GetConfigurations", WrapperNamespace = "http://www.onvif.org/ver20/ptz/wsdl", IsWrapped = true)]
public partial class GetConfigurationsRequest
{
public GetConfigurationsRequest()
{
}
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.3")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(WrapperName = "GetConfigurationsResponse", WrapperNamespace = "http://www.onvif.org/ver20/ptz/wsdl", IsWrapped = true)]
public partial class GetConfigurationsResponse
{
[System.ServiceModel.MessageBodyMemberAttribute(Namespace = "http://www.onvif.org/ver20/ptz/wsdl", Order = 0)]
[System.Xml.Serialization.XmlElementAttribute("PTZConfiguration")]
public PTZConfiguration[] PTZConfiguration;
public GetConfigurationsResponse()
{
}
public GetConfigurationsResponse(PTZConfiguration[] PTZConfiguration)
{
this.PTZConfiguration = PTZConfiguration;
}
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.3")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(WrapperName = "GetPresets", WrapperNamespace = "http://www.onvif.org/ver20/ptz/wsdl", IsWrapped = true)]
public partial class GetPresetsRequest
{
[System.ServiceModel.MessageBodyMemberAttribute(Namespace = "http://www.onvif.org/ver20/ptz/wsdl", Order = 0)]
public string ProfileToken;
public GetPresetsRequest()
{
}
public GetPresetsRequest(string ProfileToken)
{
this.ProfileToken = ProfileToken;
}
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.3")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(WrapperName = "GetPresetsResponse", WrapperNamespace = "http://www.onvif.org/ver20/ptz/wsdl", IsWrapped = true)]
public partial class GetPresetsResponse
{
[System.ServiceModel.MessageBodyMemberAttribute(Namespace = "http://www.onvif.org/ver20/ptz/wsdl", Order = 0)]
[System.Xml.Serialization.XmlElementAttribute("Preset")]
public PTZPreset[] Preset;
public GetPresetsResponse()
{
}
public GetPresetsResponse(PTZPreset[] Preset)
{
this.Preset = Preset;
}
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.3")]
[System.ServiceModel.MessageContractAttribute(WrapperName = "SetPreset", WrapperNamespace = "http://www.onvif.org/ver20/ptz/wsdl", IsWrapped = true)]
public partial class SetPresetRequest
{
[System.ServiceModel.MessageBodyMemberAttribute(Namespace = "http://www.onvif.org/ver20/ptz/wsdl", Order = 0)]
public string ProfileToken;
[System.ServiceModel.MessageBodyMemberAttribute(Namespace = "http://www.onvif.org/ver20/ptz/wsdl", Order = 1)]
public string PresetName;
[System.ServiceModel.MessageBodyMemberAttribute(Namespace = "http://www.onvif.org/ver20/ptz/wsdl", Order = 2)]
public string PresetToken;
public SetPresetRequest()
{
}
public SetPresetRequest(string ProfileToken, string PresetName, string PresetToken)
{
this.ProfileToken = ProfileToken;
this.PresetName = PresetName;
this.PresetToken = PresetToken;
}
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.3")]
[System.ServiceModel.MessageContractAttribute(WrapperName = "SetPresetResponse", WrapperNamespace = "http://www.onvif.org/ver20/ptz/wsdl", IsWrapped = true)]
public partial class SetPresetResponse
{
[System.ServiceModel.MessageBodyMemberAttribute(Namespace = "http://www.onvif.org/ver20/ptz/wsdl", Order = 0)]
public string PresetToken;
public SetPresetResponse()
{
}
public SetPresetResponse(string PresetToken)
{
this.PresetToken = PresetToken;
}
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.3")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(WrapperName = "ContinuousMove", WrapperNamespace = "http://www.onvif.org/ver20/ptz/wsdl", IsWrapped = true)]
public partial class ContinuousMoveRequest
{
[System.ServiceModel.MessageBodyMemberAttribute(Namespace = "http://www.onvif.org/ver20/ptz/wsdl", Order = 0)]
public string ProfileToken;
[System.ServiceModel.MessageBodyMemberAttribute(Namespace = "http://www.onvif.org/ver20/ptz/wsdl", Order = 1)]
public PTZSpeed Velocity;
[System.ServiceModel.MessageBodyMemberAttribute(Namespace = "http://www.onvif.org/ver20/ptz/wsdl", Order = 2)]
[System.Xml.Serialization.XmlElementAttribute(DataType = "duration")]
public string Timeout;
public ContinuousMoveRequest()
{
}
public ContinuousMoveRequest(string ProfileToken, PTZSpeed Velocity, string Timeout)
{
this.ProfileToken = ProfileToken;
this.Velocity = Velocity;
this.Timeout = Timeout;
}
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.3")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(WrapperName = "ContinuousMoveResponse", WrapperNamespace = "http://www.onvif.org/ver20/ptz/wsdl", IsWrapped = true)]
public partial class ContinuousMoveResponse
{
public ContinuousMoveResponse()
{
}
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.3")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(WrapperName = "GetPresetTours", WrapperNamespace = "http://www.onvif.org/ver20/ptz/wsdl", IsWrapped = true)]
public partial class GetPresetToursRequest
{
[System.ServiceModel.MessageBodyMemberAttribute(Namespace = "http://www.onvif.org/ver20/ptz/wsdl", Order = 0)]
public string ProfileToken;
public GetPresetToursRequest()
{
}
public GetPresetToursRequest(string ProfileToken)
{
this.ProfileToken = ProfileToken;
}
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.3")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(WrapperName = "GetPresetToursResponse", WrapperNamespace = "http://www.onvif.org/ver20/ptz/wsdl", IsWrapped = true)]
public partial class GetPresetToursResponse
{
[System.ServiceModel.MessageBodyMemberAttribute(Namespace = "http://www.onvif.org/ver20/ptz/wsdl", Order = 0)]
[System.Xml.Serialization.XmlElementAttribute("PresetTour")]
public PresetTour[] PresetTour;
public GetPresetToursResponse()
{
}
public GetPresetToursResponse(PresetTour[] PresetTour)
{
this.PresetTour = PresetTour;
}
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.3")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(WrapperName = "GetCompatibleConfigurations", WrapperNamespace = "http://www.onvif.org/ver20/ptz/wsdl", IsWrapped = true)]
public partial class GetCompatibleConfigurationsRequest
{
[System.ServiceModel.MessageBodyMemberAttribute(Namespace = "http://www.onvif.org/ver20/ptz/wsdl", Order = 0)]
public string ProfileToken;
public GetCompatibleConfigurationsRequest()
{
}
public GetCompatibleConfigurationsRequest(string ProfileToken)
{
this.ProfileToken = ProfileToken;
}
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.3")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(WrapperName = "GetCompatibleConfigurationsResponse", WrapperNamespace = "http://www.onvif.org/ver20/ptz/wsdl", IsWrapped = true)]
public partial class GetCompatibleConfigurationsResponse
{
[System.ServiceModel.MessageBodyMemberAttribute(Namespace = "http://www.onvif.org/ver20/ptz/wsdl", Order = 0)]
[System.Xml.Serialization.XmlElementAttribute("PTZConfiguration")]
public PTZConfiguration[] PTZConfiguration;
public GetCompatibleConfigurationsResponse()
{
}
public GetCompatibleConfigurationsResponse(PTZConfiguration[] PTZConfiguration)
{
this.PTZConfiguration = PTZConfiguration;
}
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.3")]
public interface PTZChannel : PTZ, System.ServiceModel.IClientChannel
{
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.3")]
public partial class PTZClient : System.ServiceModel.ClientBase<PTZ>, PTZ
{
internal PTZClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
base(binding, remoteAddress)
{
}
public System.Threading.Tasks.Task<Capabilities> GetServiceCapabilitiesAsync()
{
return base.Channel.GetServiceCapabilitiesAsync();
}
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
System.Threading.Tasks.Task<GetNodesResponse> PTZ.GetNodesAsync(GetNodesRequest request)
{
return base.Channel.GetNodesAsync(request);
}
public System.Threading.Tasks.Task<GetNodesResponse> GetNodesAsync()
{
GetNodesRequest inValue = new GetNodesRequest();
return ((PTZ)(this)).GetNodesAsync(inValue);
}
public System.Threading.Tasks.Task<PTZNode> GetNodeAsync(string NodeToken)
{
return base.Channel.GetNodeAsync(NodeToken);
}
public System.Threading.Tasks.Task<PTZConfiguration> GetConfigurationAsync(string PTZConfigurationToken)
{
return base.Channel.GetConfigurationAsync(PTZConfigurationToken);
}
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
System.Threading.Tasks.Task<GetConfigurationsResponse> PTZ.GetConfigurationsAsync(GetConfigurationsRequest request)
{
return base.Channel.GetConfigurationsAsync(request);
}
public System.Threading.Tasks.Task<GetConfigurationsResponse> GetConfigurationsAsync()
{
GetConfigurationsRequest inValue = new GetConfigurationsRequest();
return ((PTZ)(this)).GetConfigurationsAsync(inValue);
}
public System.Threading.Tasks.Task SetConfigurationAsync(PTZConfiguration PTZConfiguration, bool ForcePersistence)
{
return base.Channel.SetConfigurationAsync(PTZConfiguration, ForcePersistence);
}
public System.Threading.Tasks.Task<PTZConfigurationOptions> GetConfigurationOptionsAsync(string ConfigurationToken)
{
return base.Channel.GetConfigurationOptionsAsync(ConfigurationToken);
}
public System.Threading.Tasks.Task<string> SendAuxiliaryCommandAsync(string ProfileToken, string AuxiliaryData)
{
return base.Channel.SendAuxiliaryCommandAsync(ProfileToken, AuxiliaryData);
}
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
System.Threading.Tasks.Task<GetPresetsResponse> PTZ.GetPresetsAsync(GetPresetsRequest request)
{
return base.Channel.GetPresetsAsync(request);
}
public System.Threading.Tasks.Task<GetPresetsResponse> GetPresetsAsync(string ProfileToken)
{
GetPresetsRequest inValue = new GetPresetsRequest();
inValue.ProfileToken = ProfileToken;
return ((PTZ)(this)).GetPresetsAsync(inValue);
}
public System.Threading.Tasks.Task<SetPresetResponse> SetPresetAsync(SetPresetRequest request)
{
return base.Channel.SetPresetAsync(request);
}
public System.Threading.Tasks.Task RemovePresetAsync(string ProfileToken, string PresetToken)
{
return base.Channel.RemovePresetAsync(ProfileToken, PresetToken);
}
public System.Threading.Tasks.Task GotoPresetAsync(string ProfileToken, string PresetToken, PTZSpeed Speed)
{
return base.Channel.GotoPresetAsync(ProfileToken, PresetToken, Speed);
}
public System.Threading.Tasks.Task GotoHomePositionAsync(string ProfileToken, PTZSpeed Speed)
{
return base.Channel.GotoHomePositionAsync(ProfileToken, Speed);
}
public System.Threading.Tasks.Task SetHomePositionAsync(string ProfileToken)
{
return base.Channel.SetHomePositionAsync(ProfileToken);
}
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
System.Threading.Tasks.Task<ContinuousMoveResponse> PTZ.ContinuousMoveAsync(ContinuousMoveRequest request)
{
return base.Channel.ContinuousMoveAsync(request);
}
public System.Threading.Tasks.Task<ContinuousMoveResponse> ContinuousMoveAsync(string ProfileToken, PTZSpeed Velocity, string Timeout)
{
ContinuousMoveRequest inValue = new ContinuousMoveRequest();
inValue.ProfileToken = ProfileToken;
inValue.Velocity = Velocity;
inValue.Timeout = Timeout;
return ((PTZ)(this)).ContinuousMoveAsync(inValue);
}
public System.Threading.Tasks.Task RelativeMoveAsync(string ProfileToken, PTZVector Translation, PTZSpeed Speed)
{
return base.Channel.RelativeMoveAsync(ProfileToken, Translation, Speed);
}
public System.Threading.Tasks.Task<PTZStatus> GetStatusAsync(string ProfileToken)
{
return base.Channel.GetStatusAsync(ProfileToken);
}
public System.Threading.Tasks.Task AbsoluteMoveAsync(string ProfileToken, PTZVector Position, PTZSpeed Speed)
{
return base.Channel.AbsoluteMoveAsync(ProfileToken, Position, Speed);
}
public System.Threading.Tasks.Task GeoMoveAsync(string ProfileToken, GeoLocation Target, PTZSpeed Speed, float AreaHeight, float AreaWidth)
{
return base.Channel.GeoMoveAsync(ProfileToken, Target, Speed, AreaHeight, AreaWidth);
}
public System.Threading.Tasks.Task StopAsync(string ProfileToken, bool PanTilt, bool Zoom)
{
return base.Channel.StopAsync(ProfileToken, PanTilt, Zoom);
}
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
System.Threading.Tasks.Task<GetPresetToursResponse> PTZ.GetPresetToursAsync(GetPresetToursRequest request)
{
return base.Channel.GetPresetToursAsync(request);
}
public System.Threading.Tasks.Task<GetPresetToursResponse> GetPresetToursAsync(string ProfileToken)
{
GetPresetToursRequest inValue = new GetPresetToursRequest();
inValue.ProfileToken = ProfileToken;
return ((PTZ)(this)).GetPresetToursAsync(inValue);
}
public System.Threading.Tasks.Task<PresetTour> GetPresetTourAsync(string ProfileToken, string PresetTourToken)
{
return base.Channel.GetPresetTourAsync(ProfileToken, PresetTourToken);
}
public System.Threading.Tasks.Task<PTZPresetTourOptions> GetPresetTourOptionsAsync(string ProfileToken, string PresetTourToken)
{
return base.Channel.GetPresetTourOptionsAsync(ProfileToken, PresetTourToken);
}
public System.Threading.Tasks.Task<string> CreatePresetTourAsync(string ProfileToken)
{
return base.Channel.CreatePresetTourAsync(ProfileToken);
}
public System.Threading.Tasks.Task ModifyPresetTourAsync(string ProfileToken, PresetTour PresetTour)
{
return base.Channel.ModifyPresetTourAsync(ProfileToken, PresetTour);
}
public System.Threading.Tasks.Task OperatePresetTourAsync(string ProfileToken, string PresetTourToken, PTZPresetTourOperation Operation)
{
return base.Channel.OperatePresetTourAsync(ProfileToken, PresetTourToken, Operation);
}
public System.Threading.Tasks.Task RemovePresetTourAsync(string ProfileToken, string PresetTourToken)
{
return base.Channel.RemovePresetTourAsync(ProfileToken, PresetTourToken);
}
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
System.Threading.Tasks.Task<GetCompatibleConfigurationsResponse> PTZ.GetCompatibleConfigurationsAsync(GetCompatibleConfigurationsRequest request)
{
return base.Channel.GetCompatibleConfigurationsAsync(request);
}
public System.Threading.Tasks.Task<GetCompatibleConfigurationsResponse> GetCompatibleConfigurationsAsync(string ProfileToken)
{
GetCompatibleConfigurationsRequest inValue = new GetCompatibleConfigurationsRequest();
inValue.ProfileToken = ProfileToken;
return ((PTZ)(this)).GetCompatibleConfigurationsAsync(inValue);
}
public virtual System.Threading.Tasks.Task OpenAsync()
{
return System.Threading.Tasks.Task.Factory.FromAsync(((System.ServiceModel.ICommunicationObject)(this)).BeginOpen(null, null), new System.Action<System.IAsyncResult>(((System.ServiceModel.ICommunicationObject)(this)).EndOpen));
}
public virtual System.Threading.Tasks.Task CloseAsync()
{
return System.Threading.Tasks.Task.Factory.FromAsync(((System.ServiceModel.ICommunicationObject)(this)).BeginClose(null, null), new System.Action<System.IAsyncResult>(((System.ServiceModel.ICommunicationObject)(this)).EndClose));
}
}
}

27
BaseModule/EC.Onvif/RemoteDiscovery/Constants.cs

@ -0,0 +1,27 @@
namespace EC.Onvif.RemoteDiscovery
{
public static class Constants
{
public static string WS_MULTICAST_ADDRESS { get; } = "239.255.255.250";
public static int WS_MULTICAST_PORT { get; } = 3702;
public static string WS_PROBE_MESSAGE { get; } =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<e:Envelope xmlns:e=\"http://www.w3.org/2003/05/soap-envelope\""
+ "xmlns:w=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\""
+ "xmlns:d=\"http://schemas.xmlsoap.org/ws/2005/04/discovery\""
+ "xmlns:tds=\"https://www.onvif.org/ver10/device/wsdl/devicemgmt.wsdl\""
+ "xmlns:dn=\"http://www.onvif.org/ver10/network/wsdl\">"
+ "<e:Header>"
+ "<w:MessageID>uuid:{0}</w:MessageID>"
+ "<w:To>urn:schemas-xmlsoap-org:ws:2005:04:discovery</w:To> "
+ "<w:Action>http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe</w:Action>"
+ "</e:Header>"
+ "<e:Body>"
+ "<d:Probe><d:Types>dn:NetworkVideoTransmitter</d:Types></d:Probe>"
+ "</e:Body>"
+ "</e:Envelope>";
public static string PATTERN { get; } = @"^((onvif[s]?|ftp):\/)?\/?([^:\/\s]+)((\/\w+)*\/)([\w\-\.]+[^#?\s]+)(.*)?(#[\w\-]+)?$";
}
}

187
BaseModule/EC.Onvif/RemoteDiscovery/Discovery.cs

@ -0,0 +1,187 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Serialization;
namespace EC.Onvif.RemoteDiscovery
{
public class Discovery
{
#region Discover
/// <summary>
/// Discover new onvif devices on the network
/// </summary>
/// <param name="timeout">A timeout in seconds to wait for onvif devices</param>
/// <param name="cancellationToken">A cancellation token</param>
/// <returns>a list of <see cref="DiscoveryDevice"/></returns>
/// <remarks>Use the <see cref="Discover(int, Action{DiscoveryDevice}, CancellationToken)"/>
/// overload (with an action as a parameter) if you want to retrieve devices as they reply.</remarks>
public async Task<IEnumerable<DiscoveryDevice>> DiscoverByAdapter(IEnumerable<NetworkInterface> adapterList,
int timeout, CancellationToken cancellationToken = default)
{
List<DiscoveryDevice> deviceList = new();
await Discover(adapterList, d => deviceList.Add(d), timeout, cancellationToken);
deviceList.Sort((a, b) => CastIp(a.Address).CompareTo(CastIp(b.Address)));
return deviceList;
}
/// <summary>
/// Discover new onvif devices on the network
/// </summary>
/// <param name="timeout">A timeout in seconds to wait for onvif devices</param>
/// <param name="cancellationToken">A cancellation token</param>
/// <returns>a list of <see cref="DiscoveryDevice"/></returns>
/// <remarks>Use the <see cref="Discover(int, Action{DiscoveryDevice}, CancellationToken)"/>
/// overload (with an action as a parameter) if you want to retrieve devices as they reply.</remarks>
public async Task<IEnumerable<DiscoveryDevice>> DiscoverAll(int timeout, CancellationToken cancellationToken = default)
{
IEnumerable<NetworkInterface> adapterList = OnvifUdpClient.GetVaildNetworkAdapters();
IEnumerable<DiscoveryDevice> deviceList = await DiscoverByAdapter(adapterList, timeout, cancellationToken);
return deviceList;
}
/// <summary>
/// Discover new onvif devices on the network passing a callback
/// to retrieve devices as they reply
/// </summary>
/// <param name="onDeviceDiscovered">A method that is called each time a new device replies.</param>
/// <param name="timeout">A timeout in seconds to wait for onvif devices</param>
/// <param name="cancellationToken">A cancellation token</param>
/// <returns>The Task to be awaited</returns>
private async Task Discover(IEnumerable<NetworkInterface> adapterList, Action<DiscoveryDevice> onDeviceDiscovered,
int timeout, CancellationToken cancellationToken = default)
{
IEnumerable<OnvifUdpClient> clientList = OnvifUdpClient.CreateClientList(adapterList);
if (!clientList.Any())
{
throw new Exception("Missing valid NetworkInterfaces, UdpClients could not be created");
}
Task[] discoveries = clientList.Select(client => Discover(client, onDeviceDiscovered, timeout, cancellationToken)).ToArray();
await Task.WhenAll(discoveries);
}
private async Task Discover(OnvifUdpClient client, Action<DiscoveryDevice> onDeviceDiscovered, int timeout, CancellationToken cancellationToken = default)
{
Guid messageId = Guid.NewGuid();
List<UdpReceiveResult> responseList = new();
CancellationTokenSource cts = new(TimeSpan.FromSeconds(timeout));
try
{
await OnvifUdpClient.SendProbe(client, messageId);
while (true)
{
if (client.IsClosed) { return; }
if (cts.IsCancellationRequested || cancellationToken.IsCancellationRequested) { break; }
try
{
UdpReceiveResult response = await client.ReceiveAsync().WithCancellation(cancellationToken).WithCancellation(cts.Token);
if (responseList.Exists(resp => resp.RemoteEndPoint.Address.Equals(response.RemoteEndPoint.Address))) { continue; }
responseList.Add(response);
DiscoveryDevice discoveredDevice = ProcessResponse(response, messageId);
if (discoveredDevice != null)
{
await Task.Run(() => onDeviceDiscovered(discoveredDevice), cancellationToken);
}
}
catch (OperationCanceledException)
{
// Either the user canceled the action or the timeout has fired
}
catch (Exception)
{
// we catch all exceptions !
// Something might be bad in the response of a camera when call ReceiveAsync (BeginReceive in socket) fail
}
}
}
finally
{
client.Close();
}
}
#endregion Discover
#region Discover Helper
private DiscoveryDevice ProcessResponse(UdpReceiveResult response, Guid messageId)
{
if (response.Buffer == null) { return null; }
string strResponse = Encoding.UTF8.GetString(response.Buffer);
XmlProbeReponse xmlResponse = DeserializeResponse(strResponse);
if (xmlResponse.Header.RelatesTo.Contains(messageId.ToString())
&& xmlResponse.Body.ProbeMatches.Any()
&& !string.IsNullOrEmpty(xmlResponse.Body.ProbeMatches[0].Scopes))
{
return CreateDevice(xmlResponse.Body.ProbeMatches[0], response.RemoteEndPoint);
}
return null;
}
private XmlProbeReponse DeserializeResponse(string xml)
{
XmlSerializer serializer = new(typeof(XmlProbeReponse));
XmlReaderSettings settings = new();
using StringReader textReader = new(xml);
using XmlReader xmlReader = XmlReader.Create(textReader, settings);
return (XmlProbeReponse)serializer.Deserialize(xmlReader);
}
private DiscoveryDevice CreateDevice(ProbeMatch probeMatch, IPEndPoint remoteEndpoint)
{
string scopes = probeMatch.Scopes;
DiscoveryDevice discoveryDevice = new();
discoveryDevice.Address = remoteEndpoint.Address.ToString();
discoveryDevice.Model = Regex.Match(scopes, "(?<=hardware/).*?(?= )")?.Value;
discoveryDevice.Mfr = ParseMfrFromScopes(scopes);
discoveryDevice.XAdresses = ConvertToList(probeMatch.XAddrs);
discoveryDevice.Types = ConvertToList(probeMatch.Types);
return discoveryDevice;
}
private string ParseMfrFromScopes(string scopes)
{
string name = Regex.Match(scopes, "(?<=name/).*?(?= )")?.Value;
if (!string.IsNullOrEmpty(name)) { return name; }
string mfr = Regex.Match(scopes, "(?<=mfr/).*?(?= )")?.Value;
if (!string.IsNullOrEmpty(mfr)) { return mfr; }
return string.Empty;
}
private List<string> ConvertToList(string spacedListString)
{
string[] strings = spacedListString.Split(null);
List<string> list = new();
strings.ToList().ForEach(str => list.Add(str.Trim()));
return list;
}
private long CastIp(string ip)
{
byte[] addressBytes = IPAddress.Parse(ip).GetAddressBytes();
if (addressBytes.Length != 4)
{
return 0;
throw new ArgumentException("Must be an IPv4 address");
}
uint networkOrder = BitConverter.ToUInt32(addressBytes, 0);
return networkOrder;
//byte[] addressBytes = address.GetAddressBytes();
//int networkOrder = BitConverter.ToInt32(addressBytes, 0);
//return (uint)IPAddress.NetworkToHostOrder(networkOrder);
}
#endregion Discover Helper
}
}

33
BaseModule/EC.Onvif/RemoteDiscovery/DiscoveryDevice.cs

@ -0,0 +1,33 @@
using System.Collections.Generic;
namespace EC.Onvif.RemoteDiscovery
{
public class DiscoveryDevice
{
/// <summary>
/// The types of this onvif device. ex: NetworkVideoTransmitter
/// </summary>
public List<string> Types { get; internal set; }
/// <summary>
/// The XAddresses of this device, the url on which the device has the webservices.
/// Normally in the form of: http://{IP}:{Port}/onvif/device_service
/// </summary>
public List<string> XAdresses { get; internal set; }
/// <summary>
/// The onvif device model
/// </summary>
public string Model { get; internal set; }
/// <summary>
/// The device manufacturer
/// </summary>
public string Mfr { get; internal set; }
/// <summary>
/// The device IP address
/// </summary>
public string Address { get; internal set; }
}
}

25
BaseModule/EC.Onvif/RemoteDiscovery/ExtensionMethods.cs

@ -0,0 +1,25 @@
using System;
using System.Threading;
using System.Threading.Tasks;
namespace EC.Onvif.RemoteDiscovery
{
internal static class ExtensionMethods
{
/// <summary>
/// Used to provide cancellation possibility to any Async Methods returning a Task
/// </summary>
internal static async Task<T> WithCancellation<T>(this Task<T> task, CancellationToken cancellationToken)
{
var tcs = new TaskCompletionSource<bool>();
using (cancellationToken.Register(s => ((TaskCompletionSource<bool>)s).TrySetResult(true), tcs))
{
if (task != await Task.WhenAny(task, tcs.Task))
{
throw new OperationCanceledException(cancellationToken);
}
}
return await task;
}
}
}

140
BaseModule/EC.Onvif/RemoteDiscovery/OnvifUdpClient.cs

@ -0,0 +1,140 @@
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
namespace EC.Onvif.RemoteDiscovery
{
public class OnvifUdpClient
{
private UdpClient client { get; set; }
public bool IsClosed { get; set; }
public OnvifUdpClient(IPEndPoint localpoint)
{
client = new UdpClient(localpoint)
{
EnableBroadcast = true
};
}
public async Task<int> SendProbeAsync(Guid messageId, IPEndPoint endPoint)
{
byte[] datagram = NewProbeMessage(messageId);
return await client?.SendAsync(datagram, datagram.Length, endPoint);
}
public async Task<UdpReceiveResult> ReceiveAsync()
{
return await client.ReceiveAsync();
}
public void Close()
{
client?.Close();
IsClosed = true;
}
public static byte[] NewProbeMessage(Guid messageId)
{
if (messageId == Guid.Empty)
{
throw new ArgumentException("messageId could not be Empty");
}
var probeMessagewithguid = string.Format(Constants.WS_PROBE_MESSAGE, messageId.ToString());
return Encoding.ASCII.GetBytes(probeMessagewithguid);
}
#region CreateClient
public static OnvifUdpClient CreateClient(NetworkInterface adapter)
{
if (!IsValidAdapter(adapter)) { return null; }
OnvifUdpClient client = null;
IPInterfaceProperties adapterProperties = adapter.GetIPProperties();
foreach (UnicastIPAddressInformation ua in adapterProperties.UnicastAddresses)
{
if (ua.Address.AddressFamily != AddressFamily.InterNetwork) { continue; }
IPEndPoint myLocalEndPoint = new(ua.Address, 0); // port does not matter
try
{
client = new(myLocalEndPoint);
}
catch (SocketException)
{
throw;
}
break;
}
return client;
}
public static IEnumerable<OnvifUdpClient> CreateClientList(IEnumerable<NetworkInterface> adapterList)
{
List<OnvifUdpClient> clientList = new();
foreach (NetworkInterface adapter in adapterList)
{
OnvifUdpClient client = CreateClient(adapter);
if (client != null) { clientList.Add(client); }
}
return clientList;
}
public static IEnumerable<OnvifUdpClient> CreateClientList()
{
IEnumerable<NetworkInterface> adapterList = GetVaildNetworkAdapters();
return CreateClientList(adapterList);
}
#endregion CreateClient
#region ClientHelper
public static List<NetworkInterface> GetNetworkAdapters()
{
NetworkInterface[] nifs = NetworkInterface.GetAllNetworkInterfaces();
return new(nifs);
}
public static List<NetworkInterface> GetVaildNetworkAdapters()
{
NetworkInterface[] nifs = NetworkInterface.GetAllNetworkInterfaces();
List<NetworkInterface> list = new();
foreach (NetworkInterface nif in nifs)
{
if (IsValidAdapter(nif)) { list.Add(nif); }
}
return list;
}
public static bool IsValidAdapter(NetworkInterface adapter)
{
// Only select interfaces that are Ethernet type and support IPv4 (important to minimize waiting time)
if (adapter.NetworkInterfaceType != NetworkInterfaceType.Ethernet &&
!adapter.NetworkInterfaceType.ToString().ToLower().StartsWith("wireless")) return false;
if (adapter.OperationalStatus == OperationalStatus.Down) { return false; }
if (!adapter.Supports(NetworkInterfaceComponent.IPv4)) { return false; }
return true;
}
/// <summary>
/// 广播
/// </summary>
/// <param name="client"></param>
/// <param name="messageId"></param>
/// <returns></returns>
public static async Task SendProbe(OnvifUdpClient client, Guid messageId)
{
IPEndPoint multicastEndpoint = new(IPAddress.Parse(Constants.WS_MULTICAST_ADDRESS), Constants.WS_MULTICAST_PORT);
await client.SendProbeAsync(messageId, multicastEndpoint);
}
#endregion ClientHelper
}
}

113
BaseModule/EC.Onvif/RemoteDiscovery/XmlProbeReponse.cs

@ -0,0 +1,113 @@
using System.Xml.Serialization;
namespace EC.Onvif.RemoteDiscovery
{
/// <summary>
/// The probe response
/// </summary>
[XmlRoot("Envelope", Namespace = "http://www.w3.org/2003/05/soap-envelope")]
public class XmlProbeReponse
{
/// <summary>
/// The Header of the probe response
/// </summary>
[XmlElement(Namespace = "http://www.w3.org/2003/05/soap-envelope")]
public Header Header { get; set; }
/// <summary>
/// The Body of the probe response
/// </summary>
[XmlElement(Namespace = "http://www.w3.org/2003/05/soap-envelope")]
public Body Body { get; set; }
}
/// <summary>
/// The Header of the probe response
/// </summary>
public class Header
{
/// <summary>
/// The message id
/// </summary>
[XmlElement(Namespace = "http://schemas.xmlsoap.org/ws/2004/08/addressing")]
public string MessageID { get; set; }
/// <summary>
/// The message id that relates to
/// </summary>
[XmlElement(Namespace = "http://schemas.xmlsoap.org/ws/2004/08/addressing")]
public string RelatesTo { get; set; }
/// <summary>
/// To
/// </summary>
[XmlElement(Namespace = "http://schemas.xmlsoap.org/ws/2004/08/addressing")]
public string To { get; set; }
/// <summary>
/// App sequence
/// </summary>
[XmlElement(Namespace = "http://schemas.xmlsoap.org/ws/2005/04/discovery")]
public string AppSequence { get; set; }
}
/// <summary>
/// The Body of the probe response
/// </summary>
public class Body
{
/// <summary>
/// An array of probe matches
/// </summary>
[XmlArray(Namespace = "http://schemas.xmlsoap.org/ws/2005/04/discovery")]
public ProbeMatch[] ProbeMatches { get; set; }
}
/// <summary>
/// A probe match
/// </summary>
public class ProbeMatch
{
/// <summary>
/// The endpoint reference
/// </summary>
[XmlElement(Namespace = "http://schemas.xmlsoap.org/ws/2004/08/addressing")]
public EndpointReference EndpointReference { get; set; }
/// <summary>
/// The types
/// </summary>
[XmlElement(Namespace = "http://schemas.xmlsoap.org/ws/2005/04/discovery")]
public string Types { get; set; }
/// <summary>
/// The scopes
/// </summary>
[XmlElement(Namespace = "http://schemas.xmlsoap.org/ws/2005/04/discovery")]
public string Scopes { get; set; }
/// <summary>
/// The XAddrs
/// </summary>
[XmlElement(Namespace = "http://schemas.xmlsoap.org/ws/2005/04/discovery")]
public string XAddrs { get; set; }
/// <summary>
/// The metadata version
/// </summary>
[XmlElement(Namespace = "http://schemas.xmlsoap.org/ws/2005/04/discovery")]
public string MetadataVersion { get; set; }
}
/// <summary>
/// The endpoint reference
/// </summary>
public class EndpointReference
{
/// <summary>
/// The address
/// </summary>
[XmlElement(Namespace = "http://schemas.xmlsoap.org/ws/2004/08/addressing")]
public string Address { get; set; }
}
}

82
BaseModule/EC.Onvif/Security/SoapSecurityHeader.cs

@ -0,0 +1,82 @@
using System;
using System.Security.Cryptography;
using System.ServiceModel.Channels;
using System.Text;
using System.Xml;
namespace EC.Onvif.Security
{
public class SoapSecurityHeader : MessageHeader
{
private const string ns_wsu = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";
private readonly string username;
private readonly string password;
private readonly TimeSpan time_shift;
public override string Name { get; } = "Security";
public override string Namespace { get; } = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
public SoapSecurityHeader(string username, string password, TimeSpan timeShift)
{
this.username = username;
this.password = password;
time_shift = timeShift;
}
protected override void OnWriteHeaderContents(XmlDictionaryWriter writer, MessageVersion messageVersion)
{
var nonce = GetNonce();
var created = DateTime.UtcNow.Add(time_shift).ToString("yyyy-MM-ddTHH:mm:ss.fffZ");
var nonce_str = Convert.ToBase64String(nonce);
string password_hash = PasswordDigest(nonce, created, password);
writer.WriteStartElement("UsernameToken");
writer.WriteStartElement("Username");
writer.WriteValue(username);
writer.WriteEndElement();
writer.WriteStartElement("Password");
writer.WriteAttributeString("Type", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest");
writer.WriteValue(password_hash);
writer.WriteEndElement();
writer.WriteStartElement("Nonce");
writer.WriteAttributeString("EncodingType", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary");
writer.WriteValue(nonce_str);
writer.WriteEndElement();
writer.WriteStartElement("Created");
writer.WriteXmlnsAttribute("", ns_wsu);
writer.WriteValue(created);
writer.WriteEndElement();
writer.WriteEndElement();
}
protected override void OnWriteStartHeader(XmlDictionaryWriter writer, MessageVersion messageVersion)
{
writer.WriteStartElement("", Name, Namespace);
writer.WriteAttributeString("s", "mustUnderstand", "http://www.w3.org/2003/05/soap-envelope", "1");
writer.WriteXmlnsAttribute("", Namespace);
}
private string PasswordDigest(byte[] nonce, string created, string secret)
{
byte[] buffer = new byte[nonce.Length + Encoding.ASCII.GetByteCount(created + secret)];
nonce.CopyTo(buffer, 0);
Encoding.ASCII.GetBytes(created + password).CopyTo(buffer, nonce.Length);
return Convert.ToBase64String(SHA1.Create().ComputeHash(buffer));
}
private byte[] GetNonce()
{
byte[] nonce = new byte[0x10];
var generator = new RNGCryptoServiceProvider();
generator.GetBytes(nonce);
return nonce;
}
}
}

42
BaseModule/EC.Onvif/Security/SoapSecurityHeaderBehavior.cs

@ -0,0 +1,42 @@
using System;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
namespace EC.Onvif.Security
{
public class SoapSecurityHeaderBehavior : IEndpointBehavior
{
private readonly string username;
private readonly string password;
private readonly TimeSpan time_shift;
public SoapSecurityHeaderBehavior(string username, string password) : this(username, password, TimeSpan.FromMilliseconds(0))
{
}
public SoapSecurityHeaderBehavior(string username, string password, TimeSpan timeShift)
{
this.username = username;
this.password = password;
time_shift = timeShift;
}
public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
{
}
public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
{
clientRuntime.ClientMessageInspectors.Add(new SoapSecurityHeaderInspector(username, password, time_shift));
}
public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
{
}
public void Validate(ServiceEndpoint endpoint)
{
}
}
}

32
BaseModule/EC.Onvif/Security/SoapSecurityHeaderInspector.cs

@ -0,0 +1,32 @@
using System;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Dispatcher;
namespace EC.Onvif.Security
{
public class SoapSecurityHeaderInspector : IClientMessageInspector
{
private readonly string username;
private readonly string password;
private readonly TimeSpan time_shift;
public SoapSecurityHeaderInspector(string username, string password, TimeSpan timeShift)
{
this.username = username;
this.password = password;
time_shift = timeShift;
}
public void AfterReceiveReply(ref Message reply, object correlationState)
{
}
public object BeforeSendRequest(ref Message request, IClientChannel channel)
{
request.Headers.Add(new SoapSecurityHeader(username, password, time_shift));
return null;
}
}
}

42
BusinessModule/EC.App.Entity/Base/DictBase.cs

@ -0,0 +1,42 @@
using System.Collections.Generic;
namespace EC.App.Entity.Base
{
public class DictBase<K, V>
{
private Dictionary<K, V> Dict { get; } = new();
public DictBase()
{ }
#region Operate
public bool TryAdd(K key, V value)
{
return Dict.TryAdd(key, value);
}
public bool Remove(K key)
{
return Dict.Remove(key);
}
public bool TryUpdate(K key, V value)
{
Remove(key);
return TryAdd(key, value);
}
public bool TryGet(K key, out V value)
{
return Dict.TryGetValue(key, out value);
}
public bool IsExist(K key)
{
return Dict.ContainsKey(key);
}
#endregion Operate
}
}

11
BusinessModule/EC.App.Entity/EC.App.Entity.csproj

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\BaseModule\EC.Onvif\EC.Onvif.csproj" />
</ItemGroup>
</Project>

9
BusinessModule/EC.App.Entity/Onvif/OnvifClientDict.cs

@ -0,0 +1,9 @@
using EC.App.Entity.Base;
using EC.Onvif;
namespace EC.App.Entity.Onvif
{
public class OnvifClientDict : DictBase<string, OnvifClient>
{
}
}

13
BusinessModule/EC.App.ThatBLL/EC.App.ThatBLL.csproj

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\BaseModule\EC.App\EC.App.csproj" />
<ProjectReference Include="..\..\BaseModule\EC.Onvif\EC.Onvif.csproj" />
<ProjectReference Include="..\EC.App.ThatService\EC.App.ThatService.csproj" />
</ItemGroup>
</Project>

50
BusinessModule/EC.App.ThatBLL/Onvif/CurdBLL.cs

@ -0,0 +1,50 @@
using EC.App.Entity.Onvif;
using EC.App.ThatBLL.Onvif.Impl;
using EC.Onvif;
using System.Threading.Tasks;
namespace EC.App.ThatBLL.Onvif
{
public class CurdBLL : ICurdBLL
{
private readonly OnvifClientService _ocService;
public CurdBLL(OnvifClientService onvifClientService)
{
_ocService = onvifClientService;
}
#region Operate
public async Task<bool> Add(string ip, string username, string password)
{
bool flag = !_ocService.IsExist(ip);
if (!flag) { return false; }
OnvifClient onvifClient = new OnvifClient(ip, username, password);
await onvifClient.InitAsync();
bool ret = _ocService.TryAdd(ip, onvifClient);
return ret;
}
public bool Remove(string ip)
{
bool ret = _ocService.Remove(ip);
return ret;
}
public async Task<bool> Update(string ip, string username, string password)
{
Remove(ip);
bool ret = await Add(ip, username, password);
return ret;
}
public bool IsExist(string ip)
{
bool ret = _ocService.IsExist(ip);
return ret;
}
#endregion Operate
}
}

27
BusinessModule/EC.App.ThatBLL/Onvif/DeviceBLL.cs

@ -0,0 +1,27 @@
using EC.App.Entity.Onvif;
using EC.App.ThatBLL.Onvif.Impl;
using EC.Onvif;
namespace EC.App.ThatBLL.Onvif
{
public class DeviceBLL : IDeviceBLL
{
private readonly OnvifClientService _ocService;
public DeviceBLL(OnvifClientService onvifClientService)
{
_ocService = onvifClientService;
}
#region Operate
public bool IsConnected(string ip)
{
bool flag = _ocService.TryGet(ip, out OnvifClient onvifClient);
bool ret = flag && onvifClient.IsDeviceContected();
return ret;
}
#endregion Operate
}
}

27
BusinessModule/EC.App.ThatBLL/Onvif/ImagingBLL.cs

@ -0,0 +1,27 @@
using EC.App.Entity.Onvif;
using EC.App.ThatBLL.Onvif.Impl;
using EC.Onvif;
namespace EC.App.ThatBLL.Onvif
{
public class ImagingBLL : IImagingBLL
{
private readonly OnvifClientService _ocService;
public ImagingBLL(OnvifClientService onvifClientService)
{
_ocService = onvifClientService;
}
#region Operate
public bool IsConnected(string ip)
{
bool flag = _ocService.TryGet(ip, out OnvifClient onvifClient);
bool ret = flag && onvifClient.IsImagingContected();
return ret;
}
#endregion Operate
}
}

21
BusinessModule/EC.App.ThatBLL/Onvif/Impl/ICurdBLL.cs

@ -0,0 +1,21 @@
using EC.App.Core;
using Furion.DependencyInjection;
using System.Threading.Tasks;
namespace EC.App.ThatBLL.Onvif.Impl
{
public interface ICurdBLL : IBLL, ISingleton
{
#region Operate
Task<bool> Add(string ip, string username, string password);
bool Remove(string ip);
Task<bool> Update(string ip, string username, string password);
bool IsExist(string ip);
#endregion Operate
}
}

19
BusinessModule/EC.App.ThatBLL/Onvif/Impl/IDeviceBLL.cs

@ -0,0 +1,19 @@
using EC.App.Core;
using Furion.DependencyInjection;
namespace EC.App.ThatBLL.Onvif.Impl
{
public interface IDeviceBLL : IBLL, ISingleton
{
#region Operate
/// <summary>
/// 是否连接
/// </summary>
/// <param name="ip"></param>
/// <returns></returns>
bool IsConnected(string ip);
#endregion Operate
}
}

19
BusinessModule/EC.App.ThatBLL/Onvif/Impl/IImagingBLL.cs

@ -0,0 +1,19 @@
using EC.App.Core;
using Furion.DependencyInjection;
namespace EC.App.ThatBLL.Onvif.Impl
{
public interface IImagingBLL : IBLL, ISingleton
{
#region Operate
/// <summary>
/// 是否连接
/// </summary>
/// <param name="ip"></param>
/// <returns></returns>
bool IsConnected(string ip);
#endregion Operate
}
}

19
BusinessModule/EC.App.ThatBLL/Onvif/Impl/IMediaBLL.cs

@ -0,0 +1,19 @@
using EC.App.Core;
using Furion.DependencyInjection;
namespace EC.App.ThatBLL.Onvif.Impl
{
public interface IMediaBLL : IBLL, ISingleton
{
#region Operate
/// <summary>
/// 是否连接
/// </summary>
/// <param name="ip"></param>
/// <returns></returns>
bool IsConnected(string ip);
#endregion Operate
}
}

61
BusinessModule/EC.App.ThatBLL/Onvif/Impl/IPTZBLL.cs

@ -0,0 +1,61 @@
using EC.App.Core;
using Furion.DependencyInjection;
using System.Threading.Tasks;
namespace EC.App.ThatBLL.Onvif.Impl
{
public interface IPTZBLL : IBLL, ISingleton
{
#region Operate
/// <summary>
/// 是否连接
/// </summary>
/// <param name="ip"></param>
/// <returns></returns>
bool IsConnected(string ip);
#endregion Operate
#region Move
/// <summary>
/// 绝对移动
/// </summary>
/// <param name="ip"></param>
/// <param name="pan"></param>
/// <param name="tilt"></param>
/// <param name="zoom"></param>
/// <returns></returns>
Task<bool> AbsoluteMove(string ip, float pan, float tilt, float zoom);
/// <summary>
/// 相对移动
/// </summary>
/// <param name="ip"></param>
/// <param name="pan"></param>
/// <param name="tilt"></param>
/// <param name="zoom"></param>
/// <returns></returns>
Task<bool> RelativeMove(string ip, float pan, float tilt, float zoom);
/// <summary>
/// 持续移动
/// </summary>
/// <param name="ip"></param>
/// <param name="pan"></param>
/// <param name="tilt"></param>
/// <param name="zoom"></param>
/// <returns></returns>
Task<bool> ContinuousMove(string ip, float pan, float tilt, float zoom);
/// <summary>
/// 停止移动
/// </summary>
/// <param name="ip"></param>
/// <returns></returns>
Task<bool> StopMove(string ip);
#endregion Move
}
}

27
BusinessModule/EC.App.ThatBLL/Onvif/MediaBLL.cs

@ -0,0 +1,27 @@
using EC.App.Entity.Onvif;
using EC.App.ThatBLL.Onvif.Impl;
using EC.Onvif;
namespace EC.App.ThatBLL.Onvif
{
public class MediaBLL : IMediaBLL
{
private readonly OnvifClientService _ocService;
public MediaBLL(OnvifClientService onvifClientService)
{
_ocService = onvifClientService;
}
#region Operate
public bool IsConnected(string ip)
{
bool flag = _ocService.TryGet(ip, out OnvifClient onvifClient);
bool ret = flag && onvifClient.IsMediaContected();
return ret;
}
#endregion Operate
}
}

64
BusinessModule/EC.App.ThatBLL/Onvif/PTZBLL.cs

@ -0,0 +1,64 @@
using EC.App.Entity.Onvif;
using EC.App.ThatBLL.Onvif.Impl;
using EC.Onvif;
using System.Threading.Tasks;
namespace EC.App.ThatBLL.Onvif
{
public class PTZBLL : IPTZBLL
{
private readonly OnvifClientService _ocService;
public PTZBLL(OnvifClientService onvifClientService)
{
_ocService = onvifClientService;
}
#region Operate
public bool IsConnected(string ip)
{
bool flag = _ocService.TryGet(ip, out OnvifClient onvifClient);
bool ret = flag && onvifClient.IsPTZContected();
return ret;
}
#endregion Operate
#region Move
public async Task<bool> AbsoluteMove(string ip, float pan, float tilt, float zoom)
{
bool flag = _ocService.TryGet(ip, out OnvifClient onvifClient);
if (!flag) return false;
await onvifClient.AbsoluteMoveAsync(pan, tilt, zoom);
return true;
}
public async Task<bool> RelativeMove(string ip, float pan, float tilt, float zoom)
{
bool flag = _ocService.TryGet(ip, out OnvifClient onvifClient);
if (!flag) return false;
await onvifClient.RelativeMoveAsync(pan, tilt, zoom);
return true;
}
public async Task<bool> ContinuousMove(string ip, float pan, float tilt, float zoom)
{
bool flag = _ocService.TryGet(ip, out OnvifClient onvifClient);
if (!flag) return false;
await onvifClient.ContinuousMoveAsync(pan, tilt, zoom);
return true;
}
public async Task<bool> StopMove(string ip)
{
bool flag = _ocService.TryGet(ip, out OnvifClient onvifClient);
if (!flag) return false;
await onvifClient.StopMoveAsync();
return true;
}
#endregion Move
}
}

13
BusinessModule/EC.App.ThatService/EC.App.ThatService.csproj

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\BaseModule\EC.App\EC.App.csproj" />
<ProjectReference Include="..\..\BaseModule\EC.Onvif\EC.Onvif.csproj" />
<ProjectReference Include="..\EC.App.Entity\EC.App.Entity.csproj" />
</ItemGroup>
</Project>

9
BusinessModule/EC.App.ThatService/Onvif/Impl/IOnvifClientService.cs

@ -0,0 +1,9 @@
using EC.App.Core;
using Furion.DependencyInjection;
namespace EC.App.ThatService.Onvif.Impl
{
public interface IOnvifClientService : IService, ISingleton
{
}
}

44
BusinessModule/EC.App.ThatService/Onvif/OnvifClientService.cs

@ -0,0 +1,44 @@
using EC.App.ThatService.Onvif.Impl;
using EC.Onvif;
namespace EC.App.Entity.Onvif
{
public class OnvifClientService : IOnvifClientService
{
private readonly OnvifClientDict _dict = new OnvifClientDict();
public OnvifClientService()
{
}
public bool TryAdd(string key, OnvifClient value)
{
bool ret = _dict.TryAdd(key, value);
return ret;
}
public bool Remove(string key)
{
bool ret = _dict.Remove(key);
return ret;
}
public bool TryUpdate(string key, OnvifClient value)
{
bool ret = _dict.TryUpdate(key, value);
return ret;
}
public bool TryGet(string key, out OnvifClient value)
{
bool ret = _dict.TryGet(key, out value);
return ret;
}
public bool IsExist(string key)
{
bool ret = _dict.IsExist(key);
return ret;
}
}
}

72
OnvifServer-CSharp.sln

@ -0,0 +1,72 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.32014.148
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OnvifWebServer", "OnvifWebServer\OnvifWebServer.csproj", "{6932E7F3-56E3-4AA5-898C-1C814D53C5F6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OnvifSocketServer", "OnvifSocketServer\OnvifSocketServer.csproj", "{2CC43390-1870-475A-B2F1-5F66C17E27B5}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BaseModule", "BaseModule", "{8D6DAF0C-45FB-4650-8F4F-A63283D32F75}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BusinessModule", "BusinessModule", "{BE926C07-70B6-48E6-9A09-8089AC72DB52}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EC.Onvif", "BaseModule\EC.Onvif\EC.Onvif.csproj", "{94728605-7159-40DD-861C-4D1B9E8DEA00}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EC.App.Entity", "BusinessModule\EC.App.Entity\EC.App.Entity.csproj", "{2B89CB02-BA09-4140-A3BF-5A02109C080C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EC.App", "BaseModule\EC.App\EC.App.csproj", "{7AE950D5-1982-4D76-94F5-A38347AE8263}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EC.App.ThatBLL", "BusinessModule\EC.App.ThatBLL\EC.App.ThatBLL.csproj", "{D1528FA0-E88B-483A-932C-A682BDD4FF98}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EC.App.ThatService", "BusinessModule\EC.App.ThatService\EC.App.ThatService.csproj", "{EE03CCDB-A280-477B-86FF-B6918169FCDA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6932E7F3-56E3-4AA5-898C-1C814D53C5F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6932E7F3-56E3-4AA5-898C-1C814D53C5F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6932E7F3-56E3-4AA5-898C-1C814D53C5F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6932E7F3-56E3-4AA5-898C-1C814D53C5F6}.Release|Any CPU.Build.0 = Release|Any CPU
{2CC43390-1870-475A-B2F1-5F66C17E27B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2CC43390-1870-475A-B2F1-5F66C17E27B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2CC43390-1870-475A-B2F1-5F66C17E27B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2CC43390-1870-475A-B2F1-5F66C17E27B5}.Release|Any CPU.Build.0 = Release|Any CPU
{94728605-7159-40DD-861C-4D1B9E8DEA00}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{94728605-7159-40DD-861C-4D1B9E8DEA00}.Debug|Any CPU.Build.0 = Debug|Any CPU
{94728605-7159-40DD-861C-4D1B9E8DEA00}.Release|Any CPU.ActiveCfg = Release|Any CPU
{94728605-7159-40DD-861C-4D1B9E8DEA00}.Release|Any CPU.Build.0 = Release|Any CPU
{2B89CB02-BA09-4140-A3BF-5A02109C080C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2B89CB02-BA09-4140-A3BF-5A02109C080C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2B89CB02-BA09-4140-A3BF-5A02109C080C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2B89CB02-BA09-4140-A3BF-5A02109C080C}.Release|Any CPU.Build.0 = Release|Any CPU
{7AE950D5-1982-4D76-94F5-A38347AE8263}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7AE950D5-1982-4D76-94F5-A38347AE8263}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7AE950D5-1982-4D76-94F5-A38347AE8263}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7AE950D5-1982-4D76-94F5-A38347AE8263}.Release|Any CPU.Build.0 = Release|Any CPU
{D1528FA0-E88B-483A-932C-A682BDD4FF98}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D1528FA0-E88B-483A-932C-A682BDD4FF98}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D1528FA0-E88B-483A-932C-A682BDD4FF98}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D1528FA0-E88B-483A-932C-A682BDD4FF98}.Release|Any CPU.Build.0 = Release|Any CPU
{EE03CCDB-A280-477B-86FF-B6918169FCDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EE03CCDB-A280-477B-86FF-B6918169FCDA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EE03CCDB-A280-477B-86FF-B6918169FCDA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EE03CCDB-A280-477B-86FF-B6918169FCDA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{94728605-7159-40DD-861C-4D1B9E8DEA00} = {8D6DAF0C-45FB-4650-8F4F-A63283D32F75}
{2B89CB02-BA09-4140-A3BF-5A02109C080C} = {BE926C07-70B6-48E6-9A09-8089AC72DB52}
{7AE950D5-1982-4D76-94F5-A38347AE8263} = {8D6DAF0C-45FB-4650-8F4F-A63283D32F75}
{D1528FA0-E88B-483A-932C-A682BDD4FF98} = {BE926C07-70B6-48E6-9A09-8089AC72DB52}
{EE03CCDB-A280-477B-86FF-B6918169FCDA} = {BE926C07-70B6-48E6-9A09-8089AC72DB52}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {94E890EB-BBFB-4C67-9A75-EF7217F2E82B}
EndGlobalSection
EndGlobal

8
OnvifSocketServer/OnvifSocketServer.csproj

@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
</Project>

12
OnvifSocketServer/Program.cs

@ -0,0 +1,12 @@
using System;
namespace OnvifSocketServer
{
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}

90
OnvifWebServer/Controllers/Onvif/CurdController.cs

@ -0,0 +1,90 @@
using EC.App.Core;
using EC.App.ThatBLL.Onvif.Impl;
using Furion.DataValidation;
using Microsoft.AspNetCore.Mvc;
using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks;
namespace OnvifWebServer.Controllers.Onvif
{
/// <summary>
/// Onvif 增删改查
/// </summary>
[Route("onvif/[controller]")]
[ApiDescriptionSettings("Onvif")]
public class CurdController : ApiController
{
private readonly ICurdBLL _curdBLL;
/// <summary>
///
/// </summary>
/// <param name="curdBLL"></param>
public CurdController(ICurdBLL curdBLL)
{
_curdBLL = curdBLL;
}
#region Operate
/// <summary>
/// 添加 onvif
/// </summary>
/// <param name="ip">IP地址</param>
/// <param name="username">用户名</param>
/// <param name="password">密码</param>
/// <returns></returns>
[HttpPost]
public async Task<bool> Add(
[Required][DataValidation(ValidationTypes.IPv4)] string ip,
[Required] string username, [Required] string password)
{
bool ret = await _curdBLL.Add(ip, username, password);
return ret;
}
/// <summary>
/// 移除 onvif
/// </summary>
/// <param name="ip">IP地址</param>
/// <returns></returns>
[HttpGet]
public bool Remove(
[Required][DataValidation(ValidationTypes.IPv4)] string ip)
{
bool ret = _curdBLL.Remove(ip);
return ret;
}
/// <summary>
/// 更新 onvif
/// </summary>
/// <param name="ip">IP地址</param>
/// <param name="username">用户名</param>
/// <param name="password">密码</param>
/// <returns></returns>
[HttpPost]
public async Task<bool> Update(
[Required][DataValidation(ValidationTypes.IPv4)] string ip,
[Required] string username, [Required] string password)
{
bool ret = await _curdBLL.Update(ip, username, password);
return ret;
}
/// <summary>
/// 是否存在 onvif
/// </summary>
/// <param name="ip">IP地址</param>
/// <returns></returns>
[HttpGet]
public bool IsExist(
[Required][DataValidation(ValidationTypes.IPv4)] string ip)
{
bool ret = _curdBLL.IsExist(ip);
return ret;
}
#endregion Operate
}
}

44
OnvifWebServer/Controllers/Onvif/DeviceController.cs

@ -0,0 +1,44 @@
using EC.App.Core;
using EC.App.ThatBLL.Onvif.Impl;
using Furion.DataValidation;
using Microsoft.AspNetCore.Mvc;
using System.ComponentModel.DataAnnotations;
namespace OnvifWebServer.Controllers.Onvif
{
/// <summary>
/// Onvif 设备参数控制
/// </summary>
[Route("onvif/[controller]")]
[ApiDescriptionSettings("Onvif")]
public class DeviceController : ApiController
{
private readonly IDeviceBLL _deviceBLL;
/// <summary>
///
/// </summary>
/// <param name="deviceBLL"></param>
public DeviceController(IDeviceBLL deviceBLL)
{
this._deviceBLL = deviceBLL;
}
#region Operate
/// <summary>
/// 是否连接
/// </summary>
/// <param name="ip"></param>
/// <returns></returns>
[HttpGet]
public bool IsConnected(
[Required][DataValidation(ValidationTypes.IPv4)] string ip)
{
bool ret = _deviceBLL.IsConnected(ip);
return ret;
}
#endregion Operate
}
}

44
OnvifWebServer/Controllers/Onvif/ImagingController.cs

@ -0,0 +1,44 @@
using EC.App.Core;
using EC.App.ThatBLL.Onvif.Impl;
using Furion.DataValidation;
using Microsoft.AspNetCore.Mvc;
using System.ComponentModel.DataAnnotations;
namespace OnvifWebServer.Controllers.Onvif
{
/// <summary>
/// Onvif 成像参数控制
/// </summary>
[Route("onvif/[controller]")]
[ApiDescriptionSettings("Onvif")]
public class ImagingController : ApiController
{
private readonly IImagingBLL _imagingBLL;
/// <summary>
///
/// </summary>
/// <param name="imagingBLL"></param>
public ImagingController(IImagingBLL imagingBLL)
{
this._imagingBLL = imagingBLL;
}
#region Operate
/// <summary>
/// 是否连接
/// </summary>
/// <param name="ip"></param>
/// <returns></returns>
[HttpGet]
public bool IsConnected(
[Required][DataValidation(ValidationTypes.IPv4)] string ip)
{
bool ret = _imagingBLL.IsConnected(ip);
return ret;
}
#endregion Operate
}
}

44
OnvifWebServer/Controllers/Onvif/MediaController.cs

@ -0,0 +1,44 @@
using EC.App.Core;
using EC.App.ThatBLL.Onvif.Impl;
using Furion.DataValidation;
using Microsoft.AspNetCore.Mvc;
using System.ComponentModel.DataAnnotations;
namespace OnvifWebServer.Controllers.Onvif
{
/// <summary>
/// Onvif 媒体参数控制
/// </summary>
[Route("onvif/[controller]")]
[ApiDescriptionSettings("Onvif")]
public class MediaController : ApiController
{
private readonly IMediaBLL _mediaBLL;
/// <summary>
///
/// </summary>
/// <param name="mediaBLL"></param>
public MediaController(IMediaBLL mediaBLL)
{
this._mediaBLL = mediaBLL;
}
#region Operate
/// <summary>
/// 是否连接
/// </summary>
/// <param name="ip"></param>
/// <returns></returns>
[HttpGet]
public bool IsConnected(
[Required][DataValidation(ValidationTypes.IPv4)] string ip)
{
bool ret = _mediaBLL.IsConnected(ip);
return ret;
}
#endregion Operate
}
}

110
OnvifWebServer/Controllers/Onvif/PTZController.cs

@ -0,0 +1,110 @@
using EC.App.Core;
using EC.App.ThatBLL.Onvif.Impl;
using Furion.DataValidation;
using Microsoft.AspNetCore.Mvc;
using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks;
namespace OnvifWebServer.Controllers.Onvif
{
/// <summary>
/// Onvif 移动参数控制
/// </summary>
[Route("onvif/[controller]")]
[ApiDescriptionSettings("Onvif")]
public class PTZController : ApiController
{
private readonly IPTZBLL _ptzBLL;
/// <summary>
///
/// </summary>
/// <param name="ptzBLL"></param>
public PTZController(IPTZBLL ptzBLL)
{
this._ptzBLL = ptzBLL;
}
#region Operate
/// <summary>
/// 是否连接
/// </summary>
/// <param name="ip"></param>
/// <returns></returns>
[HttpGet]
public bool IsConnected(
[Required][DataValidation(ValidationTypes.IPv4)] string ip)
{
bool ret = _ptzBLL.IsConnected(ip);
return ret;
}
#endregion Operate
#region Move
/// <summary>
/// 绝对移动
/// </summary>
/// <param name="ip">IP地址</param>
/// <param name="pan">水平方向移动绝对点</param>
/// <param name="tilt">垂直方向移动绝对点</param>
/// <param name="zoom">变焦绝对点</param>
/// <returns></returns>
[HttpGet]
public async Task<bool> AbsoluteMove(
[DataValidation(ValidationTypes.IPv4)] string ip,
[Required] float pan, [Required] float tilt, [Required] float zoom)
{
bool ret = await _ptzBLL.AbsoluteMove(ip, pan, tilt, zoom);
return ret;
}
/// <summary>
/// 绝对移动
/// </summary>
/// <param name="ip">IP地址</param>
/// <param name="pan">水平方向移动绝对点</param>
/// <param name="tilt">垂直方向移动绝对点</param>
/// <param name="zoom">变焦绝对点</param>
[HttpGet]
public async Task<bool> RelativeMove(
[DataValidation(ValidationTypes.IPv4)] string ip,
[Required] float pan, [Required] float tilt, [Required] float zoom)
{
bool ret = await _ptzBLL.RelativeMove(ip, pan, tilt, zoom);
return ret;
}
/// <summary>
/// 持续移动
/// </summary>
/// <param name="ip">IP地址</param>
/// <param name="pan">水平方向移动绝对点</param>
/// <param name="tilt">垂直方向移动绝对点</param>
/// <param name="zoom">变焦绝对点</param>
[HttpGet]
public async Task<bool> ContinuousMove(
[DataValidation(ValidationTypes.IPv4)] string ip,
[Required] float pan, [Required] float tilt, [Required] float zoom)
{
bool ret = await _ptzBLL.ContinuousMove(ip, pan, tilt, zoom);
return ret;
}
/// <summary>
/// 停止移动
/// </summary>
/// <param name="ip">IP地址</param>
[HttpGet]
public async Task<bool> StopMove(
[Required][DataValidation(ValidationTypes.IPv4)] string ip)
{
bool ret = await _ptzBLL.StopMove(ip);
return ret;
}
#endregion Move
}
}

40
OnvifWebServer/Controllers/Onvif/TestController.cs

@ -0,0 +1,40 @@
using EC.App.Core;
using Furion.DataValidation;
using Microsoft.AspNetCore.Mvc;
using System;
using System.ComponentModel.DataAnnotations;
namespace OnvifWebServer.Controllers.Onvif
{
[Route("test/[controller]")]
[ApiDescriptionSettings("Test")]
public class TestController : ApiController
{
public TestController()
{
}
#region Operate
[HttpGet]
public string TestString(string ip)
{
return ip;
}
[HttpGet]
public string TestValid([Required][DataValidation(ValidationTypes.IPv4)] string ip)
{
return ip;
}
[HttpGet]
public string TestException(string ip)
{
throw new Exception("test");
return ip;
}
#endregion Operate
}
}

103
OnvifWebServer/Extensions/RESTfulResultProvider.cs

@ -0,0 +1,103 @@
using Furion;
using Furion.DataValidation;
using Furion.DependencyInjection;
using Furion.UnifyResult;
using Furion.UnifyResult.Internal;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using System;
using System.Threading.Tasks;
namespace OnvifWebServer.Extensions
{
/// <summary>
/// RESTful 风格返回值
/// </summary>
[SuppressSniffer, UnifyModel(typeof(RESTfulResult<>))]
public class RESTfulResultProvider : IUnifyResultProvider
{
/// <summary>
/// 异常返回值
/// </summary>
/// <param name="context"></param>
/// <param name="metadata"></param>
/// <returns></returns>
public IActionResult OnException(ExceptionContext context, ExceptionMetadata metadata)
{
return new JsonResult(RESTfulResult(metadata.StatusCode, errors: metadata.Errors));
}
/// <summary>
/// 成功返回值
/// </summary>
/// <param name="context"></param>
/// <param name="data"></param>
/// <returns></returns>
public IActionResult OnSucceeded(ActionExecutedContext context, object data)
{
return new JsonResult(RESTfulResult(StatusCodes.Status200OK, true, data));
}
/// <summary>
/// 验证失败返回值
/// </summary>
/// <param name="context"></param>
/// <param name="metadata"></param>
/// <returns></returns>
public IActionResult OnValidateFailed(ActionExecutingContext context, ValidationMetadata metadata)
{
return new JsonResult(RESTfulResult(StatusCodes.Status400BadRequest, errors: metadata.ValidationResult));
}
/// <summary>
/// 特定状态码返回值
/// </summary>
/// <param name="context"></param>
/// <param name="statusCode"></param>
/// <param name="unifyResultSettings"></param>
/// <returns></returns>
public async Task OnResponseStatusCodes(HttpContext context, int statusCode, UnifyResultSettingsOptions unifyResultSettings)
{
// 设置响应状态码
UnifyContext.SetResponseStatusCodes(context, statusCode, unifyResultSettings);
switch (statusCode)
{
// 处理 401 状态码
case StatusCodes.Status401Unauthorized:
await context.Response.WriteAsJsonAsync(RESTfulResult(statusCode, errors: "401 Unauthorized")
, App.GetOptions<JsonOptions>()?.JsonSerializerOptions);
break;
// 处理 403 状态码
case StatusCodes.Status403Forbidden:
await context.Response.WriteAsJsonAsync(RESTfulResult(statusCode, errors: "403 Forbidden")
, App.GetOptions<JsonOptions>()?.JsonSerializerOptions);
break;
default: break;
}
}
/// <summary>
/// 返回 RESTful 风格结果集
/// </summary>
/// <param name="statusCode"></param>
/// <param name="succeeded"></param>
/// <param name="data"></param>
/// <param name="errors"></param>
/// <returns></returns>
private static RESTfulResult<object> RESTfulResult(int statusCode, bool succeeded = default, object data = default, object errors = default)
{
return new RESTfulResult<object>
{
StatusCode = statusCode,
Succeeded = succeeded,
Data = data,
Errors = errors,
Extras = UnifyContext.Take(),
Timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
};
}
}
}

19
OnvifWebServer/OnvifWebServer.csproj

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<SatelliteResourceLanguages>zh-Hans</SatelliteResourceLanguages>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<AnalysisLevel>6.0</AnalysisLevel>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Furion" Version="2.20.7" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BaseModule\EC.App\EC.App.csproj" />
<ProjectReference Include="..\BusinessModule\EC.App.ThatBLL\EC.App.ThatBLL.csproj" />
</ItemGroup>
</Project>

22
OnvifWebServer/Program.cs

@ -0,0 +1,22 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
namespace OnvifWebServer
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder
.Inject() // Ìí¼ÓÕâÒ»ÐÐ
.UseStartup<Startup>();
});
}
}

29
OnvifWebServer/Properties/launchSettings.json

@ -0,0 +1,29 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:37315",
"sslPort": 44355
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"OnvifWebServer": {
"commandName": "Project",
"dotnetRunMessages": "true",
"launchBrowser": true,
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

48
OnvifWebServer/Startup.cs

@ -0,0 +1,48 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using OnvifWebServer.Extensions;
namespace OnvifWebServer
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers().AddInject().AddUnifyResult<RESTfulResultProvider>(); // 添加 AddInject();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthorization();
// 添加这一行,如果是 MVC和API共存项目,无需添加 string.Empty
app.UseInject(string.Empty);
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}

9
OnvifWebServer/appsettings.Development.json

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}

20
OnvifWebServer/appsettings.json

@ -0,0 +1,20 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
// https://dotnetchina.gitee.io/furion/docs/settings/appsettings
"AppSettings": {
"InjectSpecificationDocument": true // swagger
},
"DynamicApiControllerSettings": {
"KeepName": true, //
"KeepVerb": true, //
"LowercaseRoute": false, //
"UrlParameterization": true //
}
}
Loading…
Cancel
Save