2
0

MonoAppHost.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Reflection;
  4. using Emby.Server.Core;
  5. using Emby.Server.Implementations;
  6. using Emby.Server.Implementations.FFMpeg;
  7. using MediaBrowser.IsoMounter;
  8. using MediaBrowser.Model.IO;
  9. using MediaBrowser.Model.Logging;
  10. using MediaBrowser.Model.System;
  11. namespace MediaBrowser.Server.Mono
  12. {
  13. public class MonoAppHost : ApplicationHost
  14. {
  15. public MonoAppHost(ServerApplicationPaths applicationPaths, ILogManager logManager, StartupOptions options, IFileSystem fileSystem, IPowerManagement powerManagement, string releaseAssetFilename, IEnvironmentInfo environmentInfo, MediaBrowser.Controller.Drawing.IImageEncoder imageEncoder, ISystemEvents systemEvents, IMemoryStreamFactory memoryStreamFactory, MediaBrowser.Common.Net.INetworkManager networkManager, Action<string, string> certificateGenerator, Func<string> defaultUsernameFactory) : base(applicationPaths, logManager, options, fileSystem, powerManagement, releaseAssetFilename, environmentInfo, imageEncoder, systemEvents, memoryStreamFactory, networkManager, certificateGenerator, defaultUsernameFactory)
  16. {
  17. }
  18. public override bool CanSelfRestart
  19. {
  20. get
  21. {
  22. // A restart script must be provided
  23. return StartupOptions.ContainsOption("-restartpath");
  24. }
  25. }
  26. public override bool CanSelfUpdate
  27. {
  28. get
  29. {
  30. return false;
  31. }
  32. }
  33. protected override FFMpegInstallInfo GetFfmpegInstallInfo()
  34. {
  35. var info = new FFMpegInstallInfo();
  36. // Windows builds: http://ffmpeg.zeranoe.com/builds/
  37. // Linux builds: http://johnvansickle.com/ffmpeg/
  38. // OS X builds: http://ffmpegmac.net/
  39. // OS X x64: http://www.evermeet.cx/ffmpeg/
  40. var environment = (MonoEnvironmentInfo) EnvironmentInfo;
  41. if (environment.IsBsd)
  42. {
  43. }
  44. else if (environment.OperatingSystem == Model.System.OperatingSystem.Linux)
  45. {
  46. info.ArchiveType = "7z";
  47. info.Version = "20160215";
  48. }
  49. // No version available - user requirement
  50. info.DownloadUrls = new string[] { };
  51. return info;
  52. }
  53. protected override void RestartInternal()
  54. {
  55. MainClass.Restart(StartupOptions);
  56. }
  57. protected override List<Assembly> GetAssembliesWithPartsInternal()
  58. {
  59. var list = new List<Assembly>();
  60. list.Add(GetType().Assembly);
  61. list.AddRange(GetLinuxAssemblies());
  62. return list;
  63. }
  64. private IEnumerable<Assembly> GetLinuxAssemblies()
  65. {
  66. var list = new List<Assembly>();
  67. list.Add(typeof(LinuxIsoManager).Assembly);
  68. return list;
  69. }
  70. protected override void ShutdownInternal()
  71. {
  72. MainClass.Shutdown();
  73. }
  74. protected override bool SupportsDualModeSockets
  75. {
  76. get
  77. {
  78. return GetMonoVersion() >= new Version(4, 6);
  79. }
  80. }
  81. private static Version GetMonoVersion()
  82. {
  83. Type type = Type.GetType("Mono.Runtime");
  84. if (type != null)
  85. {
  86. MethodInfo displayName = type.GetTypeInfo().GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static);
  87. var displayNameValue = displayName.Invoke(null, null).ToString().Trim().Split(' ')[0];
  88. Version version;
  89. if (Version.TryParse(displayNameValue, out version))
  90. {
  91. return version;
  92. }
  93. }
  94. return new Version(1, 0);
  95. }
  96. protected override void AuthorizeServer()
  97. {
  98. throw new NotImplementedException();
  99. }
  100. protected override void ConfigureAutoRunInternal(bool autorun)
  101. {
  102. throw new NotImplementedException();
  103. }
  104. public override void LaunchUrl(string url)
  105. {
  106. throw new NotImplementedException();
  107. }
  108. protected override void EnableLoopbackInternal(string appName)
  109. {
  110. }
  111. public override bool SupportsRunningAsService
  112. {
  113. get
  114. {
  115. return false;
  116. }
  117. }
  118. public override bool SupportsAutoRunAtStartup
  119. {
  120. get { return false; }
  121. }
  122. public override bool IsRunningAsService
  123. {
  124. get
  125. {
  126. return false;
  127. }
  128. }
  129. }
  130. }