jellyfin/MediaBrowser.Model/Dlna/CodecProfile.cs

71 lines
1.7 KiB
C#
Raw Normal View History

#nullable disable
2020-02-04 01:49:27 +01:00
#pragma warning disable CS1591
using System;
using System.Xml.Serialization;
2021-12-20 13:31:07 +01:00
using Jellyfin.Extensions;
2018-12-28 00:27:57 +01:00
namespace MediaBrowser.Model.Dlna
{
public class CodecProfile
{
public CodecProfile()
{
Conditions = Array.Empty<ProfileCondition>();
ApplyConditions = Array.Empty<ProfileCondition>();
}
2018-12-28 00:27:57 +01:00
[XmlAttribute("type")]
public CodecType Type { get; set; }
2019-01-08 00:27:46 +01:00
2018-12-28 00:27:57 +01:00
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 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)
{
2021-12-20 13:31:07 +01:00
if (codecs.Contains(val, StringComparison.OrdinalIgnoreCase))
2018-12-28 00:27:57 +01:00
{
return true;
}
}
return false;
}
}
}