crobibero styling, format, code suggestions

pull/9554/head
Nick 1 year ago
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,8 +5,8 @@ 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> /// <summary>
/// Interface ITrickplayManager. /// Interface ITrickplayManager.
/// </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.
@ -51,4 +51,3 @@ namespace MediaBrowser.Controller.Trickplay
/// <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,8 +1,8 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
namespace MediaBrowser.Model.Configuration namespace MediaBrowser.Model.Configuration;
{
/// <summary> /// <summary>
/// Class TrickplayOptions. /// Class TrickplayOptions.
/// </summary> /// </summary>
@ -58,4 +58,3 @@ namespace MediaBrowser.Model.Configuration
/// </summary> /// </summary>
public int ProcessThreads { get; set; } = 0; public int ProcessThreads { get; set; } = 0;
} }
}

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

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

@ -12,8 +12,8 @@ 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> /// <summary>
/// Class TrickplayImagesTask. /// Class TrickplayImagesTask.
/// </summary> /// </summary>
@ -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)
{ {
@ -106,4 +106,3 @@ namespace MediaBrowser.Providers.Trickplay
} }
} }
} }
}

@ -17,8 +17,8 @@ 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> /// <summary>
/// ITrickplayManager implementation. /// ITrickplayManager implementation.
/// </summary> /// </summary>
@ -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);
@ -383,4 +383,3 @@ namespace MediaBrowser.Providers.Trickplay
} }
} }
} }
}

@ -10,8 +10,8 @@ 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.
@ -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…
Cancel
Save