diff options
| author | Luke <luke.pulverenti@gmail.com> | 2017-05-12 14:19:33 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-05-12 14:19:33 -0400 |
| commit | 1a6ee3d48aec8aa592ea2b0aab9560292ce717d6 (patch) | |
| tree | 558b953b1e01a16bd47d902c841cc747a50e0ae7 /MediaBrowser.ServerApplication | |
| parent | 65db32b1f878cd478e9f4b2b4c988890a7ca47c9 (diff) | |
| parent | 3cdb75190d457cbb3bed91bf79bfb4816cad29e2 (diff) | |
Merge pull request #2633 from MediaBrowser/beta
Beta
Diffstat (limited to 'MediaBrowser.ServerApplication')
5 files changed, 114 insertions, 68 deletions
diff --git a/MediaBrowser.ServerApplication/ImageEncoderHelper.cs b/MediaBrowser.ServerApplication/ImageEncoderHelper.cs index ddbde2f66..b8fa097d6 100644 --- a/MediaBrowser.ServerApplication/ImageEncoderHelper.cs +++ b/MediaBrowser.ServerApplication/ImageEncoderHelper.cs @@ -2,6 +2,7 @@ using Emby.Drawing; using Emby.Drawing.Net; using Emby.Drawing.ImageMagick; +using Emby.Drawing.Skia; using Emby.Server.Core; using Emby.Server.Implementations; using MediaBrowser.Common.Configuration; @@ -25,6 +26,15 @@ namespace MediaBrowser.Server.Startup.Common { try { + return new SkiaEncoder(logManager.GetLogger("Skia"), appPaths, httpClient, fileSystem); + } + catch + { + logger.Error("Error loading Skia. Will revert to ImageMagick."); + } + + try + { return new ImageMagickEncoder(logManager.GetLogger("ImageMagick"), appPaths, httpClient, fileSystem); } catch diff --git a/MediaBrowser.ServerApplication/MainStartup.cs b/MediaBrowser.ServerApplication/MainStartup.cs index 8e38c9a98..272054609 100644 --- a/MediaBrowser.ServerApplication/MainStartup.cs +++ b/MediaBrowser.ServerApplication/MainStartup.cs @@ -22,6 +22,7 @@ using Emby.Common.Implementations.IO; using Emby.Common.Implementations.Logging; using Emby.Common.Implementations.Networking; using Emby.Common.Implementations.Security; +using Emby.Drawing; using Emby.Server.Core; using Emby.Server.Core.Logging; using Emby.Server.Implementations; @@ -335,8 +336,6 @@ namespace MediaBrowser.ServerApplication var fileSystem = new ManagedFileSystem(logManager.GetLogger("FileSystem"), environmentInfo, appPaths.TempDirectory); - var imageEncoder = ImageEncoderHelper.GetImageEncoder(_logger, logManager, fileSystem, options, () => _appHost.HttpClient, appPaths); - FileSystem = fileSystem; _appHost = new WindowsAppHost(appPaths, @@ -346,7 +345,7 @@ namespace MediaBrowser.ServerApplication new PowerManagement(), "emby.windows.zip", environmentInfo, - imageEncoder, + new NullImageEncoder(), new Server.Startup.Common.SystemEvents(logManager.GetLogger("SystemEvents")), new RecyclableMemoryStreamProvider(), new Networking.NetworkManager(logManager.GetLogger("NetworkManager")), @@ -367,6 +366,19 @@ namespace MediaBrowser.ServerApplication var task = _appHost.Init(initProgress); Task.WaitAll(task); + if (!runService) + { + task = InstallVcredist2013IfNeeded(_appHost, _logger); + Task.WaitAll(task); + + // needed by skia + task = InstallVcredist2015IfNeeded(_appHost, _logger); + Task.WaitAll(task); + } + + // set image encoder here + _appHost.ImageProcessor.ImageEncoder = ImageEncoderHelper.GetImageEncoder(_logger, logManager, fileSystem, options, () => _appHost.HttpClient, appPaths); + task = task.ContinueWith(new Action<Task>(a => _appHost.RunStartupTasks()), TaskContinuationOptions.OnlyOnRanToCompletion | TaskContinuationOptions.AttachedToParent); if (runService) @@ -377,9 +389,6 @@ namespace MediaBrowser.ServerApplication { Task.WaitAll(task); - task = InstallVcredist2013IfNeeded(_appHost, _logger); - Task.WaitAll(task); - Microsoft.Win32.SystemEvents.SessionSwitch += SystemEvents_SessionSwitch; HideSplashScreen(); @@ -736,32 +745,61 @@ namespace MediaBrowser.ServerApplication Process.Start(startInfo); } - private static bool CanRestartWindowsService() + private static async Task InstallVcredist2013IfNeeded(ApplicationHost appHost, ILogger logger) { - var startInfo = new ProcessStartInfo - { - FileName = "cmd.exe", - CreateNoWindow = true, - WindowStyle = ProcessWindowStyle.Hidden, - Verb = "runas", - ErrorDialog = false, - Arguments = String.Format("/c sc query {0}", BackgroundService.GetExistingServiceName()) - }; - using (var process = Process.Start(startInfo)) + // Reference + // http://stackoverflow.com/questions/12206314/detect-if-visual-c-redistributable-for-visual-studio-2012-is-installed + + try { - process.WaitForExit(); - if (process.ExitCode == 0) - { - return true; - } - else + var subkey = Environment.Is64BitProcess + ? "SOFTWARE\\WOW6432Node\\Microsoft\\VisualStudio\\12.0\\VC\\Runtimes\\x64" + : "SOFTWARE\\Microsoft\\VisualStudio\\12.0\\VC\\Runtimes\\x86"; + + using (RegistryKey ndpKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Default) + .OpenSubKey(subkey)) { - return false; + if (ndpKey != null && ndpKey.GetValue("Version") != null) + { + var installedVersion = ((string)ndpKey.GetValue("Version")).TrimStart('v'); + if (installedVersion.StartsWith("12", StringComparison.OrdinalIgnoreCase)) + { + return; + } + } } } + catch (Exception ex) + { + logger.ErrorException("Error getting .NET Framework version", ex); + return; + } + + MessageBox.Show("The Visual C++ 2013 Runtime will now be installed.", "Install Visual C++ Runtime", MessageBoxButtons.OK, MessageBoxIcon.Information); + + try + { + await InstallVcredist(GetVcredist2013Url()).ConfigureAwait(false); + } + catch (Exception ex) + { + logger.ErrorException("Error installing Visual Studio C++ runtime", ex); + } } - private static async Task InstallVcredist2013IfNeeded(ApplicationHost appHost, ILogger logger) + private static string GetVcredist2013Url() + { + if (Environment.Is64BitProcess) + { + return "https://github.com/MediaBrowser/Emby.Resources/raw/master/vcredist2013/vcredist_x64.exe"; + } + + // TODO: ARM url - https://github.com/MediaBrowser/Emby.Resources/raw/master/vcredist2013/vcredist_arm.exe + + return "https://github.com/MediaBrowser/Emby.Resources/raw/master/vcredist2013/vcredist_x86.exe"; + } + + private static async Task InstallVcredist2015IfNeeded(ApplicationHost appHost, ILogger logger) { // Reference // http://stackoverflow.com/questions/12206314/detect-if-visual-c-redistributable-for-visual-studio-2012-is-installed @@ -769,8 +807,8 @@ namespace MediaBrowser.ServerApplication try { var subkey = Environment.Is64BitProcess - ? "SOFTWARE\\WOW6432Node\\Microsoft\\VisualStudio\\12.0\\VC\\Runtimes\\x64" - : "SOFTWARE\\Microsoft\\VisualStudio\\12.0\\VC\\Runtimes\\x86"; + ? "SOFTWARE\\WOW6432Node\\Microsoft\\VisualStudio\\14.0\\VC\\Runtimes\\x64" + : "SOFTWARE\\Microsoft\\VisualStudio\\14.0\\VC\\Runtimes\\x86"; using (RegistryKey ndpKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Default) .OpenSubKey(subkey)) @@ -778,7 +816,7 @@ namespace MediaBrowser.ServerApplication if (ndpKey != null && ndpKey.GetValue("Version") != null) { var installedVersion = ((string)ndpKey.GetValue("Version")).TrimStart('v'); - if (installedVersion.StartsWith("12", StringComparison.OrdinalIgnoreCase)) + if (installedVersion.StartsWith("14", StringComparison.OrdinalIgnoreCase)) { return; } @@ -791,9 +829,11 @@ namespace MediaBrowser.ServerApplication return; } + MessageBox.Show("The Visual C++ 2015 Runtime will now be installed.", "Install Visual C++ Runtime", MessageBoxButtons.OK, MessageBoxIcon.Information); + try { - await InstallVcredist2013().ConfigureAwait(false); + await InstallVcredist(GetVcredist2015Url()).ConfigureAwait(false); } catch (Exception ex) { @@ -801,13 +841,25 @@ namespace MediaBrowser.ServerApplication } } - private async static Task InstallVcredist2013() + private static string GetVcredist2015Url() + { + if (Environment.Is64BitProcess) + { + return "https://github.com/MediaBrowser/Emby.Resources/raw/master/vcredist2015/vc_redist.x64.exe"; + } + + // TODO: ARM url - https://github.com/MediaBrowser/Emby.Resources/raw/master/vcredist2015/vcredist_arm.exe + + return "https://github.com/MediaBrowser/Emby.Resources/raw/master/vcredist2015/vc_redist.x86.exe"; + } + + private async static Task InstallVcredist(string url) { var httpClient = _appHost.HttpClient; var tmp = await httpClient.GetTempFile(new HttpRequestOptions { - Url = GetVcredist2013Url(), + Url = url, Progress = new Progress<double>() }).ConfigureAwait(false); @@ -833,18 +885,6 @@ namespace MediaBrowser.ServerApplication } } - private static string GetVcredist2013Url() - { - if (Environment.Is64BitProcess) - { - return "https://github.com/MediaBrowser/Emby.Resources/raw/master/vcredist2013/vcredist_x64.exe"; - } - - // TODO: ARM url - https://github.com/MediaBrowser/Emby.Resources/raw/master/vcredist2013/vcredist_arm.exe - - return "https://github.com/MediaBrowser/Emby.Resources/raw/master/vcredist2013/vcredist_x86.exe"; - } - /// <summary> /// Sets the error mode. /// </summary> diff --git a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj index 749468fe2..d632007d2 100644 --- a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj +++ b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj @@ -99,12 +99,16 @@ <HintPath>..\packages\SimpleInjector.3.3.2\lib\net45\SimpleInjector.dll</HintPath> <Private>True</Private> </Reference> + <Reference Include="SkiaSharp, Version=1.57.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL"> + <HintPath>..\packages\SkiaSharp.1.57.1\lib\net45\SkiaSharp.dll</HintPath> + <Private>True</Private> + </Reference> <Reference Include="SQLitePCLRaw.core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1488e028ca7ab535, processorArchitecture=MSIL"> - <HintPath>..\packages\SQLitePCLRaw.core.1.1.2\lib\net45\SQLitePCLRaw.core.dll</HintPath> + <HintPath>..\packages\SQLitePCLRaw.core.1.1.5\lib\net45\SQLitePCLRaw.core.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="SQLitePCLRaw.provider.sqlite3, Version=1.0.0.0, Culture=neutral, PublicKeyToken=62684c7b4f184e3f, processorArchitecture=MSIL"> - <HintPath>..\packages\SQLitePCLRaw.provider.sqlite3.net45.1.1.2\lib\net45\SQLitePCLRaw.provider.sqlite3.dll</HintPath> + <HintPath>..\packages\SQLitePCLRaw.provider.sqlite3.net45.1.1.5\lib\net45\SQLitePCLRaw.provider.sqlite3.dll</HintPath> <Private>True</Private> </Reference> <Reference Include="System" /> @@ -185,6 +189,14 @@ </EmbeddedResource> </ItemGroup> <ItemGroup> + <Content Include="..\packages\SkiaSharp.1.57.1\runtimes\win7-x64\native\libSkiaSharp.dll"> + <Link>x64\libSkiaSharp.dll</Link> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <Content Include="..\packages\SkiaSharp.1.57.1\runtimes\win7-x86\native\libSkiaSharp.dll"> + <Link>x86\libSkiaSharp.dll</Link> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> <Content Include="..\Tools\Installation\MediaBrowser.InstallUtil.dll"> <Link>MediaBrowser.InstallUtil.dll</Link> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> @@ -1100,6 +1112,10 @@ <Project>{c97a239e-a96c-4d64-a844-ccf8cc30aecb}</Project> <Name>Emby.Drawing.Net</Name> </ProjectReference> + <ProjectReference Include="..\Emby.Drawing.Skia\Emby.Drawing.Skia.csproj"> + <Project>{2312da6d-ff86-4597-9777-bceec32d96dd}</Project> + <Name>Emby.Drawing.Skia</Name> + </ProjectReference> <ProjectReference Include="..\Emby.Drawing\Emby.Drawing.csproj"> <Project>{08fff49b-f175-4807-a2b5-73b0ebd9f716}</Project> <Name>Emby.Drawing</Name> diff --git a/MediaBrowser.ServerApplication/Native/LoopUtil.cs b/MediaBrowser.ServerApplication/Native/LoopUtil.cs index 9a96f5518..7c7471231 100644 --- a/MediaBrowser.ServerApplication/Native/LoopUtil.cs +++ b/MediaBrowser.ServerApplication/Native/LoopUtil.cs @@ -57,10 +57,6 @@ namespace MediaBrowser.ServerApplication.Native } - // Call this API to free the memory returned by the Enumeration API - [DllImport("FirewallAPI.dll")] - internal static extern void NetworkIsolationFreeAppContainers(IntPtr pACs); - // Call this API to load the current list of LoopUtil-enabled AppContainers [DllImport("FirewallAPI.dll")] internal static extern uint NetworkIsolationGetAppContainerConfig(out uint pdwCntACs, out IntPtr appContainerSids); @@ -69,23 +65,13 @@ namespace MediaBrowser.ServerApplication.Native [DllImport("FirewallAPI.dll")] private static extern uint NetworkIsolationSetAppContainerConfig(uint pdwCntACs, SID_AND_ATTRIBUTES[] appContainerSids); - // Use this API to convert a string SID into an actual SID [DllImport("advapi32.dll", SetLastError = true)] internal static extern bool ConvertStringSidToSid(string strSid, out IntPtr pSid); [DllImport("advapi32", /*CharSet = CharSet.Auto,*/ SetLastError = true)] - static extern bool ConvertSidToStringSid( - [MarshalAs(UnmanagedType.LPArray)] byte[] pSID, - out IntPtr ptrSid); - - [DllImport("advapi32", /*CharSet = CharSet.Auto,*/ SetLastError = true)] static extern bool ConvertSidToStringSid(IntPtr pSid, out string strSid); - // Use this API to convert a string reference (e.g. "@{blah.pri?ms-resource://whatever}") into a plain string - [DllImport("shlwapi.dll", CharSet = CharSet.Unicode, ExactSpelling = true)] - internal static extern int SHLoadIndirectString(string pszSource, StringBuilder pszOutBuf); - // Call this API to enumerate all of the AppContainers on the system [DllImport("FirewallAPI.dll")] internal static extern uint NetworkIsolationEnumAppContainers(uint Flags, out uint pdwCntPublicACs, out IntPtr ppACs); @@ -196,7 +182,6 @@ namespace MediaBrowser.ServerApplication.Native { util.SaveLoopbackState(); } - util.SaveLoopbackState(); } private static List<SID_AND_ATTRIBUTES> PI_NetworkIsolationGetAppContainerConfig() @@ -305,11 +290,5 @@ namespace MediaBrowser.ServerApplication.Native } return count; } - - public void FreeResources() - { - NetworkIsolationFreeAppContainers(_pACs); - } - } } diff --git a/MediaBrowser.ServerApplication/packages.config b/MediaBrowser.ServerApplication/packages.config index 68d0a7fda..2d4ba6170 100644 --- a/MediaBrowser.ServerApplication/packages.config +++ b/MediaBrowser.ServerApplication/packages.config @@ -5,6 +5,7 @@ <package id="ServiceStack.Text" version="4.5.4" targetFramework="net462" /> <package id="SharpCompress" version="0.14.0" targetFramework="net462" /> <package id="SimpleInjector" version="3.3.2" targetFramework="net462" /> - <package id="SQLitePCLRaw.core" version="1.1.2" targetFramework="net462" /> - <package id="SQLitePCLRaw.provider.sqlite3.net45" version="1.1.2" targetFramework="net462" /> + <package id="SkiaSharp" version="1.57.1" targetFramework="net462" /> + <package id="SQLitePCLRaw.core" version="1.1.5" targetFramework="net462" /> + <package id="SQLitePCLRaw.provider.sqlite3.net45" version="1.1.5" targetFramework="net462" /> </packages>
\ No newline at end of file |
