public async Task <bool> Reload() { if (ObsTypes.Count == 0) { ObsTypes = await ws.GetSourcesTypesList(); } Version = await ws.GetVersion(); var studiomode = await ws.StudioModeEnabled(); Mode = studiomode ? EOBSMode.Studio : EOBSMode.Normal; var OutputStatus = await ws.GetStreamingStatus(); _state = _translateStreamingStatus(OutputStatus); await _loadTransitions(); await _loadActiveTransition(); SpecialSources = await ws.GetSpecialSources(); await _loadSources(); await _loadScenes(); await _loadActiveScene(); if (Mode == EOBSMode.Studio) { _loadActivePScene(); } return(true); }
public CSLOBSConnector() { Mode = EOBSMode.Normal; Scenes = new List <SOBSScene>(); PreviewScenes = new List <SOBSScene>(); Transitions = new List <SOBSTransition>(); Sources = new List <SOBSSource>(); AudioSources = new List <SOBSAudioSource>(); ActiveScene = new SOBSScene(); ActivePreviewScene = new SOBSScene(); ActiveTransition = new SOBSTransition(); _state = new SOBSStreamingState(); _state.Stream = EOBSStreamingState.Unkown; _state.Record = EOBSStreamingState.Unkown; _state.Replay = EOBSStreamingState.Unkown; ws = new SLOBSWebsocket(); ws.ConnectionStatus += Ws_ConnectionStatus; ws.SceneChanged += Ws_SceneChanged; ws.SceneListChanged += Ws_SceneListChanged; ws.SceneItemChanged += Ws_SceneItemChanged; ws.SourceChanged += Ws_SourceChanged; ws.StreamingStatusChanged += Ws_StreamingStatusChanged; //timer for querying Recording & Replay buffer status //SLOBS api has no events for this types yet. statusTimer = new System.Timers.Timer(5000); statusTimer.Elapsed += StatusTimer_Elapsed;; statusTimer.AutoReset = true; statusTimer.Enabled = false; }
public async Task <bool> Reload() { var status = await ws.GetStreamingStatus(); if (status != null) { _state = _translateStreamingStatus((SLOBSStreamingState)status); } var remote_scenes = await ws.ListScenes(); if (remote_scenes.Count > 0) { Scenes = _translateScenes(remote_scenes); } var remote_sources = await ws.ListSources(); if (remote_sources.Count > 0) { Sources = _translateSources(remote_sources); } var remote_audio_sources = await ws.ListAudioSources(); if (remote_audio_sources.Count > 0) { AudioSources = _translateAudioSources(remote_audio_sources); } var activeSceneId = await ws.GetActiveSceneId(); if (activeSceneId != null) { for (int i = 0; i < Scenes.Count; i++) { if (Scenes[i].Id == activeSceneId) { ActiveScene = Scenes[i]; break; } } } return(true); }
private async void StatusTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { var state = await ws.GetStreamingStatus(); if (state != null) { var converted_state = _translateStreamingStatus((SLOBSStreamingState)state); if (converted_state.Stream != _state.Stream || converted_state.Replay != _state.Replay || converted_state.Record == _state.Record) { _state = converted_state; if (StreamingStatusChanged != null) { StreamingStatusChanged(this, converted_state); } } } }
public COBSConnector() { Mode = EOBSMode.Normal; Scenes = new List <SOBSScene>(); PreviewScenes = new List <SOBSScene>(); Transitions = new List <SOBSTransition>(); Sources = new List <SOBSSource>(); AudioSources = new List <SOBSAudioSource>(); ActiveScene = new SOBSScene(); ActivePreviewScene = new SOBSScene(); ActiveTransition = new SOBSTransition(); _state = new SOBSStreamingState(); _state.Stream = EOBSStreamingState.Unkown; _state.Record = EOBSStreamingState.Unkown; _state.Replay = EOBSStreamingState.Unkown; SpecialSources = new Dictionary <string, string>(); ws = new OBSWebsocket(); ws.Connected += Ws_Connected; ws.Disconnected += Ws_Disconnected; ws.OnError += Ws_OnError; ws.SceneChanged += Ws_SceneChanged; ws.PreviewSceneChanged += Ws_PreviewSceneChanged; ws.SceneCollectionChanged += Ws_SceneCollectionChanged; ws.TransitionChanged += Ws_TransitionChanged; ws.TransitionListChanged += Ws_TransitionListChanged; ws.SceneItemVisibilityChanged += Ws_SceneItemVisibilityChanged; ws.SceneItemAdded += Ws_SceneItemAdded; ws.SceneItemRemoved += Ws_SceneItemRemoved; ws.SourceOrderChanged += Ws_SourceOrderChanged; ws.StudioModeSwitched += Ws_StudioModeSwitched; ws.StreamingStateChanged += Ws_StreamingStateChanged; ws.RecordingStateChanged += Ws_RecordingStateChanged; }
private SOBSStreamingState _translateStreamingStatus(OutputStatus input) { var state = new SOBSStreamingState(); if (input.IsRecording) { state.Record = EOBSStreamingState.Started; } else { state.Record = EOBSStreamingState.Stopped; } if (input.IsStreaming) { state.Stream = EOBSStreamingState.Started; } else { state.Stream = EOBSStreamingState.Stopped; } return(state); }
private SOBSStreamingState _translateStreamingStatus(SLOBSStreamingState input) { var state = new SOBSStreamingState(); switch (input.StreamingStatus) { case ESLOBSStreamingState.Live: state.Stream = EOBSStreamingState.Started; break; case ESLOBSStreamingState.Offline: state.Stream = EOBSStreamingState.Stopped; break; case ESLOBSStreamingState.Starting: state.Stream = EOBSStreamingState.Starting; break; case ESLOBSStreamingState.Ending: state.Stream = EOBSStreamingState.Stopping; break; case ESLOBSStreamingState.Reconnecting: state.Stream = EOBSStreamingState.Reconnecting; break; default: state.Stream = EOBSStreamingState.Unkown; break; } switch (input.RecordingStatus) { case ESLOBSSRecordingState.Recording: state.Record = EOBSStreamingState.Started; break; case ESLOBSSRecordingState.Offline: state.Record = EOBSStreamingState.Stopped; break; case ESLOBSSRecordingState.Starting: state.Record = EOBSStreamingState.Starting; break; case ESLOBSSRecordingState.Stopping: state.Record = EOBSStreamingState.Stopping; break; default: state.Record = EOBSStreamingState.Unkown; break; } switch (input.ReplayBufferStatus) { case ESLOBSSReplayBufferState.Running: state.Replay = EOBSStreamingState.Started; break; case ESLOBSSReplayBufferState.Offline: state.Replay = EOBSStreamingState.Stopped; break; case ESLOBSSReplayBufferState.Saving: state.Replay = EOBSStreamingState.Stopping; break; case ESLOBSSReplayBufferState.Stopping: state.Replay = EOBSStreamingState.Stopping; break; default: state.Replay = EOBSStreamingState.Unkown; break; } return(state); }
private void Obs_StreamingStatusChanged(IOBSConnector sender, SOBSStreamingState state) { //streaming if (state.Stream == EOBSStreamingState.Starting || state.Stream == EOBSStreamingState.Reconnecting) { Midi.Display(EMidiOBSItemType.Stream, EMidiOBSOutputType.Starting, -1); } else if (state.Stream == EOBSStreamingState.Stopping) { Midi.Display(EMidiOBSItemType.Stream, EMidiOBSOutputType.Stopping, -1); } else if (state.Stream == EOBSStreamingState.Started) { Midi.Display(EMidiOBSItemType.Stream, EMidiOBSOutputType.Active, -1); } else if (state.Stream == EOBSStreamingState.Stopped) { Midi.Display(EMidiOBSItemType.Stream, EMidiOBSOutputType.On, -1); } //recording if (state.Record == EOBSStreamingState.Starting) { Midi.Display(EMidiOBSItemType.Record, EMidiOBSOutputType.Starting, -1); } else if (state.Record == EOBSStreamingState.Stopping) { Midi.Display(EMidiOBSItemType.Record, EMidiOBSOutputType.Stopping, -1); } else if (state.Record == EOBSStreamingState.Started) { Midi.Display(EMidiOBSItemType.Record, EMidiOBSOutputType.Active, -1); } else if (state.Record == EOBSStreamingState.Stopped) { Midi.Display(EMidiOBSItemType.Record, EMidiOBSOutputType.On, -1); } //replaybuffer if (state.Replay == EOBSStreamingState.Starting || state.Replay == EOBSStreamingState.Saving) { Midi.Display(EMidiOBSItemType.ReplayBuffer, EMidiOBSOutputType.Starting, -1); } else if (state.Replay == EOBSStreamingState.Stopping) { Midi.Display(EMidiOBSItemType.ReplayBuffer, EMidiOBSOutputType.Stopping, -1); } else if (state.Replay == EOBSStreamingState.Started) { Midi.Display(EMidiOBSItemType.ReplayBuffer, EMidiOBSOutputType.Active, -1); } else if (state.Replay == EOBSStreamingState.Stopped) { Midi.Display(EMidiOBSItemType.ReplayBuffer, EMidiOBSOutputType.On, -1); } if (state.Replay == EOBSStreamingState.Saving) { Midi.Display(EMidiOBSItemType.ReplayBufferSave, EMidiOBSOutputType.Active, -1); } else { Midi.Display(EMidiOBSItemType.ReplayBufferSave, EMidiOBSOutputType.On, -1); } }