2017-08-09 19:56:38 +00:00
|
|
|
|
using System;
|
2014-12-21 19:40:37 +00:00
|
|
|
|
using MediaBrowser.Controller.Configuration;
|
2015-04-20 18:04:02 +00:00
|
|
|
|
using MediaBrowser.Controller.Library;
|
2017-08-09 19:56:38 +00:00
|
|
|
|
using MediaBrowser.Controller.Net;
|
2013-12-14 23:21:03 +00:00
|
|
|
|
using MediaBrowser.Controller.Plugins;
|
2014-06-06 00:39:02 +00:00
|
|
|
|
using MediaBrowser.Controller.Session;
|
2016-11-01 03:07:45 +00:00
|
|
|
|
using MediaBrowser.Model.Diagnostics;
|
2016-10-25 19:02:04 +00:00
|
|
|
|
using MediaBrowser.Model.IO;
|
2017-08-09 19:56:38 +00:00
|
|
|
|
using MediaBrowser.Model.Logging;
|
2016-11-01 03:07:45 +00:00
|
|
|
|
using MediaBrowser.Model.Threading;
|
2017-08-09 19:56:38 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Threading;
|
2013-03-03 02:47:04 +00:00
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Api
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class ServerEntryPoint
|
|
|
|
|
/// </summary>
|
2013-03-08 19:14:09 +00:00
|
|
|
|
public class ApiEntryPoint : IServerEntryPoint
|
2013-03-03 02:47:04 +00:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The instance
|
|
|
|
|
/// </summary>
|
2013-03-08 19:14:09 +00:00
|
|
|
|
public static ApiEntryPoint Instance;
|
2013-03-03 02:47:04 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the logger.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The logger.</value>
|
2016-11-10 14:41:24 +00:00
|
|
|
|
internal ILogger Logger { get; private set; }
|
|
|
|
|
internal IHttpResultFactory ResultFactory { get; private set; }
|
2013-03-03 02:47:04 +00:00
|
|
|
|
|
2013-12-22 18:58:51 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The application paths
|
|
|
|
|
/// </summary>
|
2014-12-21 19:40:37 +00:00
|
|
|
|
private readonly IServerConfigurationManager _config;
|
2013-12-22 18:58:51 +00:00
|
|
|
|
|
2014-06-06 00:39:02 +00:00
|
|
|
|
private readonly ISessionManager _sessionManager;
|
2015-01-13 03:46:44 +00:00
|
|
|
|
private readonly IFileSystem _fileSystem;
|
2015-04-20 18:04:02 +00:00
|
|
|
|
private readonly IMediaSourceManager _mediaSourceManager;
|
2016-11-01 03:07:45 +00:00
|
|
|
|
public readonly ITimerFactory TimerFactory;
|
|
|
|
|
public readonly IProcessFactory ProcessFactory;
|
2014-06-06 00:39:02 +00:00
|
|
|
|
|
2016-09-25 18:39:13 +00:00
|
|
|
|
private readonly Dictionary<string, SemaphoreSlim> _transcodingLocks =
|
|
|
|
|
new Dictionary<string, SemaphoreSlim>();
|
2014-07-02 18:34:08 +00:00
|
|
|
|
|
2013-03-03 02:47:04 +00:00
|
|
|
|
/// <summary>
|
2013-03-08 19:14:09 +00:00
|
|
|
|
/// Initializes a new instance of the <see cref="ApiEntryPoint" /> class.
|
2013-03-03 02:47:04 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="logger">The logger.</param>
|
2014-06-26 17:04:11 +00:00
|
|
|
|
/// <param name="sessionManager">The session manager.</param>
|
2014-12-21 19:40:37 +00:00
|
|
|
|
/// <param name="config">The configuration.</param>
|
2015-04-20 18:04:02 +00:00
|
|
|
|
/// <param name="fileSystem">The file system.</param>
|
|
|
|
|
/// <param name="mediaSourceManager">The media source manager.</param>
|
2016-11-10 14:41:24 +00:00
|
|
|
|
public ApiEntryPoint(ILogger logger, ISessionManager sessionManager, IServerConfigurationManager config, IFileSystem fileSystem, IMediaSourceManager mediaSourceManager, ITimerFactory timerFactory, IProcessFactory processFactory, IHttpResultFactory resultFactory)
|
2013-03-03 02:47:04 +00:00
|
|
|
|
{
|
|
|
|
|
Logger = logger;
|
2014-06-06 00:39:02 +00:00
|
|
|
|
_sessionManager = sessionManager;
|
2014-12-21 19:40:37 +00:00
|
|
|
|
_config = config;
|
2015-01-13 03:46:44 +00:00
|
|
|
|
_fileSystem = fileSystem;
|
2015-04-20 18:04:02 +00:00
|
|
|
|
_mediaSourceManager = mediaSourceManager;
|
2016-11-01 03:07:45 +00:00
|
|
|
|
TimerFactory = timerFactory;
|
|
|
|
|
ProcessFactory = processFactory;
|
2016-11-10 14:41:24 +00:00
|
|
|
|
ResultFactory = resultFactory;
|
2013-03-03 02:47:04 +00:00
|
|
|
|
|
|
|
|
|
Instance = this;
|
2016-08-09 05:10:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-08-09 19:56:38 +00:00
|
|
|
|
public static string[] Split(string value, char separator, bool removeEmpty)
|
2016-09-25 18:39:13 +00:00
|
|
|
|
{
|
2017-08-09 19:56:38 +00:00
|
|
|
|
if (string.IsNullOrWhiteSpace(value))
|
2016-09-25 18:39:13 +00:00
|
|
|
|
{
|
2017-08-09 19:56:38 +00:00
|
|
|
|
return new string[] { };
|
2016-09-25 18:39:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-08-09 19:56:38 +00:00
|
|
|
|
if (removeEmpty)
|
2016-08-09 05:10:17 +00:00
|
|
|
|
{
|
2017-08-09 19:56:38 +00:00
|
|
|
|
return value.Split(new[] { separator }, StringSplitOptions.RemoveEmptyEntries);
|
2016-08-09 05:10:17 +00:00
|
|
|
|
}
|
2016-03-22 03:31:35 +00:00
|
|
|
|
|
2017-08-09 19:56:38 +00:00
|
|
|
|
return value.Split(separator);
|
2013-03-03 02:47:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Run()
|
|
|
|
|
{
|
2017-09-05 19:49:02 +00:00
|
|
|
|
|
2013-03-03 02:47:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
2017-09-05 19:49:02 +00:00
|
|
|
|
GC.SuppressFinalize(this);
|
2015-04-13 19:14:37 +00:00
|
|
|
|
}
|
2013-03-03 02:47:04 +00:00
|
|
|
|
}
|
|
|
|
|
}
|