diff options
| author | Nyanmisaka <nst799610810@gmail.com> | 2024-08-05 16:37:09 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-05 16:37:09 +0800 |
| commit | 2aa9cf4007c0217a8b4868f90f9295a395637277 (patch) | |
| tree | c47f46524118e9b5b1623cfe8a913001b4530865 /MediaBrowser.Model/Entities | |
| parent | 00088c295445fe2710cae468e1b09f98a32e40a5 (diff) | |
| parent | 7ea91dfcc4030892fff164d49969f6e85c8493fe (diff) | |
Merge branch 'master' into fix-hwa-video-rotation
Diffstat (limited to 'MediaBrowser.Model/Entities')
| -rw-r--r-- | MediaBrowser.Model/Entities/DownMixStereoAlgorithms.cs | 18 | ||||
| -rw-r--r-- | MediaBrowser.Model/Entities/MediaStream.cs | 9 | ||||
| -rw-r--r-- | MediaBrowser.Model/Entities/ProviderIdsExtensions.cs | 323 |
3 files changed, 202 insertions, 148 deletions
diff --git a/MediaBrowser.Model/Entities/DownMixStereoAlgorithms.cs b/MediaBrowser.Model/Entities/DownMixStereoAlgorithms.cs index 385cd6a34..0c03d430d 100644 --- a/MediaBrowser.Model/Entities/DownMixStereoAlgorithms.cs +++ b/MediaBrowser.Model/Entities/DownMixStereoAlgorithms.cs @@ -1,8 +1,7 @@ namespace MediaBrowser.Model.Entities; /// <summary> -/// An enum representing an algorithm to downmix 6ch+ to stereo. -/// Algorithms sourced from https://superuser.com/questions/852400/properly-downmix-5-1-to-stereo-using-ffmpeg/1410620#1410620. +/// An enum representing an algorithm to downmix surround sound to stereo. /// </summary> public enum DownMixStereoAlgorithms { @@ -13,11 +12,24 @@ public enum DownMixStereoAlgorithms /// <summary> /// Algorithm by Dave_750. + /// Sourced from https://superuser.com/questions/852400/properly-downmix-5-1-to-stereo-using-ffmpeg/1410620#1410620. /// </summary> Dave750 = 1, /// <summary> /// Nightmode Dialogue algorithm. + /// Sourced from https://superuser.com/questions/852400/properly-downmix-5-1-to-stereo-using-ffmpeg/1410620#1410620. /// </summary> - NightmodeDialogue = 2 + NightmodeDialogue = 2, + + /// <summary> + /// RFC7845 Section 5.1.1.5 defined algorithm. + /// </summary> + Rfc7845 = 3, + + /// <summary> + /// AC-4 standard algorithm with its default gain values. + /// Defined in ETSI TS 103 190 Section 6.2.17. + /// </summary> + Ac4 = 4 } diff --git a/MediaBrowser.Model/Entities/MediaStream.cs b/MediaBrowser.Model/Entities/MediaStream.cs index 844214fae..7e227c5aa 100644 --- a/MediaBrowser.Model/Entities/MediaStream.cs +++ b/MediaBrowser.Model/Entities/MediaStream.cs @@ -202,7 +202,7 @@ namespace MediaBrowser.Model.Entities || dvProfile == 8 || dvProfile == 9)) { - var title = "DV Profile " + dvProfile; + var title = "Dolby Vision Profile " + dvProfile; if (dvBlCompatId > 0) { @@ -214,6 +214,7 @@ namespace MediaBrowser.Model.Entities 1 => title + " (HDR10)", 2 => title + " (SDR)", 4 => title + " (HLG)", + 6 => title + " (HDR10)", // Technically means Blu-ray, but practically always HDR10 _ => title }; } @@ -336,7 +337,11 @@ namespace MediaBrowser.Model.Entities attributes.Add(Codec.ToUpperInvariant()); } - if (VideoRange != VideoRange.Unknown) + if (VideoDoViTitle is not null) + { + attributes.Add(VideoDoViTitle); + } + else if (VideoRange != VideoRange.Unknown) { attributes.Add(VideoRange.ToString()); } diff --git a/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs b/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs index 1c73091f0..479ec7712 100644 --- a/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs +++ b/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs @@ -3,177 +3,214 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; -namespace MediaBrowser.Model.Entities +namespace MediaBrowser.Model.Entities; + +/// <summary> +/// Class ProviderIdsExtensions. +/// </summary> +public static class ProviderIdsExtensions { /// <summary> - /// Class ProviderIdsExtensions. + /// Case insensitive dictionary of <see cref="MetadataProvider"/> string representation. + /// </summary> + private static readonly Dictionary<string, string> _metadataProviderEnumDictionary = + Enum.GetValues<MetadataProvider>() + .ToDictionary( + enumValue => enumValue.ToString(), + enumValue => enumValue.ToString(), + StringComparer.OrdinalIgnoreCase); + + /// <summary> + /// Checks if this instance has an id for the given provider. + /// </summary> + /// <param name="instance">The instance.</param> + /// <param name="name">The of the provider name.</param> + /// <returns><c>true</c> if a provider id with the given name was found; otherwise <c>false</c>.</returns> + public static bool HasProviderId(this IHasProviderIds instance, string name) + => instance.TryGetProviderId(name, out _); + + /// <summary> + /// Checks if this instance has an id for the given provider. + /// </summary> + /// <param name="instance">The instance.</param> + /// <param name="provider">The provider.</param> + /// <returns><c>true</c> if a provider id with the given name was found; otherwise <c>false</c>.</returns> + public static bool HasProviderId(this IHasProviderIds instance, MetadataProvider provider) + => instance.HasProviderId(provider.ToString()); + + /// <summary> + /// Gets a provider id. /// </summary> - public static class ProviderIdsExtensions + /// <param name="instance">The instance.</param> + /// <param name="name">The name.</param> + /// <param name="id">The provider id.</param> + /// <returns><c>true</c> if a provider id with the given name was found; otherwise <c>false</c>.</returns> + public static bool TryGetProviderId(this IHasProviderIds instance, string name, [NotNullWhen(true)] out string? id) { - /// <summary> - /// Case insensitive dictionary of <see cref="MetadataProvider"/> string representation. - /// </summary> - private static readonly Dictionary<string, string> _metadataProviderEnumDictionary = - Enum.GetValues<MetadataProvider>() - .ToDictionary( - enumValue => enumValue.ToString(), - enumValue => enumValue.ToString(), - StringComparer.OrdinalIgnoreCase); - - /// <summary> - /// Checks if this instance has an id for the given provider. - /// </summary> - /// <param name="instance">The instance.</param> - /// <param name="name">The of the provider name.</param> - /// <returns><c>true</c> if a provider id with the given name was found; otherwise <c>false</c>.</returns> - public static bool HasProviderId(this IHasProviderIds instance, string name) - { - ArgumentNullException.ThrowIfNull(instance); + ArgumentNullException.ThrowIfNull(instance); - return instance.TryGetProviderId(name, out _); + if (instance.ProviderIds is null) + { + id = null; + return false; } - /// <summary> - /// Checks if this instance has an id for the given provider. - /// </summary> - /// <param name="instance">The instance.</param> - /// <param name="provider">The provider.</param> - /// <returns><c>true</c> if a provider id with the given name was found; otherwise <c>false</c>.</returns> - public static bool HasProviderId(this IHasProviderIds instance, MetadataProvider provider) + var foundProviderId = instance.ProviderIds.TryGetValue(name, out id); + // This occurs when searching with Identify (and possibly in other places) + if (string.IsNullOrEmpty(id)) { - return instance.HasProviderId(provider.ToString()); + id = null; + foundProviderId = false; } - /// <summary> - /// Gets a provider id. - /// </summary> - /// <param name="instance">The instance.</param> - /// <param name="name">The name.</param> - /// <param name="id">The provider id.</param> - /// <returns><c>true</c> if a provider id with the given name was found; otherwise <c>false</c>.</returns> - public static bool TryGetProviderId(this IHasProviderIds instance, string name, [NotNullWhen(true)] out string? id) + return foundProviderId; + } + + /// <summary> + /// Gets a provider id. + /// </summary> + /// <param name="instance">The instance.</param> + /// <param name="provider">The provider.</param> + /// <param name="id">The provider id.</param> + /// <returns><c>true</c> if a provider id with the given name was found; otherwise <c>false</c>.</returns> + public static bool TryGetProviderId(this IHasProviderIds instance, MetadataProvider provider, [NotNullWhen(true)] out string? id) + { + return instance.TryGetProviderId(provider.ToString(), out id); + } + + /// <summary> + /// Gets a provider id. + /// </summary> + /// <param name="instance">The instance.</param> + /// <param name="name">The name.</param> + /// <returns>System.String.</returns> + public static string? GetProviderId(this IHasProviderIds instance, string name) + { + instance.TryGetProviderId(name, out string? id); + return id; + } + + /// <summary> + /// Gets a provider id. + /// </summary> + /// <param name="instance">The instance.</param> + /// <param name="provider">The provider.</param> + /// <returns>System.String.</returns> + public static string? GetProviderId(this IHasProviderIds instance, MetadataProvider provider) + { + return instance.GetProviderId(provider.ToString()); + } + + /// <summary> + /// Sets a provider id. + /// </summary> + /// <param name="instance">The instance.</param> + /// <param name="name">The name, this should not contain a '=' character.</param> + /// <param name="value">The value.</param> + /// <remarks>Due to how deserialization from the database works the name can not contain '='.</remarks> + /// <returns><c>true</c> if the provider id got set successfully; otherwise, <c>false</c>.</returns> + public static bool TrySetProviderId(this IHasProviderIds instance, string? name, string? value) + { + ArgumentNullException.ThrowIfNull(instance); + + // When name contains a '=' it can't be deserialized from the database + if (string.IsNullOrWhiteSpace(name) + || string.IsNullOrWhiteSpace(value) + || name.Contains('=', StringComparison.Ordinal)) { - ArgumentNullException.ThrowIfNull(instance); - - if (instance.ProviderIds is null) - { - id = null; - return false; - } - - var foundProviderId = instance.ProviderIds.TryGetValue(name, out id); - // This occurs when searching with Identify (and possibly in other places) - if (string.IsNullOrEmpty(id)) - { - id = null; - foundProviderId = false; - } - - return foundProviderId; + return false; } - /// <summary> - /// Gets a provider id. - /// </summary> - /// <param name="instance">The instance.</param> - /// <param name="provider">The provider.</param> - /// <param name="id">The provider id.</param> - /// <returns><c>true</c> if a provider id with the given name was found; otherwise <c>false</c>.</returns> - public static bool TryGetProviderId(this IHasProviderIds instance, MetadataProvider provider, [NotNullWhen(true)] out string? id) + // Ensure it exists + instance.ProviderIds ??= new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); + + // Match on internal MetadataProvider enum string values before adding arbitrary providers + if (_metadataProviderEnumDictionary.TryGetValue(name, out var enumValue)) { - return instance.TryGetProviderId(provider.ToString(), out id); + instance.ProviderIds[enumValue] = value; } - - /// <summary> - /// Gets a provider id. - /// </summary> - /// <param name="instance">The instance.</param> - /// <param name="name">The name.</param> - /// <returns>System.String.</returns> - public static string? GetProviderId(this IHasProviderIds instance, string name) + else { - instance.TryGetProviderId(name, out string? id); - return id; + instance.ProviderIds[name] = value; } - /// <summary> - /// Gets a provider id. - /// </summary> - /// <param name="instance">The instance.</param> - /// <param name="provider">The provider.</param> - /// <returns>System.String.</returns> - public static string? GetProviderId(this IHasProviderIds instance, MetadataProvider provider) + return true; + } + + /// <summary> + /// Sets a provider id. + /// </summary> + /// <param name="instance">The instance.</param> + /// <param name="provider">The provider.</param> + /// <param name="value">The value.</param> + /// <returns><c>true</c> if the provider id got set successfully; otherwise, <c>false</c>.</returns> + public static bool TrySetProviderId(this IHasProviderIds instance, MetadataProvider provider, string? value) + => instance.TrySetProviderId(provider.ToString(), value); + + /// <summary> + /// Sets a provider id. + /// </summary> + /// <param name="instance">The instance.</param> + /// <param name="name">The name, this should not contain a '=' character.</param> + /// <param name="value">The value.</param> + /// <remarks>Due to how deserialization from the database works the name can not contain '='.</remarks> + public static void SetProviderId(this IHasProviderIds instance, string name, string value) + { + ArgumentNullException.ThrowIfNull(instance); + ArgumentException.ThrowIfNullOrWhiteSpace(name); + ArgumentException.ThrowIfNullOrWhiteSpace(value); + + // When name contains a '=' it can't be deserialized from the database + if (name.Contains('=', StringComparison.Ordinal)) { - return instance.GetProviderId(provider.ToString()); + throw new ArgumentException("Provider id name cannot contain '='", nameof(name)); } - /// <summary> - /// Sets a provider id. - /// </summary> - /// <param name="instance">The instance.</param> - /// <param name="name">The name, this should not contain a '=' character.</param> - /// <param name="value">The value.</param> - /// <remarks>Due to how deserialization from the database works the name can not contain '='.</remarks> - public static void SetProviderId(this IHasProviderIds instance, string name, string value) + // Ensure it exists + instance.ProviderIds ??= new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); + + // Match on internal MetadataProvider enum string values before adding arbitrary providers + if (_metadataProviderEnumDictionary.TryGetValue(name, out var enumValue)) { - ArgumentNullException.ThrowIfNull(instance); - ArgumentException.ThrowIfNullOrEmpty(name); - ArgumentException.ThrowIfNullOrEmpty(value); - - // When name contains a '=' it can't be deserialized from the database - if (name.Contains('=', StringComparison.Ordinal)) - { - throw new ArgumentException("Provider id name cannot contain '='", nameof(name)); - } - - // Ensure it exists - instance.ProviderIds ??= new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); - - // Match on internal MetadataProvider enum string values before adding arbitrary providers - if (_metadataProviderEnumDictionary.TryGetValue(name, out var enumValue)) - { - instance.ProviderIds[enumValue] = value; - } - else - { - instance.ProviderIds[name] = value; - } + instance.ProviderIds[enumValue] = value; } - - /// <summary> - /// Sets a provider id. - /// </summary> - /// <param name="instance">The instance.</param> - /// <param name="provider">The provider.</param> - /// <param name="value">The value.</param> - public static void SetProviderId(this IHasProviderIds instance, MetadataProvider provider, string value) + else { - instance.SetProviderId(provider.ToString(), value); + instance.ProviderIds[name] = value; } + } - /// <summary> - /// Removes a provider id. - /// </summary> - /// <param name="instance">The instance.</param> - /// <param name="name">The name.</param> - public static void RemoveProviderId(this IHasProviderIds instance, string name) - { - ArgumentNullException.ThrowIfNull(instance); - ArgumentException.ThrowIfNullOrEmpty(name); + /// <summary> + /// Sets a provider id. + /// </summary> + /// <param name="instance">The instance.</param> + /// <param name="provider">The provider.</param> + /// <param name="value">The value.</param> + public static void SetProviderId(this IHasProviderIds instance, MetadataProvider provider, string value) + => instance.SetProviderId(provider.ToString(), value); - instance.ProviderIds?.Remove(name); - } + /// <summary> + /// Removes a provider id. + /// </summary> + /// <param name="instance">The instance.</param> + /// <param name="name">The name.</param> + public static void RemoveProviderId(this IHasProviderIds instance, string name) + { + ArgumentNullException.ThrowIfNull(instance); + ArgumentException.ThrowIfNullOrEmpty(name); - /// <summary> - /// Removes a provider id. - /// </summary> - /// <param name="instance">The instance.</param> - /// <param name="provider">The provider.</param> - public static void RemoveProviderId(this IHasProviderIds instance, MetadataProvider provider) - { - ArgumentNullException.ThrowIfNull(instance); + instance.ProviderIds?.Remove(name); + } - instance.ProviderIds?.Remove(provider.ToString()); - } + /// <summary> + /// Removes a provider id. + /// </summary> + /// <param name="instance">The instance.</param> + /// <param name="provider">The provider.</param> + public static void RemoveProviderId(this IHasProviderIds instance, MetadataProvider provider) + { + ArgumentNullException.ThrowIfNull(instance); + + instance.ProviderIds?.Remove(provider.ToString()); } } |
