Ejemplo n.º 1
0
 private void comboBoxDisplayIds_SelectedValueChanged(object sender, EventArgs e)
 {
     var selectedItem = comboBoxDisplayModes.SelectedItem;
     {
         if (selectedItem != null)
         {
             currentDisplayMode = selectedItem as DeckLinkDisplayModeDescription;
         }
     }
 }
Ejemplo n.º 2
0
            internal DeckLinkDeviceDescription GetDeviceDescription()
            {
                if (!initialized)
                {
                    return(null);
                }

                DeckLinkDeviceDescription deviceDescription = null;

                deckLink.GetDisplayName(out string deviceName);

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

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

                deckLinkStatus.GetInt(_BMDDeckLinkStatusID.bmdDeckLinkStatusBusy, out long deviceBusyStateFlag);
                _BMDDeviceBusyState deviceBusyState = (_BMDDeviceBusyState)deviceBusyStateFlag;
                bool isBusy = (deviceBusyState == _BMDDeviceBusyState.bmdDeviceCaptureBusy);

                deckLinkStatus.GetInt(_BMDDeckLinkStatusID.bmdDeckLinkStatusCurrentVideoInputMode, out long bmdDeckLinkStatusCurrentVideoInputModeFlag);
                _BMDDisplayMode displayModeId = (_BMDDisplayMode)bmdDeckLinkStatusCurrentVideoInputModeFlag;

                deckLinkStatus.GetInt(_BMDDeckLinkStatusID.bmdDeckLinkStatusCurrentVideoInputPixelFormat, out long currentVideoInputPixelFormatFlag);
                _BMDPixelFormat pixelFormat = (_BMDPixelFormat)currentVideoInputPixelFormatFlag;

                DeckLinkDisplayModeDescription displayDescription = null;
                IDeckLinkDisplayMode           displayMode        = null;

                try
                {
                    deckLinkInput.GetDisplayMode(displayModeId, out displayMode);

                    int width  = displayMode.GetWidth();
                    int height = displayMode.GetHeight();
                    displayMode.GetFrameRate(out long duration, out long scale);
                    displayMode.GetName(out string displayName);

                    displayDescription = new DeckLinkDisplayModeDescription
                    {
                        Width       = width,
                        Height      = height,
                        PixFmt      = (long)pixelFormat,
                        Fps         = ((double)scale / duration),
                        Description = displayName,
                    };
                }
                finally
                {
                    if (displayMode != null)
                    {
                        Marshal.ReleaseComObject(displayMode);
                    }
                }

                deviceDescription = new DeckLinkDeviceDescription
                {
                    DeviceHandle   = deviceHandle,
                    DeviceName     = deviceName,
                    Available      = available,
                    IsBusy         = isBusy,
                    DisplayModeIds = new List <DeckLinkDisplayModeDescription> {
                        displayDescription
                    },
                };

                return(deviceDescription);
            }