2014-06-04 19:32:40 -07:00
|
|
|
|
using MediaBrowser.Model.Extensions;
|
2014-03-24 10:54:45 -07:00
|
|
|
|
using System.Collections.Generic;
|
2014-03-26 08:06:48 -07:00
|
|
|
|
using System.Xml.Serialization;
|
2016-12-09 00:23:09 -07:00
|
|
|
|
using MediaBrowser.Model.Dlna;
|
2017-06-06 21:56:48 -07:00
|
|
|
|
using System.Linq;
|
2014-03-22 13:02:10 -07:00
|
|
|
|
|
2014-04-01 15:23:07 -07:00
|
|
|
|
namespace MediaBrowser.Model.Dlna
|
2014-03-22 13:02:10 -07:00
|
|
|
|
{
|
|
|
|
|
public class CodecProfile
|
|
|
|
|
{
|
2016-12-09 00:23:09 -07:00
|
|
|
|
[XmlAttribute("type")]
|
2014-03-22 13:02:10 -07:00
|
|
|
|
public CodecType Type { get; set; }
|
2014-03-26 08:06:48 -07:00
|
|
|
|
|
2014-03-23 09:42:02 -07:00
|
|
|
|
public ProfileCondition[] Conditions { get; set; }
|
2014-03-26 08:06:48 -07:00
|
|
|
|
|
2016-07-09 10:39:04 -07:00
|
|
|
|
public ProfileCondition[] ApplyConditions { get; set; }
|
|
|
|
|
|
2016-12-09 00:23:09 -07:00
|
|
|
|
[XmlAttribute("codec")]
|
2014-03-22 13:50:28 -07:00
|
|
|
|
public string Codec { get; set; }
|
2014-03-22 13:02:10 -07:00
|
|
|
|
|
2016-12-09 00:23:09 -07:00
|
|
|
|
[XmlAttribute("container")]
|
2015-05-06 20:11:51 -07:00
|
|
|
|
public string Container { get; set; }
|
|
|
|
|
|
2014-03-22 13:02:10 -07:00
|
|
|
|
public CodecProfile()
|
|
|
|
|
{
|
2014-03-23 09:42:02 -07:00
|
|
|
|
Conditions = new ProfileCondition[] {};
|
2016-07-09 10:39:04 -07:00
|
|
|
|
ApplyConditions = new ProfileCondition[] { };
|
2014-03-22 13:50:28 -07:00
|
|
|
|
}
|
|
|
|
|
|
2017-06-06 21:56:48 -07:00
|
|
|
|
private static List<string> SplitValue(string value)
|
2014-03-22 13:50:28 -07:00
|
|
|
|
{
|
2014-05-08 14:23:24 -07:00
|
|
|
|
List<string> list = new List<string>();
|
2017-06-06 21:56:48 -07:00
|
|
|
|
foreach (string i in (value ?? string.Empty).Split(','))
|
2014-05-08 14:23:24 -07:00
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(i)) list.Add(i);
|
|
|
|
|
}
|
|
|
|
|
return list;
|
2014-03-22 13:02:10 -07:00
|
|
|
|
}
|
2014-03-24 10:54:45 -07:00
|
|
|
|
|
2017-06-06 21:56:48 -07:00
|
|
|
|
public List<string> GetCodecs()
|
|
|
|
|
{
|
|
|
|
|
return SplitValue(Codec);
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-06 20:11:51 -07:00
|
|
|
|
public List<string> GetContainers()
|
|
|
|
|
{
|
2017-06-06 21:56:48 -07:00
|
|
|
|
return SplitValue(Container);
|
2015-05-06 20:11:51 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool ContainsContainer(string container)
|
|
|
|
|
{
|
|
|
|
|
List<string> containers = GetContainers();
|
|
|
|
|
|
|
|
|
|
return containers.Count == 0 || ListHelper.ContainsIgnoreCase(containers, container ?? string.Empty);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool ContainsCodec(string codec, string container)
|
2014-03-24 10:54:45 -07:00
|
|
|
|
{
|
2015-05-06 20:11:51 -07:00
|
|
|
|
if (!ContainsContainer(container))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-08 13:44:17 -07:00
|
|
|
|
List<string> codecs = GetCodecs();
|
2014-03-24 10:54:45 -07:00
|
|
|
|
|
2017-06-06 21:56:48 -07:00
|
|
|
|
return codecs.Count == 0 || ListHelper.ContainsIgnoreCase(codecs, SplitValue(codec)[0]);
|
|
|
|
|
//return codecs.Count == 0 || SplitValue(codec).Any(i => ListHelper.ContainsIgnoreCase(codecs, i));
|
2014-03-24 10:54:45 -07:00
|
|
|
|
}
|
2014-03-22 13:02:10 -07:00
|
|
|
|
}
|
|
|
|
|
}
|