< Summary - Jellyfin

Information
Class: MediaBrowser.Model.Dlna.CodecProfile
Assembly: MediaBrowser.Model
File(s): /srv/git/jellyfin/MediaBrowser.Model/Dlna/CodecProfile.cs
Line coverage
100%
Covered lines: 8
Uncovered lines: 0
Coverable lines: 8
Total lines: 94
Line coverage: 100%
Branch coverage
100%
Covered branches: 12
Total branches: 12
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%11100%
ContainsAnyCodec(...)100%66100%
ContainsAnyCodec(...)100%11100%
ContainsAnyCodec(...)100%66100%

File(s)

/srv/git/jellyfin/MediaBrowser.Model/Dlna/CodecProfile.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.Linq;
 4using System.Xml.Serialization;
 5using MediaBrowser.Model.Extensions;
 6
 7namespace MediaBrowser.Model.Dlna;
 8
 9/// <summary>
 10/// Defines the <see cref="CodecProfile"/>.
 11/// </summary>
 12public class CodecProfile
 13{
 14    /// <summary>
 15    /// Initializes a new instance of the <see cref="CodecProfile"/> class.
 16    /// </summary>
 17    public CodecProfile()
 18    {
 87719        Conditions = [];
 87720        ApplyConditions = [];
 87721    }
 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    {
 49966        var containerToCheck = useSubContainer && string.Equals(Container, "hls", StringComparison.OrdinalIgnoreCase) ? 
 49967        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    {
 233979        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    {
 233991        var containerToCheck = useSubContainer && string.Equals(Container, "hls", StringComparison.OrdinalIgnoreCase) ? 
 233992        return ContainerHelper.ContainsContainer(containerToCheck, container) && ContainerHelper.ContainsContainer(Codec
 93    }
 94}