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 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; FMode = mode; FFlags = flags; 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(); 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 void Open(IDeckLink device, _BMDDisplayMode mode, _BMDVideoInputFlags flags) { if (Ready) { Close(); } try { this.Lock.AcquireWriterLock(10000); } catch { } try { FDevice = device as IDeckLinkInput; FMode = mode; FFlags = flags; 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(); 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 (e); } finally { this.Lock.ReleaseWriterLock(); } }
public void Open(IDeckLink device, _BMDDisplayMode mode, _BMDVideoInputFlags flags) { if (Ready) Close(); try { this.Lock.AcquireWriterLock(10000); } catch { } try { FDevice = device as IDeckLinkInput; FMode = mode; FFlags = flags; 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(); 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 (e); } finally { this.Lock.ReleaseWriterLock(); } }
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; FMode = mode; FFlags = flags; 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(); 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 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(); } }); }