public void Open(DeviceRegister.DeviceIndex device, _BMDDisplayMode mode, _BMDVideoInputFlags flags) { if (Ready) Close(); WorkerThread.Singleton.PerformBlocking(() => { this.Lock.AcquireWriterLock(10000); try { if (device == null) throw (new Exception("No device selected")); IDeckLink rawDevice = DeviceRegister.Singleton.GetDeviceHandle(device.Index); FDevice = rawDevice as IDeckLinkInput; FOutDevice = rawDevice as IDeckLinkOutput; FMode = mode; FFlags = flags; FConverter = new CDeckLinkVideoConversion(); if (FDevice == null) throw (new Exception("No input device connected")); _BMDDisplayModeSupport displayModeSupported; FDevice.DoesSupportVideoMode(FMode, FPixelFormat, flags, out displayModeSupported, out FDisplayMode); Width = FDisplayMode.GetWidth(); Height = FDisplayMode.GetHeight(); // inspiration http://dviz.googlecode.com/svn/trunk/src/livemix/CameraThread.cpp FOutDevice.CreateVideoFrame(Width, Height, Width * 4, _BMDPixelFormat.bmdFormat8BitBGRA, _BMDFrameFlags.bmdFrameFlagDefault, out rgbFrame); FDevice.EnableVideoInput(FMode, FPixelFormat, FFlags); FDevice.SetCallback(this); FDevice.StartStreams(); Reinitialise = true; Ready = true; FreshData = false; } catch (Exception e) { Ready = false; Reinitialise = false; FreshData = false; throw; } finally { this.Lock.ReleaseWriterLock(); } }); }
public Bgra32FrameConverter() { m_deckLinkConversion = new CDeckLinkVideoConversion(); }
override public void TurnOn() { _nVideoStreamTime = 0; _nAudioStreamTime = 0; if (Preferences.bDeviceInput) { if (_BMDPixelFormat.bmdFormat8BitYUV != Preferences.ePixelFormat) { int nWidth = _iDLInputDisplayMode.GetWidth(), nRowBytesQty = 0; switch (Preferences.ePixelFormat) { case _BMDPixelFormat.bmdFormat8BitBGRA: case _BMDPixelFormat.bmdFormat8BitARGB: case _BMDPixelFormat.bmdFormat10BitRGB: nRowBytesQty = nWidth * 4; break; case _BMDPixelFormat.bmdFormat8BitYUV: nRowBytesQty = nWidth * 2; break; case _BMDPixelFormat.bmdFormat10BitYUV: nRowBytesQty = ((nWidth + 47) / 48) * 128; break; } ((IDeckLinkOutput)_iDLDevice).CreateVideoFrame(nWidth, _iDLInputDisplayMode.GetHeight(), nRowBytesQty, Preferences.ePixelFormat, _BMDFrameFlags.bmdFrameFlagDefault, out _iVideoFrameTarget); _iDLVideoConversion = new CDeckLinkVideoConversion(); } _iDLInput.EnableVideoInput(_iDLInputDisplayMode.GetDisplayMode(), _BMDPixelFormat.bmdFormat8BitYUV, _BMDVideoInputFlags.bmdVideoInputFlagDefault); _iDLInput.EnableAudioInput(_BMDAudioSampleRate.bmdAudioSampleRate48kHz, _BMDAudioSampleType.bmdAudioSampleType16bitInteger, 2); _iDLInput.SetCallback(this); } else { _ahFramesBuffersBinds = new Dictionary<Frame.Video, IDeckLinkMutableVideoFrame>(); _aCurrentFramesIDs = new Dictionary<ulong, long>(); _cStopWatch = System.Diagnostics.Stopwatch.StartNew(); _aBackUPFramesIDs = new List<ulong>(); DownStreamKeyer(); _iDLOutput.SetAudioCallback(this); _iDLOutput.SetScheduledFrameCompletionCallback(this); _iDLOutput.EnableVideoOutput(_iDLOutputDisplayMode.GetDisplayMode(), _BMDVideoOutputFlags.bmdVideoOutputFlagDefault); _iDLOutput.EnableAudioOutput(_eAudioSampleRate, _eAudioSampleDepth, Preferences.nAudioChannelsQty, _BMDAudioOutputStreamType.bmdAudioOutputStreamContinuous); } base.TurnOn(); if (Preferences.bDeviceInput) _iDLInput.StartStreams(); else _iDLOutput.BeginAudioPreroll(); (new Logger()).WriteNotice("decklink turned on"); }
public void Open(DeviceRegister.DeviceIndex device, _BMDDisplayMode mode, _BMDVideoInputFlags flags) { if (Ready) { Close(); } WorkerThread.Singleton.PerformBlocking(() => { this.Lock.AcquireWriterLock(10000); try { if (device == null) { throw (new Exception("No device selected")); } IDeckLink rawDevice = DeviceRegister.Singleton.GetDeviceHandle(device.Index); FDevice = rawDevice as IDeckLinkInput; FOutDevice = rawDevice as IDeckLinkOutput; FMode = mode; FFlags = flags; FConverter = new CDeckLinkVideoConversion(); if (FDevice == null) { throw (new Exception("No input device connected")); } _BMDDisplayModeSupport displayModeSupported; FDevice.DoesSupportVideoMode(FMode, FPixelFormat, flags, out displayModeSupported, out FDisplayMode); Width = FDisplayMode.GetWidth(); Height = FDisplayMode.GetHeight(); // inspiration http://dviz.googlecode.com/svn/trunk/src/livemix/CameraThread.cpp FOutDevice.CreateVideoFrame(Width, Height, Width * 4, _BMDPixelFormat.bmdFormat8BitBGRA, _BMDFrameFlags.bmdFrameFlagDefault, out rgbFrame); FDevice.EnableVideoInput(FMode, FPixelFormat, FFlags); FDevice.SetCallback(this); FDevice.StartStreams(); Reinitialise = true; Ready = true; FreshData = false; } catch (Exception e) { Ready = false; Reinitialise = false; FreshData = false; throw; } finally { this.Lock.ReleaseWriterLock(); } }); }