浏览代码

Merge pull request #2274 from MediaBrowser/dev

Dev
Luke 8 年之前
父节点
当前提交
36c01cfc76
共有 100 个文件被更改,包括 673 次插入652 次删除
  1. 6 11
      Emby.Common.Implementations/BaseApplicationHost.cs
  2. 70 0
      Emby.Common.Implementations/EnvironmentInfo/EnvironmentInfo.cs
  3. 27 6
      Emby.Common.Implementations/Net/SocketFactory.cs
  4. 28 47
      Emby.Common.Implementations/Net/UdpSocket.cs
  5. 76 40
      Emby.Common.Implementations/Networking/BaseNetworkManager.cs
  6. 9 8
      Emby.Common.Implementations/Serialization/XmlSerializer.cs
  7. 5 4
      Emby.Common.Implementations/project.json
  8. 4 4
      Emby.Dlna/Didl/DidlBuilder.cs
  9. 13 6
      Emby.Dlna/Main/DlnaEntryPoint.cs
  10. 1 1
      Emby.Dlna/Service/BaseControlHandler.cs
  11. 1 1
      Emby.Server.Implementations/Connect/ConnectData.cs
  12. 10 14
      Emby.Server.Implementations/Connect/ConnectEntryPoint.cs
  13. 4 7
      Emby.Server.Implementations/Connect/ConnectManager.cs
  14. 1 1
      Emby.Server.Implementations/Connect/Responses.cs
  15. 1 1
      Emby.Server.Implementations/Connect/Validator.cs
  16. 254 1
      Emby.Server.Implementations/Emby.Server.Implementations.csproj
  17. 7 14
      Emby.Server.Implementations/EntryPoints/UdpServerEntryPoint.cs
  18. 2 2
      Emby.Server.Implementations/HttpServer/GetSwaggerResource.cs
  19. 2 22
      Emby.Server.Implementations/HttpServer/SocketSharp/HttpUtility.cs
  20. 6 3
      Emby.Server.Implementations/HttpServer/SwaggerService.cs
  21. 6 3
      Emby.Server.Implementations/IO/FileRefresher.cs
  22. 1 1
      Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs
  23. 1 1
      Emby.Server.Implementations/LiveTv/LiveStreamHelper.cs
  24. 0 0
      Emby.Server.Implementations/Localization/Core/ar.json
  25. 0 0
      Emby.Server.Implementations/Localization/Core/bg-BG.json
  26. 0 0
      Emby.Server.Implementations/Localization/Core/ca.json
  27. 0 0
      Emby.Server.Implementations/Localization/Core/core.json
  28. 0 0
      Emby.Server.Implementations/Localization/Core/cs.json
  29. 0 0
      Emby.Server.Implementations/Localization/Core/da.json
  30. 0 0
      Emby.Server.Implementations/Localization/Core/de.json
  31. 0 0
      Emby.Server.Implementations/Localization/Core/el.json
  32. 0 0
      Emby.Server.Implementations/Localization/Core/en-GB.json
  33. 0 0
      Emby.Server.Implementations/Localization/Core/en-US.json
  34. 0 0
      Emby.Server.Implementations/Localization/Core/es-AR.json
  35. 0 0
      Emby.Server.Implementations/Localization/Core/es-MX.json
  36. 0 0
      Emby.Server.Implementations/Localization/Core/es.json
  37. 0 0
      Emby.Server.Implementations/Localization/Core/fi.json
  38. 0 0
      Emby.Server.Implementations/Localization/Core/fr-CA.json
  39. 0 0
      Emby.Server.Implementations/Localization/Core/fr.json
  40. 0 0
      Emby.Server.Implementations/Localization/Core/gsw.json
  41. 0 0
      Emby.Server.Implementations/Localization/Core/he.json
  42. 0 0
      Emby.Server.Implementations/Localization/Core/hr.json
  43. 0 0
      Emby.Server.Implementations/Localization/Core/hu.json
  44. 0 0
      Emby.Server.Implementations/Localization/Core/id.json
  45. 0 0
      Emby.Server.Implementations/Localization/Core/it.json
  46. 0 0
      Emby.Server.Implementations/Localization/Core/kk.json
  47. 0 0
      Emby.Server.Implementations/Localization/Core/ko.json
  48. 0 0
      Emby.Server.Implementations/Localization/Core/ms.json
  49. 0 0
      Emby.Server.Implementations/Localization/Core/nb.json
  50. 0 0
      Emby.Server.Implementations/Localization/Core/nl.json
  51. 0 0
      Emby.Server.Implementations/Localization/Core/pl.json
  52. 0 0
      Emby.Server.Implementations/Localization/Core/pt-BR.json
  53. 0 0
      Emby.Server.Implementations/Localization/Core/pt-PT.json
  54. 0 0
      Emby.Server.Implementations/Localization/Core/ro.json
  55. 0 0
      Emby.Server.Implementations/Localization/Core/ru.json
  56. 0 0
      Emby.Server.Implementations/Localization/Core/sl-SI.json
  57. 0 0
      Emby.Server.Implementations/Localization/Core/sv.json
  58. 0 0
      Emby.Server.Implementations/Localization/Core/tr.json
  59. 0 0
      Emby.Server.Implementations/Localization/Core/uk.json
  60. 0 0
      Emby.Server.Implementations/Localization/Core/vi.json
  61. 0 0
      Emby.Server.Implementations/Localization/Core/zh-CN.json
  62. 0 0
      Emby.Server.Implementations/Localization/Core/zh-HK.json
  63. 0 0
      Emby.Server.Implementations/Localization/Core/zh-TW.json
  64. 37 26
      Emby.Server.Implementations/Localization/LocalizationManager.cs
  65. 0 0
      Emby.Server.Implementations/Localization/Ratings/au.txt
  66. 0 0
      Emby.Server.Implementations/Localization/Ratings/be.txt
  67. 0 0
      Emby.Server.Implementations/Localization/Ratings/br.txt
  68. 0 0
      Emby.Server.Implementations/Localization/Ratings/ca.txt
  69. 0 0
      Emby.Server.Implementations/Localization/Ratings/co.txt
  70. 0 0
      Emby.Server.Implementations/Localization/Ratings/de.txt
  71. 0 0
      Emby.Server.Implementations/Localization/Ratings/dk.txt
  72. 0 0
      Emby.Server.Implementations/Localization/Ratings/fr.txt
  73. 0 0
      Emby.Server.Implementations/Localization/Ratings/gb.txt
  74. 0 0
      Emby.Server.Implementations/Localization/Ratings/ie.txt
  75. 0 0
      Emby.Server.Implementations/Localization/Ratings/jp.txt
  76. 0 0
      Emby.Server.Implementations/Localization/Ratings/kz.txt
  77. 0 0
      Emby.Server.Implementations/Localization/Ratings/mx.txt
  78. 0 0
      Emby.Server.Implementations/Localization/Ratings/nl.txt
  79. 0 0
      Emby.Server.Implementations/Localization/Ratings/nz.txt
  80. 0 0
      Emby.Server.Implementations/Localization/Ratings/ru.txt
  81. 0 0
      Emby.Server.Implementations/Localization/Ratings/us.txt
  82. 0 0
      Emby.Server.Implementations/Localization/countries.json
  83. 0 0
      Emby.Server.Implementations/Localization/iso6392.txt
  84. 2 2
      Emby.Server.Implementations/Security/EncryptionManager.cs
  85. 10 2
      Emby.Server.Implementations/Security/MBLicenseFile.cs
  86. 32 113
      Emby.Server.Implementations/Udp/UdpServer.cs
  87. 1 1
      MediaBrowser.Api/UserLibrary/UserLibraryService.cs
  88. 4 0
      MediaBrowser.Common/Net/INetworkManager.cs
  89. 2 1
      MediaBrowser.Model/MediaBrowser.Model.csproj
  90. 13 8
      MediaBrowser.Model/Net/ISocketFactory.cs
  91. 2 4
      MediaBrowser.Model/Net/IUdpSocket.cs
  92. 2 2
      MediaBrowser.Model/Net/SocketReceiveResult.cs
  93. 22 0
      MediaBrowser.Model/System/IEnvironmentInfo.cs
  94. 0 1
      MediaBrowser.Mono.sln
  95. 1 0
      MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs
  96. 1 1
      MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs
  97. 1 0
      MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpRequest.cs
  98. 8 10
      MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs
  99. 0 63
      MediaBrowser.Server.Implementations/Logging/PatternsLogger.cs
  100. 0 220
      MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj

+ 6 - 11
Emby.Common.Implementations/BaseApplicationHost.cs

@@ -29,6 +29,7 @@ using MediaBrowser.Common.Extensions;
 using Emby.Common.Implementations.Cryptography;
 using Emby.Common.Implementations.Diagnostics;
 using Emby.Common.Implementations.Net;
+using Emby.Common.Implementations.EnvironmentInfo;
 using Emby.Common.Implementations.Threading;
 using MediaBrowser.Common;
 using MediaBrowser.Common.IO;
@@ -171,6 +172,8 @@ namespace Emby.Common.Implementations
 
         protected ICryptographyProvider CryptographyProvider = new CryptographyProvider();
 
+        protected IEnvironmentInfo EnvironmentInfo = new Emby.Common.Implementations.EnvironmentInfo.EnvironmentInfo();
+
         private DeviceId _deviceId;
         public string SystemId
         {
@@ -187,16 +190,7 @@ namespace Emby.Common.Implementations
 
         public virtual string OperatingSystemDisplayName
         {
-            get
-            {
-#if NET46
-                return Environment.OSVersion.VersionString;
-#endif
-#if NETSTANDARD1_6
-                return System.Runtime.InteropServices.RuntimeInformation.OSDescription;
-#endif
-                return "Operating System";
-            }
+            get { return EnvironmentInfo.OperatingSystemName; }
         }
 
         public IMemoryStreamProvider MemoryStreamProvider { get; set; }
@@ -216,7 +210,7 @@ namespace Emby.Common.Implementations
             // hack alert, until common can target .net core
             BaseExtensions.CryptographyProvider = CryptographyProvider;
 
-            XmlSerializer = new XmlSerializer(fileSystem, logManager.GetLogger("XmlSerializer"));
+            XmlSerializer = new MyXmlSerializer(fileSystem, logManager.GetLogger("XmlSerializer"));
             FailedAssemblies = new List<string>();
 
             ApplicationPaths = applicationPaths;
@@ -534,6 +528,7 @@ return null;
             RegisterSingleInstance(Logger);
 
             RegisterSingleInstance(TaskManager);
+            RegisterSingleInstance(EnvironmentInfo);
 
             RegisterSingleInstance(FileSystemManager);
 

+ 70 - 0
Emby.Common.Implementations/EnvironmentInfo/EnvironmentInfo.cs

@@ -0,0 +1,70 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Threading.Tasks;
+using MediaBrowser.Model.System;
+
+namespace Emby.Common.Implementations.EnvironmentInfo
+{
+    public class EnvironmentInfo : IEnvironmentInfo
+    {
+        public MediaBrowser.Model.System.OperatingSystem OperatingSystem
+        {
+            get
+            {
+#if NET46
+                switch (Environment.OSVersion.Platform)
+                {
+                    case PlatformID.MacOSX:
+                        return MediaBrowser.Model.System.OperatingSystem.OSX;
+                    case PlatformID.Win32NT:
+                        return MediaBrowser.Model.System.OperatingSystem.Windows;
+                    case PlatformID.Unix:
+                        return MediaBrowser.Model.System.OperatingSystem.Linux;
+                }
+#elif NETSTANDARD1_6
+                if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+                {
+                    return OperatingSystem.OSX;
+                }
+                if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+                {
+                    return OperatingSystem.Windows;
+                }
+                if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
+                {
+                    return OperatingSystem.Linux;
+                }
+#endif
+                return MediaBrowser.Model.System.OperatingSystem.Windows;
+            }
+        }
+
+        public string OperatingSystemName
+        {
+            get
+            {
+#if NET46
+                return Environment.OSVersion.Platform.ToString();
+#elif NETSTANDARD1_6
+            return System.Runtime.InteropServices.RuntimeInformation.OSDescription;
+#endif
+                return "Operating System";
+            }
+        }
+
+        public string OperatingSystemVersion
+        {
+            get
+            {
+#if NET46
+                return Environment.OSVersion.Version.ToString() + " " + Environment.OSVersion.ServicePack.ToString();
+#elif NETSTANDARD1_6
+            return System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription;
+#endif
+                return "1.0";
+            }
+        }
+    }
+}

+ 27 - 6
Emby.Common.Implementations/Net/SocketFactory.cs

@@ -36,23 +36,45 @@ namespace Emby.Common.Implementations.Net
 
         #region ISocketFactory Members
 
+        /// <summary>
+        /// Creates a new UDP socket and binds it to the specified local port.
+        /// </summary>
+        /// <param name="localPort">An integer specifying the local port to bind the socket to.</param>
+        public IUdpSocket CreateUdpSocket(int localPort)
+        {
+            if (localPort < 0) throw new ArgumentException("localPort cannot be less than zero.", "localPort");
+
+            var retVal = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
+            try
+            {
+                retVal.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
+                return new UdpSocket(retVal, localPort, _LocalIP);
+            }
+            catch
+            {
+                if (retVal != null)
+                    retVal.Dispose();
+
+                throw;
+            }
+        }
+
         /// <summary>
         /// Creates a new UDP socket that is a member of the SSDP multicast local admin group and binds it to the specified local port.
         /// </summary>
         /// <param name="localPort">An integer specifying the local port to bind the socket to.</param>
         /// <returns>An implementation of the <see cref="IUdpSocket"/> interface used by RSSDP components to perform socket operations.</returns>
-        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "The purpose of this method is to create and returns a disposable result, it is up to the caller to dispose it when they are done with it.")]
-        public IUdpSocket CreateUdpSocket(int localPort)
+        public IUdpSocket CreateSsdpUdpSocket(int localPort)
         {
             if (localPort < 0) throw new ArgumentException("localPort cannot be less than zero.", "localPort");
 
-            var retVal = new Socket(System.Net.Sockets.AddressFamily.InterNetwork, System.Net.Sockets.SocketType.Dgram, System.Net.Sockets.ProtocolType.Udp);
+            var retVal = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
             try
             {
                 retVal.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
                 retVal.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, 4);
                 retVal.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(IPAddress.Parse("239.255.255.250"), _LocalIP));
-                return new UdpSocket(retVal, localPort, _LocalIP.ToString());
+                return new UdpSocket(retVal, localPort, _LocalIP);
             }
             catch
             {
@@ -70,7 +92,6 @@ namespace Emby.Common.Implementations.Net
         /// <param name="multicastTimeToLive">The multicast time to live value for the socket.</param>
         /// <param name="localPort">The number of the local port to bind to.</param>
         /// <returns></returns>
-        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "ip"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "The purpose of this method is to create and returns a disposable result, it is up to the caller to dispose it when they are done with it.")]
         public IUdpSocket CreateUdpMulticastSocket(string ipAddress, int multicastTimeToLive, int localPort)
         {
             if (ipAddress == null) throw new ArgumentNullException("ipAddress");
@@ -97,7 +118,7 @@ namespace Emby.Common.Implementations.Net
                 retVal.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(IPAddress.Parse(ipAddress), _LocalIP));
                 retVal.MulticastLoopback = true;
 
-                return new UdpSocket(retVal, localPort, _LocalIP.ToString());
+                return new UdpSocket(retVal, localPort, _LocalIP);
             }
             catch
             {

+ 28 - 47
Emby.Common.Implementations/Net/UdpSocket.cs

@@ -17,26 +17,20 @@ namespace Emby.Common.Implementations.Net
 
         #region Fields
 
-        private System.Net.Sockets.Socket _Socket;
+        private Socket _Socket;
         private int _LocalPort;
 
         #endregion
 
         #region Constructors
 
-        public UdpSocket(System.Net.Sockets.Socket socket, int localPort, string ipAddress)
+        public UdpSocket(Socket socket, int localPort, IPAddress ip)
         {
             if (socket == null) throw new ArgumentNullException("socket");
 
             _Socket = socket;
             _LocalPort = localPort;
 
-            IPAddress ip = null;
-            if (String.IsNullOrEmpty(ipAddress))
-                ip = IPAddress.Any;
-            else
-                ip = IPAddress.Parse(ipAddress);
-
             _Socket.Bind(new IPEndPoint(ip, _LocalPort));
             if (_LocalPort == 0)
                 _LocalPort = (_Socket.LocalEndPoint as IPEndPoint).Port;
@@ -46,18 +40,18 @@ namespace Emby.Common.Implementations.Net
 
         #region IUdpSocket Members
 
-        public Task<ReceivedUdpData> ReceiveAsync()
+        public Task<SocketReceiveResult> ReceiveAsync()
         {
             ThrowIfDisposed();
 
-            var tcs = new TaskCompletionSource<ReceivedUdpData>();
+            var tcs = new TaskCompletionSource<SocketReceiveResult>();
 
-            System.Net.EndPoint receivedFromEndPoint = new IPEndPoint(IPAddress.Any, 0);
+            EndPoint receivedFromEndPoint = new IPEndPoint(IPAddress.Any, 0);
             var state = new AsyncReceiveState(_Socket, receivedFromEndPoint);
             state.TaskCompletionSource = tcs;
 
 #if NETSTANDARD1_6
-            _Socket.ReceiveFromAsync(new System.ArraySegment<Byte>(state.Buffer), System.Net.Sockets.SocketFlags.None, state.EndPoint)
+            _Socket.ReceiveFromAsync(new ArraySegment<Byte>(state.Buffer),SocketFlags.None, state.EndPoint)
                 .ContinueWith((task, asyncState) =>
                 {
                     if (task.Status != TaskStatus.Faulted)
@@ -68,28 +62,36 @@ namespace Emby.Common.Implementations.Net
                     }
                 }, state);
 #else
-            _Socket.BeginReceiveFrom(state.Buffer, 0, state.Buffer.Length, System.Net.Sockets.SocketFlags.None, ref state.EndPoint, new AsyncCallback(this.ProcessResponse), state);
+            _Socket.BeginReceiveFrom(state.Buffer, 0, state.Buffer.Length, SocketFlags.None, ref state.EndPoint, new AsyncCallback(this.ProcessResponse), state);
 #endif
 
             return tcs.Task;
         }
 
-        public Task SendTo(byte[] messageData, IpEndPointInfo endPoint)
+        public Task SendAsync(byte[] buffer, int size, IpEndPointInfo endPoint)
         {
             ThrowIfDisposed();
 
-            if (messageData == null) throw new ArgumentNullException("messageData");
+            if (buffer == null) throw new ArgumentNullException("messageData");
             if (endPoint == null) throw new ArgumentNullException("endPoint");
 
 #if NETSTANDARD1_6
-            _Socket.SendTo(messageData, new System.Net.IPEndPoint(IPAddress.Parse(endPoint.IpAddress.ToString()), endPoint.Port));
+
+            if (size != buffer.Length)
+            {
+                byte[] copy = new byte[size];
+                Buffer.BlockCopy(buffer, 0, copy, 0, size);
+                buffer = copy;
+            }
+
+            _Socket.SendTo(buffer, new IPEndPoint(IPAddress.Parse(endPoint.IpAddress.ToString()), endPoint.Port));
             return Task.FromResult(true);
 #else
             var taskSource = new TaskCompletionSource<bool>();
 
             try
             {
-                _Socket.BeginSendTo(messageData, 0, messageData.Length, SocketFlags.None, new System.Net.IPEndPoint(IPAddress.Parse(endPoint.IpAddress.ToString()), endPoint.Port), result =>
+                _Socket.BeginSendTo(buffer, 0, size, SocketFlags.None, new System.Net.IPEndPoint(IPAddress.Parse(endPoint.IpAddress.ToString()), endPoint.Port), result =>
                 {
                     try
                     {
@@ -100,29 +102,10 @@ namespace Emby.Common.Implementations.Net
                     {
                         taskSource.TrySetException(ex);
                     }
-                    catch (ObjectDisposedException ex)
-                    {
-                        taskSource.TrySetException(ex);
-                    }
-                    catch (InvalidOperationException ex)
-                    {
-                        taskSource.TrySetException(ex);
-                    }
-                    catch (SecurityException ex)
-                    {
-                        taskSource.TrySetException(ex);
-                    }
+
                 }, null);
             }
-            catch (SocketException ex)
-            {
-                taskSource.TrySetException(ex);
-            }
-            catch (ObjectDisposedException ex)
-            {
-                taskSource.TrySetException(ex);
-            }
-            catch (SecurityException ex)
+            catch (Exception ex)
             {
                 taskSource.TrySetException(ex);
             }
@@ -151,7 +134,6 @@ namespace Emby.Common.Implementations.Net
 
         #region Private Methods
 
-        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Exceptions via task methods should be reported by task completion source, so this should be ok.")]
         private static void ProcessResponse(AsyncReceiveState state, Func<int> receiveData)
         {
             try
@@ -160,11 +142,11 @@ namespace Emby.Common.Implementations.Net
 
                 var ipEndPoint = state.EndPoint as IPEndPoint;
                 state.TaskCompletionSource.SetResult(
-                    new ReceivedUdpData()
+                    new SocketReceiveResult()
                     {
                         Buffer = state.Buffer,
                         ReceivedBytes = bytesRead,
-                        ReceivedFrom = ToIpEndPointInfo(ipEndPoint)
+                        RemoteEndPoint = ToIpEndPointInfo(ipEndPoint)
                     }
                 );
             }
@@ -204,7 +186,6 @@ namespace Emby.Common.Implementations.Net
             };
         }
 
-        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Exceptions via task methods should be reported by task completion source, so this should be ok.")]
         private void ProcessResponse(IAsyncResult asyncResult)
         {
 #if NET46
@@ -215,11 +196,11 @@ namespace Emby.Common.Implementations.Net
 
                 var ipEndPoint = state.EndPoint as IPEndPoint;
                 state.TaskCompletionSource.SetResult(
-                    new ReceivedUdpData()
+                    new SocketReceiveResult
                     {
                         Buffer = state.Buffer,
                         ReceivedBytes = bytesRead,
-                        ReceivedFrom = ToIpEndPointInfo(ipEndPoint)
+                        RemoteEndPoint = ToIpEndPointInfo(ipEndPoint)
                     }
                 );
             }
@@ -247,7 +228,7 @@ namespace Emby.Common.Implementations.Net
 
         private class AsyncReceiveState
         {
-            public AsyncReceiveState(System.Net.Sockets.Socket socket, EndPoint endPoint)
+            public AsyncReceiveState(Socket socket, EndPoint endPoint)
             {
                 this.Socket = socket;
                 this.EndPoint = endPoint;
@@ -256,9 +237,9 @@ namespace Emby.Common.Implementations.Net
             public EndPoint EndPoint;
             public byte[] Buffer = new byte[8192];
 
-            public System.Net.Sockets.Socket Socket { get; private set; }
+            public Socket Socket { get; private set; }
 
-            public TaskCompletionSource<ReceivedUdpData> TaskCompletionSource { get; set; }
+            public TaskCompletionSource<SocketReceiveResult> TaskCompletionSource { get; set; }
 
         }
 

+ 76 - 40
Emby.Common.Implementations/Networking/BaseNetworkManager.cs

@@ -8,6 +8,7 @@ using System.Net.NetworkInformation;
 using System.Net.Sockets;
 using System.Threading.Tasks;
 using MediaBrowser.Model.Extensions;
+using MediaBrowser.Model.Net;
 
 namespace Emby.Common.Implementations.Networking
 {
@@ -21,7 +22,7 @@ namespace Emby.Common.Implementations.Networking
             Logger = logger;
         }
 
-		private List<IPAddress> _localIpAddresses;
+        private List<IPAddress> _localIpAddresses;
         private readonly object _localIpAddressSyncLock = new object();
 
         /// <summary>
@@ -50,24 +51,24 @@ namespace Emby.Common.Implementations.Networking
             return _localIpAddresses;
         }
 
-		private IEnumerable<IPAddress> GetLocalIpAddressesInternal()
+        private IEnumerable<IPAddress> GetLocalIpAddressesInternal()
         {
             var list = GetIPsDefault()
                 .ToList();
 
             if (list.Count == 0)
             {
-				list.AddRange(GetLocalIpAddressesFallback().Result);
+                list.AddRange(GetLocalIpAddressesFallback().Result);
             }
 
-			return list.Where(FilterIpAddress).DistinctBy(i => i.ToString());
+            return list.Where(FilterIpAddress).DistinctBy(i => i.ToString());
         }
 
-		private bool FilterIpAddress(IPAddress address)
+        private bool FilterIpAddress(IPAddress address)
         {
-			var addressString = address.ToString ();
+            var addressString = address.ToString();
 
-			if (addressString.StartsWith("169.", StringComparison.OrdinalIgnoreCase))
+            if (addressString.StartsWith("169.", StringComparison.OrdinalIgnoreCase))
             {
                 return false;
             }
@@ -155,12 +156,12 @@ namespace Emby.Common.Implementations.Networking
                 {
                     var prefix = addressString.Substring(0, lengthMatch);
 
-					if (GetLocalIpAddresses().Any(i => i.ToString().StartsWith(prefix, StringComparison.OrdinalIgnoreCase)))
+                    if (GetLocalIpAddresses().Any(i => i.ToString().StartsWith(prefix, StringComparison.OrdinalIgnoreCase)))
                     {
                         return true;
                     }
                 }
-            } 
+            }
             else if (resolveHost)
             {
                 Uri uri;
@@ -199,45 +200,50 @@ namespace Emby.Common.Implementations.Networking
             return Dns.GetHostAddressesAsync(hostName);
         }
 
-		private List<IPAddress> GetIPsDefault()
-		{
-			NetworkInterface[] interfaces;
+        private List<IPAddress> GetIPsDefault()
+        {
+            NetworkInterface[] interfaces;
 
-			try
-			{
-				interfaces = NetworkInterface.GetAllNetworkInterfaces();
-			}
-			catch (Exception ex)
-			{
-				Logger.ErrorException("Error in GetAllNetworkInterfaces", ex);
-				return new List<IPAddress>();
-			}
+            try
+            {
+                var validStatuses = new[] { OperationalStatus.Up, OperationalStatus.Unknown };
 
-			return interfaces.SelectMany(network => {
+                interfaces = NetworkInterface.GetAllNetworkInterfaces()
+                    .Where(i => validStatuses.Contains(i.OperationalStatus))
+                    .ToArray();
+            }
+            catch (Exception ex)
+            {
+                Logger.ErrorException("Error in GetAllNetworkInterfaces", ex);
+                return new List<IPAddress>();
+            }
+
+            return interfaces.SelectMany(network =>
+            {
 
-				try
-				{
+                try
+                {
                     Logger.Debug("Querying interface: {0}. Type: {1}. Status: {2}", network.Name, network.NetworkInterfaceType, network.OperationalStatus);
 
-					var properties = network.GetIPProperties();
+                    var properties = network.GetIPProperties();
 
-					return properties.UnicastAddresses
+                    return properties.UnicastAddresses
                         .Where(i => i.IsDnsEligible)
                         .Select(i => i.Address)
                         .Where(i => i.AddressFamily == AddressFamily.InterNetwork)
-						.ToList();
-				}
-				catch (Exception ex)
-				{
-					Logger.ErrorException("Error querying network interface", ex);
-					return new List<IPAddress>();
-				}
-
-			}).DistinctBy(i => i.ToString())
-				.ToList();
-		}
-
-		private async Task<IEnumerable<IPAddress>> GetLocalIpAddressesFallback()
+                        .ToList();
+                }
+                catch (Exception ex)
+                {
+                    Logger.ErrorException("Error querying network interface", ex);
+                    return new List<IPAddress>();
+                }
+
+            }).DistinctBy(i => i.ToString())
+                .ToList();
+        }
+
+        private async Task<IEnumerable<IPAddress>> GetLocalIpAddressesFallback()
         {
             var host = await Dns.GetHostEntryAsync(Dns.GetHostName()).ConfigureAwait(false);
 
@@ -309,7 +315,7 @@ namespace Emby.Common.Implementations.Networking
             string[] values = endpointstring.Split(new char[] { ':' });
             IPAddress ipaddy;
             int port = -1;
-          
+
             //check if we have an IPv6 or ports
             if (values.Length <= 2) // ipv4 or hostname
             {
@@ -382,5 +388,35 @@ namespace Emby.Common.Implementations.Networking
 
             return hosts[0];
         }
+
+        public IpAddressInfo ParseIpAddress(string ipAddress)
+        {
+            IpAddressInfo info;
+            if (TryParseIpAddress(ipAddress, out info))
+            {
+                return info;
+            }
+
+            throw new ArgumentException("Invalid ip address: " + ipAddress);
+        }
+
+        public bool TryParseIpAddress(string ipAddress, out IpAddressInfo ipAddressInfo)
+        {
+            IPAddress address;
+            if (IPAddress.TryParse(ipAddress, out address))
+            {
+
+                ipAddressInfo = new IpAddressInfo
+                {
+                    Address = address.ToString(),
+                    IsIpv6 = address.AddressFamily == AddressFamily.InterNetworkV6
+                };
+
+                return true;
+            }
+
+            ipAddressInfo = null;
+            return false;
+        }
     }
 }

+ 9 - 8
Emby.Common.Implementations/Serialization/XmlSerializer.cs

@@ -4,6 +4,7 @@ using System.Collections.Concurrent;
 using System.Collections.Generic;
 using System.IO;
 using System.Xml;
+using System.Xml.Serialization;
 using MediaBrowser.Common.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.Logging;
@@ -13,12 +14,12 @@ namespace Emby.Common.Implementations.Serialization
     /// <summary>
     /// Provides a wrapper around third party xml serialization.
     /// </summary>
-    public class XmlSerializer : IXmlSerializer
+    public class MyXmlSerializer : IXmlSerializer
     {
         private readonly IFileSystem _fileSystem;
         private readonly ILogger _logger;
 
-        public XmlSerializer(IFileSystem fileSystem, ILogger logger)
+        public MyXmlSerializer(IFileSystem fileSystem, ILogger logger)
         {
             _fileSystem = fileSystem;
             _logger = logger;
@@ -26,18 +27,18 @@ namespace Emby.Common.Implementations.Serialization
 
         // Need to cache these
         // http://dotnetcodebox.blogspot.com/2013/01/xmlserializer-class-may-result-in.html
-        private readonly Dictionary<string, System.Xml.Serialization.XmlSerializer> _serializers =
-            new Dictionary<string, System.Xml.Serialization.XmlSerializer>();
+        private readonly Dictionary<string, XmlSerializer> _serializers =
+            new Dictionary<string, XmlSerializer>();
 
-        private System.Xml.Serialization.XmlSerializer GetSerializer(Type type)
+        private XmlSerializer GetSerializer(Type type)
         {
             var key = type.FullName;
             lock (_serializers)
             {
-                System.Xml.Serialization.XmlSerializer serializer;
+                XmlSerializer serializer;
                 if (!_serializers.TryGetValue(key, out serializer))
                 {
-                    serializer = new System.Xml.Serialization.XmlSerializer(type);
+                    serializer = new XmlSerializer(type);
                     _serializers[key] = serializer;
                 }
                 return serializer;
@@ -80,7 +81,7 @@ namespace Emby.Common.Implementations.Serialization
 #if NET46
             using (var writer = new XmlTextWriter(stream, null))            
             {
-                writer.Formatting = System.Xml.Formatting.Indented;
+                writer.Formatting = Formatting.Indented;
                 SerializeToWriter(obj, writer);
             }
 #else

+ 5 - 4
Emby.Common.Implementations/project.json

@@ -12,15 +12,14 @@
         "System.IO": "4.0.0.0",
         "System.Net": "4.0.0.0",
         "System.Net.Http": "4.0.0.0",
-        "System.Net.Http.WebRequest": "4.0.0.0",
         "System.Net.Primitives": "4.0.0.0",
+        "System.Net.Http.WebRequest": "4.0.0.0",
         "System.Runtime": "4.0.0.0",
         "System.Runtime.Extensions": "4.0.0.0",
         "System.Text.Encoding": "4.0.0.0",
         "System.Threading": "4.0.0.0",
         "System.Threading.Tasks": "4.0.0.0",
-        "System.Xml": "4.0.0.0",
-        "System.Xml.Serialization": "4.0.0.0"
+		"System.Xml.ReaderWriter": "4.0.0"
       },
       "dependencies": {
         "SimpleInjector": "3.2.4",
@@ -30,7 +29,8 @@
         },
         "MediaBrowser.Common": {
           "target": "project"
-        }      }
+        }      
+	}
     },
     "netstandard1.6": {
       "imports": "dnxcore50",
@@ -40,6 +40,7 @@
 		"System.Diagnostics.Process": "4.1.0",
 		"System.Threading.Timer": "4.0.1",
 		"System.Net.Requests": "4.0.11",
+		"System.Xml.ReaderWriter": "4.0.11",
 		"System.Xml.XmlSerializer": "4.0.11",
 		"System.Net.Http": "4.1.0",
 		"System.Net.Primitives": "4.0.11",

+ 4 - 4
Emby.Dlna/Didl/DidlBuilder.cs

@@ -104,6 +104,8 @@ namespace Emby.Dlna.Didl
 
             writer.WriteStartElement(string.Empty, "item", NS_DIDL);
 
+            AddGeneralProperties(item, null, context, writer, filter);
+
             writer.WriteAttributeString("restricted", "1");
             writer.WriteAttributeString("id", clientId);
 
@@ -122,8 +124,6 @@ namespace Emby.Dlna.Didl
 
             //AddBookmarkInfo(item, user, element);
 
-            AddGeneralProperties(item, null, context, writer, filter);
-
             // refID?
             // storeAttribute(itemNode, object, ClassProperties.REF_ID, false);
 
@@ -501,6 +501,8 @@ namespace Emby.Dlna.Didl
         {
             writer.WriteStartElement(string.Empty, "container", NS_DIDL);
 
+            AddGeneralProperties(folder, stubType, context, writer, filter);
+
             writer.WriteAttributeString("restricted", "0");
             writer.WriteAttributeString("searchable", "1");
             writer.WriteAttributeString("childCount", childCount.ToString(_usCulture));
@@ -534,8 +536,6 @@ namespace Emby.Dlna.Didl
                 }
             }
 
-            AddCommonFields(folder, stubType, null, writer, filter);
-
             AddCover(folder, context, stubType, writer);
 
             writer.WriteEndElement();

+ 13 - 6
Emby.Dlna/Main/DlnaEntryPoint.cs

@@ -20,6 +20,7 @@ using MediaBrowser.Controller.MediaEncoding;
 using MediaBrowser.Model.Dlna;
 using MediaBrowser.Model.Globalization;
 using MediaBrowser.Model.Net;
+using MediaBrowser.Model.System;
 using MediaBrowser.Model.Threading;
 using Rssdp;
 using Rssdp.Infrastructure;
@@ -52,7 +53,7 @@ namespace Emby.Dlna.Main
 
         private readonly ITimerFactory _timerFactory;
         private readonly ISocketFactory _socketFactory;
-
+        private readonly IEnvironmentInfo _environmentInfo;
 
         public DlnaEntryPoint(IServerConfigurationManager config,
             ILogManager logManager,
@@ -66,7 +67,7 @@ namespace Emby.Dlna.Main
             IUserDataManager userDataManager,
             ILocalizationManager localization,
             IMediaSourceManager mediaSourceManager,
-            IDeviceDiscovery deviceDiscovery, IMediaEncoder mediaEncoder, ISocketFactory socketFactory, ITimerFactory timerFactory)
+            IDeviceDiscovery deviceDiscovery, IMediaEncoder mediaEncoder, ISocketFactory socketFactory, ITimerFactory timerFactory, IEnvironmentInfo environmentInfo)
         {
             _config = config;
             _appHost = appHost;
@@ -83,6 +84,7 @@ namespace Emby.Dlna.Main
             _mediaEncoder = mediaEncoder;
             _socketFactory = socketFactory;
             _timerFactory = timerFactory;
+            _environmentInfo = environmentInfo;
             _logger = logManager.GetLogger("Dlna");
         }
 
@@ -169,7 +171,7 @@ namespace Emby.Dlna.Main
         private void StartPublishing()
         {
             SsdpDevicePublisherBase.LogFunction = LogMessage;
-            _Publisher = new SsdpDevicePublisher(_socketFactory, _timerFactory, "Windows", "10");
+            _Publisher = new SsdpDevicePublisher(_socketFactory, _timerFactory, _environmentInfo.OperatingSystemName, _environmentInfo.OperatingSystemVersion);
         }
 
         private void StartDeviceDiscovery()
@@ -238,6 +240,8 @@ namespace Emby.Dlna.Main
 
             var addresses = (await _appHost.GetLocalIpAddresses().ConfigureAwait(false)).ToList();
 
+            var udn = CreateUuid(_appHost.SystemId);
+
             foreach (var address in addresses)
             {
                 //if (IPAddress.IsLoopback(address))
@@ -248,8 +252,6 @@ namespace Emby.Dlna.Main
 
                 var addressString = address.ToString();
 
-                var udn = CreateUuid(addressString);
-
                 var fullService = "urn:schemas-upnp-org:device:MediaServer:1";
 
                 _logger.Info("Registering publisher for {0} on {1}", fullService, addressString);
@@ -297,7 +299,12 @@ namespace Emby.Dlna.Main
 
         private string CreateUuid(string text)
         {
-            return text.GetMD5().ToString("N");
+            Guid guid;
+            if (!Guid.TryParse(text, out guid))
+            {
+                guid = text.GetMD5();
+            }
+            return guid.ToString("N");
         }
 
         private void SetProperies(SsdpDevice device, string fullDeviceType)

+ 1 - 1
Emby.Dlna/Service/BaseControlHandler.cs

@@ -228,7 +228,7 @@ namespace Emby.Dlna.Service
             var headers = string.Join(", ", request.Headers.Select(i => string.Format("{0}={1}", i.Key, i.Value)).ToArray());
             builder.AppendFormat("Headers: {0}", headers);
             builder.AppendLine();
-            builder.Append(request.InputXml);
+            //builder.Append(request.InputXml);
 
             Logger.LogMultiline("Control request", LogSeverity.Debug, builder);
         }

+ 1 - 1
MediaBrowser.Server.Implementations/Connect/ConnectData.cs → Emby.Server.Implementations/Connect/ConnectData.cs

@@ -1,7 +1,7 @@
 using System;
 using System.Collections.Generic;
 
-namespace MediaBrowser.Server.Implementations.Connect
+namespace Emby.Server.Implementations.Connect
 {
     public class ConnectData
     {

+ 10 - 14
MediaBrowser.Server.Implementations/Connect/ConnectEntryPoint.cs → Emby.Server.Implementations/Connect/ConnectEntryPoint.cs

@@ -7,16 +7,12 @@ using MediaBrowser.Model.Logging;
 using MediaBrowser.Model.Net;
 using System;
 using System.IO;
-using System.Net;
-using System.Net.Sockets;
 using System.Text;
 using System.Threading.Tasks;
-using MediaBrowser.Common.IO;
-using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.Threading;
 
-namespace MediaBrowser.Server.Implementations.Connect
+namespace Emby.Server.Implementations.Connect
 {
     public class ConnectEntryPoint : IServerEntryPoint
     {
@@ -59,7 +55,7 @@ namespace MediaBrowser.Server.Implementations.Connect
 
         private async void TimerCallback(object state)
         {
-            IPAddress validIpAddress = null;
+            IpAddressInfo validIpAddress = null;
 
             foreach (var ipLookupUrl in _ipLookups)
             {
@@ -68,7 +64,7 @@ namespace MediaBrowser.Server.Implementations.Connect
                     validIpAddress = await GetIpAddress(ipLookupUrl).ConfigureAwait(false);
 
                     // Try to find the ipv4 address, if present
-                    if (validIpAddress.AddressFamily == AddressFamily.InterNetwork)
+                    if (!validIpAddress.IsIpv6)
                     {
                         break;
                     }
@@ -83,7 +79,7 @@ namespace MediaBrowser.Server.Implementations.Connect
             }
 
             // If this produced an ipv6 address, try again
-            if (validIpAddress != null && validIpAddress.AddressFamily == AddressFamily.InterNetworkV6)
+            if (validIpAddress != null && validIpAddress.IsIpv6)
             {
                 foreach (var ipLookupUrl in _ipLookups)
                 {
@@ -92,7 +88,7 @@ namespace MediaBrowser.Server.Implementations.Connect
                         var newAddress = await GetIpAddress(ipLookupUrl, true).ConfigureAwait(false);
 
                         // Try to find the ipv4 address, if present
-                        if (newAddress.AddressFamily == AddressFamily.InterNetwork)
+                        if (!newAddress.IsIpv6)
                         {
                             validIpAddress = newAddress;
                             break;
@@ -115,7 +111,7 @@ namespace MediaBrowser.Server.Implementations.Connect
             }
         }
 
-        private async Task<IPAddress> GetIpAddress(string lookupUrl, bool preferIpv4 = false)
+        private async Task<IpAddressInfo> GetIpAddress(string lookupUrl, bool preferIpv4 = false)
         {
             // Sometimes whatismyipaddress might fail, but it won't do us any good having users raise alarms over it.
             var logErrors = false;
@@ -140,7 +136,7 @@ namespace MediaBrowser.Server.Implementations.Connect
                 {
                     var addressString = await reader.ReadToEndAsync().ConfigureAwait(false);
 
-                    return IPAddress.Parse(addressString);
+                    return _networkManager.ParseIpAddress(addressString);
                 }
             }
         }
@@ -150,7 +146,7 @@ namespace MediaBrowser.Server.Implementations.Connect
             get { return Path.Combine(_appPaths.DataPath, "wan.txt"); }
         }
 
-        private void CacheAddress(IPAddress address)
+        private void CacheAddress(IpAddressInfo address)
         {
             var path = CacheFilePath;
 
@@ -174,9 +170,9 @@ namespace MediaBrowser.Server.Implementations.Connect
             try
             {
                 var endpoint = _fileSystem.ReadAllText(path, Encoding.UTF8);
-                IPAddress ipAddress;
+                IpAddressInfo ipAddress;
 
-                if (IPAddress.TryParse(endpoint, out ipAddress))
+                if (_networkManager.TryParseIpAddress(endpoint, out ipAddress))
                 {
                     ((ConnectManager)_connectManager).OnWanAddressResolved(ipAddress);
                 }

+ 4 - 7
MediaBrowser.Server.Implementations/Connect/ConnectManager.cs → Emby.Server.Implementations/Connect/ConnectManager.cs

@@ -19,16 +19,13 @@ using System.Globalization;
 using System.IO;
 using System.Linq;
 using System.Net;
-using System.Net.Sockets;
 using System.Text;
 using System.Threading;
 using System.Threading.Tasks;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Common.Extensions;
-using MediaBrowser.Common.IO;
-using MediaBrowser.Controller.IO;
 
-namespace MediaBrowser.Server.Implementations.Connect
+namespace Emby.Server.Implementations.Connect
 {
     public class ConnectManager : IConnectManager
     {
@@ -57,7 +54,7 @@ namespace MediaBrowser.Server.Implementations.Connect
             get { return _data.AccessKey; }
         }
 
-        private IPAddress DiscoveredWanIpAddress { get; set; }
+        private IpAddressInfo DiscoveredWanIpAddress { get; set; }
 
         public string WanIpAddress
         {
@@ -77,7 +74,7 @@ namespace MediaBrowser.Server.Implementations.Connect
 
                 if (string.IsNullOrWhiteSpace(address) && DiscoveredWanIpAddress != null)
                 {
-                    if (DiscoveredWanIpAddress.AddressFamily == AddressFamily.InterNetworkV6)
+                    if (DiscoveredWanIpAddress.IsIpv6)
                     {
                         address = "[" + DiscoveredWanIpAddress + "]";
                     }
@@ -148,7 +145,7 @@ namespace MediaBrowser.Server.Implementations.Connect
             _config.ConfigurationUpdated += _config_ConfigurationUpdated;
         }
 
-        internal void OnWanAddressResolved(IPAddress address)
+        internal void OnWanAddressResolved(IpAddressInfo address)
         {
             DiscoveredWanIpAddress = address;
 

+ 1 - 1
MediaBrowser.Server.Implementations/Connect/Responses.cs → Emby.Server.Implementations/Connect/Responses.cs

@@ -1,7 +1,7 @@
 using MediaBrowser.Model.Configuration;
 using MediaBrowser.Model.Connect;
 
-namespace MediaBrowser.Server.Implementations.Connect
+namespace Emby.Server.Implementations.Connect
 {
     public class ServerRegistrationResponse
     {

+ 1 - 1
MediaBrowser.Server.Implementations/Connect/Validator.cs → Emby.Server.Implementations/Connect/Validator.cs

@@ -1,6 +1,6 @@
 using System.Text.RegularExpressions;
 
-namespace MediaBrowser.Server.Implementations.Connect
+namespace Emby.Server.Implementations.Connect
 {
     public static class Validator
     {

+ 254 - 1
Emby.Server.Implementations/Emby.Server.Implementations.csproj

@@ -43,6 +43,11 @@
     <Compile Include="Channels\RefreshChannelsScheduledTask.cs" />
     <Compile Include="Collections\CollectionImageProvider.cs" />
     <Compile Include="Collections\CollectionManager.cs" />
+    <Compile Include="Connect\ConnectData.cs" />
+    <Compile Include="Connect\ConnectEntryPoint.cs" />
+    <Compile Include="Connect\ConnectManager.cs" />
+    <Compile Include="Connect\Responses.cs" />
+    <Compile Include="Connect\Validator.cs" />
     <Compile Include="Devices\DeviceManager.cs" />
     <Compile Include="Dto\DtoService.cs" />
     <Compile Include="EntryPoints\AutomaticRestartEntryPoint.cs" />
@@ -51,6 +56,7 @@
     <Compile Include="EntryPoints\RecordingNotifier.cs" />
     <Compile Include="EntryPoints\RefreshUsersMetadata.cs" />
     <Compile Include="EntryPoints\ServerEventNotifier.cs" />
+    <Compile Include="EntryPoints\UdpServerEntryPoint.cs" />
     <Compile Include="EntryPoints\UsageEntryPoint.cs" />
     <Compile Include="EntryPoints\UsageReporter.cs" />
     <Compile Include="EntryPoints\UserDataChangeNotifier.cs" />
@@ -61,13 +67,17 @@
     <Compile Include="FileOrganization\NameUtils.cs" />
     <Compile Include="FileOrganization\OrganizerScheduledTask.cs" />
     <Compile Include="FileOrganization\TvFolderOrganizer.cs" />
+    <Compile Include="HttpServer\GetSwaggerResource.cs" />
+    <Compile Include="HttpServer\SocketSharp\HttpUtility.cs" />
     <Compile Include="HttpServer\IHttpListener.cs" />
     <Compile Include="HttpServer\Security\AuthorizationContext.cs" />
     <Compile Include="HttpServer\Security\AuthService.cs" />
     <Compile Include="HttpServer\Security\SessionContext.cs" />
     <Compile Include="HttpServer\StreamWriter.cs" />
+    <Compile Include="HttpServer\SwaggerService.cs" />
     <Compile Include="Images\BaseDynamicImageProvider.cs" />
     <Compile Include="Intros\DefaultIntroProvider.cs" />
+    <Compile Include="IO\FileRefresher.cs" />
     <Compile Include="IO\ThrottledStream.cs" />
     <Compile Include="Library\CoreResolutionIgnoreRule.cs" />
     <Compile Include="Library\LibraryManager.cs" />
@@ -137,6 +147,7 @@
     <Compile Include="LiveTv\TunerHosts\M3UTunerHost.cs" />
     <Compile Include="LiveTv\TunerHosts\MulticastStream.cs" />
     <Compile Include="LiveTv\TunerHosts\QueueStream.cs" />
+    <Compile Include="Localization\LocalizationManager.cs" />
     <Compile Include="Logging\PatternsLogger.cs" />
     <Compile Include="MediaEncoder\EncodingManager.cs" />
     <Compile Include="News\NewsEntryPoint.cs" />
@@ -159,6 +170,7 @@
     <Compile Include="ScheduledTasks\RefreshIntrosTask.cs" />
     <Compile Include="ScheduledTasks\RefreshMediaLibraryTask.cs" />
     <Compile Include="ScheduledTasks\SystemUpdateTask.cs" />
+    <Compile Include="Security\EncryptionManager.cs" />
     <Compile Include="Security\MBLicenseFile.cs" />
     <Compile Include="Security\PluginSecurityManager.cs" />
     <Compile Include="Security\RegRecord.cs" />
@@ -217,11 +229,14 @@
     <Compile Include="Sync\TargetDataProvider.cs" />
     <Compile Include="TV\SeriesPostScanTask.cs" />
     <Compile Include="TV\TVSeriesManager.cs" />
+    <Compile Include="Udp\UdpServer.cs" />
     <Compile Include="Updates\InstallationManager.cs" />
     <Compile Include="UserViews\CollectionFolderImageProvider.cs" />
     <Compile Include="UserViews\DynamicImageProvider.cs" />
   </ItemGroup>
-  <ItemGroup />
+  <ItemGroup>
+    <EmbeddedResource Include="Localization\iso6392.txt" />
+  </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="..\MediaBrowser.Common\MediaBrowser.Common.csproj">
       <Project>{9142eefa-7570-41e1-bfcc-468bb571af2f}</Project>
@@ -257,8 +272,246 @@
     </Reference>
   </ItemGroup>
   <ItemGroup>
+    <Content Include="..\thirdparty\servicestack\swagger-ui\fonts\droid-sans-v6-latin-700.svg">
+      <Link>swagger-ui\fonts\droid-sans-v6-latin-700.svg</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="..\thirdparty\servicestack\swagger-ui\fonts\droid-sans-v6-latin-regular.svg">
+      <Link>swagger-ui\fonts\droid-sans-v6-latin-regular.svg</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="..\thirdparty\servicestack\swagger-ui\images\explorer_icons.png">
+      <Link>swagger-ui\images\explorer_icons.png</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="..\thirdparty\servicestack\swagger-ui\images\logo_small.png">
+      <Link>swagger-ui\images\logo_small.png</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="..\thirdparty\servicestack\swagger-ui\images\pet_store_api.png">
+      <Link>swagger-ui\images\pet_store_api.png</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="..\thirdparty\servicestack\swagger-ui\images\throbber.gif">
+      <Link>swagger-ui\images\throbber.gif</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="..\thirdparty\servicestack\swagger-ui\images\wordnik_api.png">
+      <Link>swagger-ui\images\wordnik_api.png</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="..\thirdparty\servicestack\swagger-ui\index.html">
+      <Link>swagger-ui\index.html</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="..\thirdparty\servicestack\swagger-ui\lib\backbone-min.js">
+      <Link>swagger-ui\lib\backbone-min.js</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="..\thirdparty\servicestack\swagger-ui\lib\handlebars-2.0.0.js">
+      <Link>swagger-ui\lib\handlebars-2.0.0.js</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="..\thirdparty\servicestack\swagger-ui\lib\highlight.7.3.pack.js">
+      <Link>swagger-ui\lib\highlight.7.3.pack.js</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="..\thirdparty\servicestack\swagger-ui\lib\jquery-1.8.0.min.js">
+      <Link>swagger-ui\lib\jquery-1.8.0.min.js</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="..\thirdparty\servicestack\swagger-ui\lib\jquery.ba-bbq.min.js">
+      <Link>swagger-ui\lib\jquery.ba-bbq.min.js</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="..\thirdparty\servicestack\swagger-ui\lib\jquery.slideto.min.js">
+      <Link>swagger-ui\lib\jquery.slideto.min.js</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="..\thirdparty\servicestack\swagger-ui\lib\jquery.wiggle.min.js">
+      <Link>swagger-ui\lib\jquery.wiggle.min.js</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="..\thirdparty\servicestack\swagger-ui\lib\marked.js">
+      <Link>swagger-ui\lib\marked.js</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="..\thirdparty\servicestack\swagger-ui\lib\shred.bundle.js">
+      <Link>swagger-ui\lib\shred.bundle.js</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="..\thirdparty\servicestack\swagger-ui\lib\shred\content.js">
+      <Link>swagger-ui\lib\shred\content.js</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="..\thirdparty\servicestack\swagger-ui\lib\swagger-client.js">
+      <Link>swagger-ui\lib\swagger-client.js</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="..\thirdparty\servicestack\swagger-ui\lib\swagger-oauth.js">
+      <Link>swagger-ui\lib\swagger-oauth.js</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="..\thirdparty\servicestack\swagger-ui\lib\underscore-min.js">
+      <Link>swagger-ui\lib\underscore-min.js</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="..\thirdparty\servicestack\swagger-ui\o2c.html">
+      <Link>swagger-ui\o2c.html</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="..\thirdparty\servicestack\swagger-ui\patch.js">
+      <Link>swagger-ui\patch.js</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="..\thirdparty\servicestack\swagger-ui\swagger-ui.js">
+      <Link>swagger-ui\swagger-ui.js</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="..\thirdparty\servicestack\swagger-ui\swagger-ui.min.js">
+      <Link>swagger-ui\swagger-ui.min.js</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <EmbeddedResource Include="Localization\Core\ar.json" />
+    <EmbeddedResource Include="Localization\Core\bg-BG.json" />
+    <EmbeddedResource Include="Localization\Core\ca.json" />
+    <EmbeddedResource Include="Localization\Core\core.json" />
+    <EmbeddedResource Include="Localization\Core\cs.json" />
+    <EmbeddedResource Include="Localization\Core\da.json" />
+    <EmbeddedResource Include="Localization\Core\de.json" />
+    <EmbeddedResource Include="Localization\Core\el.json" />
+    <EmbeddedResource Include="Localization\Core\en-GB.json" />
+    <EmbeddedResource Include="Localization\Core\en-US.json" />
+    <EmbeddedResource Include="Localization\Core\es-AR.json" />
+    <EmbeddedResource Include="Localization\Core\es-MX.json" />
+    <EmbeddedResource Include="Localization\Core\es.json" />
+    <EmbeddedResource Include="Localization\Core\fi.json" />
+    <EmbeddedResource Include="Localization\Core\fr-CA.json" />
+    <EmbeddedResource Include="Localization\Core\fr.json" />
+    <EmbeddedResource Include="Localization\Core\gsw.json" />
+    <EmbeddedResource Include="Localization\Core\he.json" />
+    <EmbeddedResource Include="Localization\Core\hr.json" />
+    <EmbeddedResource Include="Localization\Core\hu.json" />
+    <EmbeddedResource Include="Localization\Core\id.json" />
+    <EmbeddedResource Include="Localization\Core\it.json" />
+    <EmbeddedResource Include="Localization\Core\kk.json" />
+    <EmbeddedResource Include="Localization\Core\ko.json" />
+    <EmbeddedResource Include="Localization\Core\ms.json" />
+    <EmbeddedResource Include="Localization\Core\nb.json" />
+    <EmbeddedResource Include="Localization\Core\nl.json" />
+    <EmbeddedResource Include="Localization\Core\pl.json" />
+    <EmbeddedResource Include="Localization\Core\pt-BR.json" />
+    <EmbeddedResource Include="Localization\Core\pt-PT.json" />
+    <EmbeddedResource Include="Localization\Core\ro.json" />
+    <EmbeddedResource Include="Localization\Core\ru.json" />
+    <EmbeddedResource Include="Localization\Core\sl-SI.json" />
+    <EmbeddedResource Include="Localization\Core\sv.json" />
+    <EmbeddedResource Include="Localization\Core\tr.json" />
+    <EmbeddedResource Include="Localization\Core\uk.json" />
+    <EmbeddedResource Include="Localization\Core\vi.json" />
+    <EmbeddedResource Include="Localization\Core\zh-CN.json" />
+    <EmbeddedResource Include="Localization\Core\zh-HK.json" />
+    <EmbeddedResource Include="Localization\Core\zh-TW.json" />
+    <EmbeddedResource Include="Localization\countries.json" />
+    <Content Include="..\thirdparty\servicestack\swagger-ui\fonts\droid-sans-v6-latin-700.eot">
+      <Link>swagger-ui\fonts\droid-sans-v6-latin-700.eot</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="..\thirdparty\servicestack\swagger-ui\fonts\droid-sans-v6-latin-700.ttf">
+      <Link>swagger-ui\fonts\droid-sans-v6-latin-700.ttf</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="..\thirdparty\servicestack\swagger-ui\fonts\droid-sans-v6-latin-700.woff">
+      <Link>swagger-ui\fonts\droid-sans-v6-latin-700.woff</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="..\thirdparty\servicestack\swagger-ui\fonts\droid-sans-v6-latin-700.woff2">
+      <Link>swagger-ui\fonts\droid-sans-v6-latin-700.woff2</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="..\thirdparty\servicestack\swagger-ui\fonts\droid-sans-v6-latin-regular.eot">
+      <Link>swagger-ui\fonts\droid-sans-v6-latin-regular.eot</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="..\thirdparty\servicestack\swagger-ui\fonts\droid-sans-v6-latin-regular.ttf">
+      <Link>swagger-ui\fonts\droid-sans-v6-latin-regular.ttf</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="..\thirdparty\servicestack\swagger-ui\fonts\droid-sans-v6-latin-regular.woff">
+      <Link>swagger-ui\fonts\droid-sans-v6-latin-regular.woff</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="..\thirdparty\servicestack\swagger-ui\fonts\droid-sans-v6-latin-regular.woff2">
+      <Link>swagger-ui\fonts\droid-sans-v6-latin-regular.woff2</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
     <None Include="packages.config" />
   </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="Localization\Ratings\au.txt" />
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="Localization\Ratings\be.txt" />
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="Localization\Ratings\br.txt" />
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="Localization\Ratings\ca.txt" />
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="Localization\Ratings\co.txt" />
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="Localization\Ratings\de.txt" />
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="Localization\Ratings\dk.txt" />
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="Localization\Ratings\fr.txt" />
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="Localization\Ratings\gb.txt" />
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="Localization\Ratings\ie.txt" />
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="Localization\Ratings\jp.txt" />
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="Localization\Ratings\kz.txt" />
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="Localization\Ratings\mx.txt" />
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="Localization\Ratings\nl.txt" />
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="Localization\Ratings\nz.txt" />
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="Localization\Ratings\ru.txt" />
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="Localization\Ratings\us.txt" />
+  </ItemGroup>
+  <ItemGroup>
+    <Content Include="..\thirdparty\servicestack\swagger-ui\css\reset.css">
+      <Link>swagger-ui\css\reset.css</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="..\thirdparty\servicestack\swagger-ui\css\screen.css">
+      <Link>swagger-ui\css\screen.css</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+    <Content Include="..\thirdparty\servicestack\swagger-ui\css\typography.css">
+      <Link>swagger-ui\css\typography.css</Link>
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+  </ItemGroup>
   <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.

+ 7 - 14
MediaBrowser.Server.Implementations/EntryPoints/UdpServerEntryPoint.cs → Emby.Server.Implementations/EntryPoints/UdpServerEntryPoint.cs

@@ -1,12 +1,12 @@
 using System;
-using MediaBrowser.Common.Net;
 using MediaBrowser.Controller;
 using MediaBrowser.Controller.Plugins;
 using MediaBrowser.Model.Logging;
 using MediaBrowser.Model.Serialization;
-using MediaBrowser.Server.Implementations.Udp;
+using Emby.Server.Implementations.Udp;
+using MediaBrowser.Model.Net;
 
-namespace MediaBrowser.Server.Implementations.EntryPoints
+namespace Emby.Server.Implementations.EntryPoints
 {
     /// <summary>
     /// Class UdpServerEntryPoint
@@ -23,10 +23,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
         /// The _logger
         /// </summary>
         private readonly ILogger _logger;
-        /// <summary>
-        /// The _network manager
-        /// </summary>
-        private readonly INetworkManager _networkManager;
+        private readonly ISocketFactory _socketFactory;
         private readonly IServerApplicationHost _appHost;
         private readonly IJsonSerializer _json;
 
@@ -35,16 +32,12 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
         /// <summary>
         /// Initializes a new instance of the <see cref="UdpServerEntryPoint" /> class.
         /// </summary>
-        /// <param name="logger">The logger.</param>
-        /// <param name="networkManager">The network manager.</param>
-        /// <param name="appHost">The application host.</param>
-        /// <param name="json">The json.</param>
-        public UdpServerEntryPoint(ILogger logger, INetworkManager networkManager, IServerApplicationHost appHost, IJsonSerializer json)
+        public UdpServerEntryPoint(ILogger logger, IServerApplicationHost appHost, IJsonSerializer json, ISocketFactory socketFactory)
         {
             _logger = logger;
-            _networkManager = networkManager;
             _appHost = appHost;
             _json = json;
+            _socketFactory = socketFactory;
         }
 
         /// <summary>
@@ -52,7 +45,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
         /// </summary>
         public void Run()
         {
-            var udpServer = new UdpServer(_logger, _networkManager, _appHost, _json);
+            var udpServer = new UdpServer(_logger, _appHost, _json, _socketFactory);
 
             try
             {

+ 2 - 2
MediaBrowser.Server.Implementations/HttpServer/GetSwaggerResource.cs → Emby.Server.Implementations/HttpServer/GetSwaggerResource.cs

@@ -1,6 +1,6 @@
-using ServiceStack;
+using MediaBrowser.Model.Services;
 
-namespace MediaBrowser.Server.Implementations.HttpServer
+namespace Emby.Server.Implementations.HttpServer
 {
     /// <summary>
     /// Class GetDashboardResource

+ 2 - 22
MediaBrowser.Server.Implementations/HttpServer/SocketSharp/HttpUtility.cs → Emby.Server.Implementations/HttpServer/SocketSharp/HttpUtility.cs

@@ -1,33 +1,13 @@
 using System;
 using System.Collections;
 using System.Collections.Generic;
-using System.Collections.Specialized;
 using System.Text;
 using MediaBrowser.Model.Services;
 
-namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp
+namespace Emby.Server.Implementations.HttpServer.SocketSharp
 {
     public static class MyHttpUtility
     {
-        sealed class HttpQSCollection : NameValueCollection
-        {
-            public override string ToString()
-            {
-                int count = Count;
-                if (count == 0)
-                    return "";
-                StringBuilder sb = new StringBuilder();
-                string[] keys = AllKeys;
-                for (int i = 0; i < count; i++)
-                {
-                    sb.AppendFormat("{0}={1}&", keys[i], this[keys[i]]);
-                }
-                if (sb.Length > 0)
-                    sb.Length--;
-                return sb.ToString();
-            }
-        }
-
         // Must be sorted
         static readonly long[] entities = new long[] {
 			(long)'A' << 56 | (long)'E' << 48 | (long)'l' << 40 | (long)'i' << 32 | (long)'g' << 24, 
@@ -607,7 +587,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp
 
             byte[] buf = bytes.ToArray();
             bytes = null;
-            return e.GetString(buf);
+            return e.GetString(buf, 0, buf.Length);
 
         }
 

+ 6 - 3
MediaBrowser.Server.Implementations/HttpServer/SwaggerService.cs → Emby.Server.Implementations/HttpServer/SwaggerService.cs

@@ -1,17 +1,20 @@
 using MediaBrowser.Controller;
 using MediaBrowser.Controller.Net;
 using System.IO;
+using MediaBrowser.Model.IO;
 using MediaBrowser.Model.Services;
 
-namespace MediaBrowser.Server.Implementations.HttpServer
+namespace Emby.Server.Implementations.HttpServer
 {
     public class SwaggerService : IHasResultFactory, IService
     {
         private readonly IServerApplicationPaths _appPaths;
+        private readonly IFileSystem _fileSystem;
 
-        public SwaggerService(IServerApplicationPaths appPaths)
+        public SwaggerService(IServerApplicationPaths appPaths, IFileSystem fileSystem)
         {
             _appPaths = appPaths;
+            _fileSystem = fileSystem;
         }
 
         /// <summary>
@@ -23,7 +26,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
         {
             var swaggerDirectory = Path.Combine(_appPaths.ApplicationResourcesPath, "swagger-ui");
 
-            var requestedFile = Path.Combine(swaggerDirectory, request.ResourceName.Replace('/', Path.DirectorySeparatorChar));
+            var requestedFile = Path.Combine(swaggerDirectory, request.ResourceName.Replace('/', _fileSystem.DirectorySeparatorChar));
 
             return ResultFactory.GetStaticFileResult(Request, requestedFile).Result;
         }

+ 6 - 3
MediaBrowser.Server.Implementations/IO/FileRefresher.cs → Emby.Server.Implementations/IO/FileRefresher.cs

@@ -13,10 +13,11 @@ using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.Library;
 using MediaBrowser.Model.Extensions;
 using MediaBrowser.Model.Logging;
+using MediaBrowser.Model.System;
 using MediaBrowser.Model.Tasks;
 using MediaBrowser.Model.Threading;
 
-namespace MediaBrowser.Server.Implementations.IO
+namespace Emby.Server.Implementations.IO
 {
     public class FileRefresher : IDisposable
     {
@@ -32,8 +33,9 @@ namespace MediaBrowser.Server.Implementations.IO
         public string Path { get; private set; }
 
         public event EventHandler<EventArgs> Completed;
+        private readonly IEnvironmentInfo _environmentInfo;
 
-        public FileRefresher(string path, IFileSystem fileSystem, IServerConfigurationManager configurationManager, ILibraryManager libraryManager, ITaskManager taskManager, ILogger logger, ITimerFactory timerFactory)
+        public FileRefresher(string path, IFileSystem fileSystem, IServerConfigurationManager configurationManager, ILibraryManager libraryManager, ITaskManager taskManager, ILogger logger, ITimerFactory timerFactory, IEnvironmentInfo environmentInfo)
         {
             logger.Debug("New file refresher created for {0}", path);
             Path = path;
@@ -44,6 +46,7 @@ namespace MediaBrowser.Server.Implementations.IO
             TaskManager = taskManager;
             Logger = logger;
             _timerFactory = timerFactory;
+            _environmentInfo = environmentInfo;
             AddPath(path);
         }
 
@@ -226,7 +229,7 @@ namespace MediaBrowser.Server.Implementations.IO
 
         private bool IsFileLocked(string path)
         {
-            if (Environment.OSVersion.Platform != PlatformID.Win32NT)
+            if (_environmentInfo.OperatingSystem != OperatingSystem.Windows)
             {
                 // Causing lockups on linux
                 return false;

+ 1 - 1
Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs

@@ -56,7 +56,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
             {
                 var format = _liveTvOptions.RecordingEncodingFormat;
 
-                if (string.Equals(format, "mkv", StringComparison.OrdinalIgnoreCase) || string.Equals(_liveTvOptions.RecordedVideoCodec, "copy", StringComparison.OrdinalIgnoreCase))
+                if (string.Equals(format, "mkv", StringComparison.OrdinalIgnoreCase))
                 {
                     return "mkv";
                 }

+ 1 - 1
Emby.Server.Implementations/LiveTv/LiveStreamHelper.cs

@@ -33,7 +33,7 @@ namespace Emby.Server.Implementations.LiveTv
                 Protocol = mediaSource.Protocol,
                 MediaType = isAudio ? DlnaProfileType.Audio : DlnaProfileType.Video,
                 ExtractChapters = false,
-                AnalyzeDurationSections = 2
+                AnalyzeDurationSections = 3
 
             }, cancellationToken).ConfigureAwait(false);
 

+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Core/ar.json → Emby.Server.Implementations/Localization/Core/ar.json


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Core/bg-BG.json → Emby.Server.Implementations/Localization/Core/bg-BG.json


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Core/ca.json → Emby.Server.Implementations/Localization/Core/ca.json


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Core/core.json → Emby.Server.Implementations/Localization/Core/core.json


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Core/cs.json → Emby.Server.Implementations/Localization/Core/cs.json


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Core/da.json → Emby.Server.Implementations/Localization/Core/da.json


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Core/de.json → Emby.Server.Implementations/Localization/Core/de.json


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Core/el.json → Emby.Server.Implementations/Localization/Core/el.json


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Core/en-GB.json → Emby.Server.Implementations/Localization/Core/en-GB.json


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Core/en-US.json → Emby.Server.Implementations/Localization/Core/en-US.json


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Core/es-AR.json → Emby.Server.Implementations/Localization/Core/es-AR.json


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Core/es-MX.json → Emby.Server.Implementations/Localization/Core/es-MX.json


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Core/es.json → Emby.Server.Implementations/Localization/Core/es.json


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Core/fi.json → Emby.Server.Implementations/Localization/Core/fi.json


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Core/fr-CA.json → Emby.Server.Implementations/Localization/Core/fr-CA.json


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Core/fr.json → Emby.Server.Implementations/Localization/Core/fr.json


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Core/gsw.json → Emby.Server.Implementations/Localization/Core/gsw.json


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Core/he.json → Emby.Server.Implementations/Localization/Core/he.json


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Core/hr.json → Emby.Server.Implementations/Localization/Core/hr.json


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Core/hu.json → Emby.Server.Implementations/Localization/Core/hu.json


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Core/id.json → Emby.Server.Implementations/Localization/Core/id.json


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Core/it.json → Emby.Server.Implementations/Localization/Core/it.json


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Core/kk.json → Emby.Server.Implementations/Localization/Core/kk.json


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Core/ko.json → Emby.Server.Implementations/Localization/Core/ko.json


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Core/ms.json → Emby.Server.Implementations/Localization/Core/ms.json


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Core/nb.json → Emby.Server.Implementations/Localization/Core/nb.json


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Core/nl.json → Emby.Server.Implementations/Localization/Core/nl.json


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Core/pl.json → Emby.Server.Implementations/Localization/Core/pl.json


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Core/pt-BR.json → Emby.Server.Implementations/Localization/Core/pt-BR.json


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Core/pt-PT.json → Emby.Server.Implementations/Localization/Core/pt-PT.json


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Core/ro.json → Emby.Server.Implementations/Localization/Core/ro.json


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Core/ru.json → Emby.Server.Implementations/Localization/Core/ru.json


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Core/sl-SI.json → Emby.Server.Implementations/Localization/Core/sl-SI.json


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Core/sv.json → Emby.Server.Implementations/Localization/Core/sv.json


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Core/tr.json → Emby.Server.Implementations/Localization/Core/tr.json


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Core/uk.json → Emby.Server.Implementations/Localization/Core/uk.json


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Core/vi.json → Emby.Server.Implementations/Localization/Core/vi.json


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Core/zh-CN.json → Emby.Server.Implementations/Localization/Core/zh-CN.json


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Core/zh-HK.json → Emby.Server.Implementations/Localization/Core/zh-HK.json


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Core/zh-TW.json → Emby.Server.Implementations/Localization/Core/zh-TW.json


+ 37 - 26
MediaBrowser.Server.Implementations/Localization/LocalizationManager.cs → Emby.Server.Implementations/Localization/LocalizationManager.cs

@@ -9,14 +9,11 @@ using System.Collections.Generic;
 using System.Globalization;
 using System.IO;
 using System.Linq;
-using System.Reflection;
-using System.Text;
-using MediaBrowser.Common.IO;
-using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.Logging;
+using MediaBrowser.Model.Reflection;
 
-namespace MediaBrowser.Server.Implementations.Localization
+namespace Emby.Server.Implementations.Localization
 {
     /// <summary>
     /// Class LocalizationManager
@@ -39,6 +36,8 @@ namespace MediaBrowser.Server.Implementations.Localization
         private readonly IFileSystem _fileSystem;
         private readonly IJsonSerializer _jsonSerializer;
         private readonly ILogger _logger;
+        private readonly IAssemblyInfo _assemblyInfo;
+        private readonly ITextLocalizer _textLocalizer;
 
         /// <summary>
         /// Initializes a new instance of the <see cref="LocalizationManager" /> class.
@@ -46,12 +45,14 @@ namespace MediaBrowser.Server.Implementations.Localization
         /// <param name="configurationManager">The configuration manager.</param>
         /// <param name="fileSystem">The file system.</param>
         /// <param name="jsonSerializer">The json serializer.</param>
-        public LocalizationManager(IServerConfigurationManager configurationManager, IFileSystem fileSystem, IJsonSerializer jsonSerializer, ILogger logger)
+        public LocalizationManager(IServerConfigurationManager configurationManager, IFileSystem fileSystem, IJsonSerializer jsonSerializer, ILogger logger, IAssemblyInfo assemblyInfo, ITextLocalizer textLocalizer)
         {
             _configurationManager = configurationManager;
             _fileSystem = fileSystem;
             _jsonSerializer = jsonSerializer;
             _logger = logger;
+            _assemblyInfo = assemblyInfo;
+            _textLocalizer = textLocalizer;
 
             ExtractAll();
         }
@@ -65,20 +66,20 @@ namespace MediaBrowser.Server.Implementations.Localization
 
 			_fileSystem.CreateDirectory(localizationPath);
 
-            var existingFiles = Directory.EnumerateFiles(localizationPath, "ratings-*.txt", SearchOption.TopDirectoryOnly)
+            var existingFiles = GetRatingsFiles(localizationPath)
                 .Select(Path.GetFileName)
                 .ToList();
 
             // Extract from the assembly
-            foreach (var resource in type.Assembly
-                .GetManifestResourceNames()
+            foreach (var resource in _assemblyInfo
+                .GetManifestResourceNames(type)
                 .Where(i => i.StartsWith(resourcePath)))
             {
                 var filename = "ratings-" + resource.Substring(resourcePath.Length);
 
                 if (!existingFiles.Contains(filename))
                 {
-                    using (var stream = type.Assembly.GetManifestResourceStream(resource))
+                    using (var stream = _assemblyInfo.GetManifestResourceStream(type, resource))
                     {
                         var target = Path.Combine(localizationPath, filename);
                         _logger.Info("Extracting ratings to {0}", target);
@@ -90,13 +91,21 @@ namespace MediaBrowser.Server.Implementations.Localization
                     }
                 }
             }
-
-            foreach (var file in Directory.EnumerateFiles(localizationPath, "ratings-*.txt", SearchOption.TopDirectoryOnly))
+            
+            foreach (var file in GetRatingsFiles(localizationPath))
             {
                 LoadRatings(file);
             }
         }
 
+        private List<string> GetRatingsFiles(string directory)
+        {
+            return _fileSystem.GetFilePaths(directory, false)
+                .Where(i => string.Equals(Path.GetExtension(i), ".txt", StringComparison.OrdinalIgnoreCase))
+                .Where(i => Path.GetFileName(i).StartsWith("ratings-", StringComparison.OrdinalIgnoreCase))
+                .ToList();
+        }
+
         /// <summary>
         /// Gets the localization path.
         /// </summary>
@@ -111,16 +120,12 @@ namespace MediaBrowser.Server.Implementations.Localization
 
         public string RemoveDiacritics(string text)
         {
-            return String.Concat(
-                text.Normalize(NormalizationForm.FormD)
-                .Where(ch => CharUnicodeInfo.GetUnicodeCategory(ch) !=
-                                              UnicodeCategory.NonSpacingMark)
-              ).Normalize(NormalizationForm.FormC);
+            return _textLocalizer.RemoveDiacritics(text);
         }
 
         public string NormalizeFormKD(string text)
         {
-            return text.Normalize(NormalizationForm.FormKD);
+            return _textLocalizer.NormalizeFormKD(text);
         }
 
         /// <summary>
@@ -134,7 +139,7 @@ namespace MediaBrowser.Server.Implementations.Localization
 
             var list = new List<CultureDto>();
 
-            using (var stream = type.Assembly.GetManifestResourceStream(path))
+            using (var stream = _assemblyInfo.GetManifestResourceStream(type, path))
             {
                 using (var reader = new StreamReader(stream))
                 {
@@ -176,7 +181,7 @@ namespace MediaBrowser.Server.Implementations.Localization
             var type = GetType();
             var path = type.Namespace + ".countries.json";
 
-            using (var stream = type.Assembly.GetManifestResourceStream(path))
+            using (var stream = _assemblyInfo.GetManifestResourceStream(type, path))
             {
                 return _jsonSerializer.DeserializeFromStream<List<CountryInfo>>(stream);
             }
@@ -234,7 +239,7 @@ namespace MediaBrowser.Server.Implementations.Localization
         /// <returns>Dictionary{System.StringParentalRating}.</returns>
         private void LoadRatings(string file)
         {
-			var dict = File.ReadAllLines(file).Select(i =>
+			var dict = _fileSystem.ReadAllLines(file).Select(i =>
             {
                 if (!string.IsNullOrWhiteSpace(i))
                 {
@@ -337,18 +342,17 @@ namespace MediaBrowser.Server.Implementations.Localization
         {
             var dictionary = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
 
-            var assembly = GetType().Assembly;
             var namespaceName = GetType().Namespace + "." + prefix;
 
-            CopyInto(dictionary, namespaceName + "." + baseFilename, assembly);
-            CopyInto(dictionary, namespaceName + "." + GetResourceFilename(culture), assembly);
+            CopyInto(dictionary, namespaceName + "." + baseFilename);
+            CopyInto(dictionary, namespaceName + "." + GetResourceFilename(culture));
 
             return dictionary;
         }
 
-        private void CopyInto(IDictionary<string, string> dictionary, string resourcePath, Assembly assembly)
+        private void CopyInto(IDictionary<string, string> dictionary, string resourcePath)
         {
-            using (var stream = assembly.GetManifestResourceStream(resourcePath))
+            using (var stream = _assemblyInfo.GetManifestResourceStream(GetType(), resourcePath))
             {
                 if (stream != null)
                 {
@@ -419,4 +423,11 @@ namespace MediaBrowser.Server.Implementations.Localization
             }.OrderBy(i => i.Name);
         }
     }
+
+    public interface ITextLocalizer
+    {
+        string RemoveDiacritics(string text);
+
+        string NormalizeFormKD(string text);
+    }
 }

+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Ratings/au.txt → Emby.Server.Implementations/Localization/Ratings/au.txt


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Ratings/be.txt → Emby.Server.Implementations/Localization/Ratings/be.txt


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Ratings/br.txt → Emby.Server.Implementations/Localization/Ratings/br.txt


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Ratings/ca.txt → Emby.Server.Implementations/Localization/Ratings/ca.txt


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Ratings/co.txt → Emby.Server.Implementations/Localization/Ratings/co.txt


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Ratings/de.txt → Emby.Server.Implementations/Localization/Ratings/de.txt


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Ratings/dk.txt → Emby.Server.Implementations/Localization/Ratings/dk.txt


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Ratings/fr.txt → Emby.Server.Implementations/Localization/Ratings/fr.txt


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Ratings/gb.txt → Emby.Server.Implementations/Localization/Ratings/gb.txt


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Ratings/ie.txt → Emby.Server.Implementations/Localization/Ratings/ie.txt


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Ratings/jp.txt → Emby.Server.Implementations/Localization/Ratings/jp.txt


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Ratings/kz.txt → Emby.Server.Implementations/Localization/Ratings/kz.txt


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Ratings/mx.txt → Emby.Server.Implementations/Localization/Ratings/mx.txt


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Ratings/nl.txt → Emby.Server.Implementations/Localization/Ratings/nl.txt


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Ratings/nz.txt → Emby.Server.Implementations/Localization/Ratings/nz.txt


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Ratings/ru.txt → Emby.Server.Implementations/Localization/Ratings/ru.txt


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/Ratings/us.txt → Emby.Server.Implementations/Localization/Ratings/us.txt


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/countries.json → Emby.Server.Implementations/Localization/countries.json


+ 0 - 0
MediaBrowser.Server.Implementations/Localization/iso6392.txt → Emby.Server.Implementations/Localization/iso6392.txt


+ 2 - 2
MediaBrowser.Server.Implementations/Security/EncryptionManager.cs → Emby.Server.Implementations/Security/EncryptionManager.cs

@@ -2,7 +2,7 @@
 using System;
 using System.Text;
 
-namespace MediaBrowser.Server.Implementations.Security
+namespace Emby.Server.Implementations.Security
 {
     public class EncryptionManager : IEncryptionManager
     {
@@ -45,7 +45,7 @@ namespace MediaBrowser.Server.Implementations.Security
             // Yes, this isn't good, but ProtectedData in mono is throwing exceptions, so use this for now
 
             var bytes = Convert.FromBase64String(value);
-            return Encoding.UTF8.GetString(bytes);
+            return Encoding.UTF8.GetString(bytes, 0, bytes.Length);
         }
     }
 }

+ 10 - 2
Emby.Server.Implementations/Security/MBLicenseFile.cs

@@ -124,9 +124,17 @@ namespace Emby.Server.Implementations.Security
                 //the rest of the lines should be pairs of features and timestamps
                 for (var i = 2; i < contents.Length; i = i + 2)
                 {
-                    var feat = Guid.Parse(contents[i]);
+                    var line = contents[i];
+                    if (string.IsNullOrWhiteSpace(line))
+                    {
+                        continue;
+                    }
 
-                    SetUpdateRecord(feat, new DateTime(Convert.ToInt64(contents[i + 1])));
+                    Guid feat;
+                    if (Guid.TryParse(line, out feat))
+                    {
+                        SetUpdateRecord(feat, new DateTime(Convert.ToInt64(contents[i + 1])));
+                    }
                 }
             }
         }

+ 32 - 113
MediaBrowser.Server.Implementations/Udp/UdpServer.cs → Emby.Server.Implementations/Udp/UdpServer.cs

@@ -1,18 +1,16 @@
-using MediaBrowser.Common.Net;
-using MediaBrowser.Controller;
+using MediaBrowser.Controller;
 using MediaBrowser.Model.ApiClient;
 using MediaBrowser.Model.Logging;
 using MediaBrowser.Model.Serialization;
 using System;
 using System.Collections.Generic;
 using System.Linq;
-using System.Net;
-using System.Net.Sockets;
 using System.Text;
 using System.Threading.Tasks;
-using Emby.Common.Implementations.Networking;
+using MediaBrowser.Model.Events;
+using MediaBrowser.Model.Net;
 
-namespace MediaBrowser.Server.Implementations.Udp
+namespace Emby.Server.Implementations.Udp
 {
     /// <summary>
     /// Provides a Udp Server
@@ -24,14 +22,9 @@ namespace MediaBrowser.Server.Implementations.Udp
         /// </summary>
         private readonly ILogger _logger;
 
-        /// <summary>
-        /// The _network manager
-        /// </summary>
-        private readonly INetworkManager _networkManager;
-
         private bool _isDisposed;
 
-        private readonly List<Tuple<string, bool, Func<string, string, Encoding, Task>>> _responders = new List<Tuple<string, bool, Func<string, string, Encoding, Task>>>();
+        private readonly List<Tuple<string, bool, Func<string, IpEndPointInfo, Encoding, Task>>> _responders = new List<Tuple<string, bool, Func<string, IpEndPointInfo, Encoding, Task>>>();
 
         private readonly IServerApplicationHost _appHost;
         private readonly IJsonSerializer _json;
@@ -39,46 +32,43 @@ namespace MediaBrowser.Server.Implementations.Udp
         /// <summary>
         /// Initializes a new instance of the <see cref="UdpServer" /> class.
         /// </summary>
-        /// <param name="logger">The logger.</param>
-        /// <param name="networkManager">The network manager.</param>
-        /// <param name="appHost">The application host.</param>
-        /// <param name="json">The json.</param>
-        public UdpServer(ILogger logger, INetworkManager networkManager, IServerApplicationHost appHost, IJsonSerializer json)
+        public UdpServer(ILogger logger, IServerApplicationHost appHost, IJsonSerializer json, ISocketFactory socketFactory)
         {
             _logger = logger;
-            _networkManager = networkManager;
             _appHost = appHost;
             _json = json;
+            _socketFactory = socketFactory;
 
             AddMessageResponder("who is EmbyServer?", true, RespondToV2Message);
             AddMessageResponder("who is MediaBrowserServer_v2?", false, RespondToV2Message);
         }
 
-        private void AddMessageResponder(string message, bool isSubstring, Func<string, string, Encoding, Task> responder)
+        private void AddMessageResponder(string message, bool isSubstring, Func<string, IpEndPointInfo, Encoding, Task> responder)
         {
-            _responders.Add(new Tuple<string, bool, Func<string, string, Encoding, Task>>(message, isSubstring, responder));
+            _responders.Add(new Tuple<string, bool, Func<string, IpEndPointInfo, Encoding, Task>>(message, isSubstring, responder));
         }
 
         /// <summary>
         /// Raises the <see cref="E:MessageReceived" /> event.
         /// </summary>
-        /// <param name="e">The <see cref="UdpMessageReceivedEventArgs"/> instance containing the event data.</param>
-        private async void OnMessageReceived(UdpMessageReceivedEventArgs e)
+        private async void OnMessageReceived(GenericEventArgs<SocketReceiveResult> e)
         {
+            var message = e.Argument;
+
             var encoding = Encoding.UTF8;
-            var responder = GetResponder(e.Bytes, encoding);
+            var responder = GetResponder(message.Buffer, message.ReceivedBytes, encoding);
 
             if (responder == null)
             {
                 encoding = Encoding.Unicode;
-                responder = GetResponder(e.Bytes, encoding);
+                responder = GetResponder(message.Buffer, message.ReceivedBytes, encoding);
             }
 
             if (responder != null)
             {
                 try
                 {
-                    await responder.Item2.Item3(responder.Item1, e.RemoteEndPoint, encoding).ConfigureAwait(false);
+                    await responder.Item2.Item3(responder.Item1, message.RemoteEndPoint, encoding).ConfigureAwait(false);
                 }
                 catch (Exception ex)
                 {
@@ -87,9 +77,9 @@ namespace MediaBrowser.Server.Implementations.Udp
             }
         }
 
-        private Tuple<string, Tuple<string, bool, Func<string, string, Encoding, Task>>> GetResponder(byte[] bytes, Encoding encoding)
+        private Tuple<string, Tuple<string, bool, Func<string, IpEndPointInfo, Encoding, Task>>> GetResponder(byte[] buffer, int bytesReceived, Encoding encoding)
         {
-            var text = encoding.GetString(bytes);
+            var text = encoding.GetString(buffer, 0, bytesReceived);
             var responder = _responders.FirstOrDefault(i =>
             {
                 if (i.Item2)
@@ -103,10 +93,10 @@ namespace MediaBrowser.Server.Implementations.Udp
             {
                 return null;
             }
-            return new Tuple<string, Tuple<string, bool, Func<string, string, Encoding, Task>>>(text, responder);
+            return new Tuple<string, Tuple<string, bool, Func<string, IpEndPointInfo, Encoding, Task>>>(text, responder);
         }
 
-        private async Task RespondToV2Message(string messageText, string endpoint, Encoding encoding)
+        private async Task RespondToV2Message(string messageText, IpEndPointInfo endpoint, Encoding encoding)
         {
             var parts = messageText.Split('|');
 
@@ -122,7 +112,7 @@ namespace MediaBrowser.Server.Implementations.Udp
                 };
 
                 await SendAsync(encoding.GetBytes(_json.SerializeToString(response)), endpoint).ConfigureAwait(false);
-                
+
                 if (parts.Length > 1)
                 {
                     _appHost.EnableLoopback(parts[1]);
@@ -137,7 +127,8 @@ namespace MediaBrowser.Server.Implementations.Udp
         /// <summary>
         /// The _udp client
         /// </summary>
-        private UdpClient _udpClient;
+        private IUdpSocket _udpClient;
+        private readonly ISocketFactory _socketFactory;
 
         /// <summary>
         /// Starts the specified port.
@@ -145,9 +136,7 @@ namespace MediaBrowser.Server.Implementations.Udp
         /// <param name="port">The port.</param>
         public void Start(int port)
         {
-            _udpClient = new UdpClient(new IPEndPoint(IPAddress.Any, port));
-
-            _udpClient.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
+            _udpClient = _socketFactory.CreateUdpSocket(port);
 
             Task.Run(() => StartListening());
         }
@@ -158,56 +147,36 @@ namespace MediaBrowser.Server.Implementations.Udp
             {
                 try
                 {
-                    var result = await GetResult().ConfigureAwait(false);
+                    var result = await _udpClient.ReceiveAsync().ConfigureAwait(false);
 
                     OnMessageReceived(result);
                 }
                 catch (ObjectDisposedException)
                 {
-                    break;
                 }
                 catch (Exception ex)
                 {
-                    _logger.ErrorException("Error in StartListening", ex);
+                    _logger.ErrorException("Error receiving udp message", ex);
                 }
             }
         }
 
-        private Task<UdpReceiveResult> GetResult()
-        {
-            try
-            {
-                return _udpClient.ReceiveAsync();
-            }
-            catch (ObjectDisposedException)
-            {
-                return Task.FromResult(new UdpReceiveResult(new byte[] { }, new IPEndPoint(IPAddress.Any, 0)));
-            }
-            catch (Exception ex)
-            {
-                _logger.ErrorException("Error receiving udp message", ex);
-                return Task.FromResult(new UdpReceiveResult(new byte[] { }, new IPEndPoint(IPAddress.Any, 0)));
-            }
-        }
-
         /// <summary>
         /// Called when [message received].
         /// </summary>
         /// <param name="message">The message.</param>
-        private void OnMessageReceived(UdpReceiveResult message)
+        private void OnMessageReceived(SocketReceiveResult message)
         {
             if (message.RemoteEndPoint.Port == 0)
             {
                 return;
             }
-            var bytes = message.Buffer;
 
             try
             {
-                OnMessageReceived(new UdpMessageReceivedEventArgs
+                OnMessageReceived(new GenericEventArgs<SocketReceiveResult>
                 {
-                    Bytes = bytes,
-                    RemoteEndPoint = message.RemoteEndPoint.ToString()
+                    Argument = message
                 });
             }
             catch (Exception ex)
@@ -234,7 +203,7 @@ namespace MediaBrowser.Server.Implementations.Udp
 
             if (_udpClient != null)
             {
-                _udpClient.Close();
+                _udpClient.Dispose();
             }
         }
 
@@ -250,71 +219,21 @@ namespace MediaBrowser.Server.Implementations.Udp
             }
         }
 
-        /// <summary>
-        /// Sends the async.
-        /// </summary>
-        /// <param name="data">The data.</param>
-        /// <param name="ipAddress">The ip address.</param>
-        /// <param name="port">The port.</param>
-        /// <returns>Task{System.Int32}.</returns>
-        /// <exception cref="System.ArgumentNullException">data</exception>
-        public Task SendAsync(string data, string ipAddress, int port)
-        {
-            return SendAsync(Encoding.UTF8.GetBytes(data), ipAddress, port);
-        }
-
-        /// <summary>
-        /// Sends the async.
-        /// </summary>
-        /// <param name="bytes">The bytes.</param>
-        /// <param name="ipAddress">The ip address.</param>
-        /// <param name="port">The port.</param>
-        /// <returns>Task{System.Int32}.</returns>
-        /// <exception cref="System.ArgumentNullException">bytes</exception>
-        public Task SendAsync(byte[] bytes, string ipAddress, int port)
-        {
-            if (bytes == null)
-            {
-                throw new ArgumentNullException("bytes");
-            }
-
-            if (string.IsNullOrEmpty(ipAddress))
-            {
-                throw new ArgumentNullException("ipAddress");
-            }
-
-            return _udpClient.SendAsync(bytes, bytes.Length, ipAddress, port);
-        }
-
-        /// <summary>
-        /// Sends the async.
-        /// </summary>
-        /// <param name="bytes">The bytes.</param>
-        /// <param name="remoteEndPoint">The remote end point.</param>
-        /// <returns>Task.</returns>
-        /// <exception cref="System.ArgumentNullException">
-        /// bytes
-        /// or
-        /// remoteEndPoint
-        /// </exception>
-        public async Task SendAsync(byte[] bytes, string remoteEndPoint)
+        public async Task SendAsync(byte[] bytes, IpEndPointInfo remoteEndPoint)
         {
             if (bytes == null)
             {
                 throw new ArgumentNullException("bytes");
             }
 
-            if (string.IsNullOrEmpty(remoteEndPoint))
+            if (remoteEndPoint == null)
             {
                 throw new ArgumentNullException("remoteEndPoint");
             }
 
             try
             {
-                // Need to do this until Common will compile with this method
-                var nativeNetworkManager = (BaseNetworkManager) _networkManager;
-
-                await _udpClient.SendAsync(bytes, bytes.Length, nativeNetworkManager.Parse(remoteEndPoint)).ConfigureAwait(false);
+                await _udpClient.SendAsync(bytes, bytes.Length, remoteEndPoint).ConfigureAwait(false);
 
                 _logger.Info("Udp message sent to {0}", remoteEndPoint);
             }

+ 1 - 1
MediaBrowser.Api/UserLibrary/UserLibraryService.cs

@@ -322,7 +322,7 @@ namespace MediaBrowser.Api.UserLibrary
                 var item = i.Item2[0];
                 var childCount = 0;
 
-                if (i.Item1 != null && i.Item2.Count > 0)
+                if (i.Item1 != null && i.Item2.Count > 1)
                 {
                     item = i.Item1;
                     childCount = i.Item2.Count;

+ 4 - 0
MediaBrowser.Common/Net/INetworkManager.cs

@@ -46,6 +46,10 @@ namespace MediaBrowser.Common.Net
         /// <returns><c>true</c> if [is in local network] [the specified endpoint]; otherwise, <c>false</c>.</returns>
         bool IsInLocalNetwork(string endpoint);
 
+        IpAddressInfo ParseIpAddress(string ipAddress);
+
+        bool TryParseIpAddress(string ipAddress, out IpAddressInfo ipAddressInfo);
+
         /// <summary>
         /// Generates a self signed certificate at the locatation specified by <paramref name="certificatePath"/>.
         /// </summary>

+ 2 - 1
MediaBrowser.Model/MediaBrowser.Model.csproj

@@ -140,7 +140,8 @@
     <Compile Include="Net\IpEndPointInfo.cs" />
     <Compile Include="Net\ISocketFactory.cs" />
     <Compile Include="Net\IUdpSocket.cs" />
-    <Compile Include="Net\ReceivedUdpData.cs" />
+    <Compile Include="Net\SocketReceiveResult.cs" />
+    <Compile Include="System\IEnvironmentInfo.cs" />
     <Compile Include="TextEncoding\IEncoding.cs" />
     <Compile Include="Extensions\LinqExtensions.cs" />
     <Compile Include="FileOrganization\SmartMatchInfo.cs" />

+ 13 - 8
MediaBrowser.Model/Net/ISocketFactory.cs

@@ -14,13 +14,18 @@ namespace MediaBrowser.Model.Net
 		/// <returns>A <see cref="IUdpSocket"/> implementation.</returns>
 		IUdpSocket CreateUdpSocket(int localPort);
 
-		/// <summary>
-		/// Createa a new multicast socket using the specified multicast IP address, multicast time to live and local port.
-		/// </summary>
-		/// <param name="ipAddress">The multicast IP address to bind to.</param>
-		/// <param name="multicastTimeToLive">The multicast time to live value. Actually a maximum number of network hops for UDP packets.</param>
-		/// <param name="localPort">The local port to bind to.</param>
-		/// <returns>A <see cref="IUdpSocket"/> implementation.</returns>
-		IUdpSocket CreateUdpMulticastSocket(string ipAddress, int multicastTimeToLive, int localPort);
+        /// <summary>
+        /// Createa a new unicast socket using the specified local port number.
+        /// </summary>
+        IUdpSocket CreateSsdpUdpSocket(int localPort);
+
+        /// <summary>
+        /// Createa a new multicast socket using the specified multicast IP address, multicast time to live and local port.
+        /// </summary>
+        /// <param name="ipAddress">The multicast IP address to bind to.</param>
+        /// <param name="multicastTimeToLive">The multicast time to live value. Actually a maximum number of network hops for UDP packets.</param>
+        /// <param name="localPort">The local port to bind to.</param>
+        /// <returns>A <see cref="IUdpSocket"/> implementation.</returns>
+        IUdpSocket CreateUdpMulticastSocket(string ipAddress, int multicastTimeToLive, int localPort);
 	}
 }

+ 2 - 4
MediaBrowser.Model/Net/IUdpSocket.cs

@@ -15,13 +15,11 @@ namespace MediaBrowser.Model.Net
 		/// Waits for and returns the next UDP message sent to this socket (uni or multicast).
 		/// </summary>
 		/// <returns></returns>
-		Task<ReceivedUdpData> ReceiveAsync();
+		Task<SocketReceiveResult> ReceiveAsync();
 
         /// <summary>
         /// Sends a UDP message to a particular end point (uni or multicast).
         /// </summary>
-        /// <param name="messageData">The data to send.</param>
-        /// <param name="endPoint">The <see cref="IpEndPointInfo"/> providing the address and port to send to.</param>
-        Task SendTo(byte[] messageData, IpEndPointInfo endPoint);
+        Task SendAsync(byte[] buffer, int bytes, IpEndPointInfo endPoint);
 	}
 }

+ 2 - 2
MediaBrowser.Model/Net/ReceivedUdpData.cs → MediaBrowser.Model/Net/SocketReceiveResult.cs

@@ -4,7 +4,7 @@ namespace MediaBrowser.Model.Net
     /// <summary>
     /// Used by the sockets wrapper to hold raw data received from a UDP socket.
     /// </summary>
-    public sealed class ReceivedUdpData
+    public sealed class SocketReceiveResult
 	{
 		/// <summary>
 		/// The buffer to place received data into.
@@ -19,6 +19,6 @@ namespace MediaBrowser.Model.Net
         /// <summary>
         /// The <see cref="IpEndPointInfo"/> the data was received from.
         /// </summary>
-        public IpEndPointInfo ReceivedFrom { get; set; }
+        public IpEndPointInfo RemoteEndPoint { get; set; }
 	}
 }

+ 22 - 0
MediaBrowser.Model/System/IEnvironmentInfo.cs

@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MediaBrowser.Model.System
+{
+    public interface IEnvironmentInfo
+    {
+        MediaBrowser.Model.System.OperatingSystem OperatingSystem { get; }
+        string OperatingSystemName { get; }
+        string OperatingSystemVersion { get; }
+    }
+
+    public enum OperatingSystem
+    {
+        Windows,
+        Linux,
+        OSX
+    }
+}

+ 0 - 1
MediaBrowser.Mono.sln

@@ -248,7 +248,6 @@ Global
 		{4ACAB6A2-AC9A-4B50-BAEC-1FE4A1F3B8BC}.Debug|x86.ActiveCfg = Debug|Any CPU
 		{4ACAB6A2-AC9A-4B50-BAEC-1FE4A1F3B8BC}.Debug|x86.Build.0 = Debug|Any CPU
 		{4ACAB6A2-AC9A-4B50-BAEC-1FE4A1F3B8BC}.Release Mono|Any CPU.ActiveCfg = Release|Any CPU
-		{4ACAB6A2-AC9A-4B50-BAEC-1FE4A1F3B8BC}.Release Mono|Any CPU.Build.0 = Release|Any CPU
 		{4ACAB6A2-AC9A-4B50-BAEC-1FE4A1F3B8BC}.Release Mono|x86.ActiveCfg = Release|Any CPU
 		{4ACAB6A2-AC9A-4B50-BAEC-1FE4A1F3B8BC}.Release Mono|x86.Build.0 = Release|Any CPU
 		{4ACAB6A2-AC9A-4B50-BAEC-1FE4A1F3B8BC}.Release|Any CPU.ActiveCfg = Release|Any CPU

+ 1 - 0
MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs

@@ -18,6 +18,7 @@ using System.Reflection;
 using System.Threading;
 using System.Threading.Tasks;
 using Emby.Server.Implementations.HttpServer;
+using Emby.Server.Implementations.HttpServer.SocketSharp;
 using MediaBrowser.Common.Net;
 using MediaBrowser.Common.Security;
 using MediaBrowser.Controller;

+ 1 - 1
MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs

@@ -1,13 +1,13 @@
 using System.Collections.Specialized;
 using MediaBrowser.Controller.Net;
 using MediaBrowser.Model.Logging;
-using MediaBrowser.Server.Implementations.Logging;
 using SocketHttpListener.Net;
 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Threading.Tasks;
 using Emby.Server.Implementations.HttpServer;
+using Emby.Server.Implementations.Logging;
 using MediaBrowser.Common.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.Services;

+ 1 - 0
MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpRequest.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Collections.Specialized;
 using System.IO;
 using System.Text;
+using Emby.Server.Implementations.HttpServer.SocketSharp;
 using Funq;
 using MediaBrowser.Common.IO;
 using MediaBrowser.Model.IO;

+ 8 - 10
MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs

@@ -10,13 +10,14 @@ using System.Collections.Generic;
 using System.IO;
 using System.Linq;
 using System.Threading.Tasks;
+using Emby.Server.Implementations.IO;
 using MediaBrowser.Common.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Controller;
 using MediaBrowser.Controller.IO;
+using MediaBrowser.Model.System;
 using MediaBrowser.Model.Tasks;
 using MediaBrowser.Model.Threading;
-using Microsoft.Win32;
 
 namespace MediaBrowser.Server.Implementations.IO
 {
@@ -138,11 +139,12 @@ namespace MediaBrowser.Server.Implementations.IO
 
         private readonly IFileSystem _fileSystem;
         private readonly ITimerFactory _timerFactory;
+        private readonly IEnvironmentInfo _environmentInfo;
 
         /// <summary>
         /// Initializes a new instance of the <see cref="LibraryMonitor" /> class.
         /// </summary>
-        public LibraryMonitor(ILogManager logManager, ITaskManager taskManager, ILibraryManager libraryManager, IServerConfigurationManager configurationManager, IFileSystem fileSystem, ITimerFactory timerFactory)
+        public LibraryMonitor(ILogManager logManager, ITaskManager taskManager, ILibraryManager libraryManager, IServerConfigurationManager configurationManager, IFileSystem fileSystem, ITimerFactory timerFactory, ISystemEvents systemEvents, IEnvironmentInfo environmentInfo)
         {
             if (taskManager == null)
             {
@@ -155,16 +157,12 @@ namespace MediaBrowser.Server.Implementations.IO
             ConfigurationManager = configurationManager;
             _fileSystem = fileSystem;
             _timerFactory = timerFactory;
+            _environmentInfo = environmentInfo;
 
-            SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
+            systemEvents.Resume += _systemEvents_Resume;
         }
 
-        /// <summary>
-        /// Handles the PowerModeChanged event of the SystemEvents control.
-        /// </summary>
-        /// <param name="sender">The source of the event.</param>
-        /// <param name="e">The <see cref="PowerModeChangedEventArgs"/> instance containing the event data.</param>
-        void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
+        private void _systemEvents_Resume(object sender, EventArgs e)
         {
             Restart();
         }
@@ -529,7 +527,7 @@ namespace MediaBrowser.Server.Implementations.IO
                     }
                 }
 
-                var newRefresher = new FileRefresher(path, _fileSystem, ConfigurationManager, LibraryManager, TaskManager, Logger, _timerFactory);
+                var newRefresher = new FileRefresher(path, _fileSystem, ConfigurationManager, LibraryManager, TaskManager, Logger, _timerFactory, _environmentInfo);
                 newRefresher.Completed += NewRefresher_Completed;
                 _activeRefreshers.Add(newRefresher);
             }

+ 0 - 63
MediaBrowser.Server.Implementations/Logging/PatternsLogger.cs

@@ -1,63 +0,0 @@
-using Patterns.Logging;
-using System;
-
-namespace MediaBrowser.Server.Implementations.Logging
-{
-    public class PatternsLogger : ILogger
-    {
-        private readonly Model.Logging.ILogger _logger;
-
-        public PatternsLogger()
-            : this(new Model.Logging.NullLogger())
-        {
-        }
-
-        public PatternsLogger(Model.Logging.ILogger logger)
-        {
-            _logger = logger;
-        }
-
-        public void Debug(string message, params object[] paramList)
-        {
-            _logger.Debug(message, paramList);
-        }
-
-        public void Error(string message, params object[] paramList)
-        {
-            _logger.Error(message, paramList);
-        }
-
-        public void ErrorException(string message, Exception exception, params object[] paramList)
-        {
-            _logger.ErrorException(message, exception, paramList);
-        }
-
-        public void Fatal(string message, params object[] paramList)
-        {
-            _logger.Fatal(message, paramList);
-        }
-
-        public void FatalException(string message, Exception exception, params object[] paramList)
-        {
-            _logger.FatalException(message, exception, paramList);
-        }
-
-        public void Info(string message, params object[] paramList)
-        {
-            _logger.Info(message, paramList);
-        }
-
-        public void Warn(string message, params object[] paramList)
-        {
-            _logger.Warn(message, paramList);
-        }
-
-        public void Log(LogSeverity severity, string message, params object[] paramList)
-        {
-        }
-
-        public void LogMultiline(string message, LogSeverity severity, System.Text.StringBuilder additionalContent)
-        {
-        }
-    }
-}

+ 0 - 220
MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj

@@ -113,17 +113,10 @@
     <Compile Include="Archiving\ZipClient.cs" />
     <Compile Include="Collections\CollectionsDynamicFolder.cs" />
     <Compile Include="Configuration\ServerConfigurationManager.cs" />
-    <Compile Include="Connect\ConnectData.cs" />
-    <Compile Include="Connect\ConnectEntryPoint.cs" />
-    <Compile Include="Connect\ConnectManager.cs" />
-    <Compile Include="Connect\Responses.cs" />
-    <Compile Include="Connect\Validator.cs" />
     <Compile Include="Devices\DeviceRepository.cs" />
     <Compile Include="Devices\CameraUploadsFolder.cs" />
     <Compile Include="EntryPoints\ExternalPortForwarding.cs" />
-    <Compile Include="EntryPoints\UdpServerEntryPoint.cs" />
     <Compile Include="HttpServer\ContainerAdapter.cs" />
-    <Compile Include="HttpServer\GetSwaggerResource.cs" />
     <Compile Include="HttpServer\HttpListenerHost.cs" />
     <Compile Include="HttpServer\HttpResultFactory.cs" />
     <Compile Include="HttpServer\LoggerUtils.cs" />
@@ -132,15 +125,12 @@
     <Compile Include="HttpServer\ServerFactory.cs" />
     <Compile Include="HttpServer\ServerLogFactory.cs" />
     <Compile Include="HttpServer\ServerLogger.cs" />
-    <Compile Include="HttpServer\SocketSharp\HttpUtility.cs" />
     <Compile Include="HttpServer\SocketSharp\SharpWebSocket.cs" />
-    <Compile Include="HttpServer\SwaggerService.cs" />
     <Compile Include="HttpServer\SocketSharp\Extensions.cs" />
     <Compile Include="HttpServer\SocketSharp\RequestMono.cs" />
     <Compile Include="HttpServer\SocketSharp\WebSocketSharpListener.cs" />
     <Compile Include="HttpServer\SocketSharp\WebSocketSharpRequest.cs" />
     <Compile Include="HttpServer\SocketSharp\WebSocketSharpResponse.cs" />
-    <Compile Include="IO\FileRefresher.cs" />
     <Compile Include="IO\LibraryMonitor.cs" />
     <Compile Include="IO\MemoryStreamProvider.cs" />
     <Compile Include="LiveTv\TunerHosts\SatIp\ChannelScan.cs" />
@@ -165,8 +155,6 @@
     <Compile Include="LiveTv\TunerHosts\SatIp\SatIpHost.cs" />
     <Compile Include="LiveTv\TunerHosts\SatIp\TransmissionMode.cs" />
     <Compile Include="LiveTv\TunerHosts\SatIp\Utils.cs" />
-    <Compile Include="Localization\LocalizationManager.cs" />
-    <Compile Include="Logging\PatternsLogger.cs" />
     <Compile Include="Persistence\BaseSqliteRepository.cs" />
     <Compile Include="Persistence\DataExtensions.cs" />
     <Compile Include="Persistence\IDbConnector.cs" />
@@ -180,15 +168,12 @@
     <Compile Include="Playlists\ManualPlaylistsFolder.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Security\AuthenticationRepository.cs" />
-    <Compile Include="Security\EncryptionManager.cs" />
     <Compile Include="ServerApplicationPaths.cs" />
     <Compile Include="Persistence\SqliteDisplayPreferencesRepository.cs" />
     <Compile Include="Persistence\SqliteItemRepository.cs" />
     <Compile Include="Persistence\SqliteUserDataRepository.cs" />
     <Compile Include="Persistence\SqliteUserRepository.cs" />
     <Compile Include="Sync\SyncRepository.cs" />
-    <Compile Include="Udp\UdpMessageReceivedEventArgs.cs" />
-    <Compile Include="Udp\UdpServer.cs" />
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="..\Emby.Server.Implementations\Emby.Server.Implementations.csproj">
@@ -213,162 +198,7 @@
     </ProjectReference>
   </ItemGroup>
   <ItemGroup>
-    <Content Include="..\ThirdParty\ServiceStack\swagger-ui\lib\backbone-min.js">
-      <Link>swagger-ui\lib\backbone-min.js</Link>
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-    <Content Include="..\ThirdParty\ServiceStack\swagger-ui\lib\handlebars-2.0.0.js">
-      <Link>swagger-ui\lib\handlebars-2.0.0.js</Link>
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-    <Content Include="..\ThirdParty\ServiceStack\swagger-ui\lib\highlight.7.3.pack.js">
-      <Link>swagger-ui\lib\highlight.7.3.pack.js</Link>
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-    <Content Include="..\ThirdParty\ServiceStack\swagger-ui\lib\jquery-1.8.0.min.js">
-      <Link>swagger-ui\lib\jquery-1.8.0.min.js</Link>
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-    <Content Include="..\ThirdParty\ServiceStack\swagger-ui\lib\jquery.ba-bbq.min.js">
-      <Link>swagger-ui\lib\jquery.ba-bbq.min.js</Link>
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-    <Content Include="..\ThirdParty\ServiceStack\swagger-ui\lib\jquery.slideto.min.js">
-      <Link>swagger-ui\lib\jquery.slideto.min.js</Link>
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-    <Content Include="..\ThirdParty\ServiceStack\swagger-ui\lib\jquery.wiggle.min.js">
-      <Link>swagger-ui\lib\jquery.wiggle.min.js</Link>
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-    <Content Include="..\ThirdParty\ServiceStack\swagger-ui\lib\marked.js">
-      <Link>swagger-ui\lib\marked.js</Link>
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-    <Content Include="..\ThirdParty\ServiceStack\swagger-ui\lib\shred.bundle.js">
-      <Link>swagger-ui\lib\shred.bundle.js</Link>
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-    <Content Include="..\ThirdParty\ServiceStack\swagger-ui\lib\swagger-client.js">
-      <Link>swagger-ui\lib\swagger-client.js</Link>
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-    <Content Include="..\ThirdParty\ServiceStack\swagger-ui\lib\swagger-oauth.js">
-      <Link>swagger-ui\lib\swagger-oauth.js</Link>
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-    <Content Include="..\ThirdParty\ServiceStack\swagger-ui\lib\underscore-min.js">
-      <Link>swagger-ui\lib\underscore-min.js</Link>
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-    <Content Include="..\ThirdParty\ServiceStack\swagger-ui\o2c.html">
-      <Link>swagger-ui\o2c.html</Link>
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-    <Content Include="..\ThirdParty\ServiceStack\swagger-ui\patch.js">
-      <Link>swagger-ui\patch.js</Link>
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-    <Content Include="..\ThirdParty\ServiceStack\swagger-ui\swagger-ui.js">
-      <Link>swagger-ui\swagger-ui.js</Link>
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-    <Content Include="..\ThirdParty\ServiceStack\swagger-ui\swagger-ui.min.js">
-      <Link>swagger-ui\swagger-ui.min.js</Link>
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-    <Content Include="..\ThirdParty\ServiceStack\swagger-ui\fonts\droid-sans-v6-latin-700.eot">
-      <Link>swagger-ui\fonts\droid-sans-v6-latin-700.eot</Link>
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-    <Content Include="..\ThirdParty\ServiceStack\swagger-ui\fonts\droid-sans-v6-latin-700.ttf">
-      <Link>swagger-ui\fonts\droid-sans-v6-latin-700.ttf</Link>
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-    <Content Include="..\ThirdParty\ServiceStack\swagger-ui\fonts\droid-sans-v6-latin-700.woff">
-      <Link>swagger-ui\fonts\droid-sans-v6-latin-700.woff</Link>
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-    <Content Include="..\ThirdParty\ServiceStack\swagger-ui\fonts\droid-sans-v6-latin-700.woff2">
-      <Link>swagger-ui\fonts\droid-sans-v6-latin-700.woff2</Link>
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-    <Content Include="..\ThirdParty\ServiceStack\swagger-ui\fonts\droid-sans-v6-latin-regular.eot">
-      <Link>swagger-ui\fonts\droid-sans-v6-latin-regular.eot</Link>
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-    <Content Include="..\ThirdParty\ServiceStack\swagger-ui\fonts\droid-sans-v6-latin-regular.ttf">
-      <Link>swagger-ui\fonts\droid-sans-v6-latin-regular.ttf</Link>
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-    <Content Include="..\ThirdParty\ServiceStack\swagger-ui\fonts\droid-sans-v6-latin-regular.woff">
-      <Link>swagger-ui\fonts\droid-sans-v6-latin-regular.woff</Link>
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-    <Content Include="..\ThirdParty\ServiceStack\swagger-ui\fonts\droid-sans-v6-latin-regular.woff2">
-      <Link>swagger-ui\fonts\droid-sans-v6-latin-regular.woff2</Link>
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-    <EmbeddedResource Include="Localization\Ratings\us.txt" />
-    <EmbeddedResource Include="Localization\Ratings\ru.txt" />
-    <EmbeddedResource Include="Localization\Ratings\nz.txt" />
-    <EmbeddedResource Include="Localization\Ratings\nl.txt" />
-    <EmbeddedResource Include="Localization\Ratings\mx.txt" />
-    <EmbeddedResource Include="Localization\Ratings\kz.txt" />
-    <EmbeddedResource Include="Localization\Ratings\jp.txt" />
-    <EmbeddedResource Include="Localization\Ratings\ie.txt" />
-    <EmbeddedResource Include="Localization\Ratings\gb.txt" />
-    <EmbeddedResource Include="Localization\Ratings\fr.txt" />
-    <EmbeddedResource Include="Localization\Ratings\dk.txt" />
-    <EmbeddedResource Include="Localization\Ratings\de.txt" />
-    <EmbeddedResource Include="Localization\Ratings\co.txt" />
-    <EmbeddedResource Include="Localization\Ratings\ca.txt" />
-    <EmbeddedResource Include="Localization\Ratings\br.txt" />
-    <EmbeddedResource Include="Localization\Ratings\be.txt" />
-    <EmbeddedResource Include="Localization\Ratings\au.txt" />
-    <EmbeddedResource Include="Localization\iso6392.txt" />
     <None Include="app.config" />
-    <EmbeddedResource Include="Localization\Core\ar.json" />
-    <EmbeddedResource Include="Localization\Core\bg-BG.json" />
-    <EmbeddedResource Include="Localization\Core\ca.json" />
-    <EmbeddedResource Include="Localization\Core\core.json" />
-    <EmbeddedResource Include="Localization\Core\cs.json" />
-    <EmbeddedResource Include="Localization\Core\da.json" />
-    <EmbeddedResource Include="Localization\Core\de.json" />
-    <EmbeddedResource Include="Localization\Core\el.json" />
-    <EmbeddedResource Include="Localization\Core\en-GB.json" />
-    <EmbeddedResource Include="Localization\Core\en-US.json" />
-    <EmbeddedResource Include="Localization\Core\es-AR.json" />
-    <EmbeddedResource Include="Localization\Core\es-MX.json" />
-    <EmbeddedResource Include="Localization\Core\es.json" />
-    <EmbeddedResource Include="Localization\Core\fi.json" />
-    <EmbeddedResource Include="Localization\Core\fr-CA.json" />
-    <EmbeddedResource Include="Localization\Core\fr.json" />
-    <EmbeddedResource Include="Localization\Core\gsw.json" />
-    <EmbeddedResource Include="Localization\Core\he.json" />
-    <EmbeddedResource Include="Localization\Core\hr.json" />
-    <EmbeddedResource Include="Localization\Core\hu.json" />
-    <EmbeddedResource Include="Localization\Core\id.json" />
-    <EmbeddedResource Include="Localization\Core\it.json" />
-    <EmbeddedResource Include="Localization\Core\kk.json" />
-    <EmbeddedResource Include="Localization\Core\ko.json" />
-    <EmbeddedResource Include="Localization\Core\ms.json" />
-    <EmbeddedResource Include="Localization\Core\nb.json" />
-    <EmbeddedResource Include="Localization\Core\nl.json" />
-    <EmbeddedResource Include="Localization\Core\pl.json" />
-    <EmbeddedResource Include="Localization\Core\pt-BR.json" />
-    <EmbeddedResource Include="Localization\Core\pt-PT.json" />
-    <EmbeddedResource Include="Localization\Core\ro.json" />
-    <EmbeddedResource Include="Localization\Core\ru.json" />
-    <EmbeddedResource Include="Localization\Core\sl-SI.json" />
-    <EmbeddedResource Include="Localization\Core\sv.json" />
-    <EmbeddedResource Include="Localization\Core\tr.json" />
-    <EmbeddedResource Include="Localization\Core\uk.json" />
-    <EmbeddedResource Include="Localization\Core\vi.json" />
-    <EmbeddedResource Include="Localization\Core\zh-CN.json" />
-    <EmbeddedResource Include="Localization\Core\zh-HK.json" />
-    <EmbeddedResource Include="Localization\Core\zh-TW.json" />
-    <EmbeddedResource Include="Localization\countries.json" />
     <None Include="LiveTv\TunerHosts\SatIp\ini\satellite\0030.ini" />
     <None Include="LiveTv\TunerHosts\SatIp\ini\satellite\0049.ini" />
     <None Include="LiveTv\TunerHosts\SatIp\ini\satellite\0070.ini" />
@@ -540,56 +370,6 @@
     <None Include="LiveTv\TunerHosts\SatIp\ini\satellite\3594.ini" />
     <None Include="packages.config" />
   </ItemGroup>
-  <ItemGroup>
-    <Content Include="..\ThirdParty\ServiceStack\swagger-ui\css\reset.css">
-      <Link>swagger-ui\css\reset.css</Link>
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-    <Content Include="..\ThirdParty\ServiceStack\swagger-ui\css\screen.css">
-      <Link>swagger-ui\css\screen.css</Link>
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-    <Content Include="..\ThirdParty\ServiceStack\swagger-ui\css\typography.css">
-      <Link>swagger-ui\css\typography.css</Link>
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-    <Content Include="..\ThirdParty\ServiceStack\swagger-ui\fonts\droid-sans-v6-latin-700.svg">
-      <Link>swagger-ui\fonts\droid-sans-v6-latin-700.svg</Link>
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-    <Content Include="..\ThirdParty\ServiceStack\swagger-ui\fonts\droid-sans-v6-latin-regular.svg">
-      <Link>swagger-ui\fonts\droid-sans-v6-latin-regular.svg</Link>
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-    <Content Include="..\ThirdParty\ServiceStack\swagger-ui\images\explorer_icons.png">
-      <Link>swagger-ui\images\explorer_icons.png</Link>
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-    <Content Include="..\ThirdParty\ServiceStack\swagger-ui\images\logo_small.png">
-      <Link>swagger-ui\images\logo_small.png</Link>
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-    <Content Include="..\ThirdParty\ServiceStack\swagger-ui\images\pet_store_api.png">
-      <Link>swagger-ui\images\pet_store_api.png</Link>
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-    <Content Include="..\ThirdParty\ServiceStack\swagger-ui\images\throbber.gif">
-      <Link>swagger-ui\images\throbber.gif</Link>
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-    <Content Include="..\ThirdParty\ServiceStack\swagger-ui\images\wordnik_api.png">
-      <Link>swagger-ui\images\wordnik_api.png</Link>
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-    <Content Include="..\ThirdParty\ServiceStack\swagger-ui\index.html">
-      <Link>swagger-ui\index.html</Link>
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-    <Content Include="..\ThirdParty\ServiceStack\swagger-ui\lib\shred\content.js">
-      <Link>swagger-ui\lib\shred\content.js</Link>
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
-  </ItemGroup>
   <ItemGroup />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 

部分文件因为文件数量过多而无法显示