public IList <Camera> GetCameras() { List <Camera> cameras = new List <Camera>(); Dictionary <Uri, ServiceProfile> services = ServiceProvider.GetServices <IMediaPublisherService>(); foreach (var item in services) { IMediaPublisherService service = ServiceProvider.GetService <IMediaPublisherService>(item.Value.HostName, item.Value.Uri.ToString()); GetPublishedCamerasRequest request = new GetPublishedCamerasRequest(); GetPublishedCamerasResponse response = service.GetPublishedCameras(request); foreach (var publishedCamera in response.PublishedCameras) { Camera camera = new Camera() { Id = publishedCamera.Profile.CameraId, Name = publishedCamera.Profile.CameraName, Url = string.Format(CultureInfo.InvariantCulture, @"http://{0}:{1}", item.Value.HostName, publishedCamera.Destination.Port), Port = publishedCamera.Destination.Port, }; cameras.Add(camera); } } return(cameras); }
public Camera GetCamera(string cameraId) { Dictionary <Uri, ServiceProfile> services = ServiceProvider.GetServices <IMediaPublisherService>(); foreach (var item in services) { IMediaPublisherService service = ServiceProvider.GetService <IMediaPublisherService>(item.Value.HostName, item.Value.Uri.ToString()); GetPublishedCamerasRequest request = new GetPublishedCamerasRequest(); GetPublishedCamerasResponse response = service.GetPublishedCameras(request); var publishedCamera = response.PublishedCameras.FirstOrDefault(c => c.Profile.CameraId == cameraId); if (publishedCamera != null) { Camera camera = new Camera() { Id = publishedCamera.Profile.CameraId, Name = publishedCamera.Profile.CameraName, Url = string.Format(CultureInfo.InvariantCulture, @"http://{0}:{1}", item.Value.HostName, publishedCamera.Destination.Port), Port = publishedCamera.Destination.Port, }; return(camera); } } return(null); }
public IList<Camera> GetCameras() { List<Camera> cameras = new List<Camera>(); Dictionary<Uri, ServiceProfile> services = ServiceProvider.GetServices<IMediaPublisherService>(); foreach (var item in services) { IMediaPublisherService service = ServiceProvider.GetService<IMediaPublisherService>(item.Value.HostName, item.Value.Uri.ToString()); GetPublishedCamerasRequest request = new GetPublishedCamerasRequest(); GetPublishedCamerasResponse response = service.GetPublishedCameras(request); foreach (var publishedCamera in response.PublishedCameras) { Camera camera = new Camera() { Id = publishedCamera.Profile.CameraId, Name = publishedCamera.Profile.CameraName, Url = string.Format(CultureInfo.InvariantCulture, @"http://{0}:{1}", item.Value.HostName, publishedCamera.Destination.Port), Port = publishedCamera.Destination.Port, }; cameras.Add(camera); } } return cameras; }
public Camera GetCamera(string cameraId) { Dictionary<Uri, ServiceProfile> services = ServiceProvider.GetServices<IMediaPublisherService>(); foreach (var item in services) { IMediaPublisherService service = ServiceProvider.GetService<IMediaPublisherService>(item.Value.HostName, item.Value.Uri.ToString()); GetPublishedCamerasRequest request = new GetPublishedCamerasRequest(); GetPublishedCamerasResponse response = service.GetPublishedCameras(request); var publishedCamera = response.PublishedCameras.FirstOrDefault(c => c.Profile.CameraId == cameraId); if (publishedCamera != null) { Camera camera = new Camera() { Id = publishedCamera.Profile.CameraId, Name = publishedCamera.Profile.CameraName, Url = string.Format(CultureInfo.InvariantCulture, @"http://{0}:{1}", item.Value.HostName, publishedCamera.Destination.Port), Port = publishedCamera.Destination.Port, }; return camera; } } return null; }
public byte[] GetCameraThumbnail(string cameraId) { Dictionary <Uri, ServiceProfile> services = ServiceProvider.GetServices <IMediaPublisherService>(); foreach (var item in services) { IMediaPublisherService service = ServiceProvider.GetService <IMediaPublisherService>(item.Value.HostName, item.Value.Uri.ToString()); GetPublishedCamerasRequest request = new GetPublishedCamerasRequest(); GetPublishedCamerasResponse response = service.GetPublishedCameras(request); var publishedCamera = response.PublishedCameras.FirstOrDefault(c => c.Profile.CameraId == cameraId); if (publishedCamera != null) { return(publishedCamera.Profile.CameraThumbnail); } } return(null); }
public byte[] GetCameraThumbnail(string cameraId) { Dictionary<Uri, ServiceProfile> services = ServiceProvider.GetServices<IMediaPublisherService>(); foreach (var item in services) { IMediaPublisherService service = ServiceProvider.GetService<IMediaPublisherService>(item.Value.HostName, item.Value.Uri.ToString()); GetPublishedCamerasRequest request = new GetPublishedCamerasRequest(); GetPublishedCamerasResponse response = service.GetPublishedCameras(request); var publishedCamera = response.PublishedCameras.FirstOrDefault(c => c.Profile.CameraId == cameraId); if (publishedCamera != null) { return publishedCamera.Profile.CameraThumbnail; } } return null; }
public void CheckPortAvailable(string hostUri, int port, EventHandler <AsyncWorkerCallbackEventArgs <bool> > callback) { if (port <= 0) { throw new ArgumentNullException("port"); } try { AsyncWorkerHandle <bool> handle = AsyncWorkerHelper.DoWork <bool>( delegate(object sender, DoWorkEventArgs e) { e.Result = true; // check here, true is available, false is not available MediaService service = GetMediaPublisherServiceSync(hostUri); GetPublishedCamerasRequest request = new GetPublishedCamerasRequest(); GetPublishedCamerasResponse response = ServiceProvider .GetService <IMediaPublisherService>(service.HostName, service.Uri.ToString()) .GetPublishedCameras(request); if (response.PublishedCameras != null) { foreach (var item in response.PublishedCameras) { if (item.Destination.Port == port) { e.Result = false; // find this port is in using, so it's not available break; } } } }, null, callback); } catch (Exception ex) { ExceptionHandler.Handle(ex); } }
public void CheckPortAvailable(string hostUri, int port, EventHandler<AsyncWorkerCallbackEventArgs<bool>> callback) { if (port <= 0) throw new ArgumentNullException("port"); try { AsyncWorkerHandle<bool> handle = AsyncWorkerHelper.DoWork<bool>( delegate(object sender, DoWorkEventArgs e) { e.Result = true; // check here, true is available, false is not available MediaService service = GetMediaPublisherServiceSync(hostUri); GetPublishedCamerasRequest request = new GetPublishedCamerasRequest(); GetPublishedCamerasResponse response = ServiceProvider .GetService<IMediaPublisherService>(service.HostName, service.Uri.ToString()) .GetPublishedCameras(request); if (response.PublishedCameras != null) { foreach (var item in response.PublishedCameras) { if (item.Destination.Port == port) { e.Result = false; // find this port is in using, so it's not available break; } } } }, null, callback); } catch (Exception ex) { ExceptionHandler.Handle(ex); } }
public GetPublishedCamerasResponse GetPublishedCameras(GetPublishedCamerasRequest request) { try { if (request == null) { throw new ArgumentNullException("request"); } GetPublishedCamerasResponse response = new GetPublishedCamerasResponse(); response.PublishedCameras = new PublishedCameraDataCollection(); IList <PublishedCamera> list = Locator.Get <IStreamingManager>().GetPublishedCameras(); response.PublishedCameras.AddRange((from c in list select PublishedCameraTranslator.Translate(c)).ToList()); return(response); } catch (Exception ex) { throw new FaultException <DeviceConnectorServiceFault>(new DeviceConnectorServiceFault(ex.Message, ex), ex.Message); } }
public GetPublishedCamerasResponse GetPublishedCameras(GetPublishedCamerasRequest request) { try { if (request == null) { throw new ArgumentNullException("request"); } GetPublishedCamerasResponse response = new GetPublishedCamerasResponse(); IList <PublishedCamera> list = Locator.Get <IPublishedCameraManager>().GetPublishedCameras(); foreach (var item in list) { PublishedCameraData camera = new PublishedCameraData() { Profile = new PublishedCameraProfileData() { CameraId = item.Profile.CameraId, CameraName = item.Profile.CameraName, CameraThumbnail = item.Profile.CameraThumbnail, DeviceServiceHostName = item.Profile.DeviceServiceHostName, DeviceServiceUri = item.Profile.DeviceServiceUri, }, Destination = new PublishedDestinationData() { Port = item.Destination.Port, }, }; response.PublishedCameras.Add(camera); } return(response); } catch (Exception ex) { throw new FaultException <MediaPublisherServiceFault>(new MediaPublisherServiceFault(ex.Message, ex), ex.Message); } }
private static List <PublishedCamera> GetPublishedCamerasSync() { List <MediaService> services = GetMediaPublisherServicesSync(); List <PublishedCamera> cameras = new List <PublishedCamera>(); foreach (var service in services) { GetPublishedCamerasRequest request = new GetPublishedCamerasRequest(); GetPublishedCamerasResponse response = ServiceProvider .GetService <IMediaPublisherService>(service.HostName, service.Uri.ToString()) .GetPublishedCameras(request); if (response.PublishedCameras != null) { foreach (var item in response.PublishedCameras) { PublishedCamera camera = new PublishedCamera( new PublishedCameraProfile(item.Profile.CameraId, item.Profile.CameraName) { CameraThumbnail = item.Profile.CameraThumbnail, DeviceServiceHostName = item.Profile.DeviceServiceHostName, DeviceServiceUri = item.Profile.DeviceServiceUri, }, new PublishedDestination(item.Destination.Port)) { PublishServiceHostName = service.HostName, PublishServiceUri = service.Uri.ToString(), }; cameras.Add(camera); } } } return(cameras); }
public GetPublishedCamerasResponse GetPublishedCameras(GetPublishedCamerasRequest request) { try { if (request == null) throw new ArgumentNullException("request"); GetPublishedCamerasResponse response = new GetPublishedCamerasResponse(); IList<PublishedCamera> list = Locator.Get<IPublishedCameraManager>().GetPublishedCameras(); foreach (var item in list) { PublishedCameraData camera = new PublishedCameraData() { Profile = new PublishedCameraProfileData() { CameraId = item.Profile.CameraId, CameraName = item.Profile.CameraName, CameraThumbnail = item.Profile.CameraThumbnail, DeviceServiceHostName = item.Profile.DeviceServiceHostName, DeviceServiceUri = item.Profile.DeviceServiceUri, }, Destination = new PublishedDestinationData() { Port = item.Destination.Port, }, }; response.PublishedCameras.Add(camera); } return response; } catch (Exception ex) { throw new FaultException<MediaPublisherServiceFault>(new MediaPublisherServiceFault(ex.Message, ex), ex.Message); } }
private static List<PublishedCamera> GetPublishedCamerasSync() { List<MediaService> services = GetMediaPublisherServicesSync(); List<PublishedCamera> cameras = new List<PublishedCamera>(); foreach (var service in services) { GetPublishedCamerasRequest request = new GetPublishedCamerasRequest(); GetPublishedCamerasResponse response = ServiceProvider .GetService<IMediaPublisherService>(service.HostName, service.Uri.ToString()) .GetPublishedCameras(request); if (response.PublishedCameras != null) { foreach (var item in response.PublishedCameras) { PublishedCamera camera = new PublishedCamera( new PublishedCameraProfile(item.Profile.CameraId, item.Profile.CameraName) { CameraThumbnail = item.Profile.CameraThumbnail, DeviceServiceHostName = item.Profile.DeviceServiceHostName, DeviceServiceUri = item.Profile.DeviceServiceUri, }, new PublishedDestination(item.Destination.Port)) { PublishServiceHostName = service.HostName, PublishServiceUri = service.Uri.ToString(), }; cameras.Add(camera); } } } return cameras; }
public GetPublishedCamerasResponse GetPublishedCameras(GetPublishedCamerasRequest request) { try { if (request == null) throw new ArgumentNullException("request"); GetPublishedCamerasResponse response = new GetPublishedCamerasResponse(); response.PublishedCameras = new PublishedCameraDataCollection(); IList<PublishedCamera> list = Locator.Get<IStreamingManager>().GetPublishedCameras(); response.PublishedCameras.AddRange((from c in list select PublishedCameraTranslator.Translate(c)).ToList()); return response; } catch (Exception ex) { throw new FaultException<DeviceConnectorServiceFault>(new DeviceConnectorServiceFault(ex.Message, ex), ex.Message); } }