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