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 void UnpublishCamera(string cameraId, ICollection <PublishDestination> destinations) { lock (_accessLock) { if (destinations == null) { throw new ArgumentNullException("destinations"); } PublishedCamera camera = GetPublishedCamera(cameraId); if (camera != null) { foreach (var dest in destinations) { camera.RemoveDestination(dest); DateTime aliveTime; _timeToAlive.TryRemove( new CameraPublishDestination(cameraId, dest), out aliveTime); } if (camera.Destinations.Count <= 0) { camera.CameraErrorOccurred -= new EventHandler <CameraErrorOccurredEventArgs>(OnCameraErrorOccurred); camera.Stop(); _cameras.Remove(camera); camera.Dispose(); } } } }
public void UnpublishCamera(string cameraId) { lock (_accessLock) { PublishedCamera camera = GetPublishedCamera(cameraId); if (camera != null) { foreach (var dest in camera.Destinations) { DateTime aliveTime; _timeToAlive.TryRemove( new CameraPublishDestination(cameraId, dest), out aliveTime); } camera.ClearDestination(); camera.CameraErrorOccurred -= new EventHandler <CameraErrorOccurredEventArgs>(OnCameraErrorOccurred); camera.Stop(); _cameras.Remove(camera); camera.Dispose(); } } }
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); }