2014-06-05 02:32:40 +00:00
|
|
|
|
using MediaBrowser.Model.Extensions;
|
2014-03-24 17:54:45 +00:00
|
|
|
|
using System.Collections.Generic;
|
2014-03-26 15:06:48 +00:00
|
|
|
|
using System.Xml.Serialization;
|
2016-12-09 07:23:09 +00:00
|
|
|
|
using MediaBrowser.Model.Dlna;
|
2014-03-22 20:02:10 +00:00
|
|
|
|
|
2014-04-01 22:23:07 +00:00
|
|
|
|
namespace MediaBrowser.Model.Dlna
|
2014-03-22 20:02:10 +00:00
|
|
|
|
{
|
|
|
|
|
public class CodecProfile
|
|
|
|
|
{
|
2016-12-09 07:23:09 +00:00
|
|
|
|
[XmlAttribute("type")]
|
2014-03-22 20:02:10 +00:00
|
|
|
|
public CodecType Type { get; set; }
|
2014-03-26 15:06:48 +00:00
|
|
|
|
|
2014-03-23 16:42:02 +00:00
|
|
|
|
public ProfileCondition[] Conditions { get; set; }
|
2014-03-26 15:06:48 +00:00
|
|
|
|
|
2016-07-09 17:39:04 +00:00
|
|
|
|
public ProfileCondition[] ApplyConditions { get; set; }
|
|
|
|
|
|
2016-12-09 07:23:09 +00:00
|
|
|
|
[XmlAttribute("codec")]
|
2014-03-22 20:50:28 +00:00
|
|
|
|
public string Codec { get; set; }
|
2014-03-22 20:02:10 +00:00
|
|
|
|
|
2016-12-09 07:23:09 +00:00
|
|
|
|
[XmlAttribute("container")]
|
2015-05-07 03:11:51 +00:00
|
|
|
|
public string Container { get; set; }
|
|
|
|
|
|
2014-03-22 20:02:10 +00:00
|
|
|
|
public CodecProfile()
|
|
|
|
|
{
|
2014-03-23 16:42:02 +00:00
|
|
|
|
Conditions = new ProfileCondition[] {};
|
2016-07-09 17:39:04 +00:00
|
|
|
|
ApplyConditions = new ProfileCondition[] { };
|
2014-03-22 20:50:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-08-19 19:43:35 +00:00
|
|
|
|
public string[] GetCodecs()
|
2014-03-22 20:50:28 +00:00
|
|
|
|
{
|
2017-08-19 19:43:35 +00:00
|
|
|
|
return ContainerProfile.SplitValue(Codec);
|
2017-06-07 04:56:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-05-07 03:11:51 +00:00
|
|
|
|
private bool ContainsContainer(string container)
|
|
|
|
|
{
|
2017-08-04 06:34:46 +00:00
|
|
|
|
return ContainerProfile.ContainsContainer(Container, container);
|
2015-05-07 03:11:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-25 05:06:15 +00:00
|
|
|
|
public bool ContainsAnyCodec(string codec, string container)
|
|
|
|
|
{
|
|
|
|
|
return ContainsAnyCodec(ContainerProfile.SplitValue(codec), container);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool ContainsAnyCodec(string[] codec, string container)
|
2014-03-24 17:54:45 +00:00
|
|
|
|
{
|
2015-05-07 03:11:51 +00:00
|
|
|
|
if (!ContainsContainer(container))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-19 19:43:35 +00:00
|
|
|
|
var codecs = GetCodecs();
|
2017-09-25 05:06:15 +00:00
|
|
|
|
if (codecs.Length == 0)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var val in codec)
|
|
|
|
|
{
|
|
|
|
|
if (ListHelper.ContainsIgnoreCase(codecs, val))
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-03-24 17:54:45 +00:00
|
|
|
|
|
2017-09-25 05:06:15 +00:00
|
|
|
|
return false;
|
2014-03-24 17:54:45 +00:00
|
|
|
|
}
|
2014-03-22 20:02:10 +00:00
|
|
|
|
}
|
|
|
|
|
}
|