Kaynağa Gözat

Merge pull request #2593 from MediaBrowser/dev

Dev
Luke 8 yıl önce
ebeveyn
işleme
82b86449cb

+ 1 - 1
Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs

@@ -1765,7 +1765,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
 
                 if (regInfo.IsValid)
                 {
-                    return new EncodedRecorder(_logger, _fileSystem, _mediaEncoder, _config.ApplicationPaths, _jsonSerializer, config, _httpClient, _processFactory);
+                    return new EncodedRecorder(_logger, _fileSystem, _mediaEncoder, _config.ApplicationPaths, _jsonSerializer, config, _httpClient, _processFactory, _config);
                 }
             }
 

+ 17 - 2
Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs

@@ -11,14 +11,16 @@ using MediaBrowser.Model.IO;
 using MediaBrowser.Common.IO;
 using MediaBrowser.Common.Net;
 using MediaBrowser.Controller;
-using MediaBrowser.Controller.IO;
+using MediaBrowser.Controller.Configuration;
 using MediaBrowser.Controller.MediaEncoding;
+using MediaBrowser.Model.Configuration;
 using MediaBrowser.Model.Diagnostics;
 using MediaBrowser.Model.Dto;
 using MediaBrowser.Model.Entities;
 using MediaBrowser.Model.LiveTv;
 using MediaBrowser.Model.Logging;
 using MediaBrowser.Model.Serialization;
+using MediaBrowser.Common.Configuration;
 
 namespace Emby.Server.Implementations.LiveTv.EmbyTV
 {
@@ -37,8 +39,9 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
         private readonly IProcessFactory _processFactory;
         private readonly IJsonSerializer _json;
         private readonly TaskCompletionSource<bool> _taskCompletionSource = new TaskCompletionSource<bool>();
+        private readonly IServerConfigurationManager _config;
 
-        public EncodedRecorder(ILogger logger, IFileSystem fileSystem, IMediaEncoder mediaEncoder, IServerApplicationPaths appPaths, IJsonSerializer json, LiveTvOptions liveTvOptions, IHttpClient httpClient, IProcessFactory processFactory)
+        public EncodedRecorder(ILogger logger, IFileSystem fileSystem, IMediaEncoder mediaEncoder, IServerApplicationPaths appPaths, IJsonSerializer json, LiveTvOptions liveTvOptions, IHttpClient httpClient, IProcessFactory processFactory, IServerConfigurationManager config)
         {
             _logger = logger;
             _fileSystem = fileSystem;
@@ -48,6 +51,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
             _liveTvOptions = liveTvOptions;
             _httpClient = httpClient;
             _processFactory = processFactory;
+            _config = config;
         }
 
         private string OutputFormat
@@ -89,6 +93,11 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
             _logger.Info("Recording completed to file {0}", targetFile);
         }
 
+        private EncodingOptions GetEncodingOptions()
+        {
+            return _config.GetConfiguration<EncodingOptions>("encoding");
+        }
+
         private Task RecordFromFile(MediaSourceInfo mediaSource, string inputFile, string targetFile, TimeSpan duration, Action onStarted, CancellationToken cancellationToken)
         {
             _targetPath = targetFile;
@@ -163,6 +172,12 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
 
             var durationParam = " -t " + _mediaEncoder.GetTimeParameter(duration.Ticks);
             var inputModifiers = "-fflags +genpts -async 1 -vsync -1";
+
+            if (!string.IsNullOrWhiteSpace(GetEncodingOptions().HardwareAccelerationType))
+            {
+                inputModifiers += " -hwaccel auto";
+            }
+
             var commandLineArgs = "-i \"{0}\"{5} {2} -map_metadata -1 -threads 0 {3}{4}{6} -y \"{1}\"";
 
             long startTimeTicks = 0;

+ 2 - 2
MediaBrowser.Api/BaseApiService.cs

@@ -66,7 +66,7 @@ namespace MediaBrowser.Api
             return ResultFactory.GetOptimizedResult(Request, result);
         }
 
-        protected void AssertCanUpdateUser(IAuthorizationContext authContext, IUserManager userManager, string userId)
+        protected void AssertCanUpdateUser(IAuthorizationContext authContext, IUserManager userManager, string userId, bool restrictUserPreferences)
         {
             var auth = authContext.GetAuthorizationInfo(Request);
 
@@ -80,7 +80,7 @@ namespace MediaBrowser.Api
                     throw new SecurityException("Unauthorized access.");
                 }
             }
-            else
+            else if (restrictUserPreferences)
             {
                 if (!authenticatedUser.Policy.EnableUserPreferenceAccess)
                 {

+ 2 - 2
MediaBrowser.Api/Images/ImageService.cs

@@ -427,7 +427,7 @@ namespace MediaBrowser.Api.Images
         public void Post(PostUserImage request)
         {
             var userId = GetPathValue(1);
-            AssertCanUpdateUser(_authContext, _userManager, userId);
+            AssertCanUpdateUser(_authContext, _userManager, userId, true);
 
             request.Type = (ImageType)Enum.Parse(typeof(ImageType), GetPathValue(3), true);
 
@@ -462,7 +462,7 @@ namespace MediaBrowser.Api.Images
         public void Delete(DeleteUserImage request)
         {
             var userId = request.Id;
-            AssertCanUpdateUser(_authContext, _userManager, userId);
+            AssertCanUpdateUser(_authContext, _userManager, userId, true);
 
             var item = _userManager.GetUserById(userId);
 

+ 1 - 1
MediaBrowser.Api/TvShowsService.cs

@@ -497,7 +497,7 @@ namespace MediaBrowser.Api
                 }
                 else
                 {
-                    episodes = series.GetSeasonEpisodes(season, user);
+                    episodes = season.GetEpisodes(user);
                 }
             }
             else

+ 4 - 4
MediaBrowser.Api/UserService.cs

@@ -444,7 +444,7 @@ namespace MediaBrowser.Api
 
         public async Task PostAsync(UpdateUserPassword request)
         {
-            AssertCanUpdateUser(_authContext, _userManager, request.Id);
+            AssertCanUpdateUser(_authContext, _userManager, request.Id, true);
 
             var user = _userManager.GetUserById(request.Id);
 
@@ -482,7 +482,7 @@ namespace MediaBrowser.Api
         
         public async Task PostAsync(UpdateUserEasyPassword request)
         {
-            AssertCanUpdateUser(_authContext, _userManager, request.Id);
+            AssertCanUpdateUser(_authContext, _userManager, request.Id, true);
             
             var user = _userManager.GetUserById(request.Id);
 
@@ -518,7 +518,7 @@ namespace MediaBrowser.Api
             // https://code.google.com/p/servicestack/source/browse/trunk/Common/ServiceStack.Text/ServiceStack.Text/Controller/PathInfo.cs
             var id = GetPathValue(1);
 
-            AssertCanUpdateUser(_authContext, _userManager, id);
+            AssertCanUpdateUser(_authContext, _userManager, id, false);
 
             var dtoUser = request;
 
@@ -568,7 +568,7 @@ namespace MediaBrowser.Api
 
         public void Post(UpdateUserConfiguration request)
         {
-            AssertCanUpdateUser(_authContext, _userManager, request.Id);
+            AssertCanUpdateUser(_authContext, _userManager, request.Id, false);
 
             var task = _userManager.UpdateConfiguration(request.Id, request);
 

+ 5 - 0
MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs

@@ -1725,6 +1725,11 @@ namespace MediaBrowser.Controller.MediaEncoding
 
             if (state.VideoStream != null && !string.IsNullOrWhiteSpace(state.VideoStream.Codec))
             {
+                if (!string.IsNullOrWhiteSpace(encodingOptions.HardwareAccelerationType))
+                {
+                    return "-hwaccel auto";
+                }
+
                 if (string.Equals(encodingOptions.HardwareAccelerationType, "qsv", StringComparison.OrdinalIgnoreCase))
                 {
                     switch (state.MediaSource.VideoStream.Codec.ToLower())

+ 1 - 23
MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs

@@ -49,11 +49,6 @@ namespace MediaBrowser.MediaEncoding.Encoder
         /// </summary>
         private readonly SemaphoreSlim _thumbnailResourcePool = new SemaphoreSlim(1, 1);
 
-        /// <summary>
-        /// The FF probe resource pool
-        /// </summary>
-        private readonly SemaphoreSlim _ffProbeResourcePool = new SemaphoreSlim(2, 2);
-
         public string FFMpegPath { get; private set; }
 
         public string FFProbePath { get; private set; }
@@ -591,20 +586,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
 
             using (var processWrapper = new ProcessWrapper(process, this, _logger))
             {
-                await _ffProbeResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);
-
-                try
-                {
-                    StartProcess(processWrapper);
-                }
-                catch (Exception ex)
-                {
-                    _ffProbeResourcePool.Release();
-
-                    _logger.ErrorException("Error starting ffprobe", ex);
-
-                    throw;
-                }
+                StartProcess(processWrapper);
 
                 try
                 {
@@ -655,10 +637,6 @@ namespace MediaBrowser.MediaEncoding.Encoder
 
                     throw;
                 }
-                finally
-                {
-                    _ffProbeResourcePool.Release();
-                }
             }
         }
 

+ 1 - 2
MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs

@@ -524,8 +524,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
             {
                 if (!_fileSystem.FileExists(outputPath))
                 {
-                    await ExtractTextSubtitleInternal(_mediaEncoder.GetInputArgument(inputFiles, protocol), subtitleStreamIndex,
-                            outputCodec, outputPath, cancellationToken).ConfigureAwait(false);
+                    await ExtractTextSubtitleInternal(_mediaEncoder.GetInputArgument(inputFiles, protocol), subtitleStreamIndex, outputCodec, outputPath, cancellationToken).ConfigureAwait(false);
                 }
             }
             finally

+ 1 - 1
SharedVersion.cs

@@ -1,3 +1,3 @@
 using System.Reflection;
 
-[assembly: AssemblyVersion("3.2.13.1")]
+[assembly: AssemblyVersion("3.2.13.2")]