예제 #1
0
        /// <summary>
        /// Changes the camera device.
        /// </summary>
        public void ChangeCamera(int deviceID)
        {
            if (!initialized)
            {
                return;
            }

            // same device
            if (WebCamera != null && WebCamera.DeviceID == deviceID)
            {
                return;
            }

            // find the proper info
            VideoDeviceInfo newDeviceInfo = null;

            foreach (var info in Cameras)
            {
                if (info.DeviceID != deviceID)
                {
                    continue;
                }

                newDeviceInfo = info;
                break;
            }

            if (newDeviceInfo == null)
            {
                return;
            }


            // begin change device
            bool capturing = false;

            if (WebCamera != null)
            {
                // disconnect
                if (LocalImageProvider != null)
                {
                    audioConnector.Disconnect(WebCamera, LocalImageProvider);
                }
                audioConnector.Disconnect(WebCamera, phoneCallVideoSender);

                // dispose previous device
                capturing = WebCamera.Capturing;
                WebCamera.Stop();
                WebCamera.Dispose();
            }

            // create new
            WebCamera = WebCamera.GetDevice(newDeviceInfo);

            if (WebCamera != null)
            {
                audioConnector.Connect(WebCamera, LocalImageProvider);
                audioConnector.Connect(WebCamera, phoneCallVideoSender);

                if (capturing)
                {
                    WebCamera.Start();
                }
            }

            OnPropertyChanged("WebCamera");
        }
예제 #2
0
 public WebCameraEngine(VideoDeviceInfo device)
 {
     _camera     = WebCamera.GetDevice(device);
     _microphone = Microphone.GetDefaultDevice();
 }