aboutsummaryrefslogtreecommitdiff
path: root/Emby.Dlna/Server/UpnpDevice.cs
blob: 46f3d1c833f2ffb5308c41393fe8e42da7bd9124 (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
using System;
using System.Net;
using MediaBrowser.Model.Net;

namespace Emby.Dlna.Server
{
    public sealed class UpnpDevice
    {
        public readonly Uri Descriptor;
        public readonly string Type;
        public readonly string USN;
        public readonly string Uuid;
        public readonly IpAddressInfo Address;

        public UpnpDevice(string aUuid, string aType, Uri aDescriptor, IpAddressInfo address)
        {
            Uuid = aUuid;
            Type = aType;
            Descriptor = aDescriptor;

            Address = address;

            USN = CreateUSN(aUuid, aType);
        }

        private static string CreateUSN(string aUuid, string aType)
        {
            if (aType.StartsWith("uuid:", StringComparison.OrdinalIgnoreCase))
            {
                return aType;
            }
            else
            {
                return String.Format("uuid:{0}::{1}", aUuid, aType);
            }
        }
    }
}