@ -16,7 +16,7 @@ using CommonIO;
namespace MediaBrowser.Server.Startup.Common.FFMpeg
namespace MediaBrowser.Server.Startup.Common.FFMpeg
{
{
public class FFMpeg Downl oader
public class FFMpeg L oader
{
{
private readonly IHttpClient _httpClient ;
private readonly IHttpClient _httpClient ;
private readonly IApplicationPaths _appPaths ;
private readonly IApplicationPaths _appPaths ;
@ -24,14 +24,15 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
private readonly IZipClient _zipClient ;
private readonly IZipClient _zipClient ;
private readonly IFileSystem _fileSystem ;
private readonly IFileSystem _fileSystem ;
private readonly NativeEnvironment _environment ;
private readonly NativeEnvironment _environment ;
private Assembly _ownerAssembly ;
private readonly Assembly _ownerAssembly ;
private readonly FFMpegInstallInfo _ffmpegInstallInfo ;
private readonly string [ ] _fontUrls =
private readonly string [ ] _fontUrls =
{
{
"https://github.com/MediaBrowser/MediaBrowser.Resources/raw/master/ffmpeg/ARIALUNI.7z"
"https://github.com/MediaBrowser/MediaBrowser.Resources/raw/master/ffmpeg/ARIALUNI.7z"
} ;
} ;
public FFMpeg Downl oader( ILogger logger , IApplicationPaths appPaths , IHttpClient httpClient , IZipClient zipClient , IFileSystem fileSystem , NativeEnvironment environment , Assembly ownerAssembly )
public FFMpeg L oader( ILogger logger , IApplicationPaths appPaths , IHttpClient httpClient , IZipClient zipClient , IFileSystem fileSystem , NativeEnvironment environment , Assembly ownerAssembly , FFMpegInstallInfo ffmpegInstallInfo )
{
{
_logger = logger ;
_logger = logger ;
_appPaths = appPaths ;
_appPaths = appPaths ;
@ -40,6 +41,7 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
_fileSystem = fileSystem ;
_fileSystem = fileSystem ;
_environment = environment ;
_environment = environment ;
_ownerAssembly = ownerAssembly ;
_ownerAssembly = ownerAssembly ;
_ffmpegInstallInfo = ffmpegInstallInfo ;
}
}
public async Task < FFMpegInfo > GetFFMpegInfo ( NativeEnvironment environment , StartupOptions options , IProgress < double > progress )
public async Task < FFMpegInfo > GetFFMpegInfo ( NativeEnvironment environment , StartupOptions options , IProgress < double > progress )
@ -57,7 +59,7 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
} ;
} ;
}
}
var downloadInfo = FFMpegDownloadInfo. GetInfo ( environment ) ;
var downloadInfo = _ffmpegInstallInfo ;
var version = downloadInfo . Version ;
var version = downloadInfo . Version ;
@ -181,7 +183,7 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
return null ;
return null ;
}
}
private async void DownloadFFMpegInBackground ( FFMpeg Download Info downloadinfo , string directory )
private async void DownloadFFMpegInBackground ( FFMpeg Install Info downloadinfo , string directory )
{
{
try
try
{
{
@ -193,7 +195,7 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
}
}
}
}
private async Task DownloadFFMpeg ( FFMpeg Download Info downloadinfo , string directory , IProgress < double > progress )
private async Task DownloadFFMpeg ( FFMpeg Install Info downloadinfo , string directory , IProgress < double > progress )
{
{
if ( downloadinfo . IsEmbedded )
if ( downloadinfo . IsEmbedded )
{
{
@ -241,7 +243,7 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
throw new ApplicationException ( "Unable to download required components. Please try again later." ) ;
throw new ApplicationException ( "Unable to download required components. Please try again later." ) ;
}
}
private void ExtractFFMpeg ( FFMpeg Download Info downloadinfo , string tempFile , string targetFolder )
private void ExtractFFMpeg ( FFMpeg Install Info downloadinfo , string tempFile , string targetFolder )
{
{
_logger . Info ( "Extracting ffmpeg from {0}" , tempFile ) ;
_logger . Info ( "Extracting ffmpeg from {0}" , tempFile ) ;
@ -287,7 +289,7 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
}
}
}
}
private void ExtractArchive ( FFMpeg Download Info downloadinfo , string archivePath , string targetPath )
private void ExtractArchive ( FFMpeg Install Info downloadinfo , string archivePath , string targetPath )
{
{
_logger . Info ( "Extracting {0} to {1}" , archivePath , targetPath ) ;
_logger . Info ( "Extracting {0} to {1}" , archivePath , targetPath ) ;