diff options
| author | Joshua M. Boniface <joshua@boniface.me> | 2021-05-04 21:59:42 -0400 |
|---|---|---|
| committer | Joshua M. Boniface <joshua@boniface.me> | 2021-05-04 22:07:32 -0400 |
| commit | b7c3510da102793eb0a9241a7c0f330244a11022 (patch) | |
| tree | 461cee54956b1cd39b7b3ca5d84352995109b4cd /MediaBrowser.Model/Dlna/ContainerProfile.cs | |
| parent | fd102abd81b919f4eeee52fab5e92db25238495c (diff) | |
Revert "Merge pull request #5943 from Maxr1998/device-profile-defaults"
This PR broke direct play in JMP and caused aspect ratio issues in web.
This reverts commit 4c8df4c5bbc7138ec23066b98de17cdb405e9fe0.
Diffstat (limited to 'MediaBrowser.Model/Dlna/ContainerProfile.cs')
| -rw-r--r-- | MediaBrowser.Model/Dlna/ContainerProfile.cs | 61 |
1 files changed, 44 insertions, 17 deletions
diff --git a/MediaBrowser.Model/Dlna/ContainerProfile.cs b/MediaBrowser.Model/Dlna/ContainerProfile.cs index c66ec8bc3..56c89d854 100644 --- a/MediaBrowser.Model/Dlna/ContainerProfile.cs +++ b/MediaBrowser.Model/Dlna/ContainerProfile.cs @@ -1,7 +1,7 @@ +#nullable disable #pragma warning disable CS1591 using System; -using System.ComponentModel.DataAnnotations; using System.Linq; using System.Xml.Serialization; @@ -12,12 +12,22 @@ namespace MediaBrowser.Model.Dlna [XmlAttribute("type")] public DlnaProfileType Type { get; set; } - public ProfileCondition[]? Conditions { get; set; } = Array.Empty<ProfileCondition>(); + public ProfileCondition[] Conditions { get; set; } [XmlAttribute("container")] - public string Container { get; set; } = string.Empty; + public string Container { get; set; } - public static string[] SplitValue(string? value) + public ContainerProfile() + { + Conditions = Array.Empty<ProfileCondition>(); + } + + public string[] GetContainers() + { + return SplitValue(Container); + } + + public static string[] SplitValue(string value) { if (string.IsNullOrEmpty(value)) { @@ -27,14 +37,14 @@ namespace MediaBrowser.Model.Dlna return value.Split(',', StringSplitOptions.RemoveEmptyEntries); } - public bool ContainsContainer(string? container) + public bool ContainsContainer(string container) { - var containers = SplitValue(Container); + var containers = GetContainers(); return ContainsContainer(containers, container); } - public static bool ContainsContainer(string? profileContainers, string? inputContainer) + public static bool ContainsContainer(string profileContainers, string inputContainer) { var isNegativeList = false; if (profileContainers != null && profileContainers.StartsWith('-')) @@ -46,29 +56,46 @@ namespace MediaBrowser.Model.Dlna return ContainsContainer(SplitValue(profileContainers), isNegativeList, inputContainer); } - public static bool ContainsContainer(string[]? profileContainers, string? inputContainer) + public static bool ContainsContainer(string[] profileContainers, string inputContainer) { return ContainsContainer(profileContainers, false, inputContainer); } - public static bool ContainsContainer(string[]? profileContainers, bool isNegativeList, string? inputContainer) + public static bool ContainsContainer(string[] profileContainers, bool isNegativeList, string inputContainer) { - if (profileContainers == null || profileContainers.Length == 0) + if (profileContainers.Length == 0) { - return isNegativeList; + return true; } - var allInputContainers = SplitValue(inputContainer); - - foreach (var container in allInputContainers) + if (isNegativeList) { - if (profileContainers.Contains(container, StringComparer.OrdinalIgnoreCase)) + var allInputContainers = SplitValue(inputContainer); + + foreach (var container in allInputContainers) { - return !isNegativeList; + if (profileContainers.Contains(container, StringComparer.OrdinalIgnoreCase)) + { + return false; + } } + + return true; } + else + { + var allInputContainers = SplitValue(inputContainer); - return isNegativeList; + foreach (var container in allInputContainers) + { + if (profileContainers.Contains(container, StringComparer.OrdinalIgnoreCase)) + { + return true; + } + } + + return false; + } } } } |
