Beispiel #1
0
        void IDeckLinkDeviceNotificationCallback.DeckLinkDeviceArrived(IDeckLink device)
        {
            logger.Verb("IDeckLinkDeviceNotificationCallback::DeckLinkDeviceArrived()");

            DeckLinkDeviceDescription inputDescr = null;
            var inputDevice = new DeckLinkInput(device);

            if (inputDevice.Init())
            {
                inputDescr = inputDevice.GetDeviceDescription();
                inputDevices.Add(inputDevice);

                InputDeviceArrived?.Invoke(inputDescr);
            }

            if (inputDescr == null)
            {//  нас интересуют только decklink input
                if (inputDevice != null)
                {
                    inputDevice.Dispose();
                    inputDevice = null;
                }

                if (device != null)
                {
                    Marshal.ReleaseComObject(device);
                    device = null;
                }
            }
        }
Beispiel #2
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);
        }