MacAppHost.cs 4.2 KB

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