|  |  | 1 |  | using System; | 
|  |  | 2 |  | using System.Collections.Generic; | 
|  |  | 3 |  | using System.Linq; | 
|  |  | 4 |  | using System.Xml.Serialization; | 
|  |  | 5 |  | using MediaBrowser.Model.Extensions; | 
|  |  | 6 |  |  | 
|  |  | 7 |  | namespace MediaBrowser.Model.Dlna; | 
|  |  | 8 |  |  | 
|  |  | 9 |  | /// <summary> | 
|  |  | 10 |  | /// Defines the <see cref="CodecProfile"/>. | 
|  |  | 11 |  | /// </summary> | 
|  |  | 12 |  | public class CodecProfile | 
|  |  | 13 |  | { | 
|  |  | 14 |  |     /// <summary> | 
|  |  | 15 |  |     /// Initializes a new instance of the <see cref="CodecProfile"/> class. | 
|  |  | 16 |  |     /// </summary> | 
|  |  | 17 |  |     public CodecProfile() | 
|  |  | 18 |  |     { | 
|  | 931 | 19 |  |         Conditions = []; | 
|  | 931 | 20 |  |         ApplyConditions = []; | 
|  | 931 | 21 |  |     } | 
|  |  | 22 |  |  | 
|  |  | 23 |  |     /// <summary> | 
|  |  | 24 |  |     /// Gets or sets the <see cref="CodecType"/> which this container must meet. | 
|  |  | 25 |  |     /// </summary> | 
|  |  | 26 |  |     [XmlAttribute("type")] | 
|  |  | 27 |  |     public CodecType Type { get; set; } | 
|  |  | 28 |  |  | 
|  |  | 29 |  |     /// <summary> | 
|  |  | 30 |  |     /// Gets or sets the list of <see cref="ProfileCondition"/> which this profile must meet. | 
|  |  | 31 |  |     /// </summary> | 
|  |  | 32 |  |     public ProfileCondition[] Conditions { get; set; } | 
|  |  | 33 |  |  | 
|  |  | 34 |  |     /// <summary> | 
|  |  | 35 |  |     /// Gets or sets the list of <see cref="ProfileCondition"/> to apply if this profile is met. | 
|  |  | 36 |  |     /// </summary> | 
|  |  | 37 |  |     public ProfileCondition[] ApplyConditions { get; set; } | 
|  |  | 38 |  |  | 
|  |  | 39 |  |     /// <summary> | 
|  |  | 40 |  |     /// Gets or sets the codec(s) that this profile applies to. | 
|  |  | 41 |  |     /// </summary> | 
|  |  | 42 |  |     [XmlAttribute("codec")] | 
|  |  | 43 |  |     public string? Codec { get; set; } | 
|  |  | 44 |  |  | 
|  |  | 45 |  |     /// <summary> | 
|  |  | 46 |  |     /// Gets or sets the container(s) which this profile will be applied to. | 
|  |  | 47 |  |     /// </summary> | 
|  |  | 48 |  |     [XmlAttribute("container")] | 
|  |  | 49 |  |     public string? Container { get; set; } | 
|  |  | 50 |  |  | 
|  |  | 51 |  |     /// <summary> | 
|  |  | 52 |  |     /// Gets or sets the sub-container(s) which this profile will be applied to. | 
|  |  | 53 |  |     /// </summary> | 
|  |  | 54 |  |     [XmlAttribute("subcontainer")] | 
|  |  | 55 |  |     public string? SubContainer { get; set; } | 
|  |  | 56 |  |  | 
|  |  | 57 |  |     /// <summary> | 
|  |  | 58 |  |     /// Checks to see whether the codecs and containers contain the given parameters. | 
|  |  | 59 |  |     /// </summary> | 
|  |  | 60 |  |     /// <param name="codecs">The codecs to match.</param> | 
|  |  | 61 |  |     /// <param name="container">The container to match.</param> | 
|  |  | 62 |  |     /// <param name="useSubContainer">Consider sub-containers.</param> | 
|  |  | 63 |  |     /// <returns>True if both conditions are met.</returns> | 
|  |  | 64 |  |     public bool ContainsAnyCodec(IReadOnlyList<string> codecs, string? container, bool useSubContainer = false) | 
|  |  | 65 |  |     { | 
|  | 520 | 66 |  |         var containerToCheck = useSubContainer && string.Equals(Container, "hls", StringComparison.OrdinalIgnoreCase) ?  | 
|  | 520 | 67 |  |         return ContainerHelper.ContainsContainer(containerToCheck, container) && codecs.Any(c => ContainerHelper.Contain | 
|  |  | 68 |  |     } | 
|  |  | 69 |  |  | 
|  |  | 70 |  |     /// <summary> | 
|  |  | 71 |  |     /// Checks to see whether the codecs and containers contain the given parameters. | 
|  |  | 72 |  |     /// </summary> | 
|  |  | 73 |  |     /// <param name="codec">The codec to match.</param> | 
|  |  | 74 |  |     /// <param name="container">The container to match.</param> | 
|  |  | 75 |  |     /// <param name="useSubContainer">Consider sub-containers.</param> | 
|  |  | 76 |  |     /// <returns>True if both conditions are met.</returns> | 
|  |  | 77 |  |     public bool ContainsAnyCodec(string? codec, string? container, bool useSubContainer = false) | 
|  |  | 78 |  |     { | 
|  | 3190 | 79 |  |         return ContainsAnyCodec(codec.AsSpan(), container, useSubContainer); | 
|  |  | 80 |  |     } | 
|  |  | 81 |  |  | 
|  |  | 82 |  |     /// <summary> | 
|  |  | 83 |  |     /// Checks to see whether the codecs and containers contain the given parameters. | 
|  |  | 84 |  |     /// </summary> | 
|  |  | 85 |  |     /// <param name="codec">The codec to match.</param> | 
|  |  | 86 |  |     /// <param name="container">The container to match.</param> | 
|  |  | 87 |  |     /// <param name="useSubContainer">Consider sub-containers.</param> | 
|  |  | 88 |  |     /// <returns>True if both conditions are met.</returns> | 
|  |  | 89 |  |     public bool ContainsAnyCodec(ReadOnlySpan<char> codec, string? container, bool useSubContainer = false) | 
|  |  | 90 |  |     { | 
|  | 3190 | 91 |  |         var containerToCheck = useSubContainer && string.Equals(Container, "hls", StringComparison.OrdinalIgnoreCase) ?  | 
|  | 3190 | 92 |  |         return ContainerHelper.ContainsContainer(containerToCheck, container) && ContainerHelper.ContainsContainer(Codec | 
|  |  | 93 |  |     } | 
|  |  | 94 |  | } |