public void Refresh()
        {
            WorkerThread.Singleton.PerformBlocking(() => {
                foreach (var oldDevice in FDevices)
                {
                    Marshal.ReleaseComObject(oldDevice.DeviceHandle);
                }
                FDevices.Clear();

                var iterator = new CDeckLinkIterator();
                IDeckLink device;
                string modelName, displayName;
                while (true)
                {
                    iterator.Next(out device);
                    if (device == null)
                    {
                        break;
                    }

                    device.GetModelName(out modelName);
                    device.GetDisplayName(out displayName);

                    FDevices.Add(new Device()
                    {
                        DeviceHandle = device,
                        ModelName    = modelName,
                        DisplayName  = displayName
                    });
                }
            });
        }
Пример #2
0
        public ArrayList GetAvailableDeckLinks()
        {
            ArrayList list = new ArrayList();

            IDeckLinkIterator deckLinkIterator = new CDeckLinkIterator();

            if (deckLinkIterator == null)
            {
                throw new ApplicationException("This application requires the DeckLink drivers installed. Please install the Blackmagic DeckLink drivers to use the features of this application");
            }

            while (true)
            {
                IDeckLink deckLink;
                deckLinkIterator.Next(out deckLink);
                if (deckLink == null)
                {
                    break;
                }

                list.Add((IDeckLinkOutput)deckLink);
            }

            return(list);
        }
Пример #3
0
        private void find_Click(object sender, EventArgs e)
        {
            // Create the COM instance
            IDeckLinkIterator deckLinkIterator = new CDeckLinkIterator();

            if (deckLinkIterator == null)
            {
                MessageBox.Show("Deck link drivers are not installed!", "Error");
                return;
            }

            // Get the first DeckLink card
            deckLinkIterator.Next(out _DeckLink);
            if (_DeckLink == null)
            {
                stream.Enabled = false;
                MessageBox.Show("No connected decklink device found", "Error");
                return;
            }

            string displayName;
            string modelName;

            _DeckLink.GetDisplayName(out displayName);
            _DeckLink.GetModelName(out modelName);

            stream.Enabled       = true;
            this.deviceName.Text = string.Format("Device chosen: {0}", FormatDevice(displayName, modelName));
        }
Пример #4
0
        //return the current enum entries
        protected override IReadOnlyDictionary <string, object> GetEntries()
        {
            var devices = new Dictionary <string, object>();

            var iterator   = new CDeckLinkIterator();
            var deviceList = new List <IDeckLink>();

            while (true)
            {
                iterator.Next(out var deckLink);
                if (deckLink is null)
                {
                    break;
                }

                if (deckLink is IDeckLinkInput deckLinkInput)
                {
                    deckLink.GetModelName(out var modelName);
                    deckLink.GetDisplayName(out var displayName);
                    devices.Add(displayName, deckLinkInput);
                }
            }

            // Add a default entry which makes it up to the system to select a device
            if (devices.Count > 0)
            {
                devices.Add("Default", devices.Values.First());
            }

            return(devices);
        }
Пример #5
0
        public static List <DeckLinkItem> GetDeckLinkItems()
        {
            List <DeckLinkItem> outList = new List <DeckLinkItem>();


            // Create the COM instance
            IDeckLinkIterator deckLinkIterator = new CDeckLinkIterator();

            if (deckLinkIterator == null)
            {
                MessageBox.Show("This application requires the DeckLink drivers installed.\nPlease install the Blackmagic DeckLink drivers to use the features of this application", "Error");
                Environment.Exit(1);
            }


            while (true)
            {
                IDeckLink deckLink;
                deckLinkIterator.Next(out deckLink);
                if (deckLink == null)
                {
                    break;
                }

                outList.Add(new DeckLinkItem(deckLink));
            }

            return(outList);
        }
Пример #6
0
        // Check DeckLink Hardware
        public bool GetHardware()
        {
            // Create the COM instance
            IDeckLinkIterator deckLinkIterator = new CDeckLinkIterator();

            if (deckLinkIterator == null)
            {
                Console.Write("Deck link drivers are not installed!", "Error");
                return(false);
            }

            // Get the DeckLink card
            for (int i = 0; i < deckLinkCard; i++)
            {
                deckLinkIterator.Next(out DeckLink);
            }

            if (DeckLink == null)
            {
                Console.Write("No connected decklink device found", "Error");
                return(false);
            }

            string displayName;
            string modelName;

            DeckLink.GetDisplayName(out displayName);
            DeckLink.GetModelName(out modelName);

            // Compatibility: DeckLink 4K Extreme, DeckLink Quad 2
            Console.Write(string.Format("Device chosen: {0}", displayName, modelName));

            return(true);
        }
Пример #7
0
        public Decklink()
        {
            IDeckLinkIterator deckLinkIterator = new CDeckLinkIterator();

            if (deckLinkIterator == null)
            {
                throw new ApplicationException("This application requires the DeckLink drivers installed. Please install the Blackmagic DeckLink drivers to use the features of this application");
            }


            //m_running = false;

            //// Create the COM instance
            //IDeckLinkIterator deckLinkIterator = new CDeckLinkIterator();
            //if (deckLinkIterator == null)
            //{
            //    MessageBox.Show("This application requires the DeckLink drivers installed.\nPlease install the Blackmagic DeckLink drivers to use the features of this application", "Error");
            //    Environment.Exit(1);
            //}

            //// Get the first DeckLink card
            //deckLinkIterator.Next(out m_deckLink);
            //if (m_deckLink == null)
            //{
            //    MessageBox.Show("This application requires a DeckLink PCI card.\nYou will not be able to use the features of this application until a DeckLink PCI card is installed.", "Error");
            //    Environment.Exit(1);
            //}

            //// Get the IDeckLinkOutput interface
            //m_deckLinkOutput = (IDeckLinkOutput)m_deckLink;

            //// Provide this class as a delegate to the audio and video output interfaces
            //m_deckLinkOutput.SetScheduledFrameCompletionCallback(this);

            //// Populate the display mode combo with a list of display modes supported by the installed DeckLink card
            //IDeckLinkDisplayModeIterator displayModeIterator;

            ////comboBoxVideoFormat.BeginUpdate();
            ////comboBoxVideoFormat.Items.Clear();

            //m_deckLinkOutput.GetDisplayModeIterator(out displayModeIterator);

            //while (true)
            //{
            //    IDeckLinkDisplayMode deckLinkDisplayMode;

            //    displayModeIterator.Next(out deckLinkDisplayMode);
            //    if (deckLinkDisplayMode == null)
            //        break;

            //    //comboBoxVideoFormat.Items.Add(new DisplayModeEntry(deckLinkDisplayMode));
            //}

            //comboBoxVideoFormat.EndUpdate();
        }
		private void Refresh()
		{
			try
			{
				IDeckLink deckLink;
				IDeckLinkIterator iterator;

				iterator = new CDeckLinkIterator();
				if (iterator == null)
					throw (new Exception("Please check DeckLink drivers are installed."));

				FPinOutDevices.SliceCount = 0;
				FPinOutModelName.SliceCount = 0;
				FPinOutDisplayName.SliceCount = 0;

				List<IDeckLink> deviceList = new List<IDeckLink>();

				while (true)
				{
					iterator.Next(out deckLink);

					if (deckLink == null)
						break;
					else
						deviceList.Add(deckLink);
				}

				FPinOutDevices.SliceCount = deviceList.Count;
				FPinOutModelName.SliceCount = deviceList.Count;
				FPinOutDisplayName.SliceCount = deviceList.Count;

				for (int i = 0; i < deviceList.Count; i++)
				{
					deckLink = deviceList[i];

					FPinOutDevices[i] = deckLink;

					string name;
					deckLink.GetModelName(out name);
					FPinOutModelName[i] = name;

					deckLink.GetDisplayName(out name);
					FPinOutDisplayName[i] = name;
				}

				FPinOutStatus[0] = "OK";
			}

			catch (Exception e)
			{
				FPinOutStatus[0] = "ERROR : " + e.Message;
			}

		}
Пример #9
0
        public static bool GetDeviceByHandle(string deviceHandle, out IDeckLink deckLink)
        {
            logger.Verb("GetDeviceByName(...) " + deviceHandle);

            bool Success = false;

            deckLink = null;
            IDeckLinkIterator deckLinkIterator = null;

            try
            {
                deckLinkIterator = new CDeckLinkIterator();

                int index = 0;
                do
                {
                    if (deckLink != null)
                    {
                        Marshal.ReleaseComObject(deckLink);
                        deckLink = null;
                    }

                    deckLinkIterator.Next(out deckLink);
                    if (deckLink != null)
                    {
                        ((IDeckLinkProfileAttributes)deckLink).GetString(_BMDDeckLinkAttributeID.BMDDeckLinkDeviceHandle, out string handle);
                        if (deviceHandle == handle)
                        {
                            break;
                        }
                    }
                    index++;
                }while (deckLink != null);
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }
            finally
            {
                if (deckLinkIterator != null)
                {
                    Marshal.ReleaseComObject(deckLinkIterator);
                    deckLinkIterator = null;
                }
            }

            return(Success);
        }
Пример #10
0
        protected override bool Open()
        {
            if (FDevice == null && false)
            {
                return(false);
            }
            else
            {
                try
                {
                    string status;

                    //this is a hack, we recreate the device here
                    IDeckLinkIterator iterator = new CDeckLinkIterator();
                    IDeckLink         device;
                    iterator.Next(out device);
                    FDevice = (IDeckLinkInput)device;

                    _BMDDisplayModeSupport supported;

                    FDevice.DoesSupportVideoMode(FVideoMode, FPixelFormat, FVideoInputFlags, out supported, out FDisplayMode);
                    if (supported.HasFlag(_BMDDisplayModeSupport.bmdDisplayModeNotSupported))
                    {
                        status = "Display mode supported";
                    }
                    else if (supported.HasFlag(_BMDDisplayModeSupport.bmdDisplayModeSupportedWithConversion))
                    {
                        status = "Display mode supported with conversion";
                    }
                    else
                    {
                        throw(new Exception("Display mode not supported"));
                    }

                    FDevice.EnableVideoInput(FVideoMode, FPixelFormat, FVideoInputFlags);
                    FDevice.SetCallback(this);
                    FDevice.StartStreams();

                    Status = "OK : " + status;
                    return(true);
                }
                catch (Exception e)
                {
                    Status = e.Message;
                    return(false);
                }
            }
        }
Пример #11
0
        public static bool GetDeviceByIndex(int inputIndex, out IDeckLink deckLink)
        {
            logger.Verb("GetDeviceByIndex(...) " + inputIndex);

            bool Success = false;

            deckLink = null;
            IDeckLinkIterator deckLinkIterator = null;

            try
            {
                deckLinkIterator = new CDeckLinkIterator();

                int index = 0;
                do
                {
                    if (deckLink != null)
                    {
                        Marshal.ReleaseComObject(deckLink);
                        deckLink = null;
                    }

                    deckLinkIterator.Next(out deckLink);
                    if (index == inputIndex)
                    {
                        Success = true;
                        break;
                    }

                    index++;
                }while (deckLink != null);
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }
            finally
            {
                if (deckLinkIterator != null)
                {
                    Marshal.ReleaseComObject(deckLinkIterator);
                    deckLinkIterator = null;
                }
            }

            return(Success);
        }
Пример #12
0
        public ConfigViewModel(string[] args) : base(args)
        {
            Devices = new ObservableCollection <InputDevice>();
            var dli = new CDeckLinkIterator();

            while (true)
            {
                IDeckLink dl;
                dli.Next(out dl);
                if (dl == null)
                {
                    break;
                }
                var chans = GetAudioChannelCount(dl);
                if (dl is IDeckLinkInput)
                {
                    Devices.Add(new InputDevice(dl, chans));
                }
            }
            RestoreConfiguration();
        }
        public SignalGenerator()
        {
            InitializeComponent();

            m_running = false;

            // Create the COM instance
            IDeckLinkIterator deckLinkIterator = new CDeckLinkIterator();

            if (deckLinkIterator == null)
            {
                MessageBox.Show("This application requires the DeckLink drivers installed.\nPlease install the Blackmagic DeckLink drivers to use the features of this application", "Error");
                Environment.Exit(1);
            }

            // Get the first DeckLink card
            deckLinkIterator.Next(out m_deckLink);
            if (m_deckLink == null)
            {
                MessageBox.Show("This application requires a DeckLink PCI card.\nYou will not be able to use the features of this application until a DeckLink PCI card is installed.", "Error");
                Environment.Exit(1);
            }

            // Get the IDeckLinkOutput interface
            m_deckLinkOutput = (IDeckLinkOutput)m_deckLink;

            // Provide this class as a delegate to the audio and video output interfaces
            m_deckLinkOutput.SetScheduledFrameCompletionCallback(this);
            m_deckLinkOutput.SetAudioCallback(this);

            // Populate the display mode combo with a list of display modes supported by the installed DeckLink card
            IDeckLinkDisplayModeIterator displayModeIterator;

            comboBoxVideoFormat.BeginUpdate();
            comboBoxVideoFormat.Items.Clear();

            m_deckLinkOutput.GetDisplayModeIterator(out displayModeIterator);

            while (true)
            {
                IDeckLinkDisplayMode deckLinkDisplayMode;

                displayModeIterator.Next(out deckLinkDisplayMode);
                if (deckLinkDisplayMode == null)
                {
                    break;
                }

                comboBoxVideoFormat.Items.Add(new DisplayModeEntry(deckLinkDisplayMode));
            }

            comboBoxVideoFormat.EndUpdate();

            // Output signal combo box
            comboBoxOutputSignal.BeginUpdate();
            comboBoxOutputSignal.Items.Clear();
            comboBoxOutputSignal.Items.Add(new StringObjectPair <OutputSignal>("Pip", OutputSignal.kOutputSignalPip));
            comboBoxOutputSignal.Items.Add(new StringObjectPair <OutputSignal>("Drop", OutputSignal.kOutputSignalDrop));
            comboBoxOutputSignal.EndUpdate();

            // Audio channels combo box
            comboBoxAudioChannels.BeginUpdate();
            comboBoxAudioChannels.Items.Clear();
            comboBoxAudioChannels.Items.Add("2");
            comboBoxAudioChannels.Items.Add("8");
            comboBoxAudioChannels.Items.Add("16");
            comboBoxAudioChannels.EndUpdate();

            // Audio depth combo box
            comboBoxAudioDepth.BeginUpdate();
            comboBoxAudioDepth.Items.Clear();
            comboBoxAudioDepth.Items.Add(new StringObjectPair <_BMDAudioSampleType>("16 Bit", _BMDAudioSampleType.bmdAudioSampleType16bitInteger));
            comboBoxAudioDepth.Items.Add(new StringObjectPair <_BMDAudioSampleType>("32 Bit", _BMDAudioSampleType.bmdAudioSampleType32bitInteger));
            comboBoxAudioDepth.EndUpdate();

            comboBoxVideoFormat.SelectedIndex   = 0;
            comboBoxOutputSignal.SelectedIndex  = 0;
            comboBoxAudioChannels.SelectedIndex = 0;
            comboBoxAudioDepth.SelectedIndex    = 0;
        }
Пример #14
0
		new static public Device[] BoardsGet()
		{
			(new Logger()).WriteDebug3("in");
			List<Device> aRetVal = new List<Device>();
			IDeckLinkIterator cDeckLinkIterator = new CDeckLinkIterator();
			if (null != cDeckLinkIterator)
			{
				while (true)
				{
					(new Logger()).WriteDebug4("boards:get: next [brdsqty:" + aRetVal.Count + "]");
					IDeckLink cDeckLink;
					(new Logger()).WriteDebug4("boards:get:iterator:before");
					cDeckLinkIterator.Next(out cDeckLink);
					(new Logger()).WriteDebug4("boards:get:iterator:after");
					if (null == cDeckLink)
						break;
					aRetVal.Add(new Decklink(cDeckLink));
				}
			}
			(new Logger()).WriteDebug4("boards:get:device:out");
			return aRetVal.ToArray();
		}
Пример #15
0
		public void Refresh()
		{
			WorkerThread.Singleton.PerformBlocking(() => {
				foreach (var oldDevice in FDevices)
				{
					Marshal.ReleaseComObject(oldDevice.DeviceHandle);
				}
				FDevices.Clear();

				var iterator = new CDeckLinkIterator();
				IDeckLink device;
				string modelName, displayName;
				while (true)
				{
					iterator.Next(out device);
					if (device == null)
						break;

					device.GetModelName(out modelName);
					device.GetDisplayName(out displayName);

					FDevices.Add(new Device()
					{
						DeviceHandle = device,
						ModelName = modelName,
						DisplayName = displayName
					});
				}
			});
		}
Пример #16
0
        public static List <DeckLinkDeviceDescription> GetDeckLinkInputDevices()
        {
            List <DeckLinkDeviceDescription> devices = new List <DeckLinkDeviceDescription>();
            IDeckLinkIterator deckLinkIterator       = null;

            try
            {
                deckLinkIterator = new CDeckLinkIterator();

                int       index    = 0;
                IDeckLink deckLink = null;
                do
                {
                    if (deckLink != null)
                    {
                        Marshal.ReleaseComObject(deckLink);
                        deckLink = null;
                    }

                    deckLinkIterator.Next(out deckLink);

                    if (deckLink == null)
                    {
                        break;
                    }

                    deckLink.GetDisplayName(out string deviceName);

                    try
                    {
                        var deckLinkInput  = (IDeckLinkInput)deckLink;
                        var deckLinkStatus = (IDeckLinkStatus)deckLink;
                        var deckLinkAttrs  = (IDeckLinkProfileAttributes)deckLink;

                        deckLinkAttrs.GetString(_BMDDeckLinkAttributeID.BMDDeckLinkDeviceHandle, out string deviceHandle);

                        deckLinkStatus.GetFlag(_BMDDeckLinkStatusID.bmdDeckLinkStatusVideoInputSignalLocked, out int videoInputSignalLockedFlag);
                        bool available = (videoInputSignalLockedFlag != 0);

                        var pixelFormats   = SupportedPixelFormats.Keys.ToList();
                        var displayModeIds = GetDisplayDescriptions(deckLinkInput, pixelFormats);

                        DeckLinkDeviceDescription deviceDescription = new DeckLinkDeviceDescription
                        {
                            DeviceHandle   = deviceHandle,
                            DeviceIndex    = index,
                            DeviceName     = deviceName,
                            Available      = available,
                            DisplayModeIds = displayModeIds,
                        };

                        devices.Add(deviceDescription);


                        //Marshal.ReleaseComObject(deckLinkInput);
                        //Marshal.ReleaseComObject(deckLinkStatus);
                    }
                    catch (InvalidCastException)
                    {
                    }

                    index++;
                }while (deckLink != null);
            }
            catch (Exception ex)
            {
                if (deckLinkIterator == null)
                {
                    throw new Exception("This application requires the DeckLink drivers installed.\n" +
                                        "Please install the Blackmagic DeckLink drivers to use the features of this application");
                }

                throw;
            }

            return(devices);
        }
Пример #17
0
        public List <DeckLinkDeviceDescription> FindInputs()
        {
            logger.Debug("DeckLinkDeviceManager::GetDeckLinkInputs()");

            List <DeckLinkDeviceDescription> devices = new List <DeckLinkDeviceDescription>();

            IDeckLinkIterator deckLinkIterator = null;

            try
            {
                deckLinkIterator = new CDeckLinkIterator();

                int       index    = 0;
                IDeckLink deckLink = null;
                do
                {
                    if (deckLink != null)
                    {
                        Marshal.ReleaseComObject(deckLink);
                        deckLink = null;
                    }

                    deckLinkIterator.Next(out deckLink);

                    if (deckLink == null)
                    {
                        break;
                    }

                    var inputDevice = new DeckLinkInput(deckLink);
                    if (inputDevice.Init())
                    {
                        DeckLinkDeviceDescription deviceDescription = inputDevice.GetDeviceDescription();
                        if (deviceDescription != null)
                        {
                            deviceDescription.DeviceIndex = index;

                            devices.Add(deviceDescription);
                            index++;
                        }
                    }

                    if (inputDevice != null)
                    {
                        inputDevice.Dispose();
                        inputDevice = null;
                    }
                }while (deckLink != null);
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }
            finally
            {
                if (deckLinkIterator != null)
                {
                    Marshal.ReleaseComObject(deckLinkIterator);
                    deckLinkIterator = null;
                }
            }

            return(devices);
        }