Пример #1
0
        public byte[] GetCameraSnapshot(string cameraId)
        {
            byte[] snapshot;

              PublishedCamera camera = GetPublishedCamera(cameraId);
              if (camera != null)
              {
            do
            {
              snapshot = camera.LatestFrameBytes;
              if (snapshot == null) Thread.Sleep(TimeSpan.FromMilliseconds(100));
            }
            while (snapshot == null);
              }
              else
              {
            using (camera = new PublishedCamera(Locator.Get<ICameraManager>().GetCamera(cameraId)))
            {
              camera.Start();

              do
              {
            snapshot = camera.LatestFrameBytes;
            if (snapshot == null) Thread.Sleep(TimeSpan.FromMilliseconds(100));
              }
              while (snapshot == null);

              camera.Stop();
            }
              }

              return snapshot;
        }
Пример #2
0
        public PublishedCamera PublishCamera(string cameraId, PublishDestination destination)
        {
            lock (_accessLock)
            {
                if (destination == null)
                {
                    throw new ArgumentNullException("destination");
                }

                PublishedCamera camera = GetPublishedCamera(cameraId);

                if (camera != null)
                {
                    camera.AddDestination(destination);
                }
                else
                {
                    camera        = new PublishedCamera(Locator.Get <ICameraManager>().GetCamera(cameraId)).AddDestination(destination);
                    camera.Sender = StreamSenderFactory.GetSender().Start();
                    camera.CameraErrorOccurred += new EventHandler <CameraErrorOccurredEventArgs>(OnCameraErrorOccurred);
                    camera.Start();
                    _cameras.Add(camera);

                    _timeToAlive.AddOrUpdate(new CameraPublishDestination(cameraId, destination),
                                             DateTime.Now, (k, v) => { return(DateTime.Now); });
                }

                return(camera);
            }
        }
Пример #3
0
        public byte[] GetCameraSnapshot(string cameraId)
        {
            byte[] snapshot;

            PublishedCamera camera = GetPublishedCamera(cameraId);

            if (camera != null)
            {
                do
                {
                    snapshot = camera.LatestFrameBytes;
                    if (snapshot == null)
                    {
                        Thread.Sleep(TimeSpan.FromMilliseconds(100));
                    }
                }while (snapshot == null);
            }
            else
            {
                using (camera = new PublishedCamera(Locator.Get <ICameraManager>().GetCamera(cameraId)))
                {
                    camera.Start();

                    do
                    {
                        snapshot = camera.LatestFrameBytes;
                        if (snapshot == null)
                        {
                            Thread.Sleep(TimeSpan.FromMilliseconds(100));
                        }
                    }while (snapshot == null);

                    camera.Stop();
                }
            }

            return(snapshot);
        }
Пример #4
0
        public PublishedCamera PublishCamera(string cameraId, PublishDestination destination)
        {
            lock (_accessLock)
              {
            if (destination == null)
              throw new ArgumentNullException("destination");

            PublishedCamera camera = GetPublishedCamera(cameraId);

            if (camera != null)
            {
              camera.AddDestination(destination);
            }
            else
            {
              camera = new PublishedCamera(Locator.Get<ICameraManager>().GetCamera(cameraId)).AddDestination(destination);
              camera.Sender = StreamSenderFactory.GetSender().Start();
              camera.CameraErrorOccurred += new EventHandler<CameraErrorOccurredEventArgs>(OnCameraErrorOccurred);
              camera.Start();
              _cameras.Add(camera);

              _timeToAlive.AddOrUpdate(new CameraPublishDestination(cameraId, destination),
            DateTime.Now, (k, v) => { return DateTime.Now; });
            }

            return camera;
              }
        }