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