Esempio n. 1
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();
				}
			});
		}
Esempio n. 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;
                    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();
                }
            });
        }
Esempio n. 3
0
        public void StartCapture(_BMDDisplayMode mode, IDeckLinkScreenPreviewCallback screenPreviewCallback, bool applyDetectedInputMode)
        {
            logger.Debug("StartCapture(...) " + mode);

            if (currentlyCapturing)
            {
                return;
            }
            deckLinkInput.GetDisplayMode(_BMDDisplayMode.bmdModeHD1080i5994, out IDeckLinkDisplayMode displayMode);

            StartCapture(displayMode, screenPreviewCallback, applyDetectedInputMode);
        }
Esempio n. 4
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();
            }
        }
Esempio n. 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();
			}
		}
		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();
				}
			});
		}
Esempio n. 7
0
        /// <summary>
        /// Gets the list of available encoding presets for the given input mode.
        /// </summary>
        /// <param name="inputMode">The input mode</param>
        /// <returns>Returns the list of the supported encoding presets.</returns>
        private List <EncodingModeEntry> GetEncodingPresetsForInputMode(_BMDDisplayMode inputMode)
        {
            List <EncodingModeEntry> encodingPresets = new List <EncodingModeEntry>();

            IBMDStreamingVideoEncodingModePresetIterator presetIterator;

            streamingDeviceInput.GetVideoEncodingModePresetIterator(inputMode, out presetIterator);

            while (true)
            {
                IBMDStreamingVideoEncodingMode encodingMode;

                presetIterator.Next(out encodingMode);
                if (encodingMode == null)
                {
                    break;
                }

                encodingPresets.Add(new EncodingModeEntry(encodingMode));
            }

            return(encodingPresets);
        }
Esempio n. 8
0
 // Set Input DisplayMode
 public void SetInputDisplayMode(DeckLinkDisplayMode mode)
 {
     inputDisplayMode = (_BMDDisplayMode)mode;
 }
Esempio n. 9
0
 // Set Output DisplayMode
 public void SetOutputDisplayMode(DeckLinkDisplayMode mode)
 {
     displayMode = (_BMDDisplayMode)mode;
 }
Esempio n. 10
0
 public DeckLinkInputFormatChangedEventArgs(_BMDVideoInputFormatChangedEvents notificationEvents, _BMDDisplayMode displayMode, _BMDPixelFormat pixelFormat)
 {
     this.notificationEvents = notificationEvents;
     this.displayMode        = displayMode;
     this.pixelFormat        = pixelFormat;
 }
Esempio n. 11
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();
                }
            });
        }
Esempio n. 12
0
            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);
            }