mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-07 20:08:59 +02:00
70 lines
1.7 KiB
C#
70 lines
1.7 KiB
C#
#nullable disable
|
|
#pragma warning disable CS1591
|
|
|
|
using System;
|
|
using System.Linq;
|
|
using System.Xml.Serialization;
|
|
|
|
namespace MediaBrowser.Model.Dlna
|
|
{
|
|
public class CodecProfile
|
|
{
|
|
[XmlAttribute("type")]
|
|
public CodecType Type { get; set; }
|
|
|
|
public ProfileCondition[] Conditions { get; set; }
|
|
|
|
public ProfileCondition[] ApplyConditions { get; set; }
|
|
|
|
[XmlAttribute("codec")]
|
|
public string Codec { get; set; }
|
|
|
|
[XmlAttribute("container")]
|
|
public string Container { get; set; }
|
|
|
|
public CodecProfile()
|
|
{
|
|
Conditions = Array.Empty<ProfileCondition>();
|
|
ApplyConditions = Array.Empty<ProfileCondition>();
|
|
}
|
|
|
|
public string[] GetCodecs()
|
|
{
|
|
return ContainerProfile.SplitValue(Codec);
|
|
}
|
|
|
|
private bool ContainsContainer(string container)
|
|
{
|
|
return ContainerProfile.ContainsContainer(Container, container);
|
|
}
|
|
|
|
public bool ContainsAnyCodec(string codec, string container)
|
|
{
|
|
return ContainsAnyCodec(ContainerProfile.SplitValue(codec), container);
|
|
}
|
|
|
|
public bool ContainsAnyCodec(string[] codec, string container)
|
|
{
|
|
if (!ContainsContainer(container))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
var codecs = GetCodecs();
|
|
if (codecs.Length == 0)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
foreach (var val in codec)
|
|
{
|
|
if (codecs.Contains(val, StringComparer.OrdinalIgnoreCase))
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|
|
}
|