예제 #1
0
        public void StartCapture(IDeckLinkDisplayMode displayMode, IDeckLinkScreenPreviewCallback screenPreviewCallback, bool applyDetectedInputMode)
        {
            if (m_currentlyCapturing)
            {
                return;
            }

            var videoInputFlags = _BMDVideoInputFlags.bmdVideoInputFlagDefault;

            m_applyDetectedInputMode = applyDetectedInputMode;
            m_validInputSignal       = false;

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

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

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

            // Set the video input mode
            m_deckLinkInput.EnableVideoInput(displayMode.GetDisplayMode(), _BMDPixelFormat.bmdFormat8BitYUV, videoInputFlags);

            // Start the capture
            m_deckLinkInput.StartStreams();

            m_currentlyCapturing = true;
        }
예제 #2
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();
				}
			});
		}
예제 #3
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;
        }
예제 #4
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();
                }
            });
        }
예제 #5
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();
            }
        }
예제 #6
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();
				}
			});
		}
예제 #8
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);
                }
            }
        }
예제 #9
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);
        }
예제 #10
0
파일: Analyser.cs 프로젝트: malooba/lipsync
 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);
     }
 }
예제 #11
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;
 }
예제 #12
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();
                }
            });
        }