diff --git a/MediaBrowser.Api/MediaBrowser.Api.csproj b/MediaBrowser.Api/MediaBrowser.Api.csproj
index cf2a556955..97c399fbe9 100644
--- a/MediaBrowser.Api/MediaBrowser.Api.csproj
+++ b/MediaBrowser.Api/MediaBrowser.Api.csproj
@@ -97,6 +97,7 @@
+
diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs
index ce9fe0e0be..9808564105 100644
--- a/MediaBrowser.Api/Playback/BaseStreamingService.cs
+++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs
@@ -518,7 +518,7 @@ namespace MediaBrowser.Api.Playback
EnableRaisingEvents = true
};
- Plugin.Instance.OnTranscodeBeginning(outputPath, TranscodingJobType, process);
+ ServerEntryPoint.Instance.OnTranscodeBeginning(outputPath, TranscodingJobType, process);
//Logger.Info(process.StartInfo.FileName + " " + process.StartInfo.Arguments);
@@ -537,7 +537,7 @@ namespace MediaBrowser.Api.Playback
{
Logger.ErrorException("Error starting ffmpeg", ex);
- Plugin.Instance.OnTranscodeFailedToStart(outputPath, TranscodingJobType);
+ ServerEntryPoint.Instance.OnTranscodeFailedToStart(outputPath, TranscodingJobType);
state.LogFileStream.Dispose();
@@ -588,7 +588,7 @@ namespace MediaBrowser.Api.Playback
process.Dispose();
- Plugin.Instance.OnTranscodingFinished(outputFilePath, TranscodingJobType);
+ ServerEntryPoint.Instance.OnTranscodingFinished(outputFilePath, TranscodingJobType);
if (!exitCode.HasValue || exitCode.Value != 0)
{
diff --git a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs
index 8c7edbe91d..d616565ca8 100644
--- a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs
+++ b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs
@@ -77,7 +77,7 @@ namespace MediaBrowser.Api.Playback.Hls
}
else
{
- Plugin.Instance.OnTranscodeBeginRequest(playlist, TranscodingJobType.Hls);
+ ServerEntryPoint.Instance.OnTranscodeBeginRequest(playlist, TranscodingJobType.Hls);
}
// Get the current playlist text and convert to bytes
@@ -94,7 +94,7 @@ namespace MediaBrowser.Api.Playback.Hls
}
finally
{
- Plugin.Instance.OnTranscodeEndRequest(playlist, TranscodingJobType.Hls);
+ ServerEntryPoint.Instance.OnTranscodeEndRequest(playlist, TranscodingJobType.Hls);
}
}
diff --git a/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs b/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs
index 08e66c3874..bbfe65504b 100644
--- a/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs
+++ b/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs
@@ -107,7 +107,7 @@ namespace MediaBrowser.Api.Playback.Progressive
var outputPath = GetOutputFilePath(state);
- if (File.Exists(outputPath) && !Plugin.Instance.HasActiveTranscodingJob(outputPath, TranscodingJobType.Progressive))
+ if (File.Exists(outputPath) && !ServerEntryPoint.Instance.HasActiveTranscodingJob(outputPath, TranscodingJobType.Progressive))
{
return ToStaticFileResult(outputPath);
}
@@ -133,7 +133,7 @@ namespace MediaBrowser.Api.Playback.Progressive
}
else
{
- Plugin.Instance.OnTranscodeBeginRequest(outputPath, TranscodingJobType.Progressive);
+ ServerEntryPoint.Instance.OnTranscodeBeginRequest(outputPath, TranscodingJobType.Progressive);
}
return new ProgressiveStreamWriter
diff --git a/MediaBrowser.Api/Playback/Progressive/ProgressiveStreamWriter.cs b/MediaBrowser.Api/Playback/Progressive/ProgressiveStreamWriter.cs
index 9ac93694b3..b6b73c78dd 100644
--- a/MediaBrowser.Api/Playback/Progressive/ProgressiveStreamWriter.cs
+++ b/MediaBrowser.Api/Playback/Progressive/ProgressiveStreamWriter.cs
@@ -41,7 +41,7 @@ namespace MediaBrowser.Api.Playback.Progressive
}
finally
{
- Plugin.Instance.OnTranscodeEndRequest(Path, TranscodingJobType.Progressive);
+ ServerEntryPoint.Instance.OnTranscodeEndRequest(Path, TranscodingJobType.Progressive);
}
}
diff --git a/MediaBrowser.Api/Plugin.cs b/MediaBrowser.Api/Plugin.cs
index 58c0ffcfa5..b8c81bbe12 100644
--- a/MediaBrowser.Api/Plugin.cs
+++ b/MediaBrowser.Api/Plugin.cs
@@ -1,12 +1,7 @@
-using MediaBrowser.Common.Plugins;
+using MediaBrowser.Common.Kernel;
+using MediaBrowser.Common.Plugins;
using MediaBrowser.Model.Plugins;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
+using MediaBrowser.Model.Serialization;
namespace MediaBrowser.Api
{
@@ -15,6 +10,16 @@ namespace MediaBrowser.Api
///
public class Plugin : BasePlugin
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The kernel.
+ /// The XML serializer.
+ public Plugin(IKernel kernel, IXmlSerializer xmlSerializer) : base(kernel, xmlSerializer)
+ {
+ Instance = this;
+ }
+
///
/// Gets the name of the plugin
///
@@ -41,287 +46,5 @@ namespace MediaBrowser.Api
///
/// The instance.
public static Plugin Instance { get; private set; }
-
- ///
- /// Initializes a new instance of the class.
- ///
- public Plugin()
- {
- Instance = this;
- }
-
- ///
- /// Releases unmanaged and - optionally - managed resources.
- ///
- /// true to release both managed and unmanaged resources; false to release only unmanaged resources.
- protected override void DisposeOnServer(bool dispose)
- {
- if (dispose)
- {
- var jobCount = ActiveTranscodingJobs.Count;
-
- Parallel.ForEach(ActiveTranscodingJobs, OnTranscodeKillTimerStopped);
-
- // Try to allow for some time to kill the ffmpeg processes and delete the partial stream files
- if (jobCount > 0)
- {
- Thread.Sleep(1000);
- }
- }
-
- base.DisposeOnServer(dispose);
- }
-
- ///
- /// The active transcoding jobs
- ///
- private readonly List ActiveTranscodingJobs = new List();
-
- ///
- /// Called when [transcode beginning].
- ///
- /// The path.
- /// The type.
- /// The process.
- public void OnTranscodeBeginning(string path, TranscodingJobType type, Process process)
- {
- lock (ActiveTranscodingJobs)
- {
- ActiveTranscodingJobs.Add(new TranscodingJob
- {
- Type = type,
- Path = path,
- Process = process,
- ActiveRequestCount = 1
- });
- }
- }
-
- ///
- /// Called when [transcode failed to start].
- ///
- /// The path.
- /// The type.
- public void OnTranscodeFailedToStart(string path, TranscodingJobType type)
- {
- lock (ActiveTranscodingJobs)
- {
- var job = ActiveTranscodingJobs.First(j => j.Type == type && j.Path.Equals(path, StringComparison.OrdinalIgnoreCase));
-
- ActiveTranscodingJobs.Remove(job);
- }
- }
-
- ///
- /// Determines whether [has active transcoding job] [the specified path].
- ///
- /// The path.
- /// The type.
- /// true if [has active transcoding job] [the specified path]; otherwise, false.
- public bool HasActiveTranscodingJob(string path, TranscodingJobType type)
- {
- lock (ActiveTranscodingJobs)
- {
- return ActiveTranscodingJobs.Any(j => j.Type == type && j.Path.Equals(path, StringComparison.OrdinalIgnoreCase));
- }
- }
-
- ///
- /// Called when [transcode begin request].
- ///
- /// The path.
- /// The type.
- public void OnTranscodeBeginRequest(string path, TranscodingJobType type)
- {
- lock (ActiveTranscodingJobs)
- {
- var job = ActiveTranscodingJobs.FirstOrDefault(j => j.Type == type && j.Path.Equals(path, StringComparison.OrdinalIgnoreCase));
-
- if (job == null)
- {
- return;
- }
-
- job.ActiveRequestCount++;
-
- if (job.KillTimer != null)
- {
- job.KillTimer.Dispose();
- job.KillTimer = null;
- }
- }
- }
-
- ///
- /// Called when [transcode end request].
- ///
- /// The path.
- /// The type.
- public void OnTranscodeEndRequest(string path, TranscodingJobType type)
- {
- lock (ActiveTranscodingJobs)
- {
- var job = ActiveTranscodingJobs.FirstOrDefault(j => j.Type == type && j.Path.Equals(path, StringComparison.OrdinalIgnoreCase));
-
- if (job == null)
- {
- return;
- }
-
- job.ActiveRequestCount--;
-
- if (job.ActiveRequestCount == 0)
- {
- var timerDuration = type == TranscodingJobType.Progressive ? 1000 : 30000;
-
- if (job.KillTimer == null)
- {
- job.KillTimer = new Timer(OnTranscodeKillTimerStopped, job, timerDuration, Timeout.Infinite);
- }
- else
- {
- job.KillTimer.Change(timerDuration, Timeout.Infinite);
- }
- }
- }
- }
-
- ///
- /// Called when [transcoding finished].
- ///
- /// The path.
- /// The type.
- public void OnTranscodingFinished(string path, TranscodingJobType type)
- {
- lock (ActiveTranscodingJobs)
- {
- var job = ActiveTranscodingJobs.FirstOrDefault(j => j.Type == type && j.Path.Equals(path, StringComparison.OrdinalIgnoreCase));
-
- if (job == null)
- {
- return;
- }
-
- ActiveTranscodingJobs.Remove(job);
-
- if (job.KillTimer != null)
- {
- job.KillTimer.Dispose();
- job.KillTimer = null;
- }
- }
- }
-
- ///
- /// Called when [transcode kill timer stopped].
- ///
- /// The state.
- private void OnTranscodeKillTimerStopped(object state)
- {
- var job = (TranscodingJob)state;
-
- lock (ActiveTranscodingJobs)
- {
- ActiveTranscodingJobs.Remove(job);
-
- if (job.KillTimer != null)
- {
- job.KillTimer.Dispose();
- job.KillTimer = null;
- }
- }
-
- var process = job.Process;
-
- var hasExited = true;
-
- try
- {
- hasExited = process.HasExited;
- }
- catch (Win32Exception ex)
- {
- Logger.ErrorException("Error determining if ffmpeg process has exited for {0}", ex, job.Path);
- }
- catch (InvalidOperationException ex)
- {
- Logger.ErrorException("Error determining if ffmpeg process has exited for {0}", ex, job.Path);
- }
- catch (NotSupportedException ex)
- {
- Logger.ErrorException("Error determining if ffmpeg process has exited for {0}", ex, job.Path);
- }
-
- if (hasExited)
- {
- return;
- }
-
- try
- {
- Logger.Info("Killing ffmpeg process for {0}", job.Path);
-
- process.Kill();
- }
- catch (Win32Exception ex)
- {
- Logger.ErrorException("Error killing transcoding job for {0}", ex, job.Path);
- }
- catch (InvalidOperationException ex)
- {
- Logger.ErrorException("Error killing transcoding job for {0}", ex, job.Path);
- }
- catch (NotSupportedException ex)
- {
- Logger.ErrorException("Error killing transcoding job for {0}", ex, job.Path);
- }
- }
- }
-
- ///
- /// Class TranscodingJob
- ///
- public class TranscodingJob
- {
- ///
- /// Gets or sets the path.
- ///
- /// The path.
- public string Path { get; set; }
- ///
- /// Gets or sets the type.
- ///
- /// The type.
- public TranscodingJobType Type { get; set; }
- ///
- /// Gets or sets the process.
- ///
- /// The process.
- public Process Process { get; set; }
- ///
- /// Gets or sets the active request count.
- ///
- /// The active request count.
- public int ActiveRequestCount { get; set; }
- ///
- /// Gets or sets the kill timer.
- ///
- /// The kill timer.
- public Timer KillTimer { get; set; }
- }
-
- ///
- /// Enum TranscodingJobType
- ///
- public enum TranscodingJobType
- {
- ///
- /// The progressive
- ///
- Progressive,
- ///
- /// The HLS
- ///
- Hls
}
}
diff --git a/MediaBrowser.Api/PluginService.cs b/MediaBrowser.Api/PluginService.cs
index 06db7a2769..7e907c2dd2 100644
--- a/MediaBrowser.Api/PluginService.cs
+++ b/MediaBrowser.Api/PluginService.cs
@@ -1,5 +1,6 @@
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Implementations.HttpServer;
+using MediaBrowser.Common.Kernel;
using MediaBrowser.Controller;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Plugins;
@@ -123,12 +124,18 @@ namespace MediaBrowser.Api
///
private readonly IJsonSerializer _jsonSerializer;
+ ///
+ /// The _app host
+ ///
+ private readonly IApplicationHost _appHost;
+
///
/// Initializes a new instance of the class.
///
/// The json serializer.
+ /// The app host.
/// jsonSerializer
- public PluginService(IJsonSerializer jsonSerializer)
+ public PluginService(IJsonSerializer jsonSerializer, IApplicationHost appHost)
: base()
{
if (jsonSerializer == null)
@@ -136,6 +143,7 @@ namespace MediaBrowser.Api
throw new ArgumentNullException("jsonSerializer");
}
+ _appHost = appHost;
_jsonSerializer = jsonSerializer;
}
@@ -146,7 +154,7 @@ namespace MediaBrowser.Api
/// System.Object.
public object Get(GetPlugins request)
{
- var result = Kernel.Plugins.OrderBy(p => p.Name).Select(p => p.GetPluginInfo()).ToList();
+ var result = _appHost.Plugins.OrderBy(p => p.Name).Select(p => p.GetPluginInfo()).ToList();
return ToOptimizedResult(result);
}
@@ -158,7 +166,7 @@ namespace MediaBrowser.Api
/// System.Object.
public object Get(GetPluginAssembly request)
{
- var plugin = Kernel.Plugins.First(p => p.Id == request.Id);
+ var plugin = _appHost.Plugins.First(p => p.Id == request.Id);
return ToStaticFileResult(plugin.AssemblyFilePath);
}
@@ -170,7 +178,7 @@ namespace MediaBrowser.Api
/// System.Object.
public object Get(GetPluginConfiguration request)
{
- var plugin = Kernel.Plugins.First(p => p.Id == request.Id);
+ var plugin = _appHost.Plugins.First(p => p.Id == request.Id);
var dateModified = plugin.ConfigurationDateLastModified;
@@ -186,7 +194,7 @@ namespace MediaBrowser.Api
/// System.Object.
public object Get(GetPluginConfigurationFile request)
{
- var plugin = Kernel.Plugins.First(p => p.Id == request.Id);
+ var plugin = _appHost.Plugins.First(p => p.Id == request.Id);
return ToStaticFileResult(plugin.ConfigurationFilePath);
}
@@ -235,7 +243,7 @@ namespace MediaBrowser.Api
var pathInfo = PathInfo.Parse(Request.PathInfo);
var id = new Guid(pathInfo.GetArgumentValue(1));
- var plugin = Kernel.Plugins.First(p => p.Id == id);
+ var plugin = _appHost.Plugins.First(p => p.Id == id);
var configuration = _jsonSerializer.DeserializeFromStream(request.RequestStream, plugin.ConfigurationType) as BasePluginConfiguration;
@@ -250,7 +258,7 @@ namespace MediaBrowser.Api
{
var kernel = (Kernel)Kernel;
- var plugin = kernel.Plugins.First(p => p.Id == request.Id);
+ var plugin = _appHost.Plugins.First(p => p.Id == request.Id);
kernel.InstallationManager.UninstallPlugin(plugin);
}
diff --git a/MediaBrowser.Api/ServerEntryPoint.cs b/MediaBrowser.Api/ServerEntryPoint.cs
new file mode 100644
index 0000000000..663d1aeca2
--- /dev/null
+++ b/MediaBrowser.Api/ServerEntryPoint.cs
@@ -0,0 +1,333 @@
+using MediaBrowser.Controller.Plugins;
+using MediaBrowser.Model.Logging;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace MediaBrowser.Api
+{
+ ///
+ /// Class ServerEntryPoint
+ ///
+ public class ServerEntryPoint : IServerEntryPoint
+ {
+ ///
+ /// The instance
+ ///
+ public static ServerEntryPoint Instance;
+
+ ///
+ /// Gets or sets the logger.
+ ///
+ /// The logger.
+ private ILogger Logger { get; set; }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The logger.
+ public ServerEntryPoint(ILogger logger)
+ {
+ Logger = logger;
+
+ Instance = this;
+ }
+
+ ///
+ /// Runs this instance.
+ ///
+ public void Run()
+ {
+ }
+
+ ///
+ /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+ ///
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ ///
+ /// Releases unmanaged and - optionally - managed resources.
+ ///
+ /// true to release both managed and unmanaged resources; false to release only unmanaged resources.
+ protected virtual void Dispose(bool dispose)
+ {
+ var jobCount = ActiveTranscodingJobs.Count;
+
+ Parallel.ForEach(ActiveTranscodingJobs, OnTranscodeKillTimerStopped);
+
+ // Try to allow for some time to kill the ffmpeg processes and delete the partial stream files
+ if (jobCount > 0)
+ {
+ Thread.Sleep(1000);
+ }
+ }
+
+ ///
+ /// The active transcoding jobs
+ ///
+ private readonly List ActiveTranscodingJobs = new List();
+
+ ///
+ /// Called when [transcode beginning].
+ ///
+ /// The path.
+ /// The type.
+ /// The process.
+ public void OnTranscodeBeginning(string path, TranscodingJobType type, Process process)
+ {
+ lock (ActiveTranscodingJobs)
+ {
+ ActiveTranscodingJobs.Add(new TranscodingJob
+ {
+ Type = type,
+ Path = path,
+ Process = process,
+ ActiveRequestCount = 1
+ });
+ }
+ }
+
+ ///
+ ///
+ /// The progressive
+ ///
+ /// Called when [transcode failed to start].
+ ///
+ /// The path.
+ /// The type.
+ public void OnTranscodeFailedToStart(string path, TranscodingJobType type)
+ {
+ lock (ActiveTranscodingJobs)
+ {
+ var job = ActiveTranscodingJobs.First(j => j.Type == type && j.Path.Equals(path, StringComparison.OrdinalIgnoreCase));
+
+ ActiveTranscodingJobs.Remove(job);
+ }
+ }
+
+ ///
+ /// Determines whether [has active transcoding job] [the specified path].
+ ///
+ /// The path.
+ /// The type.
+ /// true if [has active transcoding job] [the specified path]; otherwise, false.
+ public bool HasActiveTranscodingJob(string path, TranscodingJobType type)
+ {
+ lock (ActiveTranscodingJobs)
+ {
+ return ActiveTranscodingJobs.Any(j => j.Type == type && j.Path.Equals(path, StringComparison.OrdinalIgnoreCase));
+ }
+ }
+
+ ///
+ /// Called when [transcode begin request].
+ ///
+ /// The path.
+ /// The type.
+ public void OnTranscodeBeginRequest(string path, TranscodingJobType type)
+ {
+ lock (ActiveTranscodingJobs)
+ {
+ var job = ActiveTranscodingJobs.FirstOrDefault(j => j.Type == type && j.Path.Equals(path, StringComparison.OrdinalIgnoreCase));
+
+ if (job == null)
+ {
+ return;
+ }
+
+ job.ActiveRequestCount++;
+
+ if (job.KillTimer != null)
+ {
+ job.KillTimer.Dispose();
+ job.KillTimer = null;
+ }
+ }
+ }
+
+ ///
+ /// Called when [transcode end request].
+ ///
+ /// The path.
+ /// The type.
+ public void OnTranscodeEndRequest(string path, TranscodingJobType type)
+ {
+ lock (ActiveTranscodingJobs)
+ {
+ var job = ActiveTranscodingJobs.FirstOrDefault(j => j.Type == type && j.Path.Equals(path, StringComparison.OrdinalIgnoreCase));
+
+ if (job == null)
+ {
+ return;
+ }
+
+ job.ActiveRequestCount--;
+
+ if (job.ActiveRequestCount == 0)
+ {
+ var timerDuration = type == TranscodingJobType.Progressive ? 1000 : 30000;
+
+ if (job.KillTimer == null)
+ {
+ job.KillTimer = new Timer(OnTranscodeKillTimerStopped, job, timerDuration, Timeout.Infinite);
+ }
+ else
+ {
+ job.KillTimer.Change(timerDuration, Timeout.Infinite);
+ }
+ }
+ }
+ }
+
+ ///
+ /// Called when [transcoding finished].
+ ///
+ /// The path.
+ /// The type.
+ public void OnTranscodingFinished(string path, TranscodingJobType type)
+ {
+ lock (ActiveTranscodingJobs)
+ {
+ var job = ActiveTranscodingJobs.FirstOrDefault(j => j.Type == type && j.Path.Equals(path, StringComparison.OrdinalIgnoreCase));
+
+ if (job == null)
+ {
+ return;
+ }
+
+ ActiveTranscodingJobs.Remove(job);
+
+ if (job.KillTimer != null)
+ {
+ job.KillTimer.Dispose();
+ job.KillTimer = null;
+ }
+ }
+ }
+
+ ///
+ /// Called when [transcode kill timer stopped].
+ ///
+ /// The state.
+ private void OnTranscodeKillTimerStopped(object state)
+ {
+ var job = (TranscodingJob)state;
+
+ lock (ActiveTranscodingJobs)
+ {
+ ActiveTranscodingJobs.Remove(job);
+
+ if (job.KillTimer != null)
+ {
+ job.KillTimer.Dispose();
+ job.KillTimer = null;
+ }
+ }
+
+ var process = job.Process;
+
+ var hasExited = true;
+
+ try
+ {
+ hasExited = process.HasExited;
+ }
+ catch (Win32Exception ex)
+ {
+ Logger.ErrorException("Error determining if ffmpeg process has exited for {0}", ex, job.Path);
+ }
+ catch (InvalidOperationException ex)
+ {
+ Logger.ErrorException("Error determining if ffmpeg process has exited for {0}", ex, job.Path);
+ }
+ catch (NotSupportedException ex)
+ {
+ Logger.ErrorException("Error determining if ffmpeg process has exited for {0}", ex, job.Path);
+ }
+
+ if (hasExited)
+ {
+ return;
+ }
+
+ try
+ {
+ Logger.Info("Killing ffmpeg process for {0}", job.Path);
+
+ process.Kill();
+ }
+ catch (Win32Exception ex)
+ {
+ Logger.ErrorException("Error killing transcoding job for {0}", ex, job.Path);
+ }
+ catch (InvalidOperationException ex)
+ {
+ Logger.ErrorException("Error killing transcoding job for {0}", ex, job.Path);
+ }
+ catch (NotSupportedException ex)
+ {
+ Logger.ErrorException("Error killing transcoding job for {0}", ex, job.Path);
+ }
+ }
+
+ }
+
+ ///
+ /// Class TranscodingJob
+ ///
+ public class TranscodingJob
+ {
+ ///
+ /// Gets or sets the path.
+ ///
+ /// The path.
+ public string Path { get; set; }
+ ///
+ /// Gets or sets the type.
+ ///
+ /// The type.
+ public TranscodingJobType Type { get; set; }
+ ///
+ /// Gets or sets the process.
+ ///
+ /// The process.
+ public Process Process { get; set; }
+ ///
+ /// Gets or sets the active request count.
+ ///
+ /// The active request count.
+ public int ActiveRequestCount { get; set; }
+ ///
+ ///
+ /// Enum TranscodingJobType
+ ///
+ ///
+ /// Gets or sets the kill timer.
+ ///
+ /// The kill timer.
+ public Timer KillTimer { get; set; }
+ }
+
+ ///
+ /// Enum TranscodingJobType
+ ///
+ public enum TranscodingJobType
+ {
+ ///
+ /// The progressive
+ ///
+ Progressive,
+ ///
+ /// The HLS
+ ///
+ Hls
+ }
+}
diff --git a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
index f23d859e8f..3d7421f67f 100644
--- a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
+++ b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
@@ -3,6 +3,7 @@ using MediaBrowser.Common.Implementations.Updates;
using MediaBrowser.Common.Implementations.WebSocket;
using MediaBrowser.Common.Kernel;
using MediaBrowser.Common.Net;
+using MediaBrowser.Common.Plugins;
using MediaBrowser.Common.ScheduledTasks;
using MediaBrowser.Common.Updates;
using MediaBrowser.Model.Logging;
@@ -25,6 +26,12 @@ namespace MediaBrowser.Common.Implementations
/// The logger.
public ILogger Logger { get; protected set; }
+ ///
+ /// Gets or sets the plugins.
+ ///
+ /// The plugins.
+ public IEnumerable Plugins { get; protected set; }
+
///
/// Gets or sets the log manager.
///
@@ -142,12 +149,13 @@ namespace MediaBrowser.Common.Implementations
///
protected virtual void FindParts()
{
- Resolve().AddTasks(GetExports(false));
-
Resolve().Init(GetExports(false));
Resolve().AddWebSocketListeners(GetExports(false));
Resolve().Start();
+ Resolve().AddTasks(GetExports(false));
+
+ Plugins = GetExports();
}
///
@@ -348,6 +356,17 @@ namespace MediaBrowser.Common.Implementations
}
+ ///
+ /// Removes the plugin.
+ ///
+ /// The plugin.
+ public void RemovePlugin(IPlugin plugin)
+ {
+ var list = Plugins.ToList();
+ list.Remove(plugin);
+ Plugins = list;
+ }
+
///
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
///
diff --git a/MediaBrowser.Common/Kernel/BaseKernel.cs b/MediaBrowser.Common/Kernel/BaseKernel.cs
index 78277ed2f3..d35ee42c93 100644
--- a/MediaBrowser.Common/Kernel/BaseKernel.cs
+++ b/MediaBrowser.Common/Kernel/BaseKernel.cs
@@ -1,16 +1,13 @@
using MediaBrowser.Common.Events;
-using MediaBrowser.Common.Plugins;
using MediaBrowser.Common.Security;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.System;
using System;
-using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
-using System.Threading.Tasks;
namespace MediaBrowser.Common.Kernel
{
@@ -121,12 +118,6 @@ namespace MediaBrowser.Common.Kernel
/// The application paths.
public TApplicationPathsType ApplicationPaths { get; private set; }
- ///
- /// Gets the list of currently loaded plugins
- ///
- /// The plugins.
- public IEnumerable Plugins { get; protected set; }
-
///
/// Gets or sets the TCP manager.
///
@@ -211,9 +202,9 @@ namespace MediaBrowser.Common.Kernel
/// Initializes the Kernel
///
/// Task.
- public async Task Init()
+ public void Init()
{
- await ReloadInternal().ConfigureAwait(false);
+ ReloadInternal();
OnReloadCompleted();
@@ -224,64 +215,11 @@ namespace MediaBrowser.Common.Kernel
/// Performs initializations that can be reloaded at anytime
///
/// Task.
- protected virtual async Task ReloadInternal()
+ protected virtual void ReloadInternal()
{
- // Set these to null so that they can be lazy loaded again
- Configuration = null;
-
- await OnConfigurationLoaded().ConfigureAwait(false);
-
- FindParts();
-
- await OnComposablePartsLoaded().ConfigureAwait(false);
-
ServerManager = ApplicationHost.Resolve();
}
- ///
- /// Called when [configuration loaded].
- ///
- /// Task.
- protected virtual Task OnConfigurationLoaded()
- {
- return Task.FromResult