示例#1
0
        void IDeckLinkInputCallback.VideoInputFormatChanged(_BMDVideoInputFormatChangedEvents notificationEvents, IDeckLinkDisplayMode newDisplayMode, _BMDDetectedVideoInputFormatFlags detectedSignalFlags)
        {
            // Restart capture with the new video mode if told to
            if (!m_applyDetectedInputMode)
            {
                return;
            }

            var pixelFormat = _BMDPixelFormat.bmdFormat8BitYUV;

            if (detectedSignalFlags.HasFlag(_BMDDetectedVideoInputFormatFlags.bmdDetectedVideoInputRGB444))
            {
                pixelFormat = _BMDPixelFormat.bmdFormat8BitBGRA;
            }

            // Stop the capture
            m_deckLinkInput.StopStreams();

            var displayMode = newDisplayMode.GetDisplayMode();

            // Set the video input mode
            m_deckLinkInput.EnableVideoInput(displayMode, pixelFormat, _BMDVideoInputFlags.bmdVideoInputEnableFormatDetection);

            // Start the capture
            m_deckLinkInput.StartStreams();

            // Register input format changed event
            var handler = InputFormatChangedHandler;

            // Check whether there are any subscribers to InputFormatChangedHandler
            if (handler != null)
            {
                handler(this, new DeckLinkInputFormatChangedEventArgs(notificationEvents, displayMode, pixelFormat));
            }
        }
示例#2
0
        void IDeckLinkInputCallback.VideoInputFormatChanged(_BMDVideoInputFormatChangedEvents notificationEvents, IDeckLinkDisplayMode newDisplayMode, _BMDDetectedVideoInputFormatFlags detectedSignalFlags)
        {
            // Restart capture with the new video mode if told to
            if (!m_applyDetectedInputMode)
            {
                return;
            }

            var pixelFormat = _BMDPixelFormat.bmdFormat10BitYUV;

            if (detectedSignalFlags.HasFlag(_BMDDetectedVideoInputFormatFlags.bmdDetectedVideoInputRGB444))
            {
                pixelFormat = _BMDPixelFormat.bmdFormat10BitRGB;
            }

            // Stop the capture
            m_deckLinkInput.StopStreams();

            // Set the video input mode
            m_deckLinkInput.EnableVideoInput(newDisplayMode.GetDisplayMode(), pixelFormat, _BMDVideoInputFlags.bmdVideoInputEnableFormatDetection);

            // Start the capture
            m_deckLinkInput.StartStreams();

            InputFormatChanged(newDisplayMode);
        }
示例#3
0
		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();
				}
			});
		}
示例#4
0
        public void StartCapture(IDeckLinkDisplayMode displayMode, IDeckLinkScreenPreviewCallback screenPreviewCallback, bool applyDetectedInputMode)
        {
            logger.Debug("StartCapture(...)");

            if (currentlyCapturing)
            {
                return;
            }

            validInputSignal            = false;
            this.applyDetectedInputMode = applyDetectedInputMode;


            var videoInputFlags = _BMDVideoInputFlags.bmdVideoInputFlagDefault;

            // Enable input video mode detection if the device supports it
            if (SupportsFormatDetection && this.applyDetectedInputMode)
            {
                videoInputFlags |= _BMDVideoInputFlags.bmdVideoInputEnableFormatDetection;
            }

            var pixelFormat    = _BMDPixelFormat.bmdFormat8BitYUV;
            var bdmDisplayMode = displayMode.GetDisplayMode();


            // Set the screen preview
            //_deckLinkInput.SetScreenPreviewCallback(screenPreviewCallback);

            // Set capture callback
            deckLinkInput.SetCallback(this);


            // Set the video input mode
            deckLinkInput.EnableVideoInput(bdmDisplayMode, pixelFormat, videoInputFlags);

            deckLinkInput.EnableAudioInput(AudioSampleRate, AudioSampleType, (uint)AudioChannelsCount);

            // Start the capture
            deckLinkInput.StartStreams();


            currentlyCapturing = true;
        }
示例#5
0
        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();
                }
            });
        }
示例#6
0
        void IDeckLinkInputCallback.VideoInputFormatChanged(_BMDVideoInputFormatChangedEvents notificationEvents, IDeckLinkDisplayMode newDisplayMode, _BMDDetectedVideoInputFormatFlags detectedSignalFlags)
        {
            // Restart capture with the new video mode if told to
            if (!m_applyDetectedInputMode)
            {
                return;
            }

            var pixelFormat = _BMDPixelFormat.bmdFormat10BitYUV;

            if (detectedSignalFlags.HasFlag(_BMDDetectedVideoInputFormatFlags.bmdDetectedVideoInputRGB444))
            {
                m_pxFormat  = "10 bit RGB";
                pixelFormat = _BMDPixelFormat.bmdFormat10BitRGB;
            }
            if (detectedSignalFlags.HasFlag(_BMDDetectedVideoInputFormatFlags.bmdDetectedVideoInputYCbCr422))
            {
                m_pxFormat  = "10 bit YUV";
                pixelFormat = _BMDPixelFormat.bmdFormat10BitYUV;
            }
            if (detectedSignalFlags.HasFlag(_BMDDetectedVideoInputFormatFlags.bmdDetectedVideoInputDualStream3D))
            {
                m_pxFormat  = "Dual Stream 3D";
                pixelFormat = _BMDPixelFormat.bmdFormat10BitYUV;
            }

            // Stop the capture
            m_deckLinkInput.StopStreams();

            // Set the video input mode
            //For upload to GPU we need 8bitYUV
            //   m_deckLinkInput.EnableVideoInput(newDisplayMode.GetDisplayMode(), pixelFormat, _BMDVideoInputFlags.bmdVideoInputEnableFormatDetection);
            m_deckLinkInput.EnableVideoInput(newDisplayMode.GetDisplayMode(), _BMDPixelFormat.bmdFormat8BitYUV, _BMDVideoInputFlags.bmdVideoInputEnableFormatDetection);
            m_deckLinkInput.EnableAudioInput(_BMDAudioSampleRate.bmdAudioSampleRate48kHz, _BMDAudioSampleType.bmdAudioSampleType16bitInteger, 16);

            // Start the capture
            m_deckLinkInput.StartStreams();

            InputFormatChanged(newDisplayMode);
        }
示例#7
0
        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();
            }
        }
示例#8
0
		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();
				}
			});
		}
示例#10
0
        protected override bool Open()
        {
            if (FDevice == null && false)
            {
                return(false);
            }
            else
            {
                try
                {
                    string status;

                    //this is a hack, we recreate the device here
                    IDeckLinkIterator iterator = new CDeckLinkIterator();
                    IDeckLink         device;
                    iterator.Next(out device);
                    FDevice = (IDeckLinkInput)device;

                    _BMDDisplayModeSupport supported;

                    FDevice.DoesSupportVideoMode(FVideoMode, FPixelFormat, FVideoInputFlags, out supported, out FDisplayMode);
                    if (supported.HasFlag(_BMDDisplayModeSupport.bmdDisplayModeNotSupported))
                    {
                        status = "Display mode supported";
                    }
                    else if (supported.HasFlag(_BMDDisplayModeSupport.bmdDisplayModeSupportedWithConversion))
                    {
                        status = "Display mode supported with conversion";
                    }
                    else
                    {
                        throw(new Exception("Display mode not supported"));
                    }

                    FDevice.EnableVideoInput(FVideoMode, FPixelFormat, FVideoInputFlags);
                    FDevice.SetCallback(this);
                    FDevice.StartStreams();

                    Status = "OK : " + status;
                    return(true);
                }
                catch (Exception e)
                {
                    Status = e.Message;
                    return(false);
                }
            }
        }
示例#11
0
        // Initialize DeckLink Stream
        public bool Initialize()
        {
            if (!cardWorking)
            {
                return(false);
            }

            // DeckLink Input Callback
            deckLinkInput.SetCallback(this);
            deckLinkInput.SetScreenPreviewCallback(this);
            var flags  = _BMDVideoInputFlags.bmdVideoInputFlagDefault | _BMDVideoInputFlags.bmdVideoInputEnableFormatDetection;
            var format = _BMDPixelFormat.bmdFormat8BitYUV;
            //var format = _BMDPixelFormat.bmdFormat8BitARGB;
            //var display = _BMDDisplayMode.bmdModeHD1080p5994; // input display mode
            _BMDDisplayModeSupport support;
            IDeckLinkDisplayMode   tmp;

            deckLinkInput.DoesSupportVideoMode(inputDisplayMode, format, flags, out support, out tmp);
            if (support != _BMDDisplayModeSupport.bmdDisplayModeSupported)
            {
                throw new Exception("display mode not working: " + support);
            }

            // Keyer
            if (keyerEnabled)
            {
                if (internalKeying)
                {
                    deckLinkKeyer.Enable(0); // 1: External alpha output, 2: Internal
                    deckLinkKeyer.SetLevel((byte)keyingLevel);
                }
                else
                {
                    deckLinkKeyer.Enable(1); // 1: External alpha output, 2: Internal
                }
            }

            // Enable Input Stream
            deckLinkInput.EnableVideoInput(inputDisplayMode, format, flags);
            deckLinkInput.EnableAudioInput(_AudioSampleRate, _AudioSampleType, _AudioChannels);
            deckLinkInput.StartStreams();

            // Enable Video Output
            //deckLinkOutput.EnableVideoOutput(displayMode, _BMDVideoOutputFlags.bmdVideoOutputFlagDefault);

            return(true);
        }
示例#12
0
 public void Start()
 {
     try
     {
         var cb = new Callback(config);
         recorder = config.Recorder;
         cb.FingerprintCreated += OnFingerprintCreated;
         recorder.SetCallback(cb);
         recorder.EnableVideoInput(config.VideoMode, _BMDPixelFormat.bmdFormat8BitYUV, _BMDVideoInputFlags.bmdVideoInputFlagDefault);
         recorder.EnableAudioInput(_BMDAudioSampleRate.bmdAudioSampleRate48kHz, _BMDAudioSampleType.bmdAudioSampleType16bitInteger, CHANNELS);
         recorder.StartStreams();
     }
     catch (Exception ex)
     {
         MessageBox.Show($"Cannot start fingerprinting: {ex.Message}", "Error", MessageBoxButton.OK);
         Stop(false);
     }
 }
示例#13
0
 private void StartDecklinkInput(DeckLinkAPI.IDeckLink device)
 {
     this.device = device;
     input = (DeckLinkAPI.IDeckLinkInput)device;
     input.SetCallback(this);
     input.EnableVideoInput(_BMDDisplayMode.bmdModeHD1080p25, _BMDPixelFormat.bmdFormat8BitYUV, _BMDVideoInputFlags.bmdVideoInputFlagDefault);
     input.StartStreams();
     frameCount = 0;
 }
示例#14
0
        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();
                }
            });
        }