Esempio n. 1
0
        void HandleDeviceChanged(object sender, EventArgs e)
        {
            Device    device = videoDevices [devicecombobox.Active];
            ListStore store  = new ListStore(typeof(string));

            deviceformatcombobox.Model = store;
            foreach (DeviceVideoFormat format in device.Formats)
            {
                deviceformatcombobox.AppendText(format.ToString());
            }
            deviceformatcombobox.Active = 0;
        }
Esempio n. 2
0
        static public List <Device> ListVideoDevices()
        {
            string [] devices;
            if (VAS.Core.Common.Utils.OS == OperatingSystemID.OSX)
            {
                devices = devices_osx;
            }
            else if (VAS.Core.Common.Utils.OS == OperatingSystemID.Windows)
            {
                devices = devices_win;
            }
            else
            {
                devices = devices_lin;
            }

            List <Device> devicesList = new List <Device> ();

            foreach (string source in devices)
            {
                GLib.List devices_raw = new GLib.List(lgm_device_enum_video_devices(source),
                                                      typeof(IntPtr), true, false);

                foreach (IntPtr device_raw in devices_raw)
                {
                    string deviceName = GLib.Marshaller.PtrToStringGFree(lgm_device_get_device_name(device_raw));

                    /* The Direct Show GStreamer element seems to have problems with the
                     * BlackMagic DeckLink cards, so filter them out. They are also
                     * available through the ksvideosrc element. */
                    if (source == DSHOWVIDEOSRC &&
                        Regex.Match(deviceName, ".*blackmagic.*|.*decklink.*", RegexOptions.IgnoreCase).Success)
                    {
                        continue;
                    }

                    Device device = new Device();
                    device.DeviceType    = CaptureSourceType.System;
                    device.SourceElement = source;
                    device.ID            = deviceName;
                    if (source == GDISCREENCAPSRC || source == DX9SCREENCAPSRC)
                    {
                        device.Prefix = Strings.Monitor;
                    }

                    GLib.List formats_raw = new GLib.List(lgm_device_get_formats(device_raw),
                                                          typeof(IntPtr), false, false);
                    foreach (IntPtr format_raw in formats_raw)
                    {
                        DeviceVideoFormat format = new DeviceVideoFormat();
                        lgm_device_video_format_get_info(format_raw, out format.width, out format.height,
                                                         out format.fps_n, out format.fps_d);
                        device.Formats.Add(format);
                    }

                    /* Make sure the device has formats
                     * before adding it to the device list */
                    if (device.Formats.Count > 0)
                    {
                        devicesList.Add(device);
                    }
                    lgm_device_free(device_raw);
                }
            }
            return(devicesList);
        }