mirror of https://github.com/jellyfin/jellyfin.git
crobibero styling, format, code suggestions
This commit is contained in:
parent
dd8ef08592
commit
3377032228
|
@ -90,6 +90,13 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||
{ "truehd", 6 },
|
||||
};
|
||||
|
||||
private static readonly string _defaultMjpegEncoder = "mjpeg";
|
||||
private static readonly Dictionary<string, string> _mjpegCodecMap = new(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
{ "vaapi", _defaultMjpegEncoder + "_vaapi" },
|
||||
{ "qsv", _defaultMjpegEncoder + "_qsv" }
|
||||
};
|
||||
|
||||
public static readonly string[] LosslessAudioCodecs = new string[]
|
||||
{
|
||||
"alac",
|
||||
|
@ -151,32 +158,20 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||
|
||||
private string GetMjpegEncoder(EncodingJobInfo state, EncodingOptions encodingOptions)
|
||||
{
|
||||
var defaultEncoder = "mjpeg";
|
||||
|
||||
if (state.VideoType == VideoType.VideoFile)
|
||||
{
|
||||
var hwType = encodingOptions.HardwareAccelerationType;
|
||||
|
||||
var codecMap = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
{ "vaapi", defaultEncoder + "_vaapi" },
|
||||
{ "qsv", defaultEncoder + "_qsv" }
|
||||
};
|
||||
|
||||
if (!string.IsNullOrEmpty(hwType)
|
||||
&& encodingOptions.EnableHardwareEncoding
|
||||
&& codecMap.ContainsKey(hwType))
|
||||
{
|
||||
var preferredEncoder = codecMap[hwType];
|
||||
|
||||
if (_mediaEncoder.SupportsEncoder(preferredEncoder))
|
||||
&& _mjpegCodecMap.TryGetValue(hwType, out var preferredEncoder)
|
||||
&& _mediaEncoder.SupportsEncoder(preferredEncoder))
|
||||
{
|
||||
return preferredEncoder;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return defaultEncoder;
|
||||
return _defaultMjpegEncoder;
|
||||
}
|
||||
|
||||
private bool IsVaapiSupported(EncodingJobInfo state)
|
||||
|
|
|
@ -5,13 +5,13 @@ using System.Threading.Tasks;
|
|||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Model.Entities;
|
||||
|
||||
namespace MediaBrowser.Controller.Trickplay
|
||||
namespace MediaBrowser.Controller.Trickplay;
|
||||
|
||||
/// <summary>
|
||||
/// Interface ITrickplayManager.
|
||||
/// </summary>
|
||||
public interface ITrickplayManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface ITrickplayManager.
|
||||
/// </summary>
|
||||
public interface ITrickplayManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Generate or replace trickplay data.
|
||||
/// </summary>
|
||||
|
@ -19,7 +19,7 @@ namespace MediaBrowser.Controller.Trickplay
|
|||
/// <param name="replace">Whether or not existing data should be replaced.</param>
|
||||
/// <param name="cancellationToken">CancellationToken to use for operation.</param>
|
||||
/// <returns>Task.</returns>
|
||||
Task RefreshTrickplayData(Video video, bool replace, CancellationToken cancellationToken);
|
||||
Task RefreshTrickplayDataAsync(Video video, bool replace, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Get available trickplay resolutions and corresponding info.
|
||||
|
@ -50,5 +50,4 @@ namespace MediaBrowser.Controller.Trickplay
|
|||
/// <param name="index">The tile grid's index.</param>
|
||||
/// <returns>The absolute path.</returns>
|
||||
string GetTrickplayTilePath(BaseItem item, int width, int index);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -793,7 +793,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|||
CancellationToken cancellationToken)
|
||||
{
|
||||
var options = allowHwAccel ? _configurationManager.GetEncodingOptions() : new EncodingOptions();
|
||||
threads = threads ?? _threads;
|
||||
threads ??= _threads;
|
||||
|
||||
// A new EncodingOptions instance must be used as to not disable HW acceleration for all of Jellyfin.
|
||||
// Additionally, we must set a few fields without defaults to prevent null pointer exceptions.
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace MediaBrowser.Model.Configuration
|
||||
namespace MediaBrowser.Model.Configuration;
|
||||
|
||||
/// <summary>
|
||||
/// Class TrickplayOptions.
|
||||
/// </summary>
|
||||
public class TrickplayOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Class TrickplayOptions.
|
||||
/// </summary>
|
||||
public class TrickplayOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether or not to use HW acceleration.
|
||||
/// </summary>
|
||||
|
@ -57,5 +57,4 @@ namespace MediaBrowser.Model.Configuration
|
|||
/// Gets or sets the number of threads to be used by ffmpeg.
|
||||
/// </summary>
|
||||
public int ProcessThreads { get; set; } = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
namespace MediaBrowser.Model.Configuration
|
||||
namespace MediaBrowser.Model.Configuration;
|
||||
|
||||
/// <summary>
|
||||
/// Enum TrickplayScanBehavior.
|
||||
/// </summary>
|
||||
public enum TrickplayScanBehavior
|
||||
{
|
||||
/// <summary>
|
||||
/// Enum TrickplayScanBehavior.
|
||||
/// </summary>
|
||||
public enum TrickplayScanBehavior
|
||||
{
|
||||
/// <summary>
|
||||
/// Starts generation, only return once complete.
|
||||
/// </summary>
|
||||
|
@ -14,5 +14,4 @@ namespace MediaBrowser.Model.Configuration
|
|||
/// Start generation, return immediately.
|
||||
/// </summary>
|
||||
NonBlocking
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
namespace MediaBrowser.Model.Entities
|
||||
namespace MediaBrowser.Model.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Class TrickplayTilesInfo.
|
||||
/// </summary>
|
||||
public class TrickplayTilesInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Class TrickplayTilesInfo.
|
||||
/// </summary>
|
||||
public class TrickplayTilesInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets width of an individual tile.
|
||||
/// </summary>
|
||||
|
@ -46,5 +46,4 @@ namespace MediaBrowser.Model.Entities
|
|||
/// </summary>
|
||||
/// <value>The bandwidth.</value>
|
||||
public int Bandwidth { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,13 +12,13 @@ using MediaBrowser.Model.Globalization;
|
|||
using MediaBrowser.Model.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace MediaBrowser.Providers.Trickplay
|
||||
namespace MediaBrowser.Providers.Trickplay;
|
||||
|
||||
/// <summary>
|
||||
/// Class TrickplayImagesTask.
|
||||
/// </summary>
|
||||
public class TrickplayImagesTask : IScheduledTask
|
||||
{
|
||||
/// <summary>
|
||||
/// Class TrickplayImagesTask.
|
||||
/// </summary>
|
||||
public class TrickplayImagesTask : IScheduledTask
|
||||
{
|
||||
private readonly ILogger<TrickplayImagesTask> _logger;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly ILocalizationManager _localization;
|
||||
|
@ -86,7 +86,7 @@ namespace MediaBrowser.Providers.Trickplay
|
|||
try
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
await _trickplayManager.RefreshTrickplayData(item, false, cancellationToken).ConfigureAwait(false);
|
||||
await _trickplayManager.RefreshTrickplayDataAsync(item, false, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
|
@ -105,5 +105,4 @@ namespace MediaBrowser.Providers.Trickplay
|
|||
progress.Report(percent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,13 +17,13 @@ using MediaBrowser.Model.IO;
|
|||
using Microsoft.Extensions.Logging;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace MediaBrowser.Providers.Trickplay
|
||||
namespace MediaBrowser.Providers.Trickplay;
|
||||
|
||||
/// <summary>
|
||||
/// ITrickplayManager implementation.
|
||||
/// </summary>
|
||||
public class TrickplayManager : ITrickplayManager
|
||||
{
|
||||
/// <summary>
|
||||
/// ITrickplayManager implementation.
|
||||
/// </summary>
|
||||
public class TrickplayManager : ITrickplayManager
|
||||
{
|
||||
private readonly ILogger<TrickplayManager> _logger;
|
||||
private readonly IItemRepository _itemRepo;
|
||||
private readonly IMediaEncoder _mediaEncoder;
|
||||
|
@ -63,7 +63,7 @@ namespace MediaBrowser.Providers.Trickplay
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task RefreshTrickplayData(Video video, bool replace, CancellationToken cancellationToken)
|
||||
public async Task RefreshTrickplayDataAsync(Video video, bool replace, CancellationToken cancellationToken)
|
||||
{
|
||||
_logger.LogDebug("Trickplay refresh for {ItemId} (replace existing: {Replace})", video.Id, replace);
|
||||
|
||||
|
@ -382,5 +382,4 @@ namespace MediaBrowser.Providers.Trickplay
|
|||
Directory.Delete(source, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,13 +10,13 @@ using MediaBrowser.Controller.Trickplay;
|
|||
using MediaBrowser.Model.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace MediaBrowser.Providers.Trickplay
|
||||
{
|
||||
/// <summary>
|
||||
/// Class TrickplayProvider. Provides images and metadata for trickplay
|
||||
/// scrubbing previews.
|
||||
/// </summary>
|
||||
public class TrickplayProvider : ICustomMetadataProvider<Episode>,
|
||||
namespace MediaBrowser.Providers.Trickplay;
|
||||
|
||||
/// <summary>
|
||||
/// Class TrickplayProvider. Provides images and metadata for trickplay
|
||||
/// scrubbing previews.
|
||||
/// </summary>
|
||||
public class TrickplayProvider : ICustomMetadataProvider<Episode>,
|
||||
ICustomMetadataProvider<MusicVideo>,
|
||||
ICustomMetadataProvider<Movie>,
|
||||
ICustomMetadataProvider<Trailer>,
|
||||
|
@ -24,7 +24,7 @@ namespace MediaBrowser.Providers.Trickplay
|
|||
IHasItemChangeMonitor,
|
||||
IHasOrder,
|
||||
IForcedProvider
|
||||
{
|
||||
{
|
||||
private readonly ILogger<TrickplayProvider> _logger;
|
||||
private readonly IServerConfigurationManager _config;
|
||||
private readonly ITrickplayManager _trickplayManager;
|
||||
|
@ -113,15 +113,14 @@ namespace MediaBrowser.Providers.Trickplay
|
|||
|
||||
if (_config.Configuration.TrickplayOptions.ScanBehavior == TrickplayScanBehavior.Blocking)
|
||||
{
|
||||
await _trickplayManager.RefreshTrickplayData(video, replace, cancellationToken).ConfigureAwait(false);
|
||||
await _trickplayManager.RefreshTrickplayDataAsync(video, replace, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
_ = _trickplayManager.RefreshTrickplayData(video, replace, cancellationToken).ConfigureAwait(false);
|
||||
_ = _trickplayManager.RefreshTrickplayDataAsync(video, replace, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
// The core doesn't need to trigger any save operations over this
|
||||
return ItemUpdateType.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue