Merge branch 'master' into network-rewrite

This commit is contained in:
Shadowghost
2023-05-09 15:25:41 +02:00
154 changed files with 1724 additions and 1078 deletions

View File

@@ -14,6 +14,7 @@ public class EncodingOptions
public EncodingOptions()
{
EnableFallbackFont = false;
EnableAudioVbr = false;
DownMixAudioBoost = 2;
DownMixStereoAlgorithm = DownMixStereoAlgorithms.None;
MaxMuxingQueueSize = 2048;
@@ -71,6 +72,11 @@ public class EncodingOptions
/// </summary>
public bool EnableFallbackFont { get; set; }
/// <summary>
/// Gets or sets a value indicating whether audio VBR is enabled.
/// </summary>
public bool EnableAudioVbr { get; set; }
/// <summary>
/// Gets or sets the audio boost applied when downmixing audio.
/// </summary>

View File

@@ -2,7 +2,6 @@
#pragma warning disable CA1819
using System;
using System.Collections.Generic;
using MediaBrowser.Model.Drawing;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Updates;

View File

@@ -80,7 +80,8 @@ namespace MediaBrowser.Model.Cryptography
{
throw new FormatException("Hash string must contain a valid id");
}
else if (nextSegment == -1)
if (nextSegment == -1)
{
return new PasswordHash(hashString.ToString(), Array.Empty<byte>());
}

View File

@@ -23,6 +23,9 @@ namespace MediaBrowser.Model.Dlna
private readonly ILogger _logger;
private readonly ITranscoderSupport _transcoderSupport;
private static readonly string[] _supportedHlsVideoCodecs = new string[] { "h264", "hevc" };
private static readonly string[] _supportedHlsAudioCodecsTs = new string[] { "aac", "ac3", "eac3", "mp3" };
private static readonly string[] _supportedHlsAudioCodecsMp4 = new string[] { "aac", "ac3", "eac3", "mp3", "alac", "flac", "opus", "dca", "truehd" };
/// <summary>
/// Initializes a new instance of the <see cref="StreamBuilder"/> class.
@@ -801,6 +804,13 @@ namespace MediaBrowser.Model.Dlna
{
// Prefer matching video codecs
var videoCodecs = ContainerProfile.SplitValue(videoCodec);
// Enforce HLS video codec restrictions
if (string.Equals(playlistItem.SubProtocol, "hls", StringComparison.OrdinalIgnoreCase))
{
videoCodecs = videoCodecs.Where(codec => _supportedHlsVideoCodecs.Contains(codec)).ToArray();
}
var directVideoCodec = ContainerProfile.ContainsContainer(videoCodecs, videoStream?.Codec) ? videoStream?.Codec : null;
if (directVideoCodec is not null)
{
@@ -836,6 +846,20 @@ namespace MediaBrowser.Model.Dlna
// Prefer matching audio codecs, could do better here
var audioCodecs = ContainerProfile.SplitValue(audioCodec);
// Enforce HLS audio codec restrictions
if (string.Equals(playlistItem.SubProtocol, "hls", StringComparison.OrdinalIgnoreCase))
{
if (string.Equals(playlistItem.Container, "mp4", StringComparison.OrdinalIgnoreCase))
{
audioCodecs = audioCodecs.Where(codec => _supportedHlsAudioCodecsMp4.Contains(codec)).ToArray();
}
else
{
audioCodecs = audioCodecs.Where(codec => _supportedHlsAudioCodecsTs.Contains(codec)).ToArray();
}
}
var directAudioStream = candidateAudioStreams.FirstOrDefault(stream => ContainerProfile.ContainsContainer(audioCodecs, stream.Codec));
playlistItem.AudioCodecs = audioCodecs;
if (directAudioStream is not null)
@@ -1051,31 +1075,38 @@ namespace MediaBrowser.Model.Dlna
{
return 128000;
}
else if (totalBitrate <= 2000000)
if (totalBitrate <= 2000000)
{
return 384000;
}
else if (totalBitrate <= 3000000)
if (totalBitrate <= 3000000)
{
return 448000;
}
else if (totalBitrate <= 4000000)
if (totalBitrate <= 4000000)
{
return 640000;
}
else if (totalBitrate <= 5000000)
if (totalBitrate <= 5000000)
{
return 768000;
}
else if (totalBitrate <= 10000000)
if (totalBitrate <= 10000000)
{
return 1536000;
}
else if (totalBitrate <= 15000000)
if (totalBitrate <= 15000000)
{
return 2304000;
}
else if (totalBitrate <= 20000000)
if (totalBitrate <= 20000000)
{
return 3584000;
}
@@ -1419,7 +1450,8 @@ namespace MediaBrowser.Model.Dlna
{
return false;
}
else if (ContainerProfile.ContainsContainer(normalizedContainers, "mkv")
if (ContainerProfile.ContainsContainer(normalizedContainers, "mkv")
|| ContainerProfile.ContainsContainer(normalizedContainers, "matroska"))
{
return true;

View File

@@ -430,7 +430,7 @@ namespace MediaBrowser.Model.Dlna
return totalBitrate.HasValue ?
Convert.ToInt64(totalBitrate.Value * totalSeconds) :
(long?)null;
null;
}
return null;

View File

@@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
using Jellyfin.Data.Enums;
using MediaBrowser.Model.Entities;
namespace MediaBrowser.Model.Dto
@@ -33,7 +34,7 @@ namespace MediaBrowser.Model.Dto
/// Gets or sets the type.
/// </summary>
/// <value>The type.</value>
public string Type { get; set; }
public PersonKind Type { get; set; }
/// <summary>
/// Gets or sets the primary image tag.

View File

@@ -0,0 +1,12 @@
namespace MediaBrowser.Model.Entities;
/// <summary>
/// Interface for access to shares.
/// </summary>
public interface IHasShares
{
/// <summary>
/// Gets or sets the shares.
/// </summary>
Share[] Shares { get; set; }
}

View File

@@ -0,0 +1,17 @@
namespace MediaBrowser.Model.Entities;
/// <summary>
/// Class to hold data on sharing permissions.
/// </summary>
public class Share
{
/// <summary>
/// Gets or sets the user id.
/// </summary>
public string? UserId { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the user has edit permissions.
/// </summary>
public bool CanEdit { get; set; }
}

View File

@@ -17,11 +17,13 @@ namespace MediaBrowser.Model.MediaInfo
{
return "Dolby Digital";
}
else if (string.Equals(codec, "eac3", StringComparison.OrdinalIgnoreCase))
if (string.Equals(codec, "eac3", StringComparison.OrdinalIgnoreCase))
{
return "Dolby Digital+";
}
else if (string.Equals(codec, "dca", StringComparison.OrdinalIgnoreCase))
if (string.Equals(codec, "dca", StringComparison.OrdinalIgnoreCase))
{
return "DTS";
}

View File

@@ -1,19 +1,36 @@
#nullable disable
#pragma warning disable CS1591
using System;
using System.Collections.Generic;
using MediaBrowser.Model.Entities;
namespace MediaBrowser.Model.Playlists
namespace MediaBrowser.Model.Playlists;
/// <summary>
/// A playlist creation request.
/// </summary>
public class PlaylistCreationRequest
{
public class PlaylistCreationRequest
{
public string Name { get; set; }
/// <summary>
/// Gets or sets the name.
/// </summary>
public string? Name { get; set; }
public IReadOnlyList<Guid> ItemIdList { get; set; } = Array.Empty<Guid>();
/// <summary>
/// Gets or sets the list of items.
/// </summary>
public IReadOnlyList<Guid> ItemIdList { get; set; } = Array.Empty<Guid>();
public string MediaType { get; set; }
/// <summary>
/// Gets or sets the media type.
/// </summary>
public string? MediaType { get; set; }
public Guid UserId { get; set; }
}
/// <summary>
/// Gets or sets the user id.
/// </summary>
public Guid UserId { get; set; }
/// <summary>
/// Gets or sets the shares.
/// </summary>
public Share[]? Shares { get; set; }
}