crobibero styling, format, code suggestions

This commit is contained in:
Nick 2023-05-01 12:51:05 -07:00
parent dd8ef08592
commit 3377032228
9 changed files with 655 additions and 667 deletions

View File

@ -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)

View File

@ -5,8 +5,8 @@ using System.Threading.Tasks;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Entities;
namespace MediaBrowser.Controller.Trickplay
{
namespace MediaBrowser.Controller.Trickplay;
/// <summary>
/// Interface ITrickplayManager.
/// </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.
@ -51,4 +51,3 @@ namespace MediaBrowser.Controller.Trickplay
/// <returns>The absolute path.</returns>
string GetTrickplayTilePath(BaseItem item, int width, int index);
}
}

View File

@ -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.

View File

@ -1,8 +1,8 @@
using System.Collections.Generic;
using System.Diagnostics;
namespace MediaBrowser.Model.Configuration
{
namespace MediaBrowser.Model.Configuration;
/// <summary>
/// Class TrickplayOptions.
/// </summary>
@ -58,4 +58,3 @@ namespace MediaBrowser.Model.Configuration
/// </summary>
public int ProcessThreads { get; set; } = 0;
}
}

View File

@ -1,5 +1,5 @@
namespace MediaBrowser.Model.Configuration
{
namespace MediaBrowser.Model.Configuration;
/// <summary>
/// Enum TrickplayScanBehavior.
/// </summary>
@ -15,4 +15,3 @@ namespace MediaBrowser.Model.Configuration
/// </summary>
NonBlocking
}
}

View File

@ -1,5 +1,5 @@
namespace MediaBrowser.Model.Entities
{
namespace MediaBrowser.Model.Entities;
/// <summary>
/// Class TrickplayTilesInfo.
/// </summary>
@ -47,4 +47,3 @@ namespace MediaBrowser.Model.Entities
/// <value>The bandwidth.</value>
public int Bandwidth { get; set; }
}
}

View File

@ -12,8 +12,8 @@ using MediaBrowser.Model.Globalization;
using MediaBrowser.Model.Tasks;
using Microsoft.Extensions.Logging;
namespace MediaBrowser.Providers.Trickplay
{
namespace MediaBrowser.Providers.Trickplay;
/// <summary>
/// Class TrickplayImagesTask.
/// </summary>
@ -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)
{
@ -106,4 +106,3 @@ namespace MediaBrowser.Providers.Trickplay
}
}
}
}

View File

@ -17,8 +17,8 @@ using MediaBrowser.Model.IO;
using Microsoft.Extensions.Logging;
using SkiaSharp;
namespace MediaBrowser.Providers.Trickplay
{
namespace MediaBrowser.Providers.Trickplay;
/// <summary>
/// ITrickplayManager implementation.
/// </summary>
@ -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);
@ -383,4 +383,3 @@ namespace MediaBrowser.Providers.Trickplay
}
}
}
}

View File

@ -10,8 +10,8 @@ using MediaBrowser.Controller.Trickplay;
using MediaBrowser.Model.Configuration;
using Microsoft.Extensions.Logging;
namespace MediaBrowser.Providers.Trickplay
{
namespace MediaBrowser.Providers.Trickplay;
/// <summary>
/// Class TrickplayProvider. Provides images and metadata for trickplay
/// scrubbing previews.
@ -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;
}
}
}