From b7c3510da102793eb0a9241a7c0f330244a11022 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Tue, 4 May 2021 21:59:42 -0400 Subject: 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. --- MediaBrowser.Model/Dlna/ContainerProfile.cs | 61 +++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 17 deletions(-) (limited to 'MediaBrowser.Model/Dlna/ContainerProfile.cs') diff --git a/MediaBrowser.Model/Dlna/ContainerProfile.cs b/MediaBrowser.Model/Dlna/ContainerProfile.cs index c66ec8bc37..56c89d854f 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(); + 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(); + } + + 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; + } } } } -- cgit v1.2.3