Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
        private async Task <bool> _loadActiveScene()
        {
            var scene = await ws.GetCurrentScene();

            for (int i = 0; i < Scenes.Count; i++)
            {
                if (Scenes[i].Name == scene.Name)
                {
                    SOBSScene item = _translateScene(scene, i);
                    ActiveScene = item;
                }
            }
            return(true);
        }
Exemplo n.º 3
0
        private bool _setActivePreviewScene(string scene_name)
        {
            var scene = Scenes.Find(x => x.Name == scene_name);

            if (scene.Id != null)
            {
                var item = new SOBSScene();
                item.Index         = scene.Index;
                item.Name          = scene.Name;
                item.ResourceId    = scene.ResourceId;
                ActivePreviewScene = item;
                return(true);
            }
            return(false);
        }
Exemplo n.º 4
0
 private bool _setActiveScene(string scene_name)
 {
     try
     {
         var scene = Scenes.Find(x => x.Name == scene_name);
         var item  = new SOBSScene();
         item.Index      = scene.Index;
         item.Id         = scene.Id;
         item.Name       = scene.Name;
         item.ResourceId = scene.ResourceId;
         ActiveScene     = item;
         return(true);
     }catch (ArgumentNullException e)
     {
     }
     return(false);
 }
Exemplo n.º 5
0
 private void Obs_SceneChanged(IOBSConnector sender, EOBSEvent eventtype, SOBSScene scene)
 {
     // throw new NotImplementedException();
     if (eventtype == EOBSEvent.SceneAdded || eventtype == EOBSEvent.SceneRemoved)
     {
         if (EOBSEvent.SceneRemoved == eventtype)
         {
             Midi.Display(EMidiOBSItemType.Scene, EMidiOBSOutputType.Off, -1);
         }
         _renderScenes();
     }
     else if (eventtype == EOBSEvent.SceneSwitched || eventtype == EOBSEvent.SceneUpdated)
     {
         _renderScenes();
         _renderSceneItems();
     }
     Midi.FlushQueue();
 }
Exemplo n.º 6
0
        private SOBSScene _translateScene(OBSScene input, int index = -1)
        {
            SOBSScene output = new SOBSScene();

            output.Index = index == -1 ? Scenes.Count() : index;
            output.Id    = _uidFromString(input.Name);
            output.Name  = input.Name;
            output.Items = new List <SOBSSceneItem>();
            if (input.Items != null && input.Items.Count > 0)
            {
                for (int i = 0; i < input.Items.Count; i++)
                {
                    SOBSSceneItem item = _translateSceneItem(input.Items[i], i);
                    output.Items.Add(item);
                }
            }
            return(output);
        }
Exemplo n.º 7
0
        private async void _loadActivePScene(bool trigger_event = false)
        {
            var scene = await ws.GetPreviewScene();

            for (int i = 0; i < Scenes.Count; i++)
            {
                if (Scenes[i].Name == scene.Name)
                {
                    SOBSScene item = _translateScene(scene, i);
                    ActivePreviewScene = item;

                    if (trigger_event)
                    {
                        SceneChanged(this, EOBSEvent.SceneUpdated, item);
                    }
                }
            }
        }
Exemplo n.º 8
0
        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;
        }
Exemplo n.º 9
0
        private void Ws_StudioModeSwitched(OBSWebsocket sender, bool enabled)
        {
            if (enabled)
            {
                Mode = EOBSMode.Studio;
            }
            else
            {
                Mode = EOBSMode.Normal;
            }
            if (ModeChanged != null)
            {
                ModeChanged(this, Mode);
            }

            if (Mode == EOBSMode.Studio)
            {
                _loadActivePScene(true);
            }
            else
            {
                ActivePreviewScene = new SOBSScene();
            }
        }
Exemplo n.º 10
0
        private async void Ws_SceneChanged(SLOBSWebsocket sender, SLOBSSceneEvent eventdata)
        {
            if (eventdata.Type == ESLOBSEventType.SceneAdded)
            {
                SOBSScene item = _translateScene(eventdata.Scene);
                Scenes.Add(item);
                if (SceneChanged != null)
                {
                    SceneChanged(this, EOBSEvent.SceneAdded, item);
                }
            }
            else if (eventdata.Type == ESLOBSEventType.SceneRemoved)
            {
                int       reindex = 0;
                SOBSScene item    = _translateScene(eventdata.Scene);
                for (int i = 0; i < Scenes.Count; i++)
                {
                    if (Scenes[i].Id == eventdata.Scene.Id)
                    {
                        Scenes.RemoveAt(i);
                    }
                    else
                    {
                        var scene = Scenes[i];
                        scene.Index = reindex;
                        Scenes[i]   = scene;
                        reindex++;
                    }
                }
                if (SceneChanged != null)
                {
                    SceneChanged(this, EOBSEvent.SceneRemoved, item);
                }
            }
            else if (eventdata.Type == ESLOBSEventType.SceneSwitched)
            {
                if (!_setActiveScene(eventdata.Scene))
                {
                    var ascenes = await ws.ListScenes();

                    Scenes.Clear();
                    Scenes = _translateScenes(ascenes);
                    _setActiveScene(eventdata.Scene);
                }

                var audio = await ws.ListAudioSources();

                AudioSources.Clear();
                AudioSources = _translateAudioSources(audio);
                if (AudioSourceChanged != null)
                {
                    AudioSourceChanged(this, EOBSEvent.SourceAdded);
                }

                if (SceneChanged != null)
                {
                    SceneChanged(this, EOBSEvent.SceneSwitched, ActiveScene);
                }
            }
            else if (eventdata.Type == ESLOBSEventType.SceneCollectionChanged)
            {
                var ascenes = await ws.ListScenes();

                Scenes.Clear();
                Scenes = _translateScenes(ascenes);
                var active_scene = await ws.GetActiveScene();

                if (active_scene != null)
                {
                    for (int i = 0; i < Scenes.Count; i++)
                    {
                        if (Scenes[i].Id == ((SLOBSScene)active_scene).Id)
                        {
                            ActiveScene = Scenes[i];
                        }
                    }
                }

                if (SceneChanged != null)
                {
                    SceneChanged(this, EOBSEvent.SceneUpdated, ActiveScene);
                }
            }
        }