UpnpDevice.cs 962 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System;
  2. using System.Net;
  3. using MediaBrowser.Model.Net;
  4. namespace Emby.Dlna.Server
  5. {
  6. public sealed class UpnpDevice
  7. {
  8. public readonly Uri Descriptor;
  9. public readonly string Type;
  10. public readonly string USN;
  11. public readonly string Uuid;
  12. public readonly IpAddressInfo Address;
  13. public UpnpDevice(string aUuid, string aType, Uri aDescriptor, IpAddressInfo address)
  14. {
  15. Uuid = aUuid;
  16. Type = aType;
  17. Descriptor = aDescriptor;
  18. Address = address;
  19. USN = CreateUSN(aUuid, aType);
  20. }
  21. private static string CreateUSN(string aUuid, string aType)
  22. {
  23. if (aType.StartsWith("uuid:", StringComparison.OrdinalIgnoreCase))
  24. {
  25. return aType;
  26. }
  27. else
  28. {
  29. return String.Format("uuid:{0}::{1}", aUuid, aType);
  30. }
  31. }
  32. }
  33. }