aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Model/Dlna/CodecProfile.cs
blob: 3e67b49f91efde730f482f7d0733b42e9d06c8f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using System.Collections.Generic;
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; }

        [XmlAttribute("codec")]
        public string Codec { get; set; }

        public CodecProfile()
        {
            Conditions = 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 bool ContainsCodec(string codec)
        {
            List<string> codecs = GetCodecs();

            return codecs.Count == 0 || codecs.Contains(codec, StringComparer.OrdinalIgnoreCase);
        }
    }
}