public VideoFrame GetFrame(Guid deviceId, Guid vsid)
        {
            ServerConnectionParameters connectionParameters = this._videoServerCache.GetVideoServerConnectionParameters(vsid);

            if (connectionParameters == null)
            {
                return((VideoFrame)null);
            }
            this._log.Debug((object)string.Format("Request to VideoServer DevId={0}", (object)deviceId));
            return(this.GetOrCreateVideoServerClient(vsid, connectionParameters).GetDetectorFrame(deviceId));
        }
        private VideoServerClient GetOrCreateVideoServerClient(Guid vsId, ServerConnectionParameters cp)
        {
            VideoServerClient videoServerClient = this._clients.GetOrAdd(vsId, (Func <Guid, VideoServerClient>)(guid => VideoServerInteraction.CreateAndOpen(cp.Ip, cp.Port)));

            if ((videoServerClient.State == CommunicationState.Faulted || videoServerClient.Endpoint.Address.Uri.Host != cp.Ip || videoServerClient.Endpoint.Address.Uri.Port != cp.Port) && this._clients.TryRemove(vsId, out videoServerClient))
            {
                this.TryCloseClient((ICommunicationObject)videoServerClient);
                videoServerClient = VideoServerInteraction.CreateAndOpen(cp.Ip, cp.Port);
                this._clients.TryAdd(vsId, videoServerClient);
            }
            return(videoServerClient);
        }
Пример #3
0
        public ServerConnectionParameters GetVideoServerConnectionParameters(Guid vsid)
        {
            string key = vsid.ToString();
            ServerConnectionParameters connectionParameters1 = this._videoServersCache.Get(key, (string)null) as ServerConnectionParameters;

            if (connectionParameters1 != null)
            {
                return(connectionParameters1);
            }
            BcVideoServer bcVideoServer = this.TryLoadVideServer(vsid);

            if (bcVideoServer == null)
            {
                return((ServerConnectionParameters)null);
            }
            ServerConnectionParameters connectionParameters2 = new ServerConnectionParameters(bcVideoServer.Ip, bcVideoServer.Port);

            this._videoServersCache.Set(key, (object)connectionParameters2, (DateTimeOffset)DateTime.Now.AddSeconds(10.0), (string)null);
            return(connectionParameters2);
        }