void GetInputs() { IBMDSwitcherInputIterator inputIterator = null; IntPtr inputIteratorPtr; Guid inputIteratorIID = typeof(IBMDSwitcherInputIterator).GUID; m_switcher.CreateIterator(ref inputIteratorIID, out inputIteratorPtr); if (inputIteratorPtr != null) { inputIterator = (IBMDSwitcherInputIterator)Marshal.GetObjectForIUnknown(inputIteratorPtr); } if (inputIterator != null) { IBMDSwitcherInput input; inputIterator.Next(out input); while (input != null) { InputMonitor newInputMonitor = new InputMonitor(input); input.AddCallback(newInputMonitor); newInputMonitor.LongNameChanged += new SwitcherEventHandler(OnInputLongNameChanged); m_inputMonitors.Add(newInputMonitor); inputIterator.Next(out input); } } }
protected override void Initialize() { Components.Add(EventsEngine = new EventsEngine(this)); Components.Add(InputMonitor = new InputMonitor(this)); Components.Add(DebugMonitor = new DebugMonitor(this, 60) { Visible = Program.Debug }); InputMonitor.KeyReleased += keys => { if (keys == Keys.F1) { DebugMonitor.Visible = !DebugMonitor.Visible; } //else if (keys == Keys.F11) Graphics.ToggleFullScreen(); }; ContentEngine.GlobalContent.LoadContent(); base.Initialize(); }
public virtual void Run() { GCSettings.LatencyMode = GCLatencyMode.SustainedLowLatency; drawThread.Start(); updateThread.Start(); if (Window != null) { Window.KeyDown += window_KeyDown; Window.Resize += window_ClientSizeChanged; Window.ExitRequested += OnExitRequested; Window.Exited += OnExited; Window.Title = $@"osu.Framework (running ""{Name}"")"; Window.FocusedChanged += delegate { setActive(Window.Focused); }; window_ClientSizeChanged(null, null); try { Window.UpdateFrame += delegate { inputPerformanceCollectionPeriod?.Dispose(); inputThread.RunUpdate(); inputPerformanceCollectionPeriod = InputMonitor.BeginCollecting(PerformanceCollectionType.WndProc); }; Window.Run(); } catch (OutOfMemoryException) { } } else { while (!ExitRequested) { inputThread.RunUpdate(); } } }
public frmUNIcastStreamer() { InitializeComponent(); // Clear sample texts lblSubject.Text = String.Empty; lblLecturer.Text = String.Empty; lblDate.Text = String.Empty; // Fix screen position bug this.StartPosition = FormStartPosition.CenterScreen; // Load settings IniFile ini = new IniFile(Path.Combine(Environment.CurrentDirectory, IniFile)); string str = ini.IniReadValue(Section, KeyStream); if (!Address.TryParse(str, out streamAddress)) { streamAddress = DefaultStreamAddress; ini.IniWriteValue(Section, KeyStream, streamAddress.ToString()); } str = ini.IniReadValue(Section, KeyMessage); if (!Address.TryParse(str, out messageAddress)) { messageAddress = DefaultMessageAddress; ini.IniWriteValue(Section, KeyMessage, messageAddress.ToString()); } // Load DeckLink API Thread deckLinkStreamerThread = new Thread(() => { deckLinkStreamer = new DeckLinkStreamer(); // Set callback deckLinkStreamer.SetCallback(this); // Initialise API if (!deckLinkStreamer.TryInitializeAPI()) { deckLinkStreamer.SetCallback(null); MessageBox.Show(strings.errorDeckLinkDriver, strings.error); Environment.Exit(1); } deckLinkAPIVersion = deckLinkStreamer.DeckLinkAPIVersion; lblDeckLinkVersion.InvokeIfRequired(c => c.Text = deckLinkAPIVersion); }); deckLinkStreamerThread.SetApartmentState(ApartmentState.MTA); deckLinkStreamerThread.IsBackground = true; deckLinkStreamerThread.Start(); // Initialise variables, load settings duration = new TimeSpan(1, 30, 00); timeMode = 0; timer = new System.Windows.Forms.Timer(); timer.Tick += timer_Tick; tabControl.SelectedIndex = 0; progressRing.ProgressPercentage = 0; isStreaming = false; streamServer = new MulticastServer(streamAddress.IP, streamAddress.Port, TTL); messageServer = new MulticastServer(messageAddress.IP, messageAddress.Port, TTL); Thread inputMonitorThread = new Thread(() => { inputMonitor = new InputMonitor(); inputMonitor.InputPositionReceived += inputMonitor_InputPositionReceived; inputMonitor.Start(); }); inputMonitorThread.IsBackground = true; inputMonitorThread.Start(); ffmpeg = new FFmpeg(); if (ffmpeg.isAvailable) { //ffmpeg.OnLogDataReceived += ffmpeg_LogDataReceived; ffmpegVersion = ffmpeg.GetVersion(); lblFFmpegVersion.Text = ffmpegVersion; } pipeHandler = new PipeHandler(); pipeHandler.ClientConnected += pipeHandler_ClientConnected; pipeHandler.ClientDisconnected += pipeHandler_ClientDisconnected; //else //{ // MessageBox.Show(strings.errorFFmpeg, strings.error); // Environment.Exit(1); //} //performanceMonitor = new PerformanceMonitor(new string[] { "ffmpeg", "BMDStreamingServer", Process.GetCurrentProcess().ProcessName }); //performanceMonitor.PerfValuesReceived += performanceMonitor_PerfValuesReceived; //performanceMonitor.StartMonitoring(); lblVersion.Text += Application.ProductVersion; progressRing.Enabled = true; messenger = new frmMessenger(); }
void inputMonitor_InputPositionReceived(object sender, InputMonitor.InputEventArgs e) { int[] values = new int[] { e.cursorPosition.X, e.cursorPosition.Y, e.caretPosition.Left, e.caretPosition.Top, e.caretPosition.Width, e.caretPosition.Height, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height}; byte[] message = new byte[8 + 1 + 8 * 4]; // Header // TimeStamp Buffer.BlockCopy(BitConverter.GetBytes(DateTime.UtcNow.ToUnixTimestamp()), 0, message, 0, 8); // MessageType message[8] = 0; // Payload for (int i = 0; i < values.Length; i++) { Buffer.BlockCopy(BitConverter.GetBytes(values[i]), 0, message, 9 + i * 4, 4); } messageServer.SendMessage(message); }
public void ReleaseControl(InputMonitor monitor) => MonitorManager.Release(monitor);
public void TakeControl(InputMonitor monitor) => MonitorManager.TakeControl(monitor);
protected override void Context() { base.Context(); Sut = new InputMonitor(); }
private void inputMonitorIsPreviewTalliedChangedHandler(BMDSwitcherAPI.IBMDSwitcherInput switcherInput, InputMonitor monitor, bool isTallied) { Inputs.FindAll(input => (input.Index == switcherInput.GetId())).ForEach(input => { input.GreenTally = isTallied; }); }
public Switcher(string ipAddress) { var options = new PusherOptions { Cluster = "us2", Encrypted = true }; pusher = new Pusher( "1137245", "f9cabd4c01730143d579", "3b87a4daf5b3f26ee1be", options); IBMDSwitcherDiscovery discovery = new CBMDSwitcherDiscovery(); _BMDSwitcherConnectToFailure failureReason; discovery.ConnectTo(ipAddress, out m_switcher, out failureReason); m_switcherMonitor = new SwitcherMonitor(); m_switcherMonitor.SwitcherDisconnected += OnSwitcherDisconnected; m_mixEffectBlockMonitor = new MixEffectBlockMonitor(); m_mixEffectBlockMonitor.ProgramInputChanged += OnSwitcherProgramChange; m_mixEffectBlockMonitor.PreviewInputChanged += OnSwitcherPreviewChange; m_switcher.AddCallback(m_switcherMonitor); IBMDSwitcherInput input = null; // We create input monitors for each input. To do this we iterate over all inputs: // This will allow us to update the combo boxes when input names change: IBMDSwitcherInputIterator inputIterator = null; IntPtr inputIteratorPtr; Guid inputIteratorIID = typeof(IBMDSwitcherInputIterator).GUID; m_switcher.CreateIterator(ref inputIteratorIID, out inputIteratorPtr); if (inputIteratorPtr != null) { inputIterator = (IBMDSwitcherInputIterator)Marshal.GetObjectForIUnknown(inputIteratorPtr); } if (inputIterator != null) { input = null; inputIterator.Next(out input); while (input != null) { InputMonitor newInputMonitor = new InputMonitor(input); input.AddCallback(newInputMonitor); m_inputMonitors.Add(newInputMonitor); inputIterator.Next(out input); } } //if (m_mixEffectBlock1 != null) //{ // // Remove callback // m_mixEffectBlock1.RemoveCallback(m_mixEffectBlockMonitor); // // Release reference // m_mixEffectBlock1 = null; //} //if (m_switcher != null) //{ // // Remove callback: // m_switcher.RemoveCallback(m_switcherMonitor); // // release reference: // m_switcher = null; //} // We want to get the first Mix Effect block (ME 1). We create a ME iterator, // and then get the first one: //m_mixEffectBlock1 = null; IBMDSwitcherMixEffectBlockIterator meIterator = null; IntPtr meIteratorPtr; Guid meIteratorIID = typeof(IBMDSwitcherMixEffectBlockIterator).GUID; m_switcher.CreateIterator(ref meIteratorIID, out meIteratorPtr); if (meIteratorPtr != null) { meIterator = (IBMDSwitcherMixEffectBlockIterator)Marshal.GetObjectForIUnknown(meIteratorPtr); } if (meIterator == null) { return; } if (meIterator != null) { meIterator.Next(out m_mixEffectBlock1); } // Install MixEffectBlockMonitor callbacks: m_mixEffectBlock1.AddCallback(m_mixEffectBlockMonitor); // Get an input iterator. inputIterator = null; inputIteratorIID = typeof(IBMDSwitcherInputIterator).GUID; m_switcher.CreateIterator(ref inputIteratorIID, out inputIteratorPtr); if (inputIteratorPtr != null) { inputIterator = (IBMDSwitcherInputIterator)Marshal.GetObjectForIUnknown(inputIteratorPtr); } if (inputIterator == null) { return; } input = null; inputIterator.Next(out input); while (input != null) { string inputName; long inputId; input.GetInputId(out inputId); input.GetLongName(out inputName); // Add items to list: m_output_list.Add(new StringObjectPair <long>(inputName, inputId)); //m_output_list.Add(new StringObjectPair<long>(inputName, inputId)); inputIterator.Next(out input); } //while (true) //{ //} }