| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335 | 
							- using MediaBrowser.Common.Net;
 
- using MediaBrowser.IsoMounter;
 
- using MediaBrowser.Model.Logging;
 
- using MediaBrowser.Server.Mono.Networking;
 
- using MediaBrowser.Server.Startup.Common;
 
- using Mono.Unix.Native;
 
- using System;
 
- using System.Collections.Generic;
 
- using System.Reflection;
 
- using System.Text.RegularExpressions;
 
- using MediaBrowser.Controller.Power;
 
- using MediaBrowser.Server.Implementations.Persistence;
 
- using MediaBrowser.Server.Startup.Common.FFMpeg;
 
- using OperatingSystem = MediaBrowser.Server.Startup.Common.OperatingSystem;
 
- namespace MediaBrowser.Server.Mono.Native
 
- {
 
-     public abstract class BaseMonoApp : INativeApp
 
-     {
 
-         protected StartupOptions StartupOptions { get; private set; }
 
-         protected ILogger Logger { get; private set; }
 
-         protected BaseMonoApp(StartupOptions startupOptions, ILogger logger)
 
-         {
 
-             StartupOptions = startupOptions;
 
-             Logger = logger;
 
-         }
 
-         /// <summary>
 
-         /// Shutdowns this instance.
 
-         /// </summary>
 
-         public abstract void Shutdown();
 
-         /// <summary>
 
-         /// Restarts this instance.
 
-         /// </summary>
 
-         public virtual void Restart(StartupOptions startupOptions)
 
-         {
 
-             throw new NotImplementedException();
 
-         }
 
-         /// <summary>
 
-         /// Determines whether this instance [can self restart].
 
-         /// </summary>
 
-         /// <returns><c>true</c> if this instance [can self restart]; otherwise, <c>false</c>.</returns>
 
-         public virtual bool CanSelfRestart
 
-         {
 
-             get
 
-             {
 
-                 return false;
 
-             }
 
-         }
 
-         /// <summary>
 
-         /// Gets a value indicating whether this instance can self update.
 
-         /// </summary>
 
-         /// <value><c>true</c> if this instance can self update; otherwise, <c>false</c>.</value>
 
-         public bool CanSelfUpdate
 
-         {
 
-             get
 
-             {
 
-                 return false;
 
-             }
 
-         }
 
-         public bool SupportsAutoRunAtStartup
 
-         {
 
-             get { return false; }
 
-         }
 
-         public void PreventSystemStandby()
 
-         {
 
-         }
 
-         public void AllowSystemStandby()
 
-         {
 
-         }
 
-         public List<Assembly> GetAssembliesWithParts()
 
-         {
 
-             var list = new List<Assembly>();
 
-             if (Environment.OperatingSystem == Startup.Common.OperatingSystem.Linux)
 
-             {
 
-                 list.AddRange(GetLinuxAssemblies());
 
-             }
 
-             list.Add(GetType().Assembly);
 
-             return list;
 
-         }
 
-         private IEnumerable<Assembly> GetLinuxAssemblies()
 
-         {
 
-             var list = new List<Assembly>();
 
-             list.Add(typeof(LinuxIsoManager).Assembly);
 
-             return list;
 
-         }
 
-         public void AuthorizeServer(int udpPort, int httpServerPort, int httpsPort, string applicationPath, string tempDirectory)
 
-         {
 
-         }
 
-         private NativeEnvironment _nativeEnvironment;
 
-         public NativeEnvironment Environment
 
-         {
 
-             get { return _nativeEnvironment ?? (_nativeEnvironment = GetEnvironmentInfo()); }
 
-         }
 
-         public bool SupportsRunningAsService
 
-         {
 
-             get
 
-             {
 
-                 return false;
 
-             }
 
-         }
 
-         public bool IsRunningAsService
 
-         {
 
-             get
 
-             {
 
-                 return false;
 
-             }
 
-         }
 
-         public bool SupportsLibraryMonitor
 
-         {
 
-             get
 
-             {
 
- 				return Environment.OperatingSystem != Startup.Common.OperatingSystem.Osx;
 
-             }
 
-         }
 
-         public void ConfigureAutoRun(bool autorun)
 
-         {
 
-         }
 
-         public INetworkManager CreateNetworkManager(ILogger logger)
 
-         {
 
-             return new NetworkManager(logger);
 
-         }
 
-         private NativeEnvironment GetEnvironmentInfo()
 
-         {
 
-             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 archX86 = new Regex("(i|I)[3-6]86");
 
-             if (archX86.IsMatch(uname.machine))
 
-             {
 
-                 info.SystemArchitecture = Architecture.X86;
 
-             }
 
-             else if (string.Equals(uname.machine, "x86_64", StringComparison.OrdinalIgnoreCase))
 
-             {
 
-                 info.SystemArchitecture = Architecture.X86_X64;
 
-             }
 
-             else if (uname.machine.StartsWith("arm", StringComparison.OrdinalIgnoreCase))
 
-             {
 
-                 info.SystemArchitecture = Architecture.Arm;
 
-             }
 
-             info.OperatingSystemVersionString = string.IsNullOrWhiteSpace(sysName) ?
 
-                 System.Environment.OSVersion.VersionString :
 
-                 sysName;
 
-             return info;
 
-         }
 
-         private Uname _unixName;
 
-         private Uname GetUnixName()
 
-         {
 
-             if (_unixName == null)
 
-             {
 
-                 var uname = new Uname();
 
-                 Utsname utsname;
 
-                 var callResult = Syscall.uname(out utsname);
 
-                 if (callResult == 0)
 
-                 {
 
-                     uname.sysname = utsname.sysname;
 
-                     uname.machine = utsname.machine;
 
-                 }
 
-                 _unixName = uname;
 
-             }
 
-             return _unixName;
 
-         }
 
-         public class Uname
 
-         {
 
-             public string sysname = string.Empty;
 
-             public string machine = string.Empty;
 
-         }
 
-         public IPowerManagement GetPowerManagement()
 
-         {
 
-             return new NullPowerManagement();
 
-         }
 
-         public FFMpegInstallInfo GetFfmpegInstallInfo()
 
-         {
 
-             return GetInfo(Environment);
 
-         }
 
-         public void LaunchUrl(string url)
 
-         {
 
-             throw new NotImplementedException();
 
-         }
 
-         public IDbConnector GetDbConnector()
 
-         {
 
-             return 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.Bsd:
 
-                     break;
 
-                 case OperatingSystem.Linux:
 
-                     info.ArchiveType = "7z";
 
-                     info.Version = "20160215";
 
-                     break;
 
-                 case OperatingSystem.Osx:
 
-                     info.ArchiveType = "7z";
 
-                     switch (environment.SystemArchitecture)
 
-                     {
 
-                         case Architecture.X86_X64:
 
-                             info.Version = "20160124";
 
-                             break;
 
-                         case Architecture.X86:
 
-                             info.Version = "20150110";
 
-                             break;
 
-                     }
 
-                     break;
 
-             }
 
-             info.DownloadUrls = GetDownloadUrls(environment);
 
-             return info;
 
-         }
 
-         private static string[] GetDownloadUrls(NativeEnvironment environment)
 
-         {
 
-             switch (environment.OperatingSystem)
 
-             {
 
-                 case OperatingSystem.Osx:
 
-                     switch (environment.SystemArchitecture)
 
-                     {
 
-                         case Architecture.X86_X64:
 
-                             return new[]
 
-                             {
 
-                                 "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/osx/ffmpeg-x64-2.8.5.7z"
 
-                             };
 
-                         case Architecture.X86:
 
-                             return new[]
 
-                             {
 
-                                 "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/osx/ffmpeg-x86-2.5.3.7z"
 
-                             };
 
-                     }
 
-                     break;
 
-                 case OperatingSystem.Linux:
 
-                     switch (environment.SystemArchitecture)
 
-                     {
 
-                         case Architecture.X86_X64:
 
-                             return new[]
 
-                             {
 
-                                 "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/linux/ffmpeg-git-20160215-64bit-static.7z"
 
-                             };
 
-                         case Architecture.X86:
 
-                             return new[]
 
-                             {
 
-                                 "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/linux/ffmpeg-git-20160215-32bit-static.7z"
 
-                             };
 
-                         case Architecture.Arm:
 
-                             return new[]
 
-                             {
 
-                                 "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/linux/ffmpeg-arm.7z"
 
-                             };
 
-                     }
 
-                     break;
 
-             }
 
-             // No version available 
 
-             return new string[] { };
 
-         }
 
-     }
 
-     public class NullPowerManagement : IPowerManagement
 
-     {
 
-         public void ScheduleWake(DateTime utcTime)
 
-         {
 
-             throw new NotImplementedException();
 
-         }
 
-     }
 
- }
 
 
  |