public static void Terminate() { MagnitudeService.Teardown(); PipeService.Teardown(); ParentHeartbeatService.Teardown(); Environment.Exit(0); }
public override void Execute() { if (!Store.Data.Obs.IsObsStarted) { if (!Obs.Startup("en-US")) { // todo: if any exceptions are thrown in this app, we need to bubble it all up to a single terminate code so consuming apps know that it shut down throw new ApplicationException("Startup failed."); } Loggers.OBSLogger.Trace("libobs version: " + Obs.GetVersion()); // forward OBS logging messages to debugger Obs.SetLogHandler((lvl, msg, p) => { Debug.WriteLine(msg); Loggers.OBSLogger.Trace(msg); }); AudioService.ResetAudioInfo(); } VideoService.ResetVideoInfo(new ResetVideoInfoParameters { CropTop = CropTop, CropRight = CropRight, CropLeft = CropLeft, CropBottom = CropBottom, FrameRate = FrameRate, OutputWidth = OutputWidth, OutputHeight = OutputHeight, CanvasWidth = CanvasWidth, CanvasHeight = CanvasHeight, ScreenX = ScreenX, ScreenY = ScreenY }); if (!Store.Data.Obs.IsObsStarted) { Obs.LoadAllModules(); Store.Data.Obs.Presentation = new Presentation(); Store.Data.Obs.Presentation.AddScene("Main"); Store.Data.Obs.Presentation.AddScene("Webcam"); Store.Data.Obs.Presentation.SetScene(Store.Data.Obs.MainScene); Store.Data.Display.DisplaySource = Store.Data.Obs.Presentation.CreateSource("monitor_capture", "Monitor Capture Source"); Store.Data.Obs.Presentation.AddSource(Store.Data.Display.DisplaySource); Store.Data.Display.DisplayItem = Store.Data.Obs.Presentation.CreateItem(Store.Data.Display.DisplaySource); Store.Data.Display.DisplayItem.Name = "Monitor Capture SceneItem"; Rectangle activeScreenBounds = ScreenHelper.GetScreen(ScreenX, ScreenY).Bounds; Store.Data.Display.DisplayItem.SetBounds(new Vector2(activeScreenBounds.Width, activeScreenBounds.Height), ObsBoundsType.None, ObsAlignment.Top); // this should always be the screen's resolution Store.Data.Obs.MainScene.Items.Add(Store.Data.Display.DisplayItem); Thread webcamWindowThread = new Thread(() => { Store.Data.Webcam.Window = new WebcamWindow(); Store.Data.App.ApplicationInstance = new Application(); Store.Data.App.ApplicationInstance.Run(Store.Data.Webcam.Window); }); webcamWindowThread.Name = Constants.Webcam.Settings.WebcamWindowThreadName; webcamWindowThread.SetApartmentState(ApartmentState.STA); webcamWindowThread.Start(); var usedAudioInputId = AudioService.SetAudioInput(this.SavedAudioInputId); var usedAudioOutputId = AudioService.SetAudioOutput(this.SavedAudioOutputId); Store.Data.Obs.Presentation.SetItem(0); Store.Data.Obs.Presentation.SetSource(0); // wait until the window is initialized before emitting a response while (Store.Data.Webcam.Window == null) { Thread.Sleep(100); } EmitService.EmitInitializeResponse(new InitializeResponse { IsSuccessful = true, SetAudioInputDevice = usedAudioInputId, SetAudioOutputDevice = usedAudioOutputId }); } MagnitudeService.Setup(); Store.Data.Obs.IsObsStarted = true; }