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