public static string GetFourCCStr(_BMDPixelFormat pixFormat) { string fourCCStr = ""; if (pixFormat == _BMDPixelFormat.bmdFormat8BitARGB) { fourCCStr = "ARGB"; } else if (pixFormat == _BMDPixelFormat.bmdFormatUnspecified) { fourCCStr = ""; } else { long format = (long)pixFormat; byte[] fourBytes = new byte[] { (byte)(format >> 24), (byte)(format >> 16), (byte)(format >> 8), (byte)(format) }; fourCCStr = Encoding.ASCII.GetString(fourBytes); } return(fourCCStr); }
public bool IsVideoModeSupported(IDeckLinkDisplayMode displayMode, _BMDPixelFormat pixelFormat) { _BMDDisplayModeSupport displayModeSupport; IDeckLinkDisplayMode resultDisplayMode; m_deckLinkInput.DoesSupportVideoMode(displayMode.GetDisplayMode(), pixelFormat, InputFlags, out displayModeSupport, out resultDisplayMode); return(displayModeSupport == _BMDDisplayModeSupport.bmdDisplayModeSupported); }
public bool IsVideoModeSupported(IDeckLinkDisplayMode displayMode, _BMDPixelFormat pixelFormat) { _BMDDisplayModeSupport displayModeSupport; IDeckLinkDisplayMode resultDisplayMode; m_deckLinkOutput.DoesSupportVideoMode(displayMode.GetDisplayMode(), pixelFormat, _BMDVideoOutputFlags.bmdVideoOutputFlagDefault, out displayModeSupport, out resultDisplayMode); return(displayModeSupport != _BMDDisplayModeSupport.bmdDisplayModeNotSupported); }
private void comboBoxPixelFormat_SelectedIndexChanged(object sender, EventArgs e) { if (comboBoxPixelFormat.SelectedIndex < 0) { return; } m_selectedPixelFormat = ((StringObjectPair <_BMDPixelFormat>)comboBoxPixelFormat.SelectedItem).value; }
public static VideoFormat GetVideoFormat(_BMDPixelFormat pixFormat) { VideoFormat format = null; if (SupportedPixelFormats.ContainsKey(pixFormat)) { format = SupportedPixelFormats[pixFormat]; } return(format); }
private void comboBoxPixelFormat_SelectedValueChanged(object sender, EventArgs e) { if (comboBoxPixelFormat.SelectedIndex < 0) { return; } m_pixelFormat = ((StringObjectPair <_BMDPixelFormat>)comboBoxPixelFormat.SelectedItem).value; // Update the video mode popup menu RefreshVideoModeList(); }
public bool IsVideoModeSupported(IDeckLinkDisplayMode displayMode, _BMDPixelFormat pixelFormat) { try { m_deckLinkOutput.DoesSupportVideoMode((_BMDVideoConnection)0, displayMode.GetDisplayMode(), pixelFormat, _BMDVideoOutputConversionMode.bmdNoVideoOutputConversion, _BMDSupportedVideoModeFlags.bmdSupportedVideoModeDefault, out _BMDDisplayMode resultDisplayMode, out int supported); } catch (Exception) { supported = 0; } return(Convert.ToBoolean(supported)); }
public bool IsVideoModeSupported(IDeckLinkDisplayMode displayMode, _BMDPixelFormat pixelFormat) { int supported = 0; try { m_deckLinkInput.DoesSupportVideoMode((_BMDVideoConnection)0, displayMode.GetDisplayMode(), pixelFormat, _BMDVideoInputConversionMode.bmdNoVideoInputConversion, _BMDSupportedVideoModeFlags.bmdSupportedVideoModeDefault, out _, out supported); } catch (Exception) { supported = 0; } return(supported != 0); }
public bool IsVideoModeSupported(IDeckLinkDisplayMode displayMode, _BMDPixelFormat pixelFormat) { _BMDDisplayMode resultDisplayMode; int supported; try { m_deckLinkOutput.DoesSupportVideoMode((_BMDVideoConnection)0, displayMode.GetDisplayMode(), pixelFormat, _BMDSupportedVideoModeFlags.bmdSupportedVideoModeDefault, out resultDisplayMode, out supported); } catch (Exception) { supported = 0; } return(supported != 0); }
public SignalGenerator() { InitializeComponent(); m_running = false; m_deckLinkDiscovery = new DeckLinkDeviceDiscovery(); m_deckLinkDiscovery.DeviceArrived += new DeckLinkDiscoveryHandler((d) => this.Invoke((Action)(() => AddDevice(d)))); m_deckLinkDiscovery.DeviceRemoved += new DeckLinkDiscoveryHandler((d) => this.Invoke((Action)(() => RemoveDevice(d)))); InitDialog(); previewWindow.InitD3D(); m_pixelFormat = ((StringObjectPair <_BMDPixelFormat>)comboBoxPixelFormat.SelectedItem).value; }
public OutputGenerator() { InitializeComponent(); m_running = false; m_deckLinkDiscovery = new DeckLinkDeviceDiscovery(); m_deckLinkDiscovery.DeviceArrived += new DeckLinkDiscoveryHandler((d) => this.Invoke((Action)(() => AddDevice(d)))); m_deckLinkDiscovery.DeviceRemoved += new DeckLinkDiscoveryHandler((d) => this.Invoke((Action)(() => RemoveDevice(d)))); m_pixelFormat = _BMDPixelFormat.bmdFormat10BitRGB; //jede, duhové barvy 10bit m_pixelFormat = _BMDPixelFormat.bmdFormat10BitYUV; //jede, pruhy svisle 10bit m_pixelFormat = _BMDPixelFormat.bmdFormat8BitYUV; //jede, pruhy... m_pixelFormat = _BMDPixelFormat.bmdFormat8BitBGRA; //správné pořadí, ale nejede... m_pixelFormat = _BMDPixelFormat.bmdFormat8BitARGB; m_audioSampleDepth = _BMDAudioSampleType.bmdAudioSampleType16bitInteger; }
public static bool ValidateAndCorrectPixelFormat(ref _BMDPixelFormat fmt) { logger.Debug("ValidateAndCorrectFormat(...)" + fmt); bool supported = true; if (IsRgbFormat(fmt)) {// fmt = _BMDPixelFormat.bmdFormat8BitBGRA; } else if (fmt == _BMDPixelFormat.bmdFormat10BitYUV || fmt == _BMDPixelFormat.bmdFormat8BitYUV || fmt == _BMDPixelFormat.bmdFormatUnspecified) { fmt = _BMDPixelFormat.bmdFormat8BitYUV; } else { // not supported... supported = false; } return(supported); }
public static PixelFormat ToPixelFormat(this _BMDPixelFormat pixelFormat) { switch (pixelFormat) { case _BMDPixelFormat.bmdFormatUnspecified: return(PixelFormat.None); case _BMDPixelFormat.bmdFormat8BitYUV: break; case _BMDPixelFormat.bmdFormat10BitYUV: break; case _BMDPixelFormat.bmdFormat8BitARGB: return(PixelFormat.B8G8R8A8_UNorm_SRgb); case _BMDPixelFormat.bmdFormat8BitBGRA: return(PixelFormat.B8G8R8A8_UNorm_SRgb); case _BMDPixelFormat.bmdFormat10BitRGB: break; case _BMDPixelFormat.bmdFormat12BitRGB: break; case _BMDPixelFormat.bmdFormat12BitRGBLE: break; case _BMDPixelFormat.bmdFormat10BitXYZ: break; case _BMDPixelFormat.bmdFormat8BitRGBA: return(PixelFormat.R8G8B8A8_UNorm_SRgb); case _BMDPixelFormat.bmdFormat10BitRGBXLE: break; case _BMDPixelFormat.bmdFormat10BitRGBX: break; case _BMDPixelFormat.bmdFormat10BitRGBXLE_FULL: break; case _BMDPixelFormat.bmdFormat10BitRGBX_FULL: break; case _BMDPixelFormat.bmdFormatProRes4444XQ: break; case _BMDPixelFormat.bmdFormatProRes4444: break; case _BMDPixelFormat.bmdFormatProResHQ: break; case _BMDPixelFormat.bmdFormatProRes: break; case _BMDPixelFormat.bmdFormatProResLT: break; case _BMDPixelFormat.bmdFormatProResProxy: break; case _BMDPixelFormat.bmdFormatH265: break; case _BMDPixelFormat.bmdFormatDNxHD: break; case _BMDPixelFormat.bmdFormatDNxHR: break; case _BMDPixelFormat.bmdFormat12BitRAWGRBG: break; case _BMDPixelFormat.bmdFormat12BitRAWJPEG: break; default: break; } return(PixelFormat.None); }
private IDeckLinkMutableVideoFrame CreateOutputVideoFrame(Action <IDeckLinkVideoFrame> fillFrame, _BMDPixelFormat fillerPxFormat = _BMDPixelFormat.bmdFormat8BitYUV) { IDeckLinkMutableVideoFrame referenceFrame = null; IDeckLinkMutableVideoFrame scheduleFrame = null; m_selectedDevice.deckLinkOutput.CreateVideoFrame(m_frameWidth, m_frameHeight, m_frameWidth * bytesPerPixel, m_pixelFormat, _BMDFrameFlags.bmdFrameFlagDefault, out scheduleFrame); if (m_pixelFormat == fillerPxFormat) { // Fill 8-bit YUV directly without conversion fillFrame(scheduleFrame); } else { int bpp = 4; if (fillerPxFormat == _BMDPixelFormat.bmdFormat8BitYUV) { bpp = 2; } // Pixel formats are different, first generate 8-bit YUV bars frame and convert to required format m_selectedDevice.deckLinkOutput.CreateVideoFrame(m_frameWidth, m_frameHeight, m_frameWidth * bpp, fillerPxFormat, _BMDFrameFlags.bmdFrameFlagDefault, out referenceFrame); fillFrame(referenceFrame); try { frameConverter.ConvertFrame(referenceFrame, scheduleFrame); } catch { return(referenceFrame); } } return(scheduleFrame); }
public void StartRunning() { // m_selectedDevice.VideoFrameCompleted += new DeckLinkVideoOutputHandler((b) => this.BeginInvoke((Action)(() => { ScheduleNextFrame(b); }))); m_selectedDevice.AudioOutputRequested += new DeckLinkAudioOutputHandler(() => this.BeginInvoke((Action)(() => { WriteNextAudioSamples(); }))); m_selectedDevice.PlaybackStopped += new DeckLinkPlaybackStoppedHandler(() => this.BeginInvoke((Action)(() => { DisableOutput(); }))); m_audioChannelCount = 16; m_audioSampleDepth = _BMDAudioSampleType.bmdAudioSampleType16bitInteger; m_audioSampleRate = _BMDAudioSampleRate.bmdAudioSampleRate48kHz; // //- Extract the IDeckLinkDisplayMode from the display mode popup menu IDeckLinkDisplayMode videoDisplayMode; videoDisplayMode = ((DisplayModeEntry)comboBoxVideoFormat.SelectedItem).displayMode; m_frameWidth = videoDisplayMode.GetWidth(); m_frameHeight = videoDisplayMode.GetHeight(); videoDisplayMode.GetFrameRate(out m_frameDuration, out m_frameTimescale); // Calculate the number of frames per second, rounded up to the nearest integer. For example, for NTSC (29.97 FPS), framesPerSecond == 30. m_framesPerSecond = (uint)((m_frameTimescale + (m_frameDuration - 1)) / m_frameDuration); var mode = videoDisplayMode.GetDisplayMode(); // Set the video output mode m_selectedDevice.deckLinkOutput.EnableVideoOutput(videoDisplayMode.GetDisplayMode(), _BMDVideoOutputFlags.bmdVideoOutputFlagDefault); // Set the audio output mode m_selectedDevice.deckLinkOutput.EnableAudioOutput(m_audioSampleRate, m_audioSampleDepth, m_audioChannelCount, _BMDAudioOutputStreamType.bmdAudioOutputStreamContinuous); // Generate one second of audio m_audioBufferSampleLength = (uint)(m_framesPerSecond * audioSamplesPerFrame()); int m_audioBufferDataLength = (int)(m_audioBufferSampleLength * audioDataPerSample()); m_audioBuffer = Marshal.AllocCoTaskMem(m_audioBufferDataLength); m_audioBufferAllocated = true; lock (m_selectedDevice) { // Zero the buffer (interpreted as audio silence) for (int i = 0; i < m_audioBufferDataLength; i++) { Marshal.WriteInt32(m_audioBuffer, i, 0); } FillSine(new IntPtr(m_audioBuffer.ToInt64()), m_audioBufferSampleLength, m_audioChannelCount, m_audioSampleDepth); m_audioBufferReadOffset = 0; m_audioBufferWriteOffset = 0; } m_videoFrameARGBBars = CreateOutputVideoFrame(FillBGRAColourBars, _BMDPixelFormat.bmdFormat8BitARGB); m_videoFrame = CreateOutputVideoFrame(FillARGBColourBars, _BMDPixelFormat.bmdFormat8BitARGB); m_videoFrameBars = CreateOutputVideoFrame(FillColourBars); m_pixelFormat = _BMDPixelFormat.bmdFormat8BitBGRA; m_videoFrameBGRA = CreateOutputVideoFrame(FillColourBars); m_videoFrameBGRABars = CreateOutputVideoFrame(FillBGRAColourBars, _BMDPixelFormat.bmdFormat8BitBGRA); m_pixelFormat = _BMDPixelFormat.bmdFormat8BitARGB; m_running = true; buttonStartStop.Text = "Stop"; // Begin video preroll by scheduling a second of frames in hardware m_totalFramesScheduled = 0; for (uint i = 0; i < m_prerollFrames; i++) { ScheduleNextFrame(true); } // Begin audio preroll. This will begin calling our audio callback, which will then start the DeckLink output stream - StartScheduledPlayback. m_selectedDevice.deckLinkOutput.BeginAudioPreroll(); // StopRunning(); }
public DeckLinkInputFormatChangedEventArgs(_BMDVideoInputFormatChangedEvents notificationEvents, _BMDDisplayMode displayMode, _BMDPixelFormat pixelFormat) { this.notificationEvents = notificationEvents; this.displayMode = displayMode; this.pixelFormat = pixelFormat; }
public static bool IsRgbFormat(_BMDPixelFormat fmt) { return(RGBPixelFormats.Contains(fmt)); }
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); }