public void Evaluate(int SpreadMax)
        {
            if (FInRefresh[0] || FInFlags.IsChanged || firstRun)
            {
                firstRun = false;
                FOutStatus.SliceCount = 1;
                try
                {
                    _BMDVideoOutputFlags flags = _BMDVideoOutputFlags.bmdVideoOutputFlagDefault;
                    for (int i = 0; i < FInFlags.SliceCount; i++)
                    {
                        if (i == 0)
                        {
                            flags = FInFlags[i];
                        }
                        else
                        {
                            flags |= FInFlags[i];
                        }
                    }
                    ModeRegister.Singleton.Refresh(flags);

                    string firstKey = ModeRegister.Singleton.Modes.Keys.First();
                    EnumManager.UpdateEnum("DeckLinkOutputMode", firstKey, ModeRegister.Singleton.EnumStrings);
                    FOutStatus[0] = "OK";
                }
                catch (Exception e)
                {
                    FOutStatus[0] = e.Message;
                }
            }

            if (FInMode.IsChanged)
            {
                FOutMode.SliceCount      = SpreadMax;
                FOutWidth.SliceCount     = SpreadMax;
                FOutHeight.SliceCount    = SpreadMax;
                FOutFrameRate.SliceCount = SpreadMax;
                FOutStatus.SliceCount    = SpreadMax;

                for (int slice = 0; slice < SpreadMax; slice++)
                {
                    try
                    {
                        var modes = ModeRegister.Singleton.Modes;

                        var selection = FInMode[slice];
                        if (!modes.ContainsKey(selection.Name))
                        {
                            throw (new Exception("No valid mode selected (" + selection.Name + ")"));
                        }

                        var mode = modes[selection.Name];
                        FOutMode[slice]      = new ModeRegister.ModeIndex(selection.Name);
                        FOutWidth[slice]     = mode.Width;
                        FOutHeight[slice]    = mode.Height;
                        FOutFrameRate[slice] = mode.FrameRate;

                        FOutStatus[slice] = "OK";
                    }
                    catch (Exception e)
                    {
                        FOutStatus[slice] = e.Message;
                    }
                }
            }
        }
Пример #2
0
        public void Refresh(_BMDVideoOutputFlags flags)
        {
            WorkerThread.Singleton.PerformBlocking(() =>
            {
                foreach (var mode in FModes.Values)
                {
                    Marshal.ReleaseComObject(mode.DisplayModeHandle);
                }
                FModes.Clear();

                DeviceRegister.Singleton.Refresh();
                foreach (var device in DeviceRegister.Singleton.Devices)
                {
                    var output = (IDeckLinkOutput)device.DeviceHandle;
                    if (output == null)
                    {
                        throw (new Exception("Device has no outputs"));
                    }

                    IDeckLinkDisplayModeIterator modeIterator;
                    output.GetDisplayModeIterator(out modeIterator);

                    while (true)
                    {
                        IDeckLinkDisplayMode mode;

                        modeIterator.Next(out mode);
                        if (mode == null)
                        {
                            break;
                        }

                        foreach (_BMDPixelFormat pixelFormat in Enum.GetValues(typeof(_BMDPixelFormat)))
                        {
                            if (true || SupportedFormats.Contains(pixelFormat))
                            {
                                try
                                {
                                    _BMDDisplayModeSupport support;
                                    IDeckLinkDisplayMode displayMode;
                                    output.DoesSupportVideoMode(mode.GetDisplayMode(), pixelFormat, flags, out support, out displayMode);

                                    string modeString;
                                    mode.GetName(out modeString);
                                    int stripLength          = "bmdFormat".Length;
                                    string pixelFormatString = pixelFormat.ToString();
                                    pixelFormatString        = pixelFormatString.Substring(stripLength, pixelFormatString.Length - stripLength);

                                    modeString += " [" + pixelFormatString + "]";

                                    long duration, timescale;
                                    mode.GetFrameRate(out duration, out timescale);

                                    Mode inserter = new Mode()
                                    {
                                        DisplayModeHandle = mode,
                                        Flags             = flags,
                                        PixelFormat       = pixelFormat,
                                        Width             = mode.GetWidth(),
                                        Height            = mode.GetHeight(),
                                        FrameRate         = (double)timescale / (double)duration
                                    };
                                    inserter.CalcPixelBoundaries();

                                    if (support == _BMDDisplayModeSupport.bmdDisplayModeSupported)
                                    {
                                        FModes.Add(modeString, inserter);
                                    }
                                    else if (support == _BMDDisplayModeSupport.bmdDisplayModeSupportedWithConversion)
                                    {
                                        modeString += " converted";
                                        FModes.Add(modeString, inserter);
                                    }
                                }
                                catch
                                {
                                }
                            }
                        }
                    }
                }
            });
        }
Пример #3
0
		public void Refresh(_BMDVideoOutputFlags flags)
		{
			WorkerThread.Singleton.PerformBlocking(() =>
			{
				foreach (var mode in FModes.Values)
					Marshal.ReleaseComObject(mode.DisplayModeHandle);
				FModes.Clear();

				DeviceRegister.Singleton.Refresh();
				foreach (var device in DeviceRegister.Singleton.Devices)
				{
					var output = (IDeckLinkOutput)device.DeviceHandle;
					if (output == null)
						throw (new Exception("Device has no outputs"));

					IDeckLinkDisplayModeIterator modeIterator;
					output.GetDisplayModeIterator(out modeIterator);

					while (true)
					{
						IDeckLinkDisplayMode mode;

						modeIterator.Next(out mode);
						if (mode == null)
							break;

						foreach (_BMDPixelFormat pixelFormat in Enum.GetValues(typeof(_BMDPixelFormat)))
						{
							if (true || SupportedFormats.Contains(pixelFormat))
							{
								try
								{
									_BMDDisplayModeSupport support;
									IDeckLinkDisplayMode displayMode;
									output.DoesSupportVideoMode(mode.GetDisplayMode(), pixelFormat, flags, out support, out displayMode);

									string modeString;
									mode.GetName(out modeString);
									int stripLength = "bmdFormat".Length;
									string pixelFormatString = pixelFormat.ToString();
									pixelFormatString = pixelFormatString.Substring(stripLength, pixelFormatString.Length - stripLength);

									modeString += " [" + pixelFormatString + "]";

									long duration, timescale;
									mode.GetFrameRate(out duration, out timescale);

									Mode inserter = new Mode()
									{
										DisplayModeHandle = mode,
										Flags = flags,
										PixelFormat = pixelFormat,
										Width = mode.GetWidth(),
										Height = mode.GetHeight(),
										FrameRate = (double)timescale / (double)duration
									};
									inserter.CalcPixelBoundaries();

									if (support == _BMDDisplayModeSupport.bmdDisplayModeSupported)
									{
										FModes.Add(modeString, inserter);
									}
									else if (support == _BMDDisplayModeSupport.bmdDisplayModeSupportedWithConversion)
									{
										modeString += " converted";
										FModes.Add(modeString, inserter);
									}
								}
								catch
								{
								}
							}
						}
					}
				}
			});
		}