コード例 #1
0
        protected override void BindCommands()
        {
            OKCommand = new RelayCommand(() =>
            {
                PublishedCameraProfile profile = new PublishedCameraProfile(SelectedCamera.Id, SelectedCamera.Name)
                {
                    CameraThumbnail       = SelectedCamera.Thumbnail,
                    DeviceServiceHostName = SelectedCamera.HostName,
                    DeviceServiceUri      = SelectedCamera.HostUri,
                };
                PublishedDestination destination = new PublishedDestination(DestinationPort);

                Status = ViewModelStatus.Saving;
                Model.PublishCamera(SelectedService.Uri.ToString(), profile, destination, PublishCameraCallback);
            });

            CancelCommand = new RelayCommand(() =>
            {
                Messenger.Default.Send(new NotificationMessage(UIMessageType.PublishMedia_CancelConfigCameraEvent));
            });

            CheckPortAvailableCommand = new RelayCommand(() =>
            {
                Status = ViewModelStatus.Loading;
                Model.CheckPortAvailable(SelectedService.Uri.ToString(), DestinationPort, CheckPortAvailableCallback);
            });
        }
コード例 #2
0
 public void PublishCamera(string hostUri, PublishedCameraProfile profile, PublishedDestination destination, EventHandler <AsyncWorkerCallbackEventArgs <bool> > callback)
 {
     try
     {
         AsyncWorkerHandle <bool> handle = AsyncWorkerHelper.DoWork <bool>(
             delegate(object sender, DoWorkEventArgs e)
         {
             e.Result = PublishCameraSync(hostUri, profile, destination);
         },
             null, callback);
     }
     catch (Exception ex)
     {
         ExceptionHandler.Handle(ex);
     }
 }
コード例 #3
0
        public void UnpublishCamera(string cameraId, PublishedDestination destination)
        {
            lock (_syncRoot)
            {
                if (destination == null)
                {
                    throw new ArgumentNullException("destination");
                }

                PublishedCamera camera = _cameras.Find(c => c.Profile.CameraId == cameraId && c.Destination.Port == destination.Port);
                if (camera != null)
                {
                    Locator.Get <IStreamingManager>().StopCameraStreaming(camera);
                    Locator.Get <IPublishedCameraRepository>().Remove(camera.Id);
                    _cameras.Remove(camera);
                }
            }
        }
コード例 #4
0
        public PublishedCamera PublishCamera(PublishedCameraProfile profile, PublishedDestination destination)
        {
            lock (_syncRoot)
            {
                if (profile == null)
                {
                    throw new ArgumentNullException("profile");
                }
                if (destination == null)
                {
                    throw new ArgumentNullException("destination");
                }

                PublishedCamera camera = _cameras.Find(c => c.Profile.CameraId == profile.CameraId && c.Destination == destination);
                if (camera == null)
                {
                    camera = new PublishedCamera(profile, destination);
                    Locator.Get <IStreamingManager>().StartCameraStreaming(camera);
                    _cameras.Add(camera);

                    DA::PublishedCamera entity = new DA::PublishedCamera()
                    {
                        Id      = camera.Id,
                        Profile = new DA::PublishedCameraProfile()
                        {
                            CameraId              = profile.CameraId,
                            CameraName            = profile.CameraName,
                            CameraThumbnail       = profile.CameraThumbnail,
                            DeviceServiceHostName = profile.DeviceServiceHostName,
                            DeviceServiceUri      = profile.DeviceServiceUri,
                        },
                        Destination = new DA::Destination()
                        {
                            Port = camera.Destination.Port,
                        },
                    };
                    Locator.Get <IPublishedCameraRepository>().Save(entity);
                }

                return(camera);
            }
        }
コード例 #5
0
        private static bool PublishCameraSync(string hostUri, PublishedCameraProfile profile, PublishedDestination destination)
        {
            MediaService service = GetMediaPublisherServiceSync(hostUri);

            if (service != null)
            {
                PublishCameraRequest request = new PublishCameraRequest()
                {
                    Profile = new PublishedCameraProfileData()
                    {
                        CameraId              = profile.CameraId,
                        CameraName            = profile.CameraName,
                        CameraThumbnail       = profile.CameraThumbnail,
                        DeviceServiceHostName = profile.DeviceServiceHostName,
                        DeviceServiceUri      = profile.DeviceServiceUri,
                    },
                    Destination = new PublishedDestinationData()
                    {
                        Port = destination.Port,
                    },
                };
                PublishCameraResponse response =
                    ServiceProvider
                    .GetService <IMediaPublisherService>(service.HostName, service.Uri.ToString())
                    .PublishCamera(request);
            }

            return(true);
        }