Ejemplo n.º 1
0
 public void UpdateDevices()
 {
     VideoDevices.Clear();
     AudioDevices.Clear();
     MpsseDevices.Clear();
     PeachCam.EnumerateDevices();
 }
Ejemplo n.º 2
0
        public void UpdateDevices()
        {
            InputDevices.Clear();
            OutputDevices.Clear();
            VideoDevices.Clear();

            for (int i = 0; i < WaveIn.DeviceCount; i++)
            {
                InputDevices.Add(new InputMenuData {
                    Name = WaveIn.GetCapabilities(i).ProductName
                });
            }

            for (int i = 0; i < WaveOut.DeviceCount; i++)
            {
                OutputDevices.Add(new OutputMenuData {
                    Name = WaveOut.GetCapabilities(i).ProductName
                });
            }

            var videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

            foreach (FilterInfo device in videoDevices)
            {
                VideoDevices.Add(new VideoMenuData {
                    Name = device.Name
                });
            }
        }
Ejemplo n.º 3
0
        private static void SetupMessageHandlers()
        {
            connection.AppendIncomingPacketHandler <byte>("GetCameraDevices", (header, connection, data) =>
            {
                string[] names       = WebcamHelper.GetDeviceNames();
                VideoDevices devices = new VideoDevices()
                {
                    videoDevices = new VideoDevice[names.Length]
                };
                for (int i = 0; i < devices.videoDevices.Length; i++)
                {
                    VideoCapabilities[] capabilities = WebcamHelper.GetDeviceCapabilities(i);
                    devices.videoDevices[i]          = new VideoDevice()
                    {
                        name         = names[i],
                        capabilities = new VideoDeviceCapabilities[capabilities.Length]
                    };
                    for (int j = 0; j < capabilities.Length; j++)
                    {
                        devices.videoDevices[i].capabilities[j] = new VideoDeviceCapabilities()
                        {
                            averageFramerate = capabilities[j].AverageFrameRate,
                            maxFramerate     = capabilities[j].MaximumFrameRate,
                            height           = capabilities[j].FrameSize.Height,
                            width            = capabilities[j].FrameSize.Width
                        };
                    }
                }
                connection.SendObject <byte[]>("CameraDevices", Serializer.Serialize <VideoDevices>(devices, encryptionKey));
            });

            connection.AppendIncomingPacketHandler <byte[]>("GetCameraImage", (header, connection, data) =>
            {
                GetImage image = Serializer.Deserialize <GetImage>(data, encryptionKey);
                WebcamHelper.GetWebcamImage(image.deviceIndex, image.width, image.height, (bitmapImage) =>
                {
                    connection.SendObject <byte[]>("CameraImage", Serializer.Serialize <ByteData>(new ByteData()
                    {
                        data = WebcamHelper.GetImagePNGBytes(bitmapImage)
                    }, encryptionKey));
                });
            });

            connection.AppendIncomingPacketHandler <byte>("GetDesktopImage", (header, connection, data) =>
            {
                connection.SendObject <byte[]>("DesktopImage", Serializer.Serialize <ByteData>(new ByteData()
                {
                    data = WebcamHelper.GetImagePNGBytes(WebcamHelper.GetDesktopScreenshot())
                }, encryptionKey));
            });

            connection.AppendIncomingPacketHandler <byte>("GetLocation", (header, connection, data) =>
            {
                LocationHelper.GetPosition((location) =>
                {
                    connection.SendObject <byte[]>("Location", Serializer.Serialize <DeviceLocation>(location, encryptionKey));
                });
            });
        }
Ejemplo n.º 4
0
        private static VideoDevices ValidateDevice(BusinessObject o, VideoDevices e)
        {
            if (IsDeviceLegal(e) == false)
            {
                //show message
            }

            return(e);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Initialize video device.
        /// </summary>
        /// <param name="videoDeviceSourceId">Video device source Id.</param>
        /// <exception cref="InvalidOperationException">Throws invalid operation exception if video device source setup fails.</exception>
        private void InitializeVideoDevice(string videoDeviceSourceId)
        {
            if (isVideoSourceInitialized)
            {
                return;
            }

            var errorAction = new Action(() => SetVideoPlayer(false, "Unable to set video device source"));

            ReleaseVideoDevice();
            if (string.IsNullOrEmpty(videoDeviceSourceId))
            {
                return;
            }

            if (videoDeviceSourceId.StartsWith("Message:", StringComparison.OrdinalIgnoreCase))
            {
                var splitString = videoDeviceSourceId.Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
                if (splitString.Length == 2)
                {
                    SetVideoPlayer(false, splitString[1]);
                }
                else
                {
                    SetVideoPlayer(false);
                }
            }
            else
            {
                try
                {
                    if (!VideoDevices.Any(item => item.UsbId.Equals(videoDeviceSourceId)))
                    {
                        return;
                    }

                    videoCaptureDevice            = new VideoCaptureDevice(videoDeviceSourceId);
                    VideoSourcePlayer.VideoSource = videoCaptureDevice;
                    VideoSourcePlayer.Start();
                    isVideoSourceInitialized = true;
                    SetVideoPlayer(true);
                }
                catch (ArgumentNullException)
                {
                    errorAction();
                }
                catch (ArgumentException)
                {
                    errorAction();
                }
            }
        }
Ejemplo n.º 6
0
        private void GetVideoDevices()
        {
            var devices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

            foreach (FilterInfo device in devices)
            {
                VideoDevices.Add(device);
            }
            if (VideoDevices.Any())
            {
                CurrentDevice = VideoDevices[0];
            }
        }
Ejemplo n.º 7
0
        public List <FilterInfo> GetVideoDevices()
        {
            var devices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

            foreach (FilterInfo device in devices)
            {
                VideoDevices.Add(device);
            }
            if (VideoDevices.Any())
            {
                CurrentDevice = VideoDevices[0];
            }

            return(VideoDevices);
        }
Ejemplo n.º 8
0
        private void GetVideoDevices()
        {
            var devices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

            foreach (FilterInfo device in devices)
            {
                VideoDevices.Add(device);
            }
            if (VideoDevices.Any())
            {
                CurrentDevice = VideoDevices[0];
            }
            else
            {
                MessageBox.Show("No webcam found");
            }
        }
Ejemplo n.º 9
0
        public void AddDevice(DeviceType deviceType, int index, string description, string friendlyName)
        {
            switch (deviceType)
            {
            case DeviceType.Video:
                VideoDevices.Add(new Tuple <int, string, string>(index, description, friendlyName));
                break;

            case DeviceType.Audio:
                AudioDevices.Add(new Tuple <int, string, string>(index, description, friendlyName));
                break;

            case DeviceType.MPSSE:
                MpsseDevices.Add(new Tuple <int, string, string>(index, description, friendlyName));
                break;
            }
        }
Ejemplo n.º 10
0
        private void ZoomServiceOnInitializedChanged(object sender, bool initialized)
        {
            if (initialized)
            {
                VideoDevices = _zoomService.EnumerateVideoDevices()?.ToList();
                if (VideoDevices != null && VideoDevices.Count > 0)
                {
                    SelectedVideoDevice = VideoDevices.First();
                }

                MicDevices = _zoomService.EnumerateMicDevices()?.ToList();
                if (MicDevices != null && MicDevices.Count > 0)
                {
                    SelectedMicDevice = MicDevices.First();
                }

                SpeakerDevices = _zoomService.EnumerateSpeakerDevices()?.ToList();
                if (SpeakerDevices != null && SpeakerDevices.Count > 0)
                {
                    SelectedSpeakerDevice = SpeakerDevices.First();
                }
            }
        }
Ejemplo n.º 11
0
        internal void UpdateDevices()
        {
            var tDevEnum = Type.GetTypeFromCLSID(
                new Guid("62be5d10-60eb-11d0-bd3b-00a0c911ce86"));
            var          devEnum     = (ICreateDevEnum)Activator.CreateInstance(tDevEnum);
            IEnumMoniker enumMoniker = null;
            var          cat         = new Guid("860bb310-5d01-11d0-bd3b-00a0c911ce86");

            VideoDevices.Clear();
            AudioDevices.Clear();

            devEnum.CreateClassEnumerator(ref cat, out enumMoniker, 0);
            if (enumMoniker != null)
            {
                VideoDevices.AddRange(DisplayDeviceInformation(DeviceType.Video, enumMoniker));
            }

            cat = new Guid("33d9a762-90c8-11d0-bd43-00a0c911ce86");
            devEnum.CreateClassEnumerator(ref cat, out enumMoniker, 0);
            if (enumMoniker != null)
            {
                AudioDevices.AddRange(DisplayDeviceInformation(DeviceType.Audio, enumMoniker));
            }
        }
Ejemplo n.º 12
0
        public void FillData()
        {
            //engine setting
            uint width, height;

            Engine.Instance.Driver.GetDisplayMode(out width, out height);
            SVideoSetting videoSetting = Engine.Instance.VideoSetting;

            //
            DisplayModes.Clear();
            DisplayModes.Add(new DisplayMode()
            {
                WindowMode = true
            });
            _cbDisplayModes.SelectedIndex     = 0;
            _cbDisplayModes.SelectionChanged += new SelectionChangedEventHandler(_option_SelectionChanged);

            //
            Resolutions.Clear();
            Resolutions.Add(new Resolution()
            {
                Width = width, Height = height
            });

            _cbResolutions.SelectedIndex     = 0;
            _cbResolutions.SelectionChanged += new SelectionChangedEventHandler(_option_SelectionChanged);

            //

            RefreshRates.Default();
            _cbRefreshRates.SelectedIndex     = 0;
            _cbRefreshRates.SelectionChanged += new SelectionChangedEventHandler(_option_SelectionChanged);

            //
            VideoDevices.Clear();
            VideoDevices.Add(new VideoDevice()
            {
                Index = 0
            });

            _cbVideoDevices.SelectedIndex     = 0;
            _cbVideoDevices.SelectionChanged += new SelectionChangedEventHandler(_option_SelectionChanged);

            //
            MultiSamples.Default();
            _cbMultisamples.SelectedItem      = (from x in MultiSamples where x.Sample == videoSetting.antialias select x).ToArray()[0];
            _cbMultisamples.SelectionChanged += new SelectionChangedEventHandler(_option_SelectionChanged);

            //
            _cbVsyncs.SelectedItem      = (from x in VSyncs where x.On == videoSetting.vsync select x).ToArray()[0];
            _cbVsyncs.SelectionChanged += new SelectionChangedEventHandler(_option_SelectionChanged);

            //
            MatResolutions.Clear();
            MatResolutions.Add(new OptionLevel()
            {
                Level = E_LEVEL.EL_LOW
            });
            MatResolutions.Add(new OptionLevel()
            {
                Level = E_LEVEL.EL_FAIR
            });
            MatResolutions.Add(new OptionLevel()
            {
                Level = E_LEVEL.EL_GOOD
            });
            MatResolutions.Add(new OptionLevel()
            {
                Level = E_LEVEL.EL_HIGH
            });

            _cbMatResolutions.SelectedItem      = (from x in MatResolutions where x.Level == videoSetting.textureResolution select x).ToArray()[0];
            _cbMatResolutions.SelectionChanged += new SelectionChangedEventHandler(_option_SelectionChanged);

            //
            _cbMatTextureFilters.SelectedItem      = (from x in MatTextureFilters where x.Filter == videoSetting.textureFiltering select x).ToArray()[0];
            _cbMatTextureFilters.SelectionChanged += new SelectionChangedEventHandler(_option_SelectionChanged);

            //
            _cbMatProjections.SelectedItem      = (from x in MatProjections where x.On == false select x).ToArray()[0];
            _cbMatProjections.SelectionChanged += new SelectionChangedEventHandler(_option_SelectionChanged);

            //
            ViewDistances.Default();
            _cbViewDistances.SelectedItem      = (from x in ViewDistances where x.Level == videoSetting.viewDistance select x).ToArray()[0];
            _cbViewDistances.SelectionChanged += new SelectionChangedEventHandler(_option_SelectionChanged);

            EnvDetails.Default();
            _cbEnvDetails.SelectedItem      = (from x in EnvDetails where x.Level == videoSetting.envDetail select x).ToArray()[0];
            _cbEnvDetails.SelectionChanged += new SelectionChangedEventHandler(_option_SelectionChanged);

            GroundScenes.Default();
            _cbGroundScenes.SelectedItem      = (from x in GroundScenes where x.Level == videoSetting.groundClutter select x).ToArray()[0];
            _cbGroundScenes.SelectionChanged += new SelectionChangedEventHandler(_option_SelectionChanged);

            ShadowQualities.Default();
            _cbShadowQuality.SelectedItem      = (from x in ShadowQualities where x.Level == videoSetting.shadowQuality select x).ToArray()[0];
            _cbShadowQuality.SelectionChanged += new SelectionChangedEventHandler(_option_SelectionChanged);

            LiquidDetails.Clear();
            LiquidDetails.Add(new OptionLevel()
            {
                Level = E_LEVEL.EL_LOW
            });
            LiquidDetails.Add(new OptionLevel()
            {
                Level = E_LEVEL.EL_FAIR
            });
            LiquidDetails.Add(new OptionLevel()
            {
                Level = E_LEVEL.EL_GOOD
            });
            LiquidDetails.Add(new OptionLevel()
            {
                Level = E_LEVEL.EL_ULTRA
            });
            _cbLiquidDetail.SelectedItem      = (from x in LiquidDetails where x.Level == videoSetting.liquidDetail select x).ToArray()[0];
            _cbLiquidDetail.SelectionChanged += new SelectionChangedEventHandler(_option_SelectionChanged);

            SunLightEffects.Clear();
            SunLightEffects.Add(new OptionLevel()
            {
                Level = E_LEVEL.EL_DISABLE
            });
            SunLightEffects.Add(new OptionLevel()
            {
                Level = E_LEVEL.EL_LOW
            });
            SunLightEffects.Add(new OptionLevel()
            {
                Level = E_LEVEL.EL_HIGH
            });
            _cbSunLightEffect.SelectedItem      = (from x in SunLightEffects where x.Level == videoSetting.sunshafts select x).ToArray()[0];
            _cbSunLightEffect.SelectionChanged += new SelectionChangedEventHandler(_option_SelectionChanged);

            ParticleDensities.Default();
            _cbParticleDensity.SelectedItem      = (from x in ParticleDensities where x.Level == videoSetting.particleDensity select x).ToArray()[0];
            _cbParticleDensity.SelectionChanged += new SelectionChangedEventHandler(_option_SelectionChanged);

            SSAOLevels.Clear();
            SSAOLevels.Add(new OptionLevel()
            {
                Level = E_LEVEL.EL_DISABLE
            });
            SSAOLevels.Add(new OptionLevel()
            {
                Level = E_LEVEL.EL_LOW
            });
            SSAOLevels.Add(new OptionLevel()
            {
                Level = E_LEVEL.EL_HIGH
            });
            _cbSSAO.SelectedItem      = (from x in SSAOLevels where x.Level == videoSetting.SSAO select x).ToArray()[0];
            _cbSSAO.SelectionChanged += new SelectionChangedEventHandler(_option_SelectionChanged);
        }
Ejemplo n.º 13
0
 private static bool isDeviceLegal(VideoDevices device)
 {
     return(device != VideoDevices.LOGITECH_PRO_5000);
 }
Ejemplo n.º 14
0
 private static bool isDeviceLegal(VideoDevices device)
 {
     return device != VideoDevices.LOGITECH_PRO_5000;
 }
Ejemplo n.º 15
0
        /// <summary>
        /// Updates the devices.
        /// </summary>
        private void UpdateDevices()
        {
            try
            {
                if (string.IsNullOrEmpty(this.FFmpegPath) || !File.Exists(this.FFmpegPath))
                {
                    return;
                }
            }
            catch { return; }

            var ffmpeg = new ProcessHelper(this.FFmpegPath)
            {
                Arguments = "-hide_banner -list_devices 1 -f dshow -i dummy"
            };

            ffmpeg.Start();
            var lines = ffmpeg.StandardError;

            var gettingVid = false;
            var gettingAud = false;

            AudioDevices.Clear();
            VideoDevices.Clear();

            foreach (var item in lines)
            {
                if (item.Contains("DirectShow video devices"))
                {
                    gettingVid = true;
                    gettingAud = false;
                    continue;
                }
                else if (item.Contains("DirectShow audio devices"))
                {
                    gettingAud = true;
                    gettingVid = false;
                    continue;
                }
                else if (string.IsNullOrEmpty(item) || item.Contains("Alternative name") || item.Contains("exit requested"))
                {
                    continue;
                }

                var quoteIndex = item.IndexOf("\"", StringComparison.Ordinal);
                if (quoteIndex < 0)
                {
                    continue;
                }

                var device = item.Remove(0, quoteIndex + 1);
                quoteIndex = device.IndexOf("\"", StringComparison.Ordinal);
                if (quoteIndex < 0)
                {
                    throw new ArgumentNullException(item);
                }

                device = device.Remove(quoteIndex);

                if (gettingAud)
                {
                    AudioDevices.Add(device);
                }
                if (gettingVid)
                {
                    VideoDevices.Add(device);
                }
            }

            OnDevicesUpdated();
        }