The Free Software Media System - Server Backend & API
update core projects
Luke Pulverenti918b9ca86d1b
diff --git a/Emby.Common.Implementations/BaseApplicationHost.cs b/Emby.Common.Implementations/BaseApplicationHost.csindex 0cf11e8255..9571ea3889 100644--- a/Emby.Common.Implementations/BaseApplicationHost.cs+++ b/Emby.Common.Implementations/BaseApplicationHost.cs@@ -172,7 +172,7 @@ namespace Emby.Common.Implementationsprotected ICryptoProvider CryptographyProvider = new CryptographyProvider();- protected IEnvironmentInfo EnvironmentInfo = new Emby.Common.Implementations.EnvironmentInfo.EnvironmentInfo();+ protected IEnvironmentInfo EnvironmentInfo { get; private set; }private DeviceId _deviceId;public string SystemId@@ -205,8 +205,11 @@ namespace Emby.Common.Implementations/// </summary>protected BaseApplicationHost(TApplicationPathsType applicationPaths,ILogManager logManager,- IFileSystem fileSystem)+ IFileSystem fileSystem,+ IEnvironmentInfo environmentInfo){+ EnvironmentInfo = environmentInfo;+// hack alert, until common can target .net coreBaseExtensions.CryptographyProvider = CryptographyProvider;diff --git a/Emby.Common.Implementations/EnvironmentInfo/EnvironmentInfo.cs b/Emby.Common.Implementations/EnvironmentInfo/EnvironmentInfo.csindex 8cea617eae..6a1b3ef74c 100644--- a/Emby.Common.Implementations/EnvironmentInfo/EnvironmentInfo.cs+++ b/Emby.Common.Implementations/EnvironmentInfo/EnvironmentInfo.cs@@ -9,6 +9,8 @@ namespace Emby.Common.Implementations.EnvironmentInfo{public class EnvironmentInfo : IEnvironmentInfo{+ public MediaBrowser.Model.System.Architecture? CustomArchitecture { get; set; }+public MediaBrowser.Model.System.OperatingSystem OperatingSystem{get@@ -66,5 +68,32 @@ namespace Emby.Common.Implementations.EnvironmentInforeturn "1.0";}}++ public MediaBrowser.Model.System.Architecture SystemArchitecture+ {+ get+ {+ if (CustomArchitecture.HasValue)+ {+ return CustomArchitecture.Value;+ }+#if NET46+ return Environment.Is64BitOperatingSystem ? MediaBrowser.Model.System.Architecture.X64 : MediaBrowser.Model.System.Architecture.X86;+#elif NETSTANDARD1_6+ switch(System.Runtime.InteropServices.RuntimeInformation.OSArchitecture)+ {+ case System.Runtime.InteropServices.Architecture.Arm:+ return MediaBrowser.Model.System.Architecture.Arm;+ case System.Runtime.InteropServices.Architecture.Arm64:+ return MediaBrowser.Model.System.Architecture.Arm64;+ case System.Runtime.InteropServices.Architecture.X64:+ return MediaBrowser.Model.System.Architecture.X64;+ case System.Runtime.InteropServices.Architecture.X86:+ return MediaBrowser.Model.System.Architecture.X86;+ }+#endif+ return MediaBrowser.Model.System.Architecture.X64;+ }+ }}}diff --git a/MediaBrowser.Server.Startup.Common/INativeApp.cs b/Emby.Server.Core/INativeApp.cssimilarity index 78%rename from MediaBrowser.Server.Startup.Common/INativeApp.csrename to Emby.Server.Core/INativeApp.csindex 182afbf003..a79d1f02b8 100644--- a/MediaBrowser.Server.Startup.Common/INativeApp.cs+++ b/Emby.Server.Core/INativeApp.cs@@ -6,7 +6,7 @@ using Emby.Server.Core;using Emby.Server.Core.Data;using Emby.Server.Core.FFMpeg;-namespace MediaBrowser.Server.Startup.Common+namespace Emby.Server.Core{public interface INativeApp{@@ -19,18 +19,8 @@ namespace MediaBrowser.Server.Startup.Common/// <summary>/// Authorizes the server./// </summary>- /// <param name="udpPort">The UDP port.</param>- /// <param name="httpServerPort">The HTTP server port.</param>- /// <param name="httpsServerPort">The HTTPS server port.</param>- /// <param name="tempDirectory">The temporary directory.</param>void AuthorizeServer(int udpPort, int httpServerPort, int httpsServerPort, string applicationPath, string tempDirectory);- /// <summary>- /// Gets the environment.- /// </summary>- /// <value>The environment.</value>- NativeEnvironment Environment { get; }-/// <summary>/// Gets a value indicating whether [supports running as service]./// </summary>@@ -54,12 +44,6 @@ namespace MediaBrowser.Server.Startup.Common/// </summary>/// <value><c>true</c> if [supports autorun at startup]; otherwise, <c>false</c>.</value>bool SupportsAutoRunAtStartup { get; }-- /// <summary>- /// Gets a value indicating whether [supports library monitor].- /// </summary>- /// <value><c>true</c> if [supports library monitor]; otherwise, <c>false</c>.</value>- bool SupportsLibraryMonitor { get; }/// <summary>/// Gets a value indicating whether this instance can self update.diff --git a/MediaBrowser.Controller/IServerApplicationHost.cs b/MediaBrowser.Controller/IServerApplicationHost.csindex d2cf23f43f..44c0031974 100644--- a/MediaBrowser.Controller/IServerApplicationHost.cs+++ b/MediaBrowser.Controller/IServerApplicationHost.cs@@ -26,12 +26,6 @@ namespace MediaBrowser.Controller/// </summary>/// <value><c>true</c> if [supports automatic run at startup]; otherwise, <c>false</c>.</value>bool SupportsAutoRunAtStartup { get; }-- /// <summary>- /// Gets a value indicating whether [supports library monitor].- /// </summary>- /// <value><c>true</c> if [supports library monitor]; otherwise, <c>false</c>.</value>- bool SupportsLibraryMonitor { get; }/// <summary>/// Gets the HTTP server port.diff --git a/MediaBrowser.Model/System/Architecture.cs b/MediaBrowser.Model/System/Architecture.csindex 09eedddc13..73f78cd582 100644--- a/MediaBrowser.Model/System/Architecture.cs+++ b/MediaBrowser.Model/System/Architecture.cs@@ -4,6 +4,7 @@{X86 = 0,X64 = 1,- Arm = 2+ Arm = 2,+ Arm64 = 3}}diff --git a/MediaBrowser.Model/System/IEnvironmentInfo.cs b/MediaBrowser.Model/System/IEnvironmentInfo.csindex 3fcacb30d4..c5f493e7c9 100644--- a/MediaBrowser.Model/System/IEnvironmentInfo.cs+++ b/MediaBrowser.Model/System/IEnvironmentInfo.cs@@ -11,6 +11,7 @@ namespace MediaBrowser.Model.SystemMediaBrowser.Model.System.OperatingSystem OperatingSystem { get; }string OperatingSystemName { get; }string OperatingSystemVersion { get; }+ Architecture SystemArchitecture { get; }}public enum OperatingSystemdiff --git a/MediaBrowser.Server.Mono/Native/MonoApp.cs b/MediaBrowser.Server.Mono/Native/MonoApp.csindex 6e7a677aee..8257a1b8df 100644--- a/MediaBrowser.Server.Mono/Native/MonoApp.cs+++ b/MediaBrowser.Server.Mono/Native/MonoApp.cs@@ -12,7 +12,6 @@ using Emby.Server.Core;using Emby.Server.Core.Data;using Emby.Server.Core.FFMpeg;using MediaBrowser.Model.System;-using OperatingSystem = MediaBrowser.Server.Startup.Common.OperatingSystem;namespace MediaBrowser.Server.Mono.Native{@@ -20,11 +19,13 @@ namespace MediaBrowser.Server.Mono.Native{protected StartupOptions StartupOptions { get; private set; }protected ILogger Logger { get; private set; }+ private readonly MonoEnvironmentInfo _environment;- public MonoApp(StartupOptions startupOptions, ILogger logger)+ public MonoApp(StartupOptions startupOptions, ILogger logger, MonoEnvironmentInfo environment){StartupOptions = startupOptions;Logger = logger;+ _environment = environment;}/// <summary>@@ -77,11 +78,6 @@ namespace MediaBrowser.Server.Mono.Native{var list = new List<Assembly>();- if (Environment.OperatingSystem == Startup.Common.OperatingSystem.Linux)- {- list.AddRange(GetLinuxAssemblies());- }-list.Add(GetType().Assembly);return list;@@ -91,7 +87,7 @@ namespace MediaBrowser.Server.Mono.Native{var list = new List<Assembly>();- list.Add(typeof(LinuxIsoManager).Assembly);+ //list.Add(typeof(LinuxIsoManager).Assembly);return list;}@@ -100,12 +96,6 @@ namespace MediaBrowser.Server.Mono.Native{}- private NativeEnvironment _nativeEnvironment;- public NativeEnvironment Environment- {- get { return _nativeEnvironment ?? (_nativeEnvironment = GetEnvironmentInfo()); }- }-public bool SupportsRunningAsService{get@@ -122,14 +112,6 @@ namespace MediaBrowser.Server.Mono.Native}}- public bool SupportsLibraryMonitor- {- get- {- return Environment.OperatingSystem != Startup.Common.OperatingSystem.Osx;- }- }-public void ConfigureAutoRun(bool autorun){}@@ -139,98 +121,31 @@ namespace MediaBrowser.Server.Mono.Nativereturn new NetworkManager(logger);}- private NativeEnvironment GetEnvironmentInfo()+ public FFMpegInstallInfo GetFfmpegInstallInfo(){- var info = new NativeEnvironment- {- OperatingSystem = Startup.Common.OperatingSystem.Linux- };-- var uname = GetUnixName();-- var sysName = uname.sysname ?? string.Empty;-- if (string.Equals(sysName, "Darwin", StringComparison.OrdinalIgnoreCase))- {- info.OperatingSystem = Startup.Common.OperatingSystem.Osx;- }- else if (string.Equals(sysName, "Linux", StringComparison.OrdinalIgnoreCase))- {- info.OperatingSystem = Startup.Common.OperatingSystem.Linux;- }- else if (string.Equals(sysName, "BSD", StringComparison.OrdinalIgnoreCase))- {- info.OperatingSystem = Startup.Common.OperatingSystem.Bsd;- }+ var info = new FFMpegInstallInfo();- var archX86 = new Regex("(i|I)[3-6]86");+ // Windows builds: http://ffmpeg.zeranoe.com/builds/+ // Linux builds: http://johnvansickle.com/ffmpeg/+ // OS X builds: http://ffmpegmac.net/+ // OS X x64: http://www.evermeet.cx/ffmpeg/- if (archX86.IsMatch(uname.machine))- {- info.SystemArchitecture = Architecture.X86;- }- else if (string.Equals(uname.machine, "x86_64", StringComparison.OrdinalIgnoreCase))- {- info.SystemArchitecture = Architecture.X64;- }- else if (uname.machine.StartsWith("arm", StringComparison.OrdinalIgnoreCase))- {- info.SystemArchitecture = Architecture.Arm;- }- else if (System.Environment.Is64BitOperatingSystem)+ if (_environment.IsBsd){- info.SystemArchitecture = Architecture.X64;+}- else+ else if (_environment.OperatingSystem == Model.System.OperatingSystem.Linux){- info.SystemArchitecture = Architecture.X86;+ info.ArchiveType = "7z";+ info.Version = "20160215";}- info.OperatingSystemVersionString = string.IsNullOrWhiteSpace(sysName) ?- System.Environment.OSVersion.VersionString :- sysName;+ // No version available - user requirement+ info.DownloadUrls = new string[] { };return info;}- private Uname _unixName;-- private Uname GetUnixName()- {- if (_unixName == null)- {- var uname = new Uname();- try- {- Utsname utsname;- var callResult = Syscall.uname(out utsname);- if (callResult == 0)- {- uname.sysname = utsname.sysname ?? string.Empty;- uname.machine = utsname.machine ?? string.Empty;- }-- }- catch (Exception ex)- {- Logger.ErrorException("Error getting unix name", ex);- }- _unixName = uname;- }- return _unixName;- }-- public class Uname- {- public string sysname = string.Empty;- public string machine = string.Empty;- }-- public FFMpegInstallInfo GetFfmpegInstallInfo()- {- return GetInfo(Environment);- }-public void LaunchUrl(string url){throw new NotImplementedException();@@ -241,33 +156,6 @@ namespace MediaBrowser.Server.Mono.Nativereturn new DbConnector(Logger);}- public static FFMpegInstallInfo GetInfo(NativeEnvironment environment)- {- var info = new FFMpegInstallInfo();-- // Windows builds: http://ffmpeg.zeranoe.com/builds/- // Linux builds: http://johnvansickle.com/ffmpeg/- // OS X builds: http://ffmpegmac.net/- // OS X x64: http://www.evermeet.cx/ffmpeg/-- switch (environment.OperatingSystem)- {- case OperatingSystem.Osx:- case OperatingSystem.Bsd:- break;- case OperatingSystem.Linux:-- info.ArchiveType = "7z";- info.Version = "20160215";- break;- }-- // No version available - user requirement- info.DownloadUrls = new string[] { };-- return info;- }-public void EnableLoopback(string appName){diff --git a/MediaBrowser.Server.Mono/Program.cs b/MediaBrowser.Server.Mono/Program.csindex 7d687bb545..7c77f67ed6 100644--- a/MediaBrowser.Server.Mono/Program.cs+++ b/MediaBrowser.Server.Mono/Program.cs@@ -11,11 +11,17 @@ using System.Net;using System.Net.Security;using System.Reflection;using System.Security.Cryptography.X509Certificates;+using System.Text.RegularExpressions;using System.Threading.Tasks;+using Emby.Common.Implementations.EnvironmentInfo;using Emby.Common.Implementations.IO;using Emby.Common.Implementations.Logging;using Emby.Server.Core;using Emby.Server.Implementations.IO;+using MediaBrowser.Model.System;+using Mono.Unix.Native;+using NLog;+using ILogger = MediaBrowser.Model.Logging.ILogger;namespace MediaBrowser.Server.Mono{@@ -80,9 +86,11 @@ namespace MediaBrowser.Server.Monovar fileSystem = new MonoFileSystem(logManager.GetLogger("FileSystem"), false, false);fileSystem.AddShortcutHandler(new MbLinkShortcutHandler(fileSystem));- var nativeApp = new MonoApp(options, logManager.GetLogger("App"));+ var environmentInfo = GetEnvironmentInfo();- _appHost = new ApplicationHost(appPaths, logManager, options, fileSystem, nativeApp, new PowerManagement(), "emby.mono.zip");+ var nativeApp = new MonoApp(options, logManager.GetLogger("App"), environmentInfo);++ _appHost = new ApplicationHost(appPaths, logManager, options, fileSystem, nativeApp, new PowerManagement(), "emby.mono.zip", environmentInfo);if (options.ContainsOption("-v")){@@ -107,6 +115,87 @@ namespace MediaBrowser.Server.MonoTask.WaitAll(task);}+ private static MonoEnvironmentInfo GetEnvironmentInfo()+ {+ var info = new MonoEnvironmentInfo();++ var uname = GetUnixName();++ var sysName = uname.sysname ?? string.Empty;++ if (string.Equals(sysName, "Darwin", StringComparison.OrdinalIgnoreCase))+ {+ //info.OperatingSystem = Startup.Common.OperatingSystem.Osx;+ }+ else if (string.Equals(sysName, "Linux", StringComparison.OrdinalIgnoreCase))+ {+ //info.OperatingSystem = Startup.Common.OperatingSystem.Linux;+ }+ else if (string.Equals(sysName, "BSD", StringComparison.OrdinalIgnoreCase))+ {+ //info.OperatingSystem = Startup.Common.OperatingSystem.Bsd;+ info.IsBsd = true;+ }++ var archX86 = new Regex("(i|I)[3-6]86");++ if (archX86.IsMatch(uname.machine))+ {+ info.CustomArchitecture = Architecture.X86;+ }+ else if (string.Equals(uname.machine, "x86_64", StringComparison.OrdinalIgnoreCase))+ {+ info.CustomArchitecture = Architecture.X64;+ }+ else if (uname.machine.StartsWith("arm", StringComparison.OrdinalIgnoreCase))+ {+ info.CustomArchitecture = Architecture.Arm;+ }+ else if (System.Environment.Is64BitOperatingSystem)+ {+ info.CustomArchitecture = Architecture.X64;+ }+ else+ {+ info.CustomArchitecture = Architecture.X86;+ }++ return info;+ }++ private static Uname _unixName;++ private static Uname GetUnixName()+ {+ if (_unixName == null)+ {+ var uname = new Uname();+ try+ {+ Utsname utsname;+ var callResult = Syscall.uname(out utsname);+ if (callResult == 0)+ {+ uname.sysname = utsname.sysname ?? string.Empty;+ uname.machine = utsname.machine ?? string.Empty;+ }++ }+ catch (Exception ex)+ {+ _logger.ErrorException("Error getting unix name", ex);+ }+ _unixName = uname;+ }+ return _unixName;+ }++ public class Uname+ {+ public string sysname = string.Empty;+ public string machine = string.Empty;+ }+/// <summary>/// Handles the SessionEnding event of the SystemEvents control./// </summary>@@ -192,4 +281,9 @@ namespace MediaBrowser.Server.Monoreturn true;}}++ public class MonoEnvironmentInfo : EnvironmentInfo+ {+ public bool IsBsd { get; set; }+ }}diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.csindex f427f9f567..87bbc48dbd 100644--- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs+++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs@@ -277,8 +277,9 @@ namespace MediaBrowser.Server.Startup.CommonIFileSystem fileSystem,INativeApp nativeApp,IPowerManagement powerManagement,- string releaseAssetFilename)- : base(applicationPaths, logManager, fileSystem)+ string releaseAssetFilename,+ IEnvironmentInfo environmentInfo)+ : base(applicationPaths, logManager, fileSystem, environmentInfo){_startupOptions = options;_releaseAssetFilename = releaseAssetFilename;@@ -301,11 +302,6 @@ namespace MediaBrowser.Server.Startup.Common}}- public override string OperatingSystemDisplayName- {- get { return NativeApp.Environment.OperatingSystemVersionString; }- }-public override bool IsRunningAsService{get { return NativeApp.IsRunningAsService; }@@ -316,11 +312,6 @@ namespace MediaBrowser.Server.Startup.Commonget { return NativeApp.SupportsRunningAsService; }}- public bool SupportsLibraryMonitor- {- get { return NativeApp.SupportsLibraryMonitor; }- }-/// <summary>/// Gets the name./// </summary>@@ -1300,7 +1291,7 @@ namespace MediaBrowser.Server.Startup.CommonHttpServerPortNumber = HttpPort,SupportsHttps = SupportsHttps,HttpsPortNumber = HttpsPort,- OperatingSystem = NativeApp.Environment.OperatingSystem.ToString(),+ OperatingSystem = EnvironmentInfo.OperatingSystem.ToString(),OperatingSystemDisplayName = OperatingSystemDisplayName,CanSelfRestart = CanSelfRestart,CanSelfUpdate = CanSelfUpdate,@@ -1312,9 +1303,9 @@ namespace MediaBrowser.Server.Startup.CommonSupportsRunningAsService = SupportsRunningAsService,ServerName = FriendlyName,LocalAddress = localAddress,- SupportsLibraryMonitor = SupportsLibraryMonitor,+ SupportsLibraryMonitor = true,EncoderLocationType = MediaEncoder.EncoderLocationType,- SystemArchitecture = NativeApp.Environment.SystemArchitecture,+ SystemArchitecture = EnvironmentInfo.SystemArchitecture,SystemUpdateLevel = ConfigurationManager.CommonConfiguration.SystemUpdateLevel,PackageName = _startupOptions.GetOption("-package")};diff --git a/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj b/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csprojindex 3b391b236c..ff7456977b 100644--- a/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj+++ b/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj@@ -114,7 +114,6 @@<Compile Include="Cryptography\X509Extensions.cs" /><Compile Include="Cryptography\X520Attributes.cs" /><Compile Include="HttpServerFactory.cs" />- <Compile Include="INativeApp.cs" /><Compile Include="IO\MemoryStreamProvider.cs" /><Compile Include="LiveTv\TunerHosts\SatIp\ChannelScan.cs" /><Compile Include="LiveTv\TunerHosts\SatIp\Rtcp\ReportBlock.cs" />@@ -138,7 +137,6 @@<Compile Include="LiveTv\TunerHosts\SatIp\SatIpHost.cs" /><Compile Include="LiveTv\TunerHosts\SatIp\TransmissionMode.cs" /><Compile Include="LiveTv\TunerHosts\SatIp\Utils.cs" />- <Compile Include="NativeEnvironment.cs" /><Compile Include="Properties\AssemblyInfo.cs" /><Compile Include="SystemEvents.cs" /></ItemGroup>diff --git a/MediaBrowser.Server.Startup.Common/NativeEnvironment.cs b/MediaBrowser.Server.Startup.Common/NativeEnvironment.csdeleted file mode 100644index b30509982e..0000000000--- a/MediaBrowser.Server.Startup.Common/NativeEnvironment.cs+++ /dev/null@@ -1,19 +0,0 @@-using MediaBrowser.Model.System;--namespace MediaBrowser.Server.Startup.Common-{- public class NativeEnvironment- {- public OperatingSystem OperatingSystem { get; set; }- public Architecture SystemArchitecture { get; set; }- public string OperatingSystemVersionString { get; set; }- }-- public enum OperatingSystem- {- Windows = 0,- Osx = 1,- Bsd = 2,- Linux = 3- }-}diff --git a/MediaBrowser.ServerApplication/MainStartup.cs b/MediaBrowser.ServerApplication/MainStartup.csindex f2967e14a0..adfc0a5886 100644--- a/MediaBrowser.ServerApplication/MainStartup.cs+++ b/MediaBrowser.ServerApplication/MainStartup.cs@@ -17,6 +17,7 @@ using System.Text;using System.Threading;using System.Threading.Tasks;using System.Windows.Forms;+using Emby.Common.Implementations.EnvironmentInfo;using Emby.Common.Implementations.IO;using Emby.Common.Implementations.Logging;using Emby.Server.Core;@@ -324,7 +325,8 @@ namespace MediaBrowser.ServerApplicationfileSystem,nativeApp,new PowerManagement(),- "emby.windows.zip");+ "emby.windows.zip",+ new EnvironmentInfo());var initProgress = new Progress<double>();diff --git a/MediaBrowser.ServerApplication/Native/WindowsApp.cs b/MediaBrowser.ServerApplication/Native/WindowsApp.csindex d0f8239fec..babe952d6d 100644--- a/MediaBrowser.ServerApplication/Native/WindowsApp.cs+++ b/MediaBrowser.ServerApplication/Native/WindowsApp.cs@@ -14,8 +14,6 @@ using Emby.Server.Core.FFMpeg;using MediaBrowser.Common.IO;using MediaBrowser.Controller.IO;using MediaBrowser.Model.IO;-using MediaBrowser.Model.System;-using OperatingSystem = MediaBrowser.Server.Startup.Common.OperatingSystem;namespace MediaBrowser.ServerApplication.Native{@@ -49,19 +47,6 @@ namespace MediaBrowser.ServerApplication.NativeServerAuthorization.AuthorizeServer(udpPort, httpServerPort, httpsPort, applicationPath, tempDirectory);}- public NativeEnvironment Environment- {- get- {- return new NativeEnvironment- {- OperatingSystem = OperatingSystem.Windows,- SystemArchitecture = System.Environment.Is64BitOperatingSystem ? Architecture.X64 : Architecture.X86,- OperatingSystemVersionString = System.Environment.OSVersion.VersionString- };- }- }-public bool SupportsLibraryMonitor{get { return true; }