2015-10-12 12:09:56 -07:00
|
|
|
|
using MediaBrowser.Common.Net;
|
2014-11-09 11:24:57 -07:00
|
|
|
|
using MediaBrowser.Model.Logging;
|
|
|
|
|
using MediaBrowser.Server.Startup.Common;
|
|
|
|
|
using MediaBrowser.ServerApplication.Networking;
|
|
|
|
|
using System.Collections.Generic;
|
2016-04-03 10:34:52 -07:00
|
|
|
|
using System.IO;
|
2014-11-09 11:24:57 -07:00
|
|
|
|
using System.Reflection;
|
2015-10-03 21:23:11 -07:00
|
|
|
|
using CommonIO;
|
2016-01-21 10:29:14 -07:00
|
|
|
|
using MediaBrowser.Controller.Power;
|
2016-04-01 21:29:48 -07:00
|
|
|
|
using MediaBrowser.Server.Startup.Common.FFMpeg;
|
2014-11-09 11:24:57 -07:00
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.ServerApplication.Native
|
|
|
|
|
{
|
|
|
|
|
public class WindowsApp : INativeApp
|
|
|
|
|
{
|
2015-01-12 20:46:44 -07:00
|
|
|
|
private readonly IFileSystem _fileSystem;
|
2016-01-21 10:45:42 -07:00
|
|
|
|
private readonly ILogger _logger;
|
2015-01-12 20:46:44 -07:00
|
|
|
|
|
2016-01-21 10:45:42 -07:00
|
|
|
|
public WindowsApp(IFileSystem fileSystem, ILogger logger)
|
2015-01-12 20:46:44 -07:00
|
|
|
|
{
|
|
|
|
|
_fileSystem = fileSystem;
|
2016-01-21 10:45:42 -07:00
|
|
|
|
_logger = logger;
|
2015-01-12 20:46:44 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-11-09 11:24:57 -07:00
|
|
|
|
public List<Assembly> GetAssembliesWithParts()
|
|
|
|
|
{
|
|
|
|
|
var list = new List<Assembly>();
|
|
|
|
|
|
2015-10-12 12:09:56 -07:00
|
|
|
|
if (!System.Environment.Is64BitProcess)
|
|
|
|
|
{
|
2016-01-06 09:57:15 -07:00
|
|
|
|
//list.Add(typeof(PismoIsoManager).Assembly);
|
2015-10-12 12:09:56 -07:00
|
|
|
|
}
|
2014-11-09 11:24:57 -07:00
|
|
|
|
|
|
|
|
|
list.Add(GetType().Assembly);
|
2016-04-01 21:29:48 -07:00
|
|
|
|
|
2014-11-09 11:24:57 -07:00
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-26 10:51:27 -07:00
|
|
|
|
public void AuthorizeServer(int udpPort, int httpServerPort, int httpsPort, string applicationPath, string tempDirectory)
|
2014-11-09 11:24:57 -07:00
|
|
|
|
{
|
2016-03-26 10:51:27 -07:00
|
|
|
|
ServerAuthorization.AuthorizeServer(udpPort, httpServerPort, httpsPort, applicationPath, tempDirectory);
|
2014-11-09 11:24:57 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public NativeEnvironment Environment
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return new NativeEnvironment
|
|
|
|
|
{
|
|
|
|
|
OperatingSystem = OperatingSystem.Windows,
|
2014-11-23 16:10:41 -07:00
|
|
|
|
SystemArchitecture = System.Environment.Is64BitOperatingSystem ? Architecture.X86_X64 : Architecture.X86,
|
|
|
|
|
OperatingSystemVersionString = System.Environment.OSVersion.VersionString
|
2014-11-09 11:24:57 -07:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-03 11:13:53 -07:00
|
|
|
|
public bool SupportsLibraryMonitor
|
|
|
|
|
{
|
|
|
|
|
get { return true; }
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-09 11:24:57 -07:00
|
|
|
|
public bool SupportsRunningAsService
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsRunningAsService
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool CanSelfRestart
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return MainStartup.CanSelfRestart;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool SupportsAutoRunAtStartup
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool CanSelfUpdate
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return MainStartup.CanSelfUpdate;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Shutdown()
|
|
|
|
|
{
|
|
|
|
|
MainStartup.Shutdown();
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-05 07:27:01 -07:00
|
|
|
|
public void Restart(StartupOptions startupOptions)
|
2014-11-09 11:24:57 -07:00
|
|
|
|
{
|
|
|
|
|
MainStartup.Restart();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ConfigureAutoRun(bool autorun)
|
|
|
|
|
{
|
2016-04-03 10:34:52 -07:00
|
|
|
|
var shortcutPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.StartMenu), "Emby", "Emby Server.lnk");
|
|
|
|
|
|
|
|
|
|
var startupPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Startup);
|
|
|
|
|
|
|
|
|
|
if (autorun)
|
|
|
|
|
{
|
|
|
|
|
//Copy our shortut into the startup folder for this user
|
|
|
|
|
var targetPath = Path.Combine(startupPath, Path.GetFileName(shortcutPath) ?? "Emby Server.lnk");
|
|
|
|
|
_fileSystem.CreateDirectory(Path.GetDirectoryName(targetPath));
|
|
|
|
|
File.Copy(shortcutPath, targetPath, true);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//Remove our shortcut from the startup folder for this user
|
|
|
|
|
_fileSystem.DeleteFile(Path.Combine(startupPath, Path.GetFileName(shortcutPath) ?? "Emby Server.lnk"));
|
|
|
|
|
}
|
2014-11-09 11:24:57 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public INetworkManager CreateNetworkManager(ILogger logger)
|
|
|
|
|
{
|
|
|
|
|
return new NetworkManager(logger);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void PreventSystemStandby()
|
|
|
|
|
{
|
|
|
|
|
Standby.PreventSystemStandby();
|
|
|
|
|
}
|
2016-01-21 10:29:14 -07:00
|
|
|
|
|
|
|
|
|
public IPowerManagement GetPowerManagement()
|
|
|
|
|
{
|
2016-01-21 10:45:42 -07:00
|
|
|
|
return new WindowsPowerManagement(_logger);
|
2016-01-21 10:29:14 -07:00
|
|
|
|
}
|
2016-04-01 21:29:48 -07:00
|
|
|
|
|
|
|
|
|
public FFMpegInstallInfo GetFfmpegInstallInfo()
|
|
|
|
|
{
|
|
|
|
|
var info = new FFMpegInstallInfo();
|
|
|
|
|
|
|
|
|
|
info.FFMpegFilename = "ffmpeg.exe";
|
|
|
|
|
info.FFProbeFilename = "ffprobe.exe";
|
|
|
|
|
info.Version = "20160401";
|
|
|
|
|
info.ArchiveType = "7z";
|
|
|
|
|
info.IsEmbedded = true;
|
|
|
|
|
info.DownloadUrls = GetDownloadUrls();
|
|
|
|
|
|
|
|
|
|
return info;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string[] GetDownloadUrls()
|
|
|
|
|
{
|
|
|
|
|
switch (Environment.SystemArchitecture)
|
|
|
|
|
{
|
|
|
|
|
case Architecture.X86_X64:
|
|
|
|
|
return new[] { "MediaBrowser.ServerApplication.ffmpeg.ffmpegx64.7z" };
|
|
|
|
|
case Architecture.X86:
|
|
|
|
|
return new[] { "MediaBrowser.ServerApplication.ffmpeg.ffmpegx86.7z" };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new string[] { };
|
|
|
|
|
}
|
2014-11-09 11:24:57 -07:00
|
|
|
|
}
|
|
|
|
|
}
|