public static bool Startup(string assemblyPath = "", bool throwExceptions = false) { if (IsStarted) { if (!throwExceptions) { return(false); } throw new InvalidOperationException("IsStarted " + IsStarted); } try { InstanceFactory.AssemblyPath = assemblyPath; InstanceFactory.RegisterType <IMediaToolkitBootstrapper>("MediaToolkit.dll"); InstanceFactory.RegisterType <IVideoRenderer>("MediaToolkit.dll"); InstanceFactory.RegisterType <IAudioRenderer>("MediaToolkit.dll"); InstanceFactory.RegisterType <IMediaRenderSession>("MediaToolkit.dll"); InstanceFactory.RegisterType <IHttpScreenStreamer>("MediaToolkit.dll"); InstanceFactory.RegisterType <IScreenCasterControl>("MediaToolkit.UI.dll", "ScreenCastControl"); //InstanceFactory.RegisterType<IScreenCasterControl>("MediaToolkit.UI.dll", "ScreenCastControlEx"); InstanceFactory.RegisterType <IDeckLinkInputControl>("MediaToolkit.UI.dll"); //... mediaToolkit = InstanceFactory.CreateInstance <IMediaToolkitBootstrapper>(); mediaToolkit.Startup(); IsStarted = true; } catch (Exception ex) { Debug.WriteLine(ex); //Debug.Fail(ex.Message); if (throwExceptions) { throw; } } return(IsStarted); }
public static bool Startup(string assemblyPath = "", bool throwExceptions = false) { if (IsStarted) { if (!throwExceptions) { return(false); } throw new InvalidOperationException("IsStarted " + IsStarted); } InstanceFactory.EnableLog = true; InstanceFactory.Log += (log, level) => { if (level == InstanceFactory.LogLevel.Error) { logger?.Error(log); } else { logger?.Debug(log); } }; try { InstanceFactory.AssemblyPath = assemblyPath; InstanceFactory.RegisterType <IMediaToolkitBootstrapper>("MediaToolkit.dll"); InstanceFactory.RegisterType <IVideoRenderer>("MediaToolkit.dll"); InstanceFactory.RegisterType <IAudioRenderer>("MediaToolkit.dll"); InstanceFactory.RegisterType <IMediaRenderSession>("MediaToolkit.dll"); if (!TryGetAppSettingsValue("ScreenCasterClassName", out string className)) { className = "ScreenCastControl"; } InstanceFactory.RegisterType <IScreenCasterControl>("MediaToolkit.UI.dll", className); //InstanceFactory.RegisterType<IScreenCasterControl>("MediaToolkit.UI.dll", "ScreenCastControl"); mediaToolkit = InstanceFactory.CreateInstance <IMediaToolkitBootstrapper>(); mediaToolkit.Startup(); IsStarted = true; } catch (Exception ex) { logger.Error(ex); //Debug.Fail(ex.Message); if (throwExceptions) { throw; } } return(IsStarted); }