MacAppHost.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Reflection;
  4. using Emby.Server.Core;
  5. using Emby.Server.Core.Data;
  6. using Emby.Server.Core.FFMpeg;
  7. using MediaBrowser.IsoMounter;
  8. using MediaBrowser.Model.IO;
  9. using MediaBrowser.Model.Logging;
  10. using MediaBrowser.Model.System;
  11. using MediaBrowser.Server.Mono.Native;
  12. using System.Diagnostics;
  13. namespace MediaBrowser.Server.Mac
  14. {
  15. public class MacAppHost
  16. {
  17. public MacAppHost(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)
  18. {
  19. }
  20. public override bool CanSelfRestart
  21. {
  22. get
  23. {
  24. return false;
  25. }
  26. }
  27. public override bool CanSelfUpdate
  28. {
  29. get
  30. {
  31. return false;
  32. }
  33. }
  34. protected override FFMpegInstallInfo GetFfmpegInstallInfo()
  35. {
  36. var info = new FFMpegInstallInfo();
  37. info.ArchiveType = "7z";
  38. switch (EnvironmentInfo.SystemArchitecture)
  39. {
  40. case Architecture.X64:
  41. info.Version = "20160124";
  42. break;
  43. case Architecture.X86:
  44. info.Version = "20150110";
  45. break;
  46. }
  47. info.DownloadUrls = GetDownloadUrls(environment);
  48. return info;
  49. }
  50. private static string[] GetDownloadUrls(NativeEnvironment environment)
  51. {
  52. switch (EnvironmentInfo.SystemArchitecture)
  53. {
  54. case Architecture.X64:
  55. return new[]
  56. {
  57. "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/osx/ffmpeg-x64-2.8.5.7z"
  58. };
  59. }
  60. // No version available
  61. return new string[] { };
  62. }
  63. protected override void RestartInternal()
  64. {
  65. MainClass.Restart(StartupOptions);
  66. }
  67. protected override List<Assembly> GetAssembliesWithPartsInternal()
  68. {
  69. var list = new List<Assembly>();
  70. list.Add(GetType().Assembly);
  71. return list;
  72. }
  73. protected override void ShutdownInternal()
  74. {
  75. MainClass.Shutdown();
  76. }
  77. protected override void AuthorizeServer()
  78. {
  79. throw new NotImplementedException();
  80. }
  81. protected override IDbConnector GetDbConnector()
  82. {
  83. return new DbConnector(Logger);
  84. }
  85. protected override void ConfigureAutoRunInternal(bool autorun)
  86. {
  87. throw new NotImplementedException();
  88. }
  89. public override void LaunchUrl(string url)
  90. {
  91. var process = new Process
  92. {
  93. StartInfo = new ProcessStartInfo
  94. {
  95. FileName = url
  96. },
  97. EnableRaisingEvents = true,
  98. };
  99. process.Exited += ProcessExited;
  100. process.Start();
  101. }
  102. private static void ProcessExited(object sender, EventArgs e)
  103. {
  104. ((Process)sender).Dispose();
  105. }
  106. protected override void EnableLoopbackInternal(string appName)
  107. {
  108. }
  109. public override bool SupportsRunningAsService
  110. {
  111. get
  112. {
  113. return false;
  114. }
  115. }
  116. public override bool SupportsAutoRunAtStartup
  117. {
  118. get { return false; }
  119. }
  120. public override bool IsRunningAsService
  121. {
  122. get
  123. {
  124. return false;
  125. }
  126. }
  127. }
  128. }