Example #1
0
 bool System.Collections.IEnumerator.MoveNext()
 {
     _displayModeIterator.Next(out _displayMode);
     return(_displayMode != null);
 }
Example #2
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;
            }
        }