static async Task AsyncHelper(BaseOnvifPtzCamera camera)
        {
            camera.Camera = await OnvifClientFactory.CreateDeviceClientAsync(camera.HostAddress, camera.UserName, camera.Password);

            camera.Media = await OnvifClientFactory.CreateMediaClientAsync(camera.HostAddress, camera.UserName, camera.Password);

            camera.PtzController = await OnvifClientFactory.CreatePTZClientAsync(camera.HostAddress, camera.UserName, camera.Password);
        }
        /// <summary>
        /// Sets up the connection to the camera, enquires to get metadata from the Onvif service
        /// </summary>
        /// <param name="camera"></param>
        /// <returns></returns>
        static async Task AsyncHelper(BaseOnvifPtzCamera camera)
        {
            Globals.Log.Debug(string.Format("Connecting to camera at {0}", camera.HostAddress));

            camera.Camera = await OnvifClientFactory.CreateDeviceClientAsync(camera.HostAddress, camera.UserName, camera.Password);

            camera.MediaClient   = await OnvifClientFactory.CreateMediaClientAsync(camera.HostAddress, camera.UserName, camera.Password);;
            camera.PtzController = await OnvifClientFactory.CreatePTZClientAsync(camera.HostAddress, camera.UserName, camera.Password);

            Mictlanix.DotNet.Onvif.Media.GetProfilesResponse profiles = await camera.MediaClient.GetProfilesAsync();

            camera.MediaProfile = profiles.Profiles.FirstOrDefault();
            if (camera.MediaProfile != null)
            {
                StreamSetup streamSetup = new StreamSetup
                {
                    Stream = StreamType.RTPUnicast, Transport = new Transport()
                };

                streamSetup.Transport.Protocol = TransportProtocol.TCP;
                MediaUri videoStreamUriObject = await camera.MediaClient.GetStreamUriAsync(streamSetup, camera.MediaProfile.Name);

                camera.VideoStreamUri = videoStreamUriObject.Uri;
            }

            Mictlanix.DotNet.Onvif.Device.GetNetworkProtocolsRequest  request  = new Mictlanix.DotNet.Onvif.Device.GetNetworkProtocolsRequest();
            Mictlanix.DotNet.Onvif.Device.GetNetworkProtocolsResponse response = await camera.Camera.GetNetworkProtocolsAsync(request);

            // store http and rtsp ports
            foreach (NetworkProtocol protocol in response.NetworkProtocols)
            {
                string protocolName = protocol.Name.ToString();
                switch (protocolName)
                {
                case "HTTP":
                    camera.HttpPort = protocol.Port[0];
                    break;

                case "RTSP":
                    camera.RtspPort = protocol.Port[0];
                    break;
                }
            }

            Mictlanix.DotNet.Onvif.Media.GetVideoSourcesResponse video_sources = await camera.MediaClient.GetVideoSourcesAsync();

            Globals.Log.Debug("Camera connected");
        }