Merge pull request #1059 from Bond-009/os

Remove EnvironmentInfo
This commit is contained in:
Vasily 2019-03-13 00:01:00 +03:00 committed by GitHub
commit 297f25cfc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 143 additions and 223 deletions

View File

@ -22,6 +22,7 @@ using MediaBrowser.Model.System;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Rssdp; using Rssdp;
using Rssdp.Infrastructure; using Rssdp.Infrastructure;
using OperatingSystem = MediaBrowser.Common.System.OperatingSystem;
namespace Emby.Dlna.Main namespace Emby.Dlna.Main
{ {
@ -48,7 +49,6 @@ namespace Emby.Dlna.Main
private SsdpDevicePublisher _Publisher; private SsdpDevicePublisher _Publisher;
private readonly ISocketFactory _socketFactory; private readonly ISocketFactory _socketFactory;
private readonly IEnvironmentInfo _environmentInfo;
private readonly INetworkManager _networkManager; private readonly INetworkManager _networkManager;
private ISsdpCommunicationsServer _communicationsServer; private ISsdpCommunicationsServer _communicationsServer;
@ -74,7 +74,6 @@ namespace Emby.Dlna.Main
IDeviceDiscovery deviceDiscovery, IDeviceDiscovery deviceDiscovery,
IMediaEncoder mediaEncoder, IMediaEncoder mediaEncoder,
ISocketFactory socketFactory, ISocketFactory socketFactory,
IEnvironmentInfo environmentInfo,
INetworkManager networkManager, INetworkManager networkManager,
IUserViewManager userViewManager, IUserViewManager userViewManager,
ITVSeriesManager tvSeriesManager) ITVSeriesManager tvSeriesManager)
@ -93,7 +92,6 @@ namespace Emby.Dlna.Main
_deviceDiscovery = deviceDiscovery; _deviceDiscovery = deviceDiscovery;
_mediaEncoder = mediaEncoder; _mediaEncoder = mediaEncoder;
_socketFactory = socketFactory; _socketFactory = socketFactory;
_environmentInfo = environmentInfo;
_networkManager = networkManager; _networkManager = networkManager;
_logger = loggerFactory.CreateLogger("Dlna"); _logger = loggerFactory.CreateLogger("Dlna");
@ -166,8 +164,8 @@ namespace Emby.Dlna.Main
{ {
if (_communicationsServer == null) if (_communicationsServer == null)
{ {
var enableMultiSocketBinding = _environmentInfo.OperatingSystem == MediaBrowser.Model.System.OperatingSystem.Windows || var enableMultiSocketBinding = OperatingSystem.Id == OperatingSystemId.Windows ||
_environmentInfo.OperatingSystem == MediaBrowser.Model.System.OperatingSystem.Linux; OperatingSystem.Id == OperatingSystemId.Linux;
_communicationsServer = new SsdpCommunicationsServer(_config, _socketFactory, _networkManager, _logger, enableMultiSocketBinding) _communicationsServer = new SsdpCommunicationsServer(_config, _socketFactory, _networkManager, _logger, enableMultiSocketBinding)
{ {
@ -227,7 +225,7 @@ namespace Emby.Dlna.Main
try try
{ {
_Publisher = new SsdpDevicePublisher(_communicationsServer, _networkManager, _environmentInfo.OperatingSystemName, _environmentInfo.OperatingSystemVersion, _config.GetDlnaConfiguration().SendOnlyMatchedHost); _Publisher = new SsdpDevicePublisher(_communicationsServer, _networkManager, OperatingSystem.Name, Environment.OSVersion.VersionString, _config.GetDlnaConfiguration().SendOnlyMatchedHost);
_Publisher.LogFunction = LogMessage; _Publisher.LogFunction = LogMessage;
_Publisher.SupportPnpRootDevice = false; _Publisher.SupportPnpRootDevice = false;

View File

@ -7,6 +7,7 @@ using MediaBrowser.Model.Diagnostics;
using MediaBrowser.Model.IO; using MediaBrowser.Model.IO;
using MediaBrowser.Model.System; using MediaBrowser.Model.System;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using OperatingSystem = MediaBrowser.Common.System.OperatingSystem;
namespace IsoMounter namespace IsoMounter
{ {
@ -17,7 +18,6 @@ namespace IsoMounter
#region Private Fields #region Private Fields
private readonly IEnvironmentInfo EnvironmentInfo;
private readonly bool ExecutablesAvailable; private readonly bool ExecutablesAvailable;
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly string MountCommand; private readonly string MountCommand;
@ -30,10 +30,8 @@ namespace IsoMounter
#region Constructor(s) #region Constructor(s)
public LinuxIsoManager(ILogger logger, IEnvironmentInfo environment, IProcessFactory processFactory) public LinuxIsoManager(ILogger logger, IProcessFactory processFactory)
{ {
EnvironmentInfo = environment;
_logger = logger; _logger = logger;
ProcessFactory = processFactory; ProcessFactory = processFactory;
@ -109,7 +107,7 @@ namespace IsoMounter
public bool CanMount(string path) public bool CanMount(string path)
{ {
if (EnvironmentInfo.OperatingSystem != MediaBrowser.Model.System.OperatingSystem.Linux) if (OperatingSystem.Id != OperatingSystemId.Linux)
{ {
return false; return false;
} }
@ -118,7 +116,7 @@ namespace IsoMounter
Name, Name,
path, path,
Path.GetExtension(path), Path.GetExtension(path),
EnvironmentInfo.OperatingSystem, OperatingSystem.Name,
ExecutablesAvailable ExecutablesAvailable
); );

View File

@ -111,6 +111,7 @@ using Microsoft.Extensions.Logging;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.DependencyInjection.Extensions;
using ServiceStack; using ServiceStack;
using OperatingSystem = MediaBrowser.Common.System.OperatingSystem;
namespace Emby.Server.Implementations namespace Emby.Server.Implementations
{ {
@ -139,12 +140,8 @@ namespace Emby.Server.Implementations
return false; return false;
} }
if (EnvironmentInfo.OperatingSystem == MediaBrowser.Model.System.OperatingSystem.Windows) if (OperatingSystem.Id == OperatingSystemId.Windows
{ || OperatingSystem.Id == OperatingSystemId.Darwin)
return true;
}
if (EnvironmentInfo.OperatingSystem == MediaBrowser.Model.System.OperatingSystem.OSX)
{ {
return true; return true;
} }
@ -214,8 +211,6 @@ namespace Emby.Server.Implementations
public IFileSystem FileSystemManager { get; set; } public IFileSystem FileSystemManager { get; set; }
protected IEnvironmentInfo EnvironmentInfo { get; set; }
public PackageVersionClass SystemUpdateLevel public PackageVersionClass SystemUpdateLevel
{ {
get get
@ -235,15 +230,6 @@ namespace Emby.Server.Implementations
/// <value>The server configuration manager.</value> /// <value>The server configuration manager.</value>
public IServerConfigurationManager ServerConfigurationManager => (IServerConfigurationManager)ConfigurationManager; public IServerConfigurationManager ServerConfigurationManager => (IServerConfigurationManager)ConfigurationManager;
/// <summary>
/// Gets the configuration manager.
/// </summary>
/// <returns>IConfigurationManager.</returns>
protected IConfigurationManager GetConfigurationManager()
{
return new ServerConfigurationManager(ApplicationPaths, LoggerFactory, XmlSerializer, FileSystemManager);
}
protected virtual IResourceFileManager CreateResourceFileManager() protected virtual IResourceFileManager CreateResourceFileManager()
{ {
return new ResourceFileManager(HttpResultFactory, LoggerFactory, FileSystemManager); return new ResourceFileManager(HttpResultFactory, LoggerFactory, FileSystemManager);
@ -352,7 +338,6 @@ namespace Emby.Server.Implementations
ILoggerFactory loggerFactory, ILoggerFactory loggerFactory,
IStartupOptions options, IStartupOptions options,
IFileSystem fileSystem, IFileSystem fileSystem,
IEnvironmentInfo environmentInfo,
IImageEncoder imageEncoder, IImageEncoder imageEncoder,
INetworkManager networkManager, INetworkManager networkManager,
IConfiguration configuration) IConfiguration configuration)
@ -366,13 +351,12 @@ namespace Emby.Server.Implementations
NetworkManager = networkManager; NetworkManager = networkManager;
networkManager.LocalSubnetsFn = GetConfiguredLocalSubnets; networkManager.LocalSubnetsFn = GetConfiguredLocalSubnets;
EnvironmentInfo = environmentInfo;
ApplicationPaths = applicationPaths; ApplicationPaths = applicationPaths;
LoggerFactory = loggerFactory; LoggerFactory = loggerFactory;
FileSystemManager = fileSystem; FileSystemManager = fileSystem;
ConfigurationManager = GetConfigurationManager(); ConfigurationManager = new ServerConfigurationManager(ApplicationPaths, LoggerFactory, XmlSerializer, FileSystemManager);
Logger = LoggerFactory.CreateLogger("App"); Logger = LoggerFactory.CreateLogger("App");
@ -528,7 +512,7 @@ namespace Emby.Server.Implementations
/// <summary> /// <summary>
/// Runs the startup tasks. /// Runs the startup tasks.
/// </summary> /// </summary>
public async Task RunStartupTasks() public async Task RunStartupTasksAsync()
{ {
Logger.LogInformation("Running startup tasks"); Logger.LogInformation("Running startup tasks");
@ -580,7 +564,7 @@ namespace Emby.Server.Implementations
} }
} }
public async Task Init(IServiceCollection serviceCollection) public async Task InitAsync(IServiceCollection serviceCollection)
{ {
HttpPort = ServerConfigurationManager.Configuration.HttpServerPortNumber; HttpPort = ServerConfigurationManager.Configuration.HttpServerPortNumber;
HttpsPort = ServerConfigurationManager.Configuration.HttpsPortNumber; HttpsPort = ServerConfigurationManager.Configuration.HttpsPortNumber;
@ -704,8 +688,6 @@ namespace Emby.Server.Implementations
serviceCollection.AddLogging(); serviceCollection.AddLogging();
serviceCollection.AddSingleton(Logger); serviceCollection.AddSingleton(Logger);
serviceCollection.AddSingleton(EnvironmentInfo);
serviceCollection.AddSingleton(FileSystemManager); serviceCollection.AddSingleton(FileSystemManager);
serviceCollection.AddSingleton<TvDbClientManager>(); serviceCollection.AddSingleton<TvDbClientManager>();
@ -779,7 +761,7 @@ namespace Emby.Server.Implementations
var musicManager = new MusicManager(LibraryManager); var musicManager = new MusicManager(LibraryManager);
serviceCollection.AddSingleton<IMusicManager>(new MusicManager(LibraryManager)); serviceCollection.AddSingleton<IMusicManager>(new MusicManager(LibraryManager));
LibraryMonitor = new LibraryMonitor(LoggerFactory, LibraryManager, ServerConfigurationManager, FileSystemManager, EnvironmentInfo); LibraryMonitor = new LibraryMonitor(LoggerFactory, LibraryManager, ServerConfigurationManager, FileSystemManager);
serviceCollection.AddSingleton(LibraryMonitor); serviceCollection.AddSingleton(LibraryMonitor);
serviceCollection.AddSingleton<ISearchEngine>(new SearchEngine(LoggerFactory, LibraryManager, UserManager)); serviceCollection.AddSingleton<ISearchEngine>(new SearchEngine(LoggerFactory, LibraryManager, UserManager));
@ -900,7 +882,7 @@ namespace Emby.Server.Implementations
public virtual string PackageRuntime => "netcore"; public virtual string PackageRuntime => "netcore";
public static void LogEnvironmentInfo(ILogger logger, IApplicationPaths appPaths, EnvironmentInfo.EnvironmentInfo environmentInfo) public static void LogEnvironmentInfo(ILogger logger, IApplicationPaths appPaths)
{ {
// Distinct these to prevent users from reporting problems that aren't actually problems // Distinct these to prevent users from reporting problems that aren't actually problems
var commandLineArgs = Environment var commandLineArgs = Environment
@ -908,8 +890,9 @@ namespace Emby.Server.Implementations
.Distinct(); .Distinct();
logger.LogInformation("Arguments: {Args}", commandLineArgs); logger.LogInformation("Arguments: {Args}", commandLineArgs);
logger.LogInformation("Operating system: {OS} {OSVersion}", environmentInfo.OperatingSystemName, environmentInfo.OperatingSystemVersion); // FIXME: @bond this logs the kernel version, not the OS version
logger.LogInformation("Architecture: {Architecture}", environmentInfo.SystemArchitecture); logger.LogInformation("Operating system: {OS} {OSVersion}", OperatingSystem.Name, Environment.OSVersion.Version);
logger.LogInformation("Architecture: {Architecture}", RuntimeInformation.OSArchitecture);
logger.LogInformation("64-Bit Process: {Is64Bit}", Environment.Is64BitProcess); logger.LogInformation("64-Bit Process: {Is64Bit}", Environment.Is64BitProcess);
logger.LogInformation("User Interactive: {IsUserInteractive}", Environment.UserInteractive); logger.LogInformation("User Interactive: {IsUserInteractive}", Environment.UserInteractive);
logger.LogInformation("Processor count: {ProcessorCount}", Environment.ProcessorCount); logger.LogInformation("Processor count: {ProcessorCount}", Environment.ProcessorCount);
@ -1395,8 +1378,8 @@ namespace Emby.Server.Implementations
HttpServerPortNumber = HttpPort, HttpServerPortNumber = HttpPort,
SupportsHttps = SupportsHttps, SupportsHttps = SupportsHttps,
HttpsPortNumber = HttpsPort, HttpsPortNumber = HttpsPort,
OperatingSystem = EnvironmentInfo.OperatingSystem.ToString(), OperatingSystem = OperatingSystem.Id.ToString(),
OperatingSystemDisplayName = EnvironmentInfo.OperatingSystemName, OperatingSystemDisplayName = OperatingSystem.Name,
CanSelfRestart = CanSelfRestart, CanSelfRestart = CanSelfRestart,
CanLaunchWebBrowser = CanLaunchWebBrowser, CanLaunchWebBrowser = CanLaunchWebBrowser,
WanAddress = wanAddress, WanAddress = wanAddress,
@ -1406,7 +1389,7 @@ namespace Emby.Server.Implementations
LocalAddress = localAddress, LocalAddress = localAddress,
SupportsLibraryMonitor = true, SupportsLibraryMonitor = true,
EncoderLocation = MediaEncoder.EncoderLocation, EncoderLocation = MediaEncoder.EncoderLocation,
SystemArchitecture = EnvironmentInfo.SystemArchitecture, SystemArchitecture = RuntimeInformation.OSArchitecture,
SystemUpdateLevel = SystemUpdateLevel, SystemUpdateLevel = SystemUpdateLevel,
PackageName = StartupOptions.PackageName PackageName = StartupOptions.PackageName
}; };
@ -1430,7 +1413,7 @@ namespace Emby.Server.Implementations
{ {
Version = ApplicationVersion, Version = ApplicationVersion,
Id = SystemId, Id = SystemId,
OperatingSystem = EnvironmentInfo.OperatingSystem.ToString(), OperatingSystem = OperatingSystem.Id.ToString(),
WanAddress = wanAddress, WanAddress = wanAddress,
ServerName = FriendlyName, ServerName = FriendlyName,
LocalAddress = localAddress LocalAddress = localAddress

View File

@ -1,36 +0,0 @@
using System;
using System.Runtime.InteropServices;
using MediaBrowser.Model.System;
namespace Emby.Server.Implementations.EnvironmentInfo
{
public class EnvironmentInfo : IEnvironmentInfo
{
public EnvironmentInfo(MediaBrowser.Model.System.OperatingSystem operatingSystem)
{
OperatingSystem = operatingSystem;
}
public MediaBrowser.Model.System.OperatingSystem OperatingSystem { get; private set; }
public string OperatingSystemName
{
get
{
switch (OperatingSystem)
{
case MediaBrowser.Model.System.OperatingSystem.Android: return "Android";
case MediaBrowser.Model.System.OperatingSystem.BSD: return "BSD";
case MediaBrowser.Model.System.OperatingSystem.Linux: return "Linux";
case MediaBrowser.Model.System.OperatingSystem.OSX: return "macOS";
case MediaBrowser.Model.System.OperatingSystem.Windows: return "Windows";
default: throw new Exception($"Unknown OS {OperatingSystem}");
}
}
}
public string OperatingSystemVersion => Environment.OSVersion.Version.ToString() + " " + Environment.OSVersion.ServicePack.ToString();
public Architecture SystemArchitecture => RuntimeInformation.OSArchitecture;
}
}

View File

@ -10,8 +10,8 @@ using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Plugins; using MediaBrowser.Controller.Plugins;
using MediaBrowser.Model.IO; using MediaBrowser.Model.IO;
using MediaBrowser.Model.System; using MediaBrowser.Model.System;
using MediaBrowser.Model.Tasks;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using OperatingSystem = MediaBrowser.Common.System.OperatingSystem;
namespace Emby.Server.Implementations.IO namespace Emby.Server.Implementations.IO
{ {
@ -127,7 +127,6 @@ namespace Emby.Server.Implementations.IO
private IServerConfigurationManager ConfigurationManager { get; set; } private IServerConfigurationManager ConfigurationManager { get; set; }
private readonly IFileSystem _fileSystem; private readonly IFileSystem _fileSystem;
private readonly IEnvironmentInfo _environmentInfo;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="LibraryMonitor" /> class. /// Initializes a new instance of the <see cref="LibraryMonitor" /> class.
@ -136,14 +135,12 @@ namespace Emby.Server.Implementations.IO
ILoggerFactory loggerFactory, ILoggerFactory loggerFactory,
ILibraryManager libraryManager, ILibraryManager libraryManager,
IServerConfigurationManager configurationManager, IServerConfigurationManager configurationManager,
IFileSystem fileSystem, IFileSystem fileSystem)
IEnvironmentInfo environmentInfo)
{ {
LibraryManager = libraryManager; LibraryManager = libraryManager;
Logger = loggerFactory.CreateLogger(GetType().Name); Logger = loggerFactory.CreateLogger(GetType().Name);
ConfigurationManager = configurationManager; ConfigurationManager = configurationManager;
_fileSystem = fileSystem; _fileSystem = fileSystem;
_environmentInfo = environmentInfo;
} }
private bool IsLibraryMonitorEnabled(BaseItem item) private bool IsLibraryMonitorEnabled(BaseItem item)
@ -267,7 +264,7 @@ namespace Emby.Server.Implementations.IO
return; return;
} }
if (_environmentInfo.OperatingSystem != MediaBrowser.Model.System.OperatingSystem.Windows) if (OperatingSystem.Id != OperatingSystemId.Windows)
{ {
if (path.StartsWith("\\\\", StringComparison.OrdinalIgnoreCase) || path.StartsWith("smb://", StringComparison.OrdinalIgnoreCase)) if (path.StartsWith("\\\\", StringComparison.OrdinalIgnoreCase) || path.StartsWith("smb://", StringComparison.OrdinalIgnoreCase))
{ {
@ -276,12 +273,6 @@ namespace Emby.Server.Implementations.IO
} }
} }
if (_environmentInfo.OperatingSystem == MediaBrowser.Model.System.OperatingSystem.Android)
{
// causing crashing
return;
}
// Already being watched // Already being watched
if (_fileSystemWatchers.ContainsKey(path)) if (_fileSystemWatchers.ContainsKey(path))
{ {

View File

@ -8,6 +8,7 @@ using MediaBrowser.Common.Configuration;
using MediaBrowser.Model.IO; using MediaBrowser.Model.IO;
using MediaBrowser.Model.System; using MediaBrowser.Model.System;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using OperatingSystem = MediaBrowser.Common.System.OperatingSystem;
namespace Emby.Server.Implementations.IO namespace Emby.Server.Implementations.IO
{ {
@ -24,22 +25,19 @@ namespace Emby.Server.Implementations.IO
private readonly string _tempPath; private readonly string _tempPath;
private readonly IEnvironmentInfo _environmentInfo;
private readonly bool _isEnvironmentCaseInsensitive; private readonly bool _isEnvironmentCaseInsensitive;
public ManagedFileSystem( public ManagedFileSystem(
ILoggerFactory loggerFactory, ILoggerFactory loggerFactory,
IEnvironmentInfo environmentInfo,
IApplicationPaths applicationPaths) IApplicationPaths applicationPaths)
{ {
Logger = loggerFactory.CreateLogger("FileSystem"); Logger = loggerFactory.CreateLogger("FileSystem");
_supportsAsyncFileStreams = true; _supportsAsyncFileStreams = true;
_tempPath = applicationPaths.TempDirectory; _tempPath = applicationPaths.TempDirectory;
_environmentInfo = environmentInfo;
SetInvalidFileNameChars(environmentInfo.OperatingSystem == MediaBrowser.Model.System.OperatingSystem.Windows); SetInvalidFileNameChars(OperatingSystem.Id == OperatingSystemId.Windows);
_isEnvironmentCaseInsensitive = environmentInfo.OperatingSystem == MediaBrowser.Model.System.OperatingSystem.Windows; _isEnvironmentCaseInsensitive = OperatingSystem.Id == OperatingSystemId.Windows;
} }
public virtual void AddShortcutHandler(IShortcutHandler handler) public virtual void AddShortcutHandler(IShortcutHandler handler)
@ -468,7 +466,7 @@ namespace Emby.Server.Implementations.IO
public virtual void SetHidden(string path, bool isHidden) public virtual void SetHidden(string path, bool isHidden)
{ {
if (_environmentInfo.OperatingSystem != MediaBrowser.Model.System.OperatingSystem.Windows) if (OperatingSystem.Id != MediaBrowser.Model.System.OperatingSystemId.Windows)
{ {
return; return;
} }
@ -492,7 +490,7 @@ namespace Emby.Server.Implementations.IO
public virtual void SetReadOnly(string path, bool isReadOnly) public virtual void SetReadOnly(string path, bool isReadOnly)
{ {
if (_environmentInfo.OperatingSystem != MediaBrowser.Model.System.OperatingSystem.Windows) if (OperatingSystem.Id != MediaBrowser.Model.System.OperatingSystemId.Windows)
{ {
return; return;
} }
@ -516,7 +514,7 @@ namespace Emby.Server.Implementations.IO
public virtual void SetAttributes(string path, bool isHidden, bool isReadOnly) public virtual void SetAttributes(string path, bool isHidden, bool isReadOnly)
{ {
if (_environmentInfo.OperatingSystem != MediaBrowser.Model.System.OperatingSystem.Windows) if (OperatingSystem.Id != MediaBrowser.Model.System.OperatingSystemId.Windows)
{ {
return; return;
} }
@ -801,7 +799,7 @@ namespace Emby.Server.Implementations.IO
public virtual void SetExecutable(string path) public virtual void SetExecutable(string path)
{ {
if (_environmentInfo.OperatingSystem == MediaBrowser.Model.System.OperatingSystem.OSX) if (OperatingSystem.Id == MediaBrowser.Model.System.OperatingSystemId.Darwin)
{ {
RunProcess("chmod", "+x \"" + path + "\"", Path.GetDirectoryName(path)); RunProcess("chmod", "+x \"" + path + "\"", Path.GetDirectoryName(path));
} }

View File

@ -7,11 +7,11 @@ using System.Net.NetworkInformation;
using System.Net.Sockets; using System.Net.Sockets;
using System.Threading.Tasks; using System.Threading.Tasks;
using MediaBrowser.Common.Net; using MediaBrowser.Common.Net;
using MediaBrowser.Model.Extensions;
using MediaBrowser.Model.IO; using MediaBrowser.Model.IO;
using MediaBrowser.Model.Net; using MediaBrowser.Model.Net;
using MediaBrowser.Model.System; using MediaBrowser.Model.System;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using OperatingSystem = MediaBrowser.Common.System.OperatingSystem;
namespace Emby.Server.Implementations.Networking namespace Emby.Server.Implementations.Networking
{ {
@ -22,14 +22,12 @@ namespace Emby.Server.Implementations.Networking
public event EventHandler NetworkChanged; public event EventHandler NetworkChanged;
public Func<string[]> LocalSubnetsFn { get; set; } public Func<string[]> LocalSubnetsFn { get; set; }
public NetworkManager( public NetworkManager(ILoggerFactory loggerFactory)
ILoggerFactory loggerFactory,
IEnvironmentInfo environment)
{ {
Logger = loggerFactory.CreateLogger(nameof(NetworkManager)); Logger = loggerFactory.CreateLogger(nameof(NetworkManager));
// In FreeBSD these events cause a crash // In FreeBSD these events cause a crash
if (environment.OperatingSystem != MediaBrowser.Model.System.OperatingSystem.BSD) if (OperatingSystem.Id != OperatingSystemId.BSD)
{ {
try try
{ {

View File

@ -3,7 +3,6 @@ using System.Reflection;
using Emby.Server.Implementations; using Emby.Server.Implementations;
using Emby.Server.Implementations.HttpServer; using Emby.Server.Implementations.HttpServer;
using MediaBrowser.Model.IO; using MediaBrowser.Model.IO;
using MediaBrowser.Model.System;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
@ -16,7 +15,6 @@ namespace Jellyfin.Server
ILoggerFactory loggerFactory, ILoggerFactory loggerFactory,
StartupOptions options, StartupOptions options,
IFileSystem fileSystem, IFileSystem fileSystem,
IEnvironmentInfo environmentInfo,
MediaBrowser.Controller.Drawing.IImageEncoder imageEncoder, MediaBrowser.Controller.Drawing.IImageEncoder imageEncoder,
MediaBrowser.Common.Net.INetworkManager networkManager, MediaBrowser.Common.Net.INetworkManager networkManager,
IConfiguration configuration) IConfiguration configuration)
@ -25,7 +23,6 @@ namespace Jellyfin.Server
loggerFactory, loggerFactory,
options, options,
fileSystem, fileSystem,
environmentInfo,
imageEncoder, imageEncoder,
networkManager, networkManager,
configuration) configuration)

View File

@ -12,7 +12,6 @@ using System.Threading.Tasks;
using CommandLine; using CommandLine;
using Emby.Drawing; using Emby.Drawing;
using Emby.Server.Implementations; using Emby.Server.Implementations;
using Emby.Server.Implementations.EnvironmentInfo;
using Emby.Server.Implementations.IO; using Emby.Server.Implementations.IO;
using Emby.Server.Implementations.Networking; using Emby.Server.Implementations.Networking;
using Jellyfin.Drawing.Skia; using Jellyfin.Drawing.Skia;
@ -46,7 +45,6 @@ namespace Jellyfin.Server
const string pattern = @"^(-[^-\s]{2})"; // Match -xx, not -x, not --xx, not xx const string pattern = @"^(-[^-\s]{2})"; // Match -xx, not -x, not --xx, not xx
const string substitution = @"-$1"; // Prepend with additional single-hyphen const string substitution = @"-$1"; // Prepend with additional single-hyphen
var regex = new Regex(pattern); var regex = new Regex(pattern);
for (var i = 0; i < args.Length; i++) for (var i = 0; i < args.Length; i++)
{ {
args[i] = regex.Replace(args[i], substitution); args[i] = regex.Replace(args[i], substitution);
@ -54,9 +52,7 @@ namespace Jellyfin.Server
// Parse the command line arguments and either start the app or exit indicating error // Parse the command line arguments and either start the app or exit indicating error
await Parser.Default.ParseArguments<StartupOptions>(args) await Parser.Default.ParseArguments<StartupOptions>(args)
.MapResult( .MapResult(StartApp, _ => Task.CompletedTask).ConfigureAwait(false);
options => StartApp(options),
errs => Task.FromResult(0)).ConfigureAwait(false);
} }
public static void Shutdown() public static void Shutdown()
@ -119,31 +115,29 @@ namespace Jellyfin.Server
_logger.LogInformation("Jellyfin version: {Version}", Assembly.GetEntryAssembly().GetName().Version); _logger.LogInformation("Jellyfin version: {Version}", Assembly.GetEntryAssembly().GetName().Version);
EnvironmentInfo environmentInfo = new EnvironmentInfo(GetOperatingSystem()); ApplicationHost.LogEnvironmentInfo(_logger, appPaths);
ApplicationHost.LogEnvironmentInfo(_logger, appPaths, environmentInfo);
SQLitePCL.Batteries_V2.Init(); SQLitePCL.Batteries_V2.Init();
// Allow all https requests // Allow all https requests
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return true; }); ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return true; });
var fileSystem = new ManagedFileSystem(_loggerFactory, environmentInfo, appPaths); var fileSystem = new ManagedFileSystem(_loggerFactory, appPaths);
using (var appHost = new CoreAppHost( using (var appHost = new CoreAppHost(
appPaths, appPaths,
_loggerFactory, _loggerFactory,
options, options,
fileSystem, fileSystem,
environmentInfo,
new NullImageEncoder(), new NullImageEncoder(),
new NetworkManager(_loggerFactory, environmentInfo), new NetworkManager(_loggerFactory),
appConfig)) appConfig))
{ {
await appHost.Init(new ServiceCollection()).ConfigureAwait(false); await appHost.InitAsync(new ServiceCollection()).ConfigureAwait(false);
appHost.ImageProcessor.ImageEncoder = GetImageEncoder(fileSystem, appPaths, appHost.LocalizationManager); appHost.ImageProcessor.ImageEncoder = GetImageEncoder(fileSystem, appPaths, appHost.LocalizationManager);
await appHost.RunStartupTasks().ConfigureAwait(false); await appHost.RunStartupTasksAsync().ConfigureAwait(false);
try try
{ {
@ -179,7 +173,6 @@ namespace Jellyfin.Server
// ELSE IF $XDG_DATA_HOME then use $XDG_DATA_HOME/jellyfin // ELSE IF $XDG_DATA_HOME then use $XDG_DATA_HOME/jellyfin
// ELSE use $HOME/.local/share/jellyfin // ELSE use $HOME/.local/share/jellyfin
var dataDir = options.DataDir; var dataDir = options.DataDir;
if (string.IsNullOrEmpty(dataDir)) if (string.IsNullOrEmpty(dataDir))
{ {
dataDir = Environment.GetEnvironmentVariable("JELLYFIN_DATA_DIR"); dataDir = Environment.GetEnvironmentVariable("JELLYFIN_DATA_DIR");
@ -234,7 +227,6 @@ namespace Jellyfin.Server
// ELSE IF XDG_CACHE_HOME, use $XDG_CACHE_HOME/jellyfin // ELSE IF XDG_CACHE_HOME, use $XDG_CACHE_HOME/jellyfin
// ELSE HOME/.cache/jellyfin // ELSE HOME/.cache/jellyfin
var cacheDir = options.CacheDir; var cacheDir = options.CacheDir;
if (string.IsNullOrEmpty(cacheDir)) if (string.IsNullOrEmpty(cacheDir))
{ {
cacheDir = Environment.GetEnvironmentVariable("JELLYFIN_CACHE_DIR"); cacheDir = Environment.GetEnvironmentVariable("JELLYFIN_CACHE_DIR");
@ -285,7 +277,6 @@ namespace Jellyfin.Server
// ELSE IF --datadir, use <datadir>/log (assume portable run) // ELSE IF --datadir, use <datadir>/log (assume portable run)
// ELSE <datadir>/log // ELSE <datadir>/log
var logDir = options.LogDir; var logDir = options.LogDir;
if (string.IsNullOrEmpty(logDir)) if (string.IsNullOrEmpty(logDir))
{ {
logDir = Environment.GetEnvironmentVariable("JELLYFIN_LOG_DIR"); logDir = Environment.GetEnvironmentVariable("JELLYFIN_LOG_DIR");
@ -380,36 +371,6 @@ namespace Jellyfin.Server
return new NullImageEncoder(); return new NullImageEncoder();
} }
private static MediaBrowser.Model.System.OperatingSystem GetOperatingSystem()
{
switch (Environment.OSVersion.Platform)
{
case PlatformID.MacOSX:
return MediaBrowser.Model.System.OperatingSystem.OSX;
case PlatformID.Win32NT:
return MediaBrowser.Model.System.OperatingSystem.Windows;
case PlatformID.Unix:
default:
{
string osDescription = RuntimeInformation.OSDescription;
if (osDescription.Contains("linux", StringComparison.OrdinalIgnoreCase))
{
return MediaBrowser.Model.System.OperatingSystem.Linux;
}
else if (osDescription.Contains("darwin", StringComparison.OrdinalIgnoreCase))
{
return MediaBrowser.Model.System.OperatingSystem.OSX;
}
else if (osDescription.Contains("bsd", StringComparison.OrdinalIgnoreCase))
{
return MediaBrowser.Model.System.OperatingSystem.BSD;
}
throw new Exception($"Can't resolve OS with description: '{osDescription}'");
}
}
}
private static void StartNewInstance(StartupOptions options) private static void StartNewInstance(StartupOptions options)
{ {
_logger.LogInformation("Starting new instance"); _logger.LogInformation("Starting new instance");

View File

@ -698,12 +698,11 @@ namespace MediaBrowser.Api.LiveTv
private readonly IFileSystem _fileSystem; private readonly IFileSystem _fileSystem;
private readonly IAuthorizationContext _authContext; private readonly IAuthorizationContext _authContext;
private readonly ISessionContext _sessionContext; private readonly ISessionContext _sessionContext;
private readonly IEnvironmentInfo _environment;
private ICryptoProvider _cryptographyProvider; private ICryptoProvider _cryptographyProvider;
private IStreamHelper _streamHelper; private IStreamHelper _streamHelper;
private IMediaSourceManager _mediaSourceManager; private IMediaSourceManager _mediaSourceManager;
public LiveTvService(ICryptoProvider crypto, IMediaSourceManager mediaSourceManager, IStreamHelper streamHelper, ILiveTvManager liveTvManager, IUserManager userManager, IServerConfigurationManager config, IHttpClient httpClient, ILibraryManager libraryManager, IDtoService dtoService, IFileSystem fileSystem, IAuthorizationContext authContext, ISessionContext sessionContext, IEnvironmentInfo environment) public LiveTvService(ICryptoProvider crypto, IMediaSourceManager mediaSourceManager, IStreamHelper streamHelper, ILiveTvManager liveTvManager, IUserManager userManager, IServerConfigurationManager config, IHttpClient httpClient, ILibraryManager libraryManager, IDtoService dtoService, IFileSystem fileSystem, IAuthorizationContext authContext, ISessionContext sessionContext)
{ {
_liveTvManager = liveTvManager; _liveTvManager = liveTvManager;
_userManager = userManager; _userManager = userManager;
@ -714,7 +713,6 @@ namespace MediaBrowser.Api.LiveTv
_fileSystem = fileSystem; _fileSystem = fileSystem;
_authContext = authContext; _authContext = authContext;
_sessionContext = sessionContext; _sessionContext = sessionContext;
_environment = environment;
_cryptographyProvider = crypto; _cryptographyProvider = crypto;
_streamHelper = streamHelper; _streamHelper = streamHelper;
_mediaSourceManager = mediaSourceManager; _mediaSourceManager = mediaSourceManager;
@ -756,7 +754,7 @@ namespace MediaBrowser.Api.LiveTv
[HeaderNames.ContentType] = Model.Net.MimeTypes.GetMimeType(path) [HeaderNames.ContentType] = Model.Net.MimeTypes.GetMimeType(path)
}; };
return new ProgressiveFileCopier(_fileSystem, _streamHelper, path, outputHeaders, Logger, _environment) return new ProgressiveFileCopier(_fileSystem, _streamHelper, path, outputHeaders, Logger)
{ {
AllowEndOfFile = false AllowEndOfFile = false
}; };
@ -779,7 +777,7 @@ namespace MediaBrowser.Api.LiveTv
[HeaderNames.ContentType] = Model.Net.MimeTypes.GetMimeType("file." + request.Container) [HeaderNames.ContentType] = Model.Net.MimeTypes.GetMimeType("file." + request.Container)
}; };
return new ProgressiveFileCopier(directStreamProvider, _streamHelper, outputHeaders, Logger, _environment) return new ProgressiveFileCopier(directStreamProvider, _streamHelper, outputHeaders, Logger)
{ {
AllowEndOfFile = false AllowEndOfFile = false
}; };

View File

@ -5,7 +5,6 @@ using System.Threading.Tasks;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
using MediaBrowser.Model.IO; using MediaBrowser.Model.IO;
using MediaBrowser.Model.Services; using MediaBrowser.Model.Services;
using MediaBrowser.Model.System;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace MediaBrowser.Api.LiveTv namespace MediaBrowser.Api.LiveTv
@ -23,25 +22,22 @@ namespace MediaBrowser.Api.LiveTv
public bool AllowEndOfFile = true; public bool AllowEndOfFile = true;
private readonly IDirectStreamProvider _directStreamProvider; private readonly IDirectStreamProvider _directStreamProvider;
private readonly IEnvironmentInfo _environment;
private IStreamHelper _streamHelper; private IStreamHelper _streamHelper;
public ProgressiveFileCopier(IFileSystem fileSystem, IStreamHelper streamHelper, string path, Dictionary<string, string> outputHeaders, ILogger logger, IEnvironmentInfo environment) public ProgressiveFileCopier(IFileSystem fileSystem, IStreamHelper streamHelper, string path, Dictionary<string, string> outputHeaders, ILogger logger)
{ {
_fileSystem = fileSystem; _fileSystem = fileSystem;
_path = path; _path = path;
_outputHeaders = outputHeaders; _outputHeaders = outputHeaders;
_logger = logger; _logger = logger;
_environment = environment;
_streamHelper = streamHelper; _streamHelper = streamHelper;
} }
public ProgressiveFileCopier(IDirectStreamProvider directStreamProvider, IStreamHelper streamHelper, Dictionary<string, string> outputHeaders, ILogger logger, IEnvironmentInfo environment) public ProgressiveFileCopier(IDirectStreamProvider directStreamProvider, IStreamHelper streamHelper, Dictionary<string, string> outputHeaders, ILogger logger)
{ {
_directStreamProvider = directStreamProvider; _directStreamProvider = directStreamProvider;
_outputHeaders = outputHeaders; _outputHeaders = outputHeaders;
_logger = logger; _logger = logger;
_environment = environment;
_streamHelper = streamHelper; _streamHelper = streamHelper;
} }

View File

@ -3,7 +3,6 @@ using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Devices; using MediaBrowser.Controller.Devices;
using MediaBrowser.Controller.Dlna; using MediaBrowser.Controller.Dlna;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.MediaEncoding; using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Net;
@ -11,7 +10,6 @@ using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.IO; using MediaBrowser.Model.IO;
using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.Services; using MediaBrowser.Model.Services;
using MediaBrowser.Model.System;
namespace MediaBrowser.Api.Playback.Progressive namespace MediaBrowser.Api.Playback.Progressive
{ {
@ -46,8 +44,7 @@ namespace MediaBrowser.Api.Playback.Progressive
IDeviceManager deviceManager, IDeviceManager deviceManager,
IMediaSourceManager mediaSourceManager, IMediaSourceManager mediaSourceManager,
IJsonSerializer jsonSerializer, IJsonSerializer jsonSerializer,
IAuthorizationContext authorizationContext, IAuthorizationContext authorizationContext)
IEnvironmentInfo environmentInfo)
: base(httpClient, : base(httpClient,
serverConfig, serverConfig,
userManager, userManager,
@ -60,8 +57,7 @@ namespace MediaBrowser.Api.Playback.Progressive
deviceManager, deviceManager,
mediaSourceManager, mediaSourceManager,
jsonSerializer, jsonSerializer,
authorizationContext, authorizationContext)
environmentInfo)
{ {
} }

View File

@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.IO; using System.IO;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -8,15 +7,12 @@ using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Devices; using MediaBrowser.Controller.Devices;
using MediaBrowser.Controller.Dlna; using MediaBrowser.Controller.Dlna;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.MediaEncoding; using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Net;
using MediaBrowser.Model.IO; using MediaBrowser.Model.IO;
using MediaBrowser.Model.MediaInfo; using MediaBrowser.Model.MediaInfo;
using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.Services;
using MediaBrowser.Model.System;
using Microsoft.Net.Http.Headers; using Microsoft.Net.Http.Headers;
namespace MediaBrowser.Api.Playback.Progressive namespace MediaBrowser.Api.Playback.Progressive
@ -26,7 +22,6 @@ namespace MediaBrowser.Api.Playback.Progressive
/// </summary> /// </summary>
public abstract class BaseProgressiveStreamingService : BaseStreamingService public abstract class BaseProgressiveStreamingService : BaseStreamingService
{ {
protected readonly IEnvironmentInfo EnvironmentInfo;
protected IHttpClient HttpClient { get; private set; } protected IHttpClient HttpClient { get; private set; }
public BaseProgressiveStreamingService( public BaseProgressiveStreamingService(
@ -42,8 +37,7 @@ namespace MediaBrowser.Api.Playback.Progressive
IDeviceManager deviceManager, IDeviceManager deviceManager,
IMediaSourceManager mediaSourceManager, IMediaSourceManager mediaSourceManager,
IJsonSerializer jsonSerializer, IJsonSerializer jsonSerializer,
IAuthorizationContext authorizationContext, IAuthorizationContext authorizationContext)
IEnvironmentInfo environmentInfo)
: base(serverConfig, : base(serverConfig,
userManager, userManager,
libraryManager, libraryManager,
@ -57,7 +51,6 @@ namespace MediaBrowser.Api.Playback.Progressive
jsonSerializer, jsonSerializer,
authorizationContext) authorizationContext)
{ {
EnvironmentInfo = environmentInfo;
HttpClient = httpClient; HttpClient = httpClient;
} }
@ -157,7 +150,7 @@ namespace MediaBrowser.Api.Playback.Progressive
// TODO: Don't hardcode this // TODO: Don't hardcode this
outputHeaders[HeaderNames.ContentType] = Model.Net.MimeTypes.GetMimeType("file.ts"); outputHeaders[HeaderNames.ContentType] = Model.Net.MimeTypes.GetMimeType("file.ts");
return new ProgressiveFileCopier(state.DirectStreamProvider, outputHeaders, null, Logger, EnvironmentInfo, CancellationToken.None) return new ProgressiveFileCopier(state.DirectStreamProvider, outputHeaders, null, Logger, CancellationToken.None)
{ {
AllowEndOfFile = false AllowEndOfFile = false
}; };
@ -203,7 +196,7 @@ namespace MediaBrowser.Api.Playback.Progressive
}; };
return new ProgressiveFileCopier(FileSystem, state.MediaPath, outputHeaders, null, Logger, EnvironmentInfo, CancellationToken.None) return new ProgressiveFileCopier(FileSystem, state.MediaPath, outputHeaders, null, Logger, CancellationToken.None)
{ {
AllowEndOfFile = false AllowEndOfFile = false
}; };
@ -397,7 +390,7 @@ namespace MediaBrowser.Api.Playback.Progressive
outputHeaders[item.Key] = item.Value; outputHeaders[item.Key] = item.Value;
} }
return new ProgressiveFileCopier(FileSystem, outputPath, outputHeaders, job, Logger, EnvironmentInfo, CancellationToken.None); return new ProgressiveFileCopier(FileSystem, outputPath, outputHeaders, job, Logger, CancellationToken.None);
} }
finally finally
{ {

View File

@ -8,6 +8,7 @@ using MediaBrowser.Model.IO;
using MediaBrowser.Model.Services; using MediaBrowser.Model.Services;
using MediaBrowser.Model.System; using MediaBrowser.Model.System;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using OperatingSystem = MediaBrowser.Common.System.OperatingSystem;
namespace MediaBrowser.Api.Playback.Progressive namespace MediaBrowser.Api.Playback.Progressive
{ {
@ -27,9 +28,8 @@ namespace MediaBrowser.Api.Playback.Progressive
public bool AllowEndOfFile = true; public bool AllowEndOfFile = true;
private readonly IDirectStreamProvider _directStreamProvider; private readonly IDirectStreamProvider _directStreamProvider;
private readonly IEnvironmentInfo _environment;
public ProgressiveFileCopier(IFileSystem fileSystem, string path, Dictionary<string, string> outputHeaders, TranscodingJob job, ILogger logger, IEnvironmentInfo environment, CancellationToken cancellationToken) public ProgressiveFileCopier(IFileSystem fileSystem, string path, Dictionary<string, string> outputHeaders, TranscodingJob job, ILogger logger, CancellationToken cancellationToken)
{ {
_fileSystem = fileSystem; _fileSystem = fileSystem;
_path = path; _path = path;
@ -37,17 +37,15 @@ namespace MediaBrowser.Api.Playback.Progressive
_job = job; _job = job;
_logger = logger; _logger = logger;
_cancellationToken = cancellationToken; _cancellationToken = cancellationToken;
_environment = environment;
} }
public ProgressiveFileCopier(IDirectStreamProvider directStreamProvider, Dictionary<string, string> outputHeaders, TranscodingJob job, ILogger logger, IEnvironmentInfo environment, CancellationToken cancellationToken) public ProgressiveFileCopier(IDirectStreamProvider directStreamProvider, Dictionary<string, string> outputHeaders, TranscodingJob job, ILogger logger, CancellationToken cancellationToken)
{ {
_directStreamProvider = directStreamProvider; _directStreamProvider = directStreamProvider;
_outputHeaders = outputHeaders; _outputHeaders = outputHeaders;
_job = job; _job = job;
_logger = logger; _logger = logger;
_cancellationToken = cancellationToken; _cancellationToken = cancellationToken;
_environment = environment;
} }
public IDictionary<string, string> Headers => _outputHeaders; public IDictionary<string, string> Headers => _outputHeaders;
@ -79,7 +77,7 @@ namespace MediaBrowser.Api.Playback.Progressive
var eofCount = 0; var eofCount = 0;
// use non-async filestream along with read due to https://github.com/dotnet/corefx/issues/6039 // use non-async filestream along with read due to https://github.com/dotnet/corefx/issues/6039
var allowAsyncFileRead = _environment.OperatingSystem != Model.System.OperatingSystem.Windows; var allowAsyncFileRead = OperatingSystem.Id != OperatingSystemId.Windows;
using (var inputStream = GetInputStream(allowAsyncFileRead)) using (var inputStream = GetInputStream(allowAsyncFileRead))
{ {

View File

@ -3,7 +3,6 @@ using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Devices; using MediaBrowser.Controller.Devices;
using MediaBrowser.Controller.Dlna; using MediaBrowser.Controller.Dlna;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.MediaEncoding; using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Net;
@ -11,7 +10,6 @@ using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.IO; using MediaBrowser.Model.IO;
using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.Services; using MediaBrowser.Model.Services;
using MediaBrowser.Model.System;
namespace MediaBrowser.Api.Playback.Progressive namespace MediaBrowser.Api.Playback.Progressive
{ {
@ -83,8 +81,7 @@ namespace MediaBrowser.Api.Playback.Progressive
IDeviceManager deviceManager, IDeviceManager deviceManager,
IMediaSourceManager mediaSourceManager, IMediaSourceManager mediaSourceManager,
IJsonSerializer jsonSerializer, IJsonSerializer jsonSerializer,
IAuthorizationContext authorizationContext, IAuthorizationContext authorizationContext)
IEnvironmentInfo environmentInfo)
: base(httpClient, : base(httpClient,
serverConfig, serverConfig,
userManager, userManager,
@ -97,8 +94,7 @@ namespace MediaBrowser.Api.Playback.Progressive
deviceManager, deviceManager,
mediaSourceManager, mediaSourceManager,
jsonSerializer, jsonSerializer,
authorizationContext, authorizationContext)
environmentInfo)
{ {
} }

View File

@ -18,7 +18,6 @@ using MediaBrowser.Model.IO;
using MediaBrowser.Model.MediaInfo; using MediaBrowser.Model.MediaInfo;
using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.Services; using MediaBrowser.Model.Services;
using MediaBrowser.Model.System;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace MediaBrowser.Api.Playback namespace MediaBrowser.Api.Playback
@ -93,7 +92,6 @@ namespace MediaBrowser.Api.Playback
IAuthorizationContext authorizationContext, IAuthorizationContext authorizationContext,
IImageProcessor imageProcessor, IImageProcessor imageProcessor,
INetworkManager networkManager, INetworkManager networkManager,
IEnvironmentInfo environmentInfo,
ILoggerFactory loggerFactory) ILoggerFactory loggerFactory)
{ {
HttpClient = httpClient; HttpClient = httpClient;
@ -112,7 +110,6 @@ namespace MediaBrowser.Api.Playback
AuthorizationContext = authorizationContext; AuthorizationContext = authorizationContext;
ImageProcessor = imageProcessor; ImageProcessor = imageProcessor;
NetworkManager = networkManager; NetworkManager = networkManager;
EnvironmentInfo = environmentInfo;
_loggerFactory = loggerFactory; _loggerFactory = loggerFactory;
_logger = loggerFactory.CreateLogger(nameof(UniversalAudioService)); _logger = loggerFactory.CreateLogger(nameof(UniversalAudioService));
} }
@ -133,7 +130,6 @@ namespace MediaBrowser.Api.Playback
protected IAuthorizationContext AuthorizationContext { get; private set; } protected IAuthorizationContext AuthorizationContext { get; private set; }
protected IImageProcessor ImageProcessor { get; private set; } protected IImageProcessor ImageProcessor { get; private set; }
protected INetworkManager NetworkManager { get; private set; } protected INetworkManager NetworkManager { get; private set; }
protected IEnvironmentInfo EnvironmentInfo { get; private set; }
private ILoggerFactory _loggerFactory; private ILoggerFactory _loggerFactory;
private ILogger _logger; private ILogger _logger;
@ -338,8 +334,7 @@ namespace MediaBrowser.Api.Playback
DeviceManager, DeviceManager,
MediaSourceManager, MediaSourceManager,
JsonSerializer, JsonSerializer,
AuthorizationContext, AuthorizationContext)
EnvironmentInfo)
{ {
Request = Request Request = Request
}; };

View File

@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using MediaBrowser.Common.Plugins; using MediaBrowser.Common.Plugins;
using MediaBrowser.Model.Events; using MediaBrowser.Model.Events;
@ -107,7 +106,7 @@ namespace MediaBrowser.Common
/// <summary> /// <summary>
/// Inits this instance. /// Inits this instance.
/// </summary> /// </summary>
Task Init(IServiceCollection serviceCollection); Task InitAsync(IServiceCollection serviceCollection);
/// <summary> /// <summary>
/// Creates the instance. /// Creates the instance.

View File

@ -0,0 +1,72 @@
using System;
using System.Runtime.InteropServices;
using System.Threading;
using MediaBrowser.Model.System;
namespace MediaBrowser.Common.System
{
public static class OperatingSystem
{
// We can't use Interlocked.CompareExchange for enums
private static int _id = int.MaxValue;
public static OperatingSystemId Id
{
get
{
if (_id == int.MaxValue)
{
Interlocked.CompareExchange(ref _id, (int)GetId(), int.MaxValue);
}
return (OperatingSystemId)_id;
}
}
public static string Name
{
get
{
switch (Id)
{
case OperatingSystemId.BSD: return "BSD";
case OperatingSystemId.Linux: return "Linux";
case OperatingSystemId.Darwin: return "macOS";
case OperatingSystemId.Windows: return "Windows";
default: throw new Exception($"Unknown OS {Id}");
}
}
}
private static OperatingSystemId GetId()
{
switch (Environment.OSVersion.Platform)
{
// On .NET Core `MacOSX` got replaced by `Unix`, this case should never be hit.
case PlatformID.MacOSX:
return OperatingSystemId.Darwin;
case PlatformID.Win32NT:
return OperatingSystemId.Windows;
case PlatformID.Unix:
default:
{
string osDescription = RuntimeInformation.OSDescription;
if (osDescription.IndexOf("linux", StringComparison.OrdinalIgnoreCase) != -1)
{
return OperatingSystemId.Linux;
}
else if (osDescription.IndexOf("darwin", StringComparison.OrdinalIgnoreCase) != -1)
{
return OperatingSystemId.Darwin;
}
else if (osDescription.IndexOf("bsd", StringComparison.OrdinalIgnoreCase) != -1)
{
return OperatingSystemId.BSD;
}
throw new Exception($"Can't resolve OS with description: '{osDescription}'");
}
}
}
}
}

View File

@ -1,21 +0,0 @@
using System.Runtime.InteropServices;
namespace MediaBrowser.Model.System
{
public interface IEnvironmentInfo
{
OperatingSystem OperatingSystem { get; }
string OperatingSystemName { get; }
string OperatingSystemVersion { get; }
Architecture SystemArchitecture { get; }
}
public enum OperatingSystem
{
Windows,
Linux,
OSX,
BSD,
Android
}
}

View File

@ -0,0 +1,10 @@
namespace MediaBrowser.Model.System
{
public enum OperatingSystemId
{
Windows,
Linux,
Darwin,
BSD
}
}