示例#1
0
        IEnumerator <IDeckLinkDisplayMode> IEnumerable <IDeckLinkDisplayMode> .GetEnumerator()
        {
            IDeckLinkDisplayModeIterator displayModeIterator;

            m_deckLinkInput.GetDisplayModeIterator(out displayModeIterator);
            return(new DisplayModeEnum(displayModeIterator));
        }
示例#2
0
 // Get IDeckLink Interface
 private bool GetIDeckLinkInterface()
 {
     try
     {
         deckLinkOutput = (IDeckLinkOutput)DeckLink;
         deckLinkInput  = (IDeckLinkInput)DeckLink;
         deckLinkConfig = (IDeckLinkConfiguration)DeckLink;
         IDeckLinkDisplayModeIterator displayIterator;
         deckLinkInput.GetDisplayModeIterator(out displayIterator);
         var supportedModes = new List <IDeckLinkDisplayMode>();
         deckLinkKeyer = (IDeckLinkKeyer)DeckLink;
     }
     catch
     {
         return(false);
     }
     return(true);
 }
示例#3
0
        public static List <DeckLinkDisplayModeDescription> GetDisplayDescriptions(IDeckLinkInput deckLinkInput, List <_BMDPixelFormat> pixelFormats,
                                                                                   _BMDVideoConnection connection             = _BMDVideoConnection.bmdVideoConnectionHDMI,
                                                                                   _BMDSupportedVideoModeFlags videoModeFlags = _BMDSupportedVideoModeFlags.bmdSupportedVideoModeDefault)
        {
            List <DeckLinkDisplayModeDescription> displayDescriptions = new List <DeckLinkDisplayModeDescription>();

            IDeckLinkDisplayModeIterator iterator = null;

            try
            {
                deckLinkInput.GetDisplayModeIterator(out iterator);

                while (true)
                {
                    IDeckLinkDisplayMode displayMode = null;
                    try
                    {
                        iterator.Next(out displayMode);
                        if (displayMode == null)
                        {
                            break;
                        }

                        var displayModeId = displayMode.GetDisplayMode();

                        displayMode.GetName(out string displayName);
                        displayMode.GetFrameRate(out long frameDuration, out long timeScale);
                        var fps = (double)timeScale / frameDuration;

                        int width      = displayMode.GetWidth();
                        int height     = displayMode.GetHeight();
                        var resolution = width + "x" + height;

                        var displayModeFlags = displayMode.GetFlags();
                        var fieldDominance   = displayMode.GetFieldDominance();

                        foreach (var pixFmt in pixelFormats)
                        {
                            deckLinkInput.DoesSupportVideoMode(connection, displayModeId, pixFmt, videoModeFlags, out int supported);
                            if (supported != 0)
                            {
                                displayDescriptions.Add(new DeckLinkDisplayModeDescription
                                {
                                    ModeId      = (long)displayModeId,
                                    Width       = width,
                                    Height      = height,
                                    Fps         = fps,
                                    PixFmt      = (long)pixFmt,
                                    Description = displayName + " (" + resolution + " " + fps.ToString("0.##") + " fps " + GetFourCCStr(pixFmt) + ")",
                                });
                            }
                            else
                            {
                                //Console.WriteLine("Display mode not supported: "+ displayModeId + " " + pixFmt);
                            }
                        }
                    }
                    finally
                    {
                        if (displayMode != null)
                        {
                            Marshal.ReleaseComObject(displayMode);
                            displayMode = null;
                        }
                    }
                }
            }
            finally
            {
                if (iterator != null)
                {
                    Marshal.ReleaseComObject(iterator);
                    iterator = null;
                }
            }

            return(displayDescriptions);
        }
示例#4
0
        public DeckLinkDevice(IDeckLink deckLink)
        {
            this.deckLink = deckLink;

            // Get input interface
            try
            {
                deckLinkInput  = (IDeckLinkInput)this.deckLink;
                deckLinkStatus = (IDeckLinkStatus)this.deckLink;

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

                if (videoInputSignalLocked)
                {
                    throw new Exception("Video input locked");
                }

                this.deckLink.GetDisplayName(out deviceName);
                this.deckLink.GetModelName(out modelName);


                var deckLinkAttributes = (IDeckLinkProfileAttributes)deckLink;
                deckLinkAttributes.GetFlag(_BMDDeckLinkAttributeID.BMDDeckLinkSupportsInputFormatDetection, out int supportsFormatDetectionFlag);
                supportsFormatDetection = (supportsFormatDetectionFlag != 0);


                logger.Debug("------------------------- " + deviceName + " -------------------------");

                IDeckLinkDisplayModeIterator iterator = null;
                deckLinkInput.GetDisplayModeIterator(out iterator);
                IDeckLinkDisplayMode displayMode = null;
                do
                {
                    if (iterator != null)
                    {
                        iterator.Next(out displayMode);
                        if (displayMode != null)
                        {
                            displayMode.GetName(out string displayName);
                            displayMode.GetFrameRate(out long frameDuration, out long timeScale);

                            int width            = displayMode.GetWidth();
                            int height           = displayMode.GetHeight();
                            var bdmDisplayMode   = displayMode.GetDisplayMode();
                            var displayModeFlags = displayMode.GetFlags();
                            var fieldDominance   = displayMode.GetFieldDominance();


                            var resolution = width + "x" + height;

                            // var log = string.Join(", " , displayName, resolution, bdmDisplayMode, displayModeFlags, frameDuration, timeScale, fieldDominance);
                            var videoModeFlags = _BMDSupportedVideoModeFlags.bmdSupportedVideoModeDefault;

                            //var allPixelFormats = Enum.GetValues(typeof(_BMDPixelFormat));
                            var formatLog = "";
                            foreach (var fmtObj in pixelFormats)
                            {
                                var pixelFormat = (_BMDPixelFormat)fmtObj;
                                deckLinkInput.DoesSupportVideoMode(_BMDVideoConnection.bmdVideoConnectionHDMI, bdmDisplayMode, pixelFormat, videoModeFlags, out int supported);
                                if (supported != 0)
                                {
                                    formatLog += " " + pixelFormat;
                                }
                            }

                            var log = string.Join(", ", displayName, resolution);
                            logger.Debug(displayName + " " + resolution + " (" + formatLog + ")");
                        }
                        else
                        {
                            break;
                        }
                    }
                }while (displayMode != null);


                logger.Debug("-----------------------------------------------------");
            }
            catch (InvalidCastException)
            {
                // No output interface found, eg in case of DeckLink Mini Monitor
                return;
            }
        }