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; }
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); } }
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); }
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; } }