aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Startup.Common
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Server.Startup.Common')
-rw-r--r--MediaBrowser.Server.Startup.Common/ApplicationHost.cs35
-rw-r--r--MediaBrowser.Server.Startup.Common/Browser/BrowserLauncher.cs21
-rw-r--r--MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegDownloadInfo.cs20
-rw-r--r--MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegDownloader.cs16
-rw-r--r--MediaBrowser.Server.Startup.Common/FFMpeg/FFmpegValidator.cs91
-rw-r--r--MediaBrowser.Server.Startup.Common/Migrations/MigrateUserFolders.cs3
-rw-r--r--MediaBrowser.Server.Startup.Common/UnhandledExceptionWriter.cs4
7 files changed, 89 insertions, 101 deletions
diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
index 9ecd0764a..c38c81866 100644
--- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
+++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
@@ -42,7 +42,6 @@ using MediaBrowser.Controller.Social;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Controller.Subtitles;
using MediaBrowser.Controller.Sync;
-using MediaBrowser.Controller.Themes;
using MediaBrowser.Controller.TV;
using MediaBrowser.Dlna;
using MediaBrowser.Dlna.ConnectionManager;
@@ -87,7 +86,6 @@ using MediaBrowser.Server.Implementations.ServerManager;
using MediaBrowser.Server.Implementations.Session;
using MediaBrowser.Server.Implementations.Social;
using MediaBrowser.Server.Implementations.Sync;
-using MediaBrowser.Server.Implementations.Themes;
using MediaBrowser.Server.Implementations.TV;
using MediaBrowser.Server.Startup.Common.FFMpeg;
using MediaBrowser.Server.Startup.Common.Migrations;
@@ -124,7 +122,7 @@ namespace MediaBrowser.Server.Startup.Common
/// <returns>IConfigurationManager.</returns>
protected override IConfigurationManager GetConfigurationManager()
{
- return new ServerConfigurationManager(ApplicationPaths, LogManager, XmlSerializer);
+ return new ServerConfigurationManager(ApplicationPaths, LogManager, XmlSerializer, FileSystemManager);
}
/// <summary>
@@ -314,6 +312,7 @@ namespace MediaBrowser.Server.Startup.Common
await base.RunStartupTasks().ConfigureAwait(false);
Logger.Info("Core startup complete");
+ HttpServer.GlobalResponse = null;
Parallel.ForEach(GetExports<IServerEntryPoint>(), entryPoint =>
{
@@ -434,6 +433,7 @@ namespace MediaBrowser.Server.Startup.Common
RegisterSingleInstance<ISearchEngine>(() => new SearchEngine(LogManager, LibraryManager, UserManager));
HttpServer = ServerFactory.CreateServer(this, LogManager, ServerConfigurationManager, "Emby", "web/index.html");
+ HttpServer.GlobalResponse = LocalizationManager.GetLocalizedString("StartupEmbyServerIsLoading");
RegisterSingleInstance(HttpServer, false);
progress.Report(10);
@@ -458,7 +458,7 @@ namespace MediaBrowser.Server.Startup.Common
var encryptionManager = new EncryptionManager();
RegisterSingleInstance<IEncryptionManager>(encryptionManager);
- ConnectManager = new ConnectManager(LogManager.GetLogger("Connect"), ApplicationPaths, JsonSerializer, encryptionManager, HttpClient, this, ServerConfigurationManager, UserManager, ProviderManager, SecurityManager);
+ ConnectManager = new ConnectManager(LogManager.GetLogger("Connect"), ApplicationPaths, JsonSerializer, encryptionManager, HttpClient, this, ServerConfigurationManager, UserManager, ProviderManager, SecurityManager, FileSystemManager);
RegisterSingleInstance(ConnectManager);
DeviceManager = new DeviceManager(new DeviceRepository(ApplicationPaths, JsonSerializer, LogManager.GetLogger("DeviceManager"), FileSystemManager), UserManager, FileSystemManager, LibraryMonitor, ConfigurationManager, LogManager.GetLogger("DeviceManager"), NetworkManager);
@@ -475,15 +475,12 @@ namespace MediaBrowser.Server.Startup.Common
ChannelManager = new ChannelManager(UserManager, DtoService, LibraryManager, LogManager.GetLogger("ChannelManager"), ServerConfigurationManager, FileSystemManager, UserDataManager, JsonSerializer, LocalizationManager, HttpClient);
RegisterSingleInstance(ChannelManager);
- MediaSourceManager = new MediaSourceManager(ItemRepository, UserManager, LibraryManager, LogManager.GetLogger("MediaSourceManager"), JsonSerializer);
+ MediaSourceManager = new MediaSourceManager(ItemRepository, UserManager, LibraryManager, LogManager.GetLogger("MediaSourceManager"), JsonSerializer, FileSystemManager);
RegisterSingleInstance(MediaSourceManager);
SessionManager = new SessionManager(UserDataManager, LogManager.GetLogger("SessionManager"), UserRepository, LibraryManager, UserManager, musicManager, DtoService, ImageProcessor, JsonSerializer, this, HttpClient, AuthenticationRepository, DeviceManager, MediaSourceManager);
RegisterSingleInstance(SessionManager);
- var appThemeManager = new AppThemeManager(ApplicationPaths, FileSystemManager, JsonSerializer, Logger);
- RegisterSingleInstance<IAppThemeManager>(appThemeManager);
-
var dlnaManager = new DlnaManager(XmlSerializer, FileSystemManager, ApplicationPaths, LogManager.GetLogger("Dlna"), JsonSerializer, this);
RegisterSingleInstance<IDlnaManager>(dlnaManager);
@@ -573,7 +570,7 @@ namespace MediaBrowser.Server.Startup.Common
{
try
{
- return new ImageMagickEncoder(LogManager.GetLogger("ImageMagick"), ApplicationPaths, HttpClient);
+ return new ImageMagickEncoder(LogManager.GetLogger("ImageMagick"), ApplicationPaths, HttpClient, FileSystemManager);
}
catch (Exception ex)
{
@@ -598,9 +595,7 @@ namespace MediaBrowser.Server.Startup.Common
var info = await new FFMpegDownloader(Logger, ApplicationPaths, HttpClient, ZipClient, FileSystemManager, NativeApp.Environment)
.GetFFMpegInfo(NativeApp.Environment, _startupOptions, progress).ConfigureAwait(false);
- new FFmpegValidator(Logger, ApplicationPaths).Validate(info);
-
- MediaEncoder = new MediaEncoder(LogManager.GetLogger("MediaEncoder"),
+ var mediaEncoder = new MediaEncoder(LogManager.GetLogger("MediaEncoder"),
JsonSerializer,
info.EncoderPath,
info.ProbePath,
@@ -614,7 +609,17 @@ namespace MediaBrowser.Server.Startup.Common
SessionManager,
() => SubtitleEncoder,
() => MediaSourceManager);
+
+ MediaEncoder = mediaEncoder;
RegisterSingleInstance(MediaEncoder);
+
+ Task.Run(() =>
+ {
+ var result = new FFmpegValidator(Logger, ApplicationPaths, FileSystemManager).Validate(info);
+
+ mediaEncoder.SetAvailableDecoders(result.Item1);
+ mediaEncoder.SetAvailableEncoders(result.Item2);
+ });
}
/// <summary>
@@ -793,7 +798,7 @@ namespace MediaBrowser.Server.Startup.Common
SessionManager.AddParts(GetExports<ISessionControllerFactory>());
- ChannelManager.AddParts(GetExports<IChannel>(), GetExports<IChannelFactory>());
+ ChannelManager.AddParts(GetExports<IChannel>());
MediaSourceManager.AddParts(GetExports<IMediaSourceProvider>());
@@ -851,9 +856,9 @@ namespace MediaBrowser.Server.Startup.Common
if (generateCertificate)
{
- if (!File.Exists(certPath))
+ if (!FileSystemManager.FileExists(certPath))
{
- Directory.CreateDirectory(Path.GetDirectoryName(certPath));
+ FileSystemManager.CreateDirectory(Path.GetDirectoryName(certPath));
try
{
diff --git a/MediaBrowser.Server.Startup.Common/Browser/BrowserLauncher.cs b/MediaBrowser.Server.Startup.Common/Browser/BrowserLauncher.cs
index 3eeb072a8..a4504f25a 100644
--- a/MediaBrowser.Server.Startup.Common/Browser/BrowserLauncher.cs
+++ b/MediaBrowser.Server.Startup.Common/Browser/BrowserLauncher.cs
@@ -24,15 +24,6 @@ namespace MediaBrowser.Server.Startup.Common.Browser
}
/// <summary>
- /// Opens the github.
- /// </summary>
- /// <param name="logger">The logger.</param>
- public static void OpenGithub(ILogger logger)
- {
- OpenUrl("https://github.com/MediaBrowser/MediaBrowser", logger);
- }
-
- /// <summary>
/// Opens the community.
/// </summary>
/// <param name="logger">The logger.</param>
@@ -62,18 +53,6 @@ namespace MediaBrowser.Server.Startup.Common.Browser
}
/// <summary>
- /// Opens the swagger.
- /// </summary>
- /// <param name="appHost">The app host.</param>
- /// <param name="logger">The logger.</param>
- public static void OpenSwagger(IServerApplicationHost appHost, ILogger logger)
- {
- var url = appHost.GetLocalApiUrl("localhost") + "/swagger-ui/index.html";
-
- OpenUrl(url, logger);
- }
-
- /// <summary>
/// Opens the URL.
/// </summary>
/// <param name="url">The URL.</param>
diff --git a/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegDownloadInfo.cs b/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegDownloadInfo.cs
index 2910479ef..42fc73488 100644
--- a/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegDownloadInfo.cs
+++ b/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegDownloadInfo.cs
@@ -33,7 +33,7 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
case OperatingSystem.Linux:
info.ArchiveType = "7z";
- info.Version = "20150717";
+ info.Version = "20150917";
break;
case OperatingSystem.Osx:
@@ -42,7 +42,7 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
switch (environment.SystemArchitecture)
{
case Architecture.X86_X64:
- info.Version = "20150827";
+ info.Version = "20150917";
break;
case Architecture.X86:
info.Version = "20150110";
@@ -54,7 +54,7 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
info.FFMpegFilename = "ffmpeg.exe";
info.FFProbeFilename = "ffprobe.exe";
- info.Version = "20150717";
+ info.Version = "20150918";
info.ArchiveType = "7z";
switch (environment.SystemArchitecture)
@@ -83,14 +83,14 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
case Architecture.X86_X64:
return new[]
{
- "http://ffmpeg.zeranoe.com/builds/win64/static/ffmpeg-20150717-git-8250943-win64-static.7z",
- "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/windows/ffmpeg-20150901-git-b54e03c-win64-static.7z"
+ "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/windows/ffmpeg-20150918-win64.7z",
+ "http://ffmpeg.zeranoe.com/builds/win64/static/ffmpeg-20150916-git-cbbd906-win64-static.7z"
};
case Architecture.X86:
return new[]
{
- "http://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-20150717-git-8250943-win32-static.7z",
- "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/windows/ffmpeg-20150901-git-b54e03c-win32-static.7z"
+ "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/windows/ffmpeg-20150918-win32.7z",
+ "http://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-20150916-git-cbbd906-win32-static.7z"
};
}
break;
@@ -102,7 +102,7 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
case Architecture.X86_X64:
return new[]
{
- "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/osx/ffmpeg-x64-2.7.2.7z"
+ "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/osx/ffmpeg-x64-2.8.0.7z"
};
case Architecture.X86:
return new[]
@@ -119,12 +119,12 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
case Architecture.X86_X64:
return new[]
{
- "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/linux/ffmpeg-2.7.1-64bit-static.7z"
+ "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/linux/ffmpeg-2.8.0-64bit-static.7z"
};
case Architecture.X86:
return new[]
{
- "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/linux/ffmpeg-2.7.1-32bit-static.7z"
+ "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/linux/ffmpeg-2.8.0-32bit-static.7z"
};
}
break;
diff --git a/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegDownloader.cs b/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegDownloader.cs
index fe7cd943a..16864898a 100644
--- a/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegDownloader.cs
+++ b/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegDownloader.cs
@@ -78,11 +78,11 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
Version = version
};
- Directory.CreateDirectory(versionedDirectoryPath);
+ _fileSystem.CreateDirectory(versionedDirectoryPath);
var excludeFromDeletions = new List<string> { versionedDirectoryPath };
- if (!File.Exists(info.ProbePath) || !File.Exists(info.EncoderPath))
+ if (!_fileSystem.FileExists(info.ProbePath) || !_fileSystem.FileExists(info.EncoderPath))
{
// ffmpeg not present. See if there's an older version we can start with
var existingVersion = GetExistingVersion(info, rootEncoderPath);
@@ -218,7 +218,7 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
var tempFolder = Path.Combine(_appPaths.TempDirectory, Guid.NewGuid().ToString());
- Directory.CreateDirectory(tempFolder);
+ _fileSystem.CreateDirectory(tempFolder);
try
{
@@ -237,7 +237,7 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
}))
{
var targetFile = Path.Combine(targetFolder, Path.GetFileName(file));
- File.Copy(file, targetFile, true);
+ _fileSystem.CopyFile(file, targetFile, true);
SetFilePermissions(targetFile);
}
}
@@ -301,13 +301,13 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
{
var fontsDirectory = Path.Combine(targetPath, "fonts");
- Directory.CreateDirectory(fontsDirectory);
+ _fileSystem.CreateDirectory(fontsDirectory);
const string fontFilename = "ARIALUNI.TTF";
var fontFile = Path.Combine(fontsDirectory, fontFilename);
- if (File.Exists(fontFile))
+ if (_fileSystem.FileExists(fontFile))
{
await WriteFontConfigFile(fontsDirectory).ConfigureAwait(false);
}
@@ -350,7 +350,7 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
{
try
{
- File.Copy(existingFile, Path.Combine(fontsDirectory, fontFilename), true);
+ _fileSystem.CopyFile(existingFile, Path.Combine(fontsDirectory, fontFilename), true);
return;
}
catch (IOException ex)
@@ -412,7 +412,7 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
const string fontConfigFilename = "fonts.conf";
var fontConfigFile = Path.Combine(fontsDirectory, fontConfigFilename);
- if (!File.Exists(fontConfigFile))
+ if (!_fileSystem.FileExists(fontConfigFile))
{
var contents = string.Format("<?xml version=\"1.0\"?><fontconfig><dir>{0}</dir><alias><family>Arial</family><prefer>Arial Unicode MS</prefer></alias></fontconfig>", fontsDirectory);
diff --git a/MediaBrowser.Server.Startup.Common/FFMpeg/FFmpegValidator.cs b/MediaBrowser.Server.Startup.Common/FFMpeg/FFmpegValidator.cs
index 124a7f74b..d3388f47e 100644
--- a/MediaBrowser.Server.Startup.Common/FFMpeg/FFmpegValidator.cs
+++ b/MediaBrowser.Server.Startup.Common/FFMpeg/FFmpegValidator.cs
@@ -6,6 +6,8 @@ using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Text;
+using MediaBrowser.Common.IO;
+using System.Collections.Generic;
namespace MediaBrowser.Server.Startup.Common.FFMpeg
{
@@ -13,78 +15,74 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
{
private readonly ILogger _logger;
private readonly IApplicationPaths _appPaths;
+ private readonly IFileSystem _fileSystem;
- public FFmpegValidator(ILogger logger, IApplicationPaths appPaths)
+ public FFmpegValidator(ILogger logger, IApplicationPaths appPaths, IFileSystem fileSystem)
{
_logger = logger;
_appPaths = appPaths;
+ _fileSystem = fileSystem;
}
- public void Validate(FFMpegInfo info)
+ public Tuple<List<string>,List<string>> Validate(FFMpegInfo info)
{
_logger.Info("FFMpeg: {0}", info.EncoderPath);
_logger.Info("FFProbe: {0}", info.ProbePath);
- string cacheKey;
+ var decoders = GetDecoders(info.EncoderPath);
+ var encoders = GetEncoders(info.EncoderPath);
- try
- {
- cacheKey = new FileInfo(info.EncoderPath).Length.ToString(CultureInfo.InvariantCulture).GetMD5().ToString("N");
- }
- catch (IOException)
- {
- // This could happen if ffmpeg is coming from a Path variable and we don't have the full path
- cacheKey = Guid.NewGuid().ToString("N");
- }
- catch
- {
- cacheKey = Guid.NewGuid().ToString("N");
- }
-
- var cachePath = Path.Combine(_appPaths.CachePath, "1" + cacheKey);
-
- ValidateCodecs(info.EncoderPath, cachePath);
+ return new Tuple<List<string>, List<string>>(decoders, encoders);
}
- private void ValidateCodecs(string ffmpegPath, string cachePath)
+ private List<string> GetDecoders(string ffmpegPath)
{
- string output = null;
+ string output = string.Empty;
try
{
- output = File.ReadAllText(cachePath, Encoding.UTF8);
+ output = GetFFMpegOutput(ffmpegPath, "-decoders");
}
catch
{
-
}
- if (string.IsNullOrWhiteSpace(output))
+ var found = new List<string>();
+ var required = new[]
{
- try
- {
- output = GetFFMpegOutput(ffmpegPath, "-encoders");
- }
- catch
- {
- return;
- }
+ "h264_qsv",
+ "mpeg2_qsv",
+ "vc1_qsv"
+ };
- try
+ foreach (var codec in required)
+ {
+ var srch = " " + codec + " ";
+
+ if (output.IndexOf(srch, StringComparison.OrdinalIgnoreCase) == -1)
{
- Directory.CreateDirectory(Path.GetDirectoryName(cachePath));
- File.WriteAllText(cachePath, output, Encoding.UTF8);
+ _logger.Warn("ffmpeg is missing decoder " + codec);
}
- catch
+ else
{
-
+ found.Add(codec);
}
}
- ValidateCodecsFromOutput(output);
+ return found;
}
- private void ValidateCodecsFromOutput(string output)
+ private List<string> GetEncoders(string ffmpegPath)
{
+ string output = null;
+ try
+ {
+ output = GetFFMpegOutput(ffmpegPath, "-encoders");
+ }
+ catch
+ {
+ }
+
+ var found = new List<string>();
var required = new[]
{
"libx264",
@@ -100,16 +98,21 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
"srt"
};
- foreach (var encoder in required)
+ foreach (var codec in required)
{
- var srch = " " + encoder + " ";
+ var srch = " " + codec + " ";
if (output.IndexOf(srch, StringComparison.OrdinalIgnoreCase) == -1)
{
- _logger.Error("ffmpeg is missing encoder " + encoder);
- //throw new ArgumentException("ffmpeg is missing encoder " + encoder);
+ _logger.Warn("ffmpeg is missing encoder " + codec);
+ }
+ else
+ {
+ found.Add(codec);
}
}
+
+ return found;
}
private string GetFFMpegOutput(string path, string arguments)
diff --git a/MediaBrowser.Server.Startup.Common/Migrations/MigrateUserFolders.cs b/MediaBrowser.Server.Startup.Common/Migrations/MigrateUserFolders.cs
index cb566d6cf..1dfe4c0b5 100644
--- a/MediaBrowser.Server.Startup.Common/Migrations/MigrateUserFolders.cs
+++ b/MediaBrowser.Server.Startup.Common/Migrations/MigrateUserFolders.cs
@@ -23,7 +23,8 @@ namespace MediaBrowser.Server.Startup.Common.Migrations
{
var rootPath = _appPaths.RootFolderPath;
- var folders = new DirectoryInfo(rootPath).EnumerateDirectories("*", SearchOption.TopDirectoryOnly).Where(i => !string.Equals(i.Name, "default", StringComparison.OrdinalIgnoreCase))
+ var folders = _fileSystem.GetDirectories(rootPath)
+ .Where(i => !string.Equals(i.Name, "default", StringComparison.OrdinalIgnoreCase))
.ToList();
foreach (var folder in folders)
diff --git a/MediaBrowser.Server.Startup.Common/UnhandledExceptionWriter.cs b/MediaBrowser.Server.Startup.Common/UnhandledExceptionWriter.cs
index 96c24eaab..804533b9d 100644
--- a/MediaBrowser.Server.Startup.Common/UnhandledExceptionWriter.cs
+++ b/MediaBrowser.Server.Startup.Common/UnhandledExceptionWriter.cs
@@ -25,7 +25,7 @@ namespace MediaBrowser.Server.Startup.Common
_logManager.Flush();
var path = Path.Combine(_appPaths.LogDirectoryPath, "unhandled_" + Guid.NewGuid() + ".txt");
- Directory.CreateDirectory(Path.GetDirectoryName(path));
+ Directory.CreateDirectory(Path.GetDirectoryName(path));
var builder = LogHelper.GetLogMessage(ex);
@@ -33,7 +33,7 @@ namespace MediaBrowser.Server.Startup.Common
Console.WriteLine("UnhandledException");
Console.WriteLine(builder.ToString());
- File.WriteAllText(path, builder.ToString());
+ File.WriteAllText(path, builder.ToString());
}
}
}