diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-10-29 18:22:20 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-10-29 18:22:20 -0400 |
| commit | dca78b13411db96366dddfa0d68bb6d36d28ad14 (patch) | |
| tree | 7d41e670f1cadec0db9e1ed7115e151da891f7ea /Emby.Dlna/ProfileSerialization/CodecProfile.cs | |
| parent | 597e27d1c6199a40398abb068282711a9cb9db1b (diff) | |
rework dlna project
Diffstat (limited to 'Emby.Dlna/ProfileSerialization/CodecProfile.cs')
| -rw-r--r-- | Emby.Dlna/ProfileSerialization/CodecProfile.cs | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/Emby.Dlna/ProfileSerialization/CodecProfile.cs b/Emby.Dlna/ProfileSerialization/CodecProfile.cs new file mode 100644 index 000000000..4619d91bc --- /dev/null +++ b/Emby.Dlna/ProfileSerialization/CodecProfile.cs @@ -0,0 +1,68 @@ +using MediaBrowser.Model.Extensions; +using System.Collections.Generic; +using System.Xml.Serialization; +using MediaBrowser.Model.Dlna; + +namespace MediaBrowser.Dlna.ProfileSerialization +{ + 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 = new ProfileCondition[] {}; + ApplyConditions = new ProfileCondition[] { }; + } + + public List<string> GetCodecs() + { + List<string> list = new List<string>(); + foreach (string i in (Codec ?? string.Empty).Split(',')) + { + if (!string.IsNullOrEmpty(i)) list.Add(i); + } + return list; + } + + public List<string> GetContainers() + { + List<string> list = new List<string>(); + foreach (string i in (Container ?? string.Empty).Split(',')) + { + if (!string.IsNullOrEmpty(i)) list.Add(i); + } + return list; + } + + 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) + { + if (!ContainsContainer(container)) + { + return false; + } + + List<string> codecs = GetCodecs(); + + return codecs.Count == 0 || ListHelper.ContainsIgnoreCase(codecs, codec); + } + } +} |
