public static void PTZHome(Structures set, OPTZ.PTZSpeed speed) { try { if (set.GetPTZTokens() == "" || !set.IsActive || !set.GetPTZController().IsSuported) { return; } var messageElement = new TextMessageEncodingBindingElement(); messageElement.MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.None); HttpTransportBindingElement httpBinding = new HttpTransportBindingElement(); httpBinding.AuthenticationScheme = AuthenticationSchemes.Basic; CustomBinding bind = new CustomBinding(messageElement, httpBinding); EndpointAddress mediaAddress = new EndpointAddress(set.GetONVIF + "/onvif/PTZ"); PTZClient mediaClient = new PTZClient(bind, mediaAddress); mediaClient.ClientCredentials.UserName.UserName = set.Login; mediaClient.ClientCredentials.UserName.Password = set.Password; mediaClient.GotoHomePosition(set.GetPTZTokens(), speed); } catch { return; } }
public static void CountinuousRotatePTZ(Structures set, OPTZ.PTZSpeed speed, int timeout = -1) { try { if (set.GetPTZTokens() == "" || !set.IsActive) { return; } var messageElement = new TextMessageEncodingBindingElement(); messageElement.MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.None); HttpTransportBindingElement httpBinding = new HttpTransportBindingElement(); httpBinding.AuthenticationScheme = AuthenticationSchemes.Basic; CustomBinding bind = new CustomBinding(messageElement, httpBinding); EndpointAddress mediaAddress = new EndpointAddress(set.GetONVIF + "onvif/PTZ"); PTZClient mediaClient = new PTZClient(bind, mediaAddress); mediaClient.ClientCredentials.UserName.UserName = set.Login; mediaClient.ClientCredentials.UserName.Password = set.Password; mediaClient.ContinuousMove(set.GetMediaTokens()[0], speed, "0"); System.Threading.Thread.Sleep(timeout <= 0 ? (int)Settings.StaticMembers.PTZSettings.Timeout : timeout);//1000 mediaClient.Stop(set.GetPTZTokens(), true, true); } catch { return; } }
public static void RotatePTZ(Structures set, PTZVector vector, OPTZ.PTZSpeed speed) { try { if (set.GetPTZTokens() == "" || !set.IsActive) { return; } var messageElement = new TextMessageEncodingBindingElement(); messageElement.MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.None); HttpTransportBindingElement httpBinding = new HttpTransportBindingElement(); httpBinding.AuthenticationScheme = AuthenticationSchemes.Basic; CustomBinding bind = new CustomBinding(messageElement, httpBinding); EndpointAddress mediaAddress = new EndpointAddress(set.GetONVIF + "/onvif/PTZ"); PTZClient mediaClient = new PTZClient(bind, mediaAddress); mediaClient.ClientCredentials.UserName.UserName = set.Login; mediaClient.ClientCredentials.UserName.Password = set.Password; var t = mediaClient.GetConfigurations()[0].DefaultPTZTimeout; mediaClient.RelativeMove(set.GetMediaTokens()[0], vector, speed); //set.GetMediaTokens()[0] //mediaClient.ContinuousMove(set.GetMediaTokens()[0], speed) } catch { return; } }
public static void AsyncCountinuousRotatePTZ(Structures set, OPTZ.PTZSpeed speed) { Thread th = new Thread(new ParameterizedThreadStart(_AsyncCountinuousRotatePTZ)); th.Start(new CRPTZ(set, speed)); }
public CRPTZ(Structures set, OPTZ.PTZSpeed speed) { this.set = set; this.speed = speed; }