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; } } }
void IDeckLinkDeviceNotificationCallback.DeckLinkDeviceRemoved(IDeckLink device) {// Удаление не проверялось т.к не было в наличии устройств поддерживающий динамическое отключение logger.Verb("IDeckLinkDeviceNotificationCallback::DeckLinkDeviceRemoved()"); try { var inputDevice = inputDevices.FirstOrDefault(d => d.deckLink == device); DeckLinkDeviceDescription inputDescr = inputDevice?.GetDeviceDescription(); if (inputDescr != null) { bool removed = inputDevices.Remove(inputDevice); Debug.Assert(removed, "removed"); InputDeviceRemoved?.Invoke(inputDescr); } if (inputDevice != null) { inputDevice.Dispose(); inputDevice = null; } } finally { if (device != null) { var refCount = Marshal.ReleaseComObject(device); Debug.Assert(refCount == 0, "refCount == 0"); device = null; } } }
private void DeviceManager_DeviceRemoved(DeckLinkDeviceDescription device) { //logger.Debug("DeviceManager_DeviceRemoved() " + device?.ToString() ?? ""); if (device != null) { var displayMode = device.DisplayModeIds.FirstOrDefault(); logger.Info("DeviceRemoved: " + device.ToString() + " " + displayMode.ToString()); } }
public List <DeckLinkDeviceDescription> GetInputs() { List <DeckLinkDeviceDescription> deviceDescriptions = new List <DeckLinkDeviceDescription>(); for (int index = 0; index < inputDevices.Count; index++) { var inputDevice = inputDevices[index]; DeckLinkDeviceDescription deviceDescription = inputDevice.GetDeviceDescription(); if (deviceDescription != null) { deviceDescription.DeviceIndex = index; deviceDescriptions.Add(deviceDescription); } } return(deviceDescriptions); }
private void comboBoxDevices_SelectedValueChanged(object sender, EventArgs e) { logger.Debug("comboBoxDevices_SelectedValueChanged(...)"); var selectedItem = comboBoxDevices.SelectedItem; if (selectedItem != null) { var selectedDevice = selectedItem as DeckLinkDeviceDescription; if (selectedDevice != null) { currentDevice = selectedDevice; comboBoxDisplayModes.DisplayMember = "Description"; displayModes.Add(new DeckLinkDisplayModeDescription { Description = "Auto" }); displayModes.AddRange(currentDevice.DisplayModeIds); comboBoxDisplayModes.DataSource = displayModes; } } }
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); }
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); }
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); }