aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2016-11-05 15:36:32 -0400
committerGitHub <noreply@github.com>2016-11-05 15:36:32 -0400
commit36c01cfc7649b95c7ff63833424f1952e7889d07 (patch)
treebe560399d41766ff4ef6e49dd90c488e88838488
parent398398f3018434de7c057dffccb6c0373ff97526 (diff)
parenta4832369bf3abe7afbc2a35faa991be1ace64494 (diff)
Merge pull request #2274 from MediaBrowser/dev
Dev
-rw-r--r--Emby.Common.Implementations/BaseApplicationHost.cs17
-rw-r--r--Emby.Common.Implementations/EnvironmentInfo/EnvironmentInfo.cs70
-rw-r--r--Emby.Common.Implementations/Net/SocketFactory.cs33
-rw-r--r--Emby.Common.Implementations/Net/UdpSocket.cs75
-rw-r--r--Emby.Common.Implementations/Networking/BaseNetworkManager.cs116
-rw-r--r--Emby.Common.Implementations/Serialization/XmlSerializer.cs17
-rw-r--r--Emby.Common.Implementations/project.json9
-rw-r--r--Emby.Dlna/Didl/DidlBuilder.cs8
-rw-r--r--Emby.Dlna/Main/DlnaEntryPoint.cs19
-rw-r--r--Emby.Dlna/Service/BaseControlHandler.cs2
-rw-r--r--Emby.Server.Implementations/Connect/ConnectData.cs (renamed from MediaBrowser.Server.Implementations/Connect/ConnectData.cs)2
-rw-r--r--Emby.Server.Implementations/Connect/ConnectEntryPoint.cs (renamed from MediaBrowser.Server.Implementations/Connect/ConnectEntryPoint.cs)24
-rw-r--r--Emby.Server.Implementations/Connect/ConnectManager.cs (renamed from MediaBrowser.Server.Implementations/Connect/ConnectManager.cs)11
-rw-r--r--Emby.Server.Implementations/Connect/Responses.cs (renamed from MediaBrowser.Server.Implementations/Connect/Responses.cs)2
-rw-r--r--Emby.Server.Implementations/Connect/Validator.cs (renamed from MediaBrowser.Server.Implementations/Connect/Validator.cs)2
-rw-r--r--Emby.Server.Implementations/Emby.Server.Implementations.csproj255
-rw-r--r--Emby.Server.Implementations/EntryPoints/UdpServerEntryPoint.cs (renamed from MediaBrowser.Server.Implementations/EntryPoints/UdpServerEntryPoint.cs)21
-rw-r--r--Emby.Server.Implementations/HttpServer/GetSwaggerResource.cs (renamed from MediaBrowser.Server.Implementations/HttpServer/GetSwaggerResource.cs)4
-rw-r--r--Emby.Server.Implementations/HttpServer/SocketSharp/HttpUtility.cs (renamed from MediaBrowser.Server.Implementations/HttpServer/SocketSharp/HttpUtility.cs)24
-rw-r--r--Emby.Server.Implementations/HttpServer/SwaggerService.cs (renamed from MediaBrowser.Server.Implementations/HttpServer/SwaggerService.cs)9
-rw-r--r--Emby.Server.Implementations/IO/FileRefresher.cs (renamed from MediaBrowser.Server.Implementations/IO/FileRefresher.cs)9
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs2
-rw-r--r--Emby.Server.Implementations/LiveTv/LiveStreamHelper.cs2
-rw-r--r--Emby.Server.Implementations/Localization/Core/ar.json (renamed from MediaBrowser.Server.Implementations/Localization/Core/ar.json)0
-rw-r--r--Emby.Server.Implementations/Localization/Core/bg-BG.json (renamed from MediaBrowser.Server.Implementations/Localization/Core/bg-BG.json)0
-rw-r--r--Emby.Server.Implementations/Localization/Core/ca.json (renamed from MediaBrowser.Server.Implementations/Localization/Core/ca.json)0
-rw-r--r--Emby.Server.Implementations/Localization/Core/core.json (renamed from MediaBrowser.Server.Implementations/Localization/Core/core.json)0
-rw-r--r--Emby.Server.Implementations/Localization/Core/cs.json (renamed from MediaBrowser.Server.Implementations/Localization/Core/cs.json)0
-rw-r--r--Emby.Server.Implementations/Localization/Core/da.json (renamed from MediaBrowser.Server.Implementations/Localization/Core/da.json)0
-rw-r--r--Emby.Server.Implementations/Localization/Core/de.json (renamed from MediaBrowser.Server.Implementations/Localization/Core/de.json)0
-rw-r--r--Emby.Server.Implementations/Localization/Core/el.json (renamed from MediaBrowser.Server.Implementations/Localization/Core/el.json)0
-rw-r--r--Emby.Server.Implementations/Localization/Core/en-GB.json (renamed from MediaBrowser.Server.Implementations/Localization/Core/en-GB.json)0
-rw-r--r--Emby.Server.Implementations/Localization/Core/en-US.json (renamed from MediaBrowser.Server.Implementations/Localization/Core/en-US.json)0
-rw-r--r--Emby.Server.Implementations/Localization/Core/es-AR.json (renamed from MediaBrowser.Server.Implementations/Localization/Core/es-AR.json)0
-rw-r--r--Emby.Server.Implementations/Localization/Core/es-MX.json (renamed from MediaBrowser.Server.Implementations/Localization/Core/es-MX.json)0
-rw-r--r--Emby.Server.Implementations/Localization/Core/es.json (renamed from MediaBrowser.Server.Implementations/Localization/Core/es.json)0
-rw-r--r--Emby.Server.Implementations/Localization/Core/fi.json (renamed from MediaBrowser.Server.Implementations/Localization/Core/fi.json)0
-rw-r--r--Emby.Server.Implementations/Localization/Core/fr-CA.json (renamed from MediaBrowser.Server.Implementations/Localization/Core/fr-CA.json)0
-rw-r--r--Emby.Server.Implementations/Localization/Core/fr.json (renamed from MediaBrowser.Server.Implementations/Localization/Core/fr.json)0
-rw-r--r--Emby.Server.Implementations/Localization/Core/gsw.json (renamed from MediaBrowser.Server.Implementations/Localization/Core/gsw.json)0
-rw-r--r--Emby.Server.Implementations/Localization/Core/he.json (renamed from MediaBrowser.Server.Implementations/Localization/Core/he.json)0
-rw-r--r--Emby.Server.Implementations/Localization/Core/hr.json (renamed from MediaBrowser.Server.Implementations/Localization/Core/hr.json)0
-rw-r--r--Emby.Server.Implementations/Localization/Core/hu.json (renamed from MediaBrowser.Server.Implementations/Localization/Core/hu.json)0
-rw-r--r--Emby.Server.Implementations/Localization/Core/id.json (renamed from MediaBrowser.Server.Implementations/Localization/Core/id.json)0
-rw-r--r--Emby.Server.Implementations/Localization/Core/it.json (renamed from MediaBrowser.Server.Implementations/Localization/Core/it.json)0
-rw-r--r--Emby.Server.Implementations/Localization/Core/kk.json (renamed from MediaBrowser.Server.Implementations/Localization/Core/kk.json)0
-rw-r--r--Emby.Server.Implementations/Localization/Core/ko.json (renamed from MediaBrowser.Server.Implementations/Localization/Core/ko.json)0
-rw-r--r--Emby.Server.Implementations/Localization/Core/ms.json (renamed from MediaBrowser.Server.Implementations/Localization/Core/ms.json)0
-rw-r--r--Emby.Server.Implementations/Localization/Core/nb.json (renamed from MediaBrowser.Server.Implementations/Localization/Core/nb.json)0
-rw-r--r--Emby.Server.Implementations/Localization/Core/nl.json (renamed from MediaBrowser.Server.Implementations/Localization/Core/nl.json)0
-rw-r--r--Emby.Server.Implementations/Localization/Core/pl.json (renamed from MediaBrowser.Server.Implementations/Localization/Core/pl.json)0
-rw-r--r--Emby.Server.Implementations/Localization/Core/pt-BR.json (renamed from MediaBrowser.Server.Implementations/Localization/Core/pt-BR.json)0
-rw-r--r--Emby.Server.Implementations/Localization/Core/pt-PT.json (renamed from MediaBrowser.Server.Implementations/Localization/Core/pt-PT.json)0
-rw-r--r--Emby.Server.Implementations/Localization/Core/ro.json (renamed from MediaBrowser.Server.Implementations/Localization/Core/ro.json)0
-rw-r--r--Emby.Server.Implementations/Localization/Core/ru.json (renamed from MediaBrowser.Server.Implementations/Localization/Core/ru.json)0
-rw-r--r--Emby.Server.Implementations/Localization/Core/sl-SI.json (renamed from MediaBrowser.Server.Implementations/Localization/Core/sl-SI.json)0
-rw-r--r--Emby.Server.Implementations/Localization/Core/sv.json (renamed from MediaBrowser.Server.Implementations/Localization/Core/sv.json)0
-rw-r--r--Emby.Server.Implementations/Localization/Core/tr.json (renamed from MediaBrowser.Server.Implementations/Localization/Core/tr.json)0
-rw-r--r--Emby.Server.Implementations/Localization/Core/uk.json (renamed from MediaBrowser.Server.Implementations/Localization/Core/uk.json)0
-rw-r--r--Emby.Server.Implementations/Localization/Core/vi.json (renamed from MediaBrowser.Server.Implementations/Localization/Core/vi.json)0
-rw-r--r--Emby.Server.Implementations/Localization/Core/zh-CN.json (renamed from MediaBrowser.Server.Implementations/Localization/Core/zh-CN.json)0
-rw-r--r--Emby.Server.Implementations/Localization/Core/zh-HK.json (renamed from MediaBrowser.Server.Implementations/Localization/Core/zh-HK.json)0
-rw-r--r--Emby.Server.Implementations/Localization/Core/zh-TW.json (renamed from MediaBrowser.Server.Implementations/Localization/Core/zh-TW.json)0
-rw-r--r--Emby.Server.Implementations/Localization/LocalizationManager.cs (renamed from MediaBrowser.Server.Implementations/Localization/LocalizationManager.cs)63
-rw-r--r--Emby.Server.Implementations/Localization/Ratings/au.txt (renamed from MediaBrowser.Server.Implementations/Localization/Ratings/au.txt)0
-rw-r--r--Emby.Server.Implementations/Localization/Ratings/be.txt (renamed from MediaBrowser.Server.Implementations/Localization/Ratings/be.txt)0
-rw-r--r--Emby.Server.Implementations/Localization/Ratings/br.txt (renamed from MediaBrowser.Server.Implementations/Localization/Ratings/br.txt)0
-rw-r--r--Emby.Server.Implementations/Localization/Ratings/ca.txt (renamed from MediaBrowser.Server.Implementations/Localization/Ratings/ca.txt)0
-rw-r--r--Emby.Server.Implementations/Localization/Ratings/co.txt (renamed from MediaBrowser.Server.Implementations/Localization/Ratings/co.txt)0
-rw-r--r--Emby.Server.Implementations/Localization/Ratings/de.txt (renamed from MediaBrowser.Server.Implementations/Localization/Ratings/de.txt)0
-rw-r--r--Emby.Server.Implementations/Localization/Ratings/dk.txt (renamed from MediaBrowser.Server.Implementations/Localization/Ratings/dk.txt)0
-rw-r--r--Emby.Server.Implementations/Localization/Ratings/fr.txt (renamed from MediaBrowser.Server.Implementations/Localization/Ratings/fr.txt)0
-rw-r--r--Emby.Server.Implementations/Localization/Ratings/gb.txt (renamed from MediaBrowser.Server.Implementations/Localization/Ratings/gb.txt)0
-rw-r--r--Emby.Server.Implementations/Localization/Ratings/ie.txt (renamed from MediaBrowser.Server.Implementations/Localization/Ratings/ie.txt)0
-rw-r--r--Emby.Server.Implementations/Localization/Ratings/jp.txt (renamed from MediaBrowser.Server.Implementations/Localization/Ratings/jp.txt)0
-rw-r--r--Emby.Server.Implementations/Localization/Ratings/kz.txt (renamed from MediaBrowser.Server.Implementations/Localization/Ratings/kz.txt)0
-rw-r--r--Emby.Server.Implementations/Localization/Ratings/mx.txt (renamed from MediaBrowser.Server.Implementations/Localization/Ratings/mx.txt)0
-rw-r--r--Emby.Server.Implementations/Localization/Ratings/nl.txt (renamed from MediaBrowser.Server.Implementations/Localization/Ratings/nl.txt)0
-rw-r--r--Emby.Server.Implementations/Localization/Ratings/nz.txt (renamed from MediaBrowser.Server.Implementations/Localization/Ratings/nz.txt)0
-rw-r--r--Emby.Server.Implementations/Localization/Ratings/ru.txt (renamed from MediaBrowser.Server.Implementations/Localization/Ratings/ru.txt)0
-rw-r--r--Emby.Server.Implementations/Localization/Ratings/us.txt (renamed from MediaBrowser.Server.Implementations/Localization/Ratings/us.txt)0
-rw-r--r--Emby.Server.Implementations/Localization/countries.json (renamed from MediaBrowser.Server.Implementations/Localization/countries.json)0
-rw-r--r--Emby.Server.Implementations/Localization/iso6392.txt (renamed from MediaBrowser.Server.Implementations/Localization/iso6392.txt)0
-rw-r--r--Emby.Server.Implementations/Security/EncryptionManager.cs (renamed from MediaBrowser.Server.Implementations/Security/EncryptionManager.cs)4
-rw-r--r--Emby.Server.Implementations/Security/MBLicenseFile.cs12
-rw-r--r--Emby.Server.Implementations/Udp/UdpServer.cs (renamed from MediaBrowser.Server.Implementations/Udp/UdpServer.cs)145
-rw-r--r--MediaBrowser.Api/UserLibrary/UserLibraryService.cs2
-rw-r--r--MediaBrowser.Common/Net/INetworkManager.cs4
-rw-r--r--MediaBrowser.Model/MediaBrowser.Model.csproj3
-rw-r--r--MediaBrowser.Model/Net/ISocketFactory.cs21
-rw-r--r--MediaBrowser.Model/Net/IUdpSocket.cs6
-rw-r--r--MediaBrowser.Model/Net/SocketReceiveResult.cs (renamed from MediaBrowser.Model/Net/ReceivedUdpData.cs)4
-rw-r--r--MediaBrowser.Model/System/IEnvironmentInfo.cs22
-rw-r--r--MediaBrowser.Mono.sln1
-rw-r--r--MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs1
-rw-r--r--MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs2
-rw-r--r--MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpRequest.cs1
-rw-r--r--MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs18
-rw-r--r--MediaBrowser.Server.Implementations/Logging/PatternsLogger.cs63
-rw-r--r--MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj220
-rw-r--r--MediaBrowser.Server.Implementations/Udp/UdpMessageReceivedEventArgs.cs21
-rw-r--r--MediaBrowser.Server.Startup.Common/ApplicationHost.cs16
-rw-r--r--MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj1
-rw-r--r--MediaBrowser.Server.Startup.Common/TextLocalizer.cs25
-rw-r--r--Nuget/MediaBrowser.Common.nuspec6
-rw-r--r--Nuget/MediaBrowser.Server.Core.nuspec4
-rw-r--r--RSSDP/SsdpCommunicationsServer.cs55
107 files changed, 735 insertions, 718 deletions
diff --git a/Emby.Common.Implementations/BaseApplicationHost.cs b/Emby.Common.Implementations/BaseApplicationHost.cs
index bdebe894e..9585abb2a 100644
--- a/Emby.Common.Implementations/BaseApplicationHost.cs
+++ b/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);
diff --git a/Emby.Common.Implementations/EnvironmentInfo/EnvironmentInfo.cs b/Emby.Common.Implementations/EnvironmentInfo/EnvironmentInfo.cs
new file mode 100644
index 000000000..8cea617ea
--- /dev/null
+++ b/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";
+ }
+ }
+ }
+}
diff --git a/Emby.Common.Implementations/Net/SocketFactory.cs b/Emby.Common.Implementations/Net/SocketFactory.cs
index 3a2cea12a..bb38c72da 100644
--- a/Emby.Common.Implementations/Net/SocketFactory.cs
+++ b/Emby.Common.Implementations/Net/SocketFactory.cs
@@ -37,22 +37,44 @@ 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
{
diff --git a/Emby.Common.Implementations/Net/UdpSocket.cs b/Emby.Common.Implementations/Net/UdpSocket.cs
index 86ce9c83b..d999d3fe8 100644
--- a/Emby.Common.Implementations/Net/UdpSocket.cs
+++ b/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; }
}
diff --git a/Emby.Common.Implementations/Networking/BaseNetworkManager.cs b/Emby.Common.Implementations/Networking/BaseNetworkManager.cs
index bab340e27..10d0db968 100644
--- a/Emby.Common.Implementations/Networking/BaseNetworkManager.cs
+++ b/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;
+ }
}
}
diff --git a/Emby.Common.Implementations/Serialization/XmlSerializer.cs b/Emby.Common.Implementations/Serialization/XmlSerializer.cs
index aea63a57e..3583f998e 100644
--- a/Emby.Common.Implementations/Serialization/XmlSerializer.cs
+++ b/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
diff --git a/Emby.Common.Implementations/project.json b/Emby.Common.Implementations/project.json
index dc96f5726..2b2357e38 100644
--- a/Emby.Common.Implementations/project.json
+++ b/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",
diff --git a/Emby.Dlna/Didl/DidlBuilder.cs b/Emby.Dlna/Didl/DidlBuilder.cs
index 50668f555..ee5c8fecd 100644
--- a/Emby.Dlna/Didl/DidlBuilder.cs
+++ b/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();
diff --git a/Emby.Dlna/Main/DlnaEntryPoint.cs b/Emby.Dlna/Main/DlnaEntryPoint.cs
index 14fbbcfa2..142b9f96e 100644
--- a/Emby.Dlna/Main/DlnaEntryPoint.cs
+++ b/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)
diff --git a/Emby.Dlna/Service/BaseControlHandler.cs b/Emby.Dlna/Service/BaseControlHandler.cs
index df4d29e8b..afc66b1d7 100644
--- a/Emby.Dlna/Service/BaseControlHandler.cs
+++ b/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);
}
diff --git a/MediaBrowser.Server.Implementations/Connect/ConnectData.cs b/Emby.Server.Implementations/Connect/ConnectData.cs
index 5ec0bea22..41b89ce52 100644
--- a/MediaBrowser.Server.Implementations/Connect/ConnectData.cs
+++ b/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
{
diff --git a/MediaBrowser.Server.Implementations/Connect/ConnectEntryPoint.cs b/Emby.Server.Implementations/Connect/ConnectEntryPoint.cs
index 565eeb259..d7574d466 100644
--- a/MediaBrowser.Server.Implementations/Connect/ConnectEntryPoint.cs
+++ b/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);
}
diff --git a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs b/Emby.Server.Implementations/Connect/ConnectManager.cs
index 27bbfbe82..6c2ac40c3 100644
--- a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs
+++ b/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;
diff --git a/MediaBrowser.Server.Implementations/Connect/Responses.cs b/Emby.Server.Implementations/Connect/Responses.cs
index f86527829..87cb6cdf9 100644
--- a/MediaBrowser.Server.Implementations/Connect/Responses.cs
+++ b/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
{
diff --git a/MediaBrowser.Server.Implementations/Connect/Validator.cs b/Emby.Server.Implementations/Connect/Validator.cs
index 8cdfc4a6b..5c94fa71c 100644
--- a/MediaBrowser.Server.Implementations/Connect/Validator.cs
+++ b/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
{
diff --git a/Emby.Server.Implementations/Emby.Server.Implementations.csproj b/Emby.Server.Implementations/Emby.Server.Implementations.csproj
index 4a27ddb74..33f29d64d 100644
--- a/Emby.Server.Implementations/Emby.Server.Implementations.csproj
+++ b/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.
diff --git a/MediaBrowser.Server.Implementations/EntryPoints/UdpServerEntryPoint.cs b/Emby.Server.Implementations/EntryPoints/UdpServerEntryPoint.cs
index 1febcdd40..df5a7c985 100644
--- a/MediaBrowser.Server.Implementations/EntryPoints/UdpServerEntryPoint.cs
+++ b/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
{
diff --git a/MediaBrowser.Server.Implementations/HttpServer/GetSwaggerResource.cs b/Emby.Server.Implementations/HttpServer/GetSwaggerResource.cs
index 36a257f63..819ede1ab 100644
--- a/MediaBrowser.Server.Implementations/HttpServer/GetSwaggerResource.cs
+++ b/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
diff --git a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/HttpUtility.cs b/Emby.Server.Implementations/HttpServer/SocketSharp/HttpUtility.cs
index 49d6bceb4..4fbe0ed94 100644
--- a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/HttpUtility.cs
+++ b/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);
}
diff --git a/MediaBrowser.Server.Implementations/HttpServer/SwaggerService.cs b/Emby.Server.Implementations/HttpServer/SwaggerService.cs
index 54ee5fbb2..3c181e425 100644
--- a/MediaBrowser.Server.Implementations/HttpServer/SwaggerService.cs
+++ b/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;
}
diff --git a/MediaBrowser.Server.Implementations/IO/FileRefresher.cs b/Emby.Server.Implementations/IO/FileRefresher.cs
index 2742e1a26..39033249f 100644
--- a/MediaBrowser.Server.Implementations/IO/FileRefresher.cs
+++ b/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;
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs
index 93ba9c420..5d70d0383 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs
+++ b/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";
}
diff --git a/Emby.Server.Implementations/LiveTv/LiveStreamHelper.cs b/Emby.Server.Implementations/LiveTv/LiveStreamHelper.cs
index a338ae23a..99996c252 100644
--- a/Emby.Server.Implementations/LiveTv/LiveStreamHelper.cs
+++ b/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);
diff --git a/MediaBrowser.Server.Implementations/Localization/Core/ar.json b/Emby.Server.Implementations/Localization/Core/ar.json
index 28977c4f9..28977c4f9 100644
--- a/MediaBrowser.Server.Implementations/Localization/Core/ar.json
+++ b/Emby.Server.Implementations/Localization/Core/ar.json
diff --git a/MediaBrowser.Server.Implementations/Localization/Core/bg-BG.json b/Emby.Server.Implementations/Localization/Core/bg-BG.json
index 22b99408d..22b99408d 100644
--- a/MediaBrowser.Server.Implementations/Localization/Core/bg-BG.json
+++ b/Emby.Server.Implementations/Localization/Core/bg-BG.json
diff --git a/MediaBrowser.Server.Implementations/Localization/Core/ca.json b/Emby.Server.Implementations/Localization/Core/ca.json
index 7ca8e1553..7ca8e1553 100644
--- a/MediaBrowser.Server.Implementations/Localization/Core/ca.json
+++ b/Emby.Server.Implementations/Localization/Core/ca.json
diff --git a/MediaBrowser.Server.Implementations/Localization/Core/core.json b/Emby.Server.Implementations/Localization/Core/core.json
index 976faa8cb..976faa8cb 100644
--- a/MediaBrowser.Server.Implementations/Localization/Core/core.json
+++ b/Emby.Server.Implementations/Localization/Core/core.json
diff --git a/MediaBrowser.Server.Implementations/Localization/Core/cs.json b/Emby.Server.Implementations/Localization/Core/cs.json
index e3055f5ba..e3055f5ba 100644
--- a/MediaBrowser.Server.Implementations/Localization/Core/cs.json
+++ b/Emby.Server.Implementations/Localization/Core/cs.json
diff --git a/MediaBrowser.Server.Implementations/Localization/Core/da.json b/Emby.Server.Implementations/Localization/Core/da.json
index d2a628a80..d2a628a80 100644
--- a/MediaBrowser.Server.Implementations/Localization/Core/da.json
+++ b/Emby.Server.Implementations/Localization/Core/da.json
diff --git a/MediaBrowser.Server.Implementations/Localization/Core/de.json b/Emby.Server.Implementations/Localization/Core/de.json
index 30e3d9215..30e3d9215 100644
--- a/MediaBrowser.Server.Implementations/Localization/Core/de.json
+++ b/Emby.Server.Implementations/Localization/Core/de.json
diff --git a/MediaBrowser.Server.Implementations/Localization/Core/el.json b/Emby.Server.Implementations/Localization/Core/el.json
index 9e2d321cc..9e2d321cc 100644
--- a/MediaBrowser.Server.Implementations/Localization/Core/el.json
+++ b/Emby.Server.Implementations/Localization/Core/el.json
diff --git a/MediaBrowser.Server.Implementations/Localization/Core/en-GB.json b/Emby.Server.Implementations/Localization/Core/en-GB.json
index 493c6c4e9..493c6c4e9 100644
--- a/MediaBrowser.Server.Implementations/Localization/Core/en-GB.json
+++ b/Emby.Server.Implementations/Localization/Core/en-GB.json
diff --git a/MediaBrowser.Server.Implementations/Localization/Core/en-US.json b/Emby.Server.Implementations/Localization/Core/en-US.json
index bc0dc236d..bc0dc236d 100644
--- a/MediaBrowser.Server.Implementations/Localization/Core/en-US.json
+++ b/Emby.Server.Implementations/Localization/Core/en-US.json
diff --git a/MediaBrowser.Server.Implementations/Localization/Core/es-AR.json b/Emby.Server.Implementations/Localization/Core/es-AR.json
index 0555aa9d9..0555aa9d9 100644
--- a/MediaBrowser.Server.Implementations/Localization/Core/es-AR.json
+++ b/Emby.Server.Implementations/Localization/Core/es-AR.json
diff --git a/MediaBrowser.Server.Implementations/Localization/Core/es-MX.json b/Emby.Server.Implementations/Localization/Core/es-MX.json
index 630c7a037..630c7a037 100644
--- a/MediaBrowser.Server.Implementations/Localization/Core/es-MX.json
+++ b/Emby.Server.Implementations/Localization/Core/es-MX.json
diff --git a/MediaBrowser.Server.Implementations/Localization/Core/es.json b/Emby.Server.Implementations/Localization/Core/es.json
index d1a56240d..d1a56240d 100644
--- a/MediaBrowser.Server.Implementations/Localization/Core/es.json
+++ b/Emby.Server.Implementations/Localization/Core/es.json
diff --git a/MediaBrowser.Server.Implementations/Localization/Core/fi.json b/Emby.Server.Implementations/Localization/Core/fi.json
index 20efa1406..20efa1406 100644
--- a/MediaBrowser.Server.Implementations/Localization/Core/fi.json
+++ b/Emby.Server.Implementations/Localization/Core/fi.json
diff --git a/MediaBrowser.Server.Implementations/Localization/Core/fr-CA.json b/Emby.Server.Implementations/Localization/Core/fr-CA.json
index 789817c84..789817c84 100644
--- a/MediaBrowser.Server.Implementations/Localization/Core/fr-CA.json
+++ b/Emby.Server.Implementations/Localization/Core/fr-CA.json
diff --git a/MediaBrowser.Server.Implementations/Localization/Core/fr.json b/Emby.Server.Implementations/Localization/Core/fr.json
index 25c722989..25c722989 100644
--- a/MediaBrowser.Server.Implementations/Localization/Core/fr.json
+++ b/Emby.Server.Implementations/Localization/Core/fr.json
diff --git a/MediaBrowser.Server.Implementations/Localization/Core/gsw.json b/Emby.Server.Implementations/Localization/Core/gsw.json
index 88af82b7e..88af82b7e 100644
--- a/MediaBrowser.Server.Implementations/Localization/Core/gsw.json
+++ b/Emby.Server.Implementations/Localization/Core/gsw.json
diff --git a/MediaBrowser.Server.Implementations/Localization/Core/he.json b/Emby.Server.Implementations/Localization/Core/he.json
index 137b45544..137b45544 100644
--- a/MediaBrowser.Server.Implementations/Localization/Core/he.json
+++ b/Emby.Server.Implementations/Localization/Core/he.json
diff --git a/MediaBrowser.Server.Implementations/Localization/Core/hr.json b/Emby.Server.Implementations/Localization/Core/hr.json
index 7a94dc32b..7a94dc32b 100644
--- a/MediaBrowser.Server.Implementations/Localization/Core/hr.json
+++ b/Emby.Server.Implementations/Localization/Core/hr.json
diff --git a/MediaBrowser.Server.Implementations/Localization/Core/hu.json b/Emby.Server.Implementations/Localization/Core/hu.json
index 2b9d28d8c..2b9d28d8c 100644
--- a/MediaBrowser.Server.Implementations/Localization/Core/hu.json
+++ b/Emby.Server.Implementations/Localization/Core/hu.json
diff --git a/MediaBrowser.Server.Implementations/Localization/Core/id.json b/Emby.Server.Implementations/Localization/Core/id.json
index 8d64b63c4..8d64b63c4 100644
--- a/MediaBrowser.Server.Implementations/Localization/Core/id.json
+++ b/Emby.Server.Implementations/Localization/Core/id.json
diff --git a/MediaBrowser.Server.Implementations/Localization/Core/it.json b/Emby.Server.Implementations/Localization/Core/it.json
index d2d697c3e..d2d697c3e 100644
--- a/MediaBrowser.Server.Implementations/Localization/Core/it.json
+++ b/Emby.Server.Implementations/Localization/Core/it.json
diff --git a/MediaBrowser.Server.Implementations/Localization/Core/kk.json b/Emby.Server.Implementations/Localization/Core/kk.json
index 93252c30b..93252c30b 100644
--- a/MediaBrowser.Server.Implementations/Localization/Core/kk.json
+++ b/Emby.Server.Implementations/Localization/Core/kk.json
diff --git a/MediaBrowser.Server.Implementations/Localization/Core/ko.json b/Emby.Server.Implementations/Localization/Core/ko.json
index 834ccc17b..834ccc17b 100644
--- a/MediaBrowser.Server.Implementations/Localization/Core/ko.json
+++ b/Emby.Server.Implementations/Localization/Core/ko.json
diff --git a/MediaBrowser.Server.Implementations/Localization/Core/ms.json b/Emby.Server.Implementations/Localization/Core/ms.json
index fe5eef894..fe5eef894 100644
--- a/MediaBrowser.Server.Implementations/Localization/Core/ms.json
+++ b/Emby.Server.Implementations/Localization/Core/ms.json
diff --git a/MediaBrowser.Server.Implementations/Localization/Core/nb.json b/Emby.Server.Implementations/Localization/Core/nb.json
index 315d49b5f..315d49b5f 100644
--- a/MediaBrowser.Server.Implementations/Localization/Core/nb.json
+++ b/Emby.Server.Implementations/Localization/Core/nb.json
diff --git a/MediaBrowser.Server.Implementations/Localization/Core/nl.json b/Emby.Server.Implementations/Localization/Core/nl.json
index 2818fbf6a..2818fbf6a 100644
--- a/MediaBrowser.Server.Implementations/Localization/Core/nl.json
+++ b/Emby.Server.Implementations/Localization/Core/nl.json
diff --git a/MediaBrowser.Server.Implementations/Localization/Core/pl.json b/Emby.Server.Implementations/Localization/Core/pl.json
index cdaa87c4d..cdaa87c4d 100644
--- a/MediaBrowser.Server.Implementations/Localization/Core/pl.json
+++ b/Emby.Server.Implementations/Localization/Core/pl.json
diff --git a/MediaBrowser.Server.Implementations/Localization/Core/pt-BR.json b/Emby.Server.Implementations/Localization/Core/pt-BR.json
index 67f204b2e..67f204b2e 100644
--- a/MediaBrowser.Server.Implementations/Localization/Core/pt-BR.json
+++ b/Emby.Server.Implementations/Localization/Core/pt-BR.json
diff --git a/MediaBrowser.Server.Implementations/Localization/Core/pt-PT.json b/Emby.Server.Implementations/Localization/Core/pt-PT.json
index f12939b10..f12939b10 100644
--- a/MediaBrowser.Server.Implementations/Localization/Core/pt-PT.json
+++ b/Emby.Server.Implementations/Localization/Core/pt-PT.json
diff --git a/MediaBrowser.Server.Implementations/Localization/Core/ro.json b/Emby.Server.Implementations/Localization/Core/ro.json
index c58df27d5..c58df27d5 100644
--- a/MediaBrowser.Server.Implementations/Localization/Core/ro.json
+++ b/Emby.Server.Implementations/Localization/Core/ro.json
diff --git a/MediaBrowser.Server.Implementations/Localization/Core/ru.json b/Emby.Server.Implementations/Localization/Core/ru.json
index 62fe3b496..62fe3b496 100644
--- a/MediaBrowser.Server.Implementations/Localization/Core/ru.json
+++ b/Emby.Server.Implementations/Localization/Core/ru.json
diff --git a/MediaBrowser.Server.Implementations/Localization/Core/sl-SI.json b/Emby.Server.Implementations/Localization/Core/sl-SI.json
index 0631e3fa8..0631e3fa8 100644
--- a/MediaBrowser.Server.Implementations/Localization/Core/sl-SI.json
+++ b/Emby.Server.Implementations/Localization/Core/sl-SI.json
diff --git a/MediaBrowser.Server.Implementations/Localization/Core/sv.json b/Emby.Server.Implementations/Localization/Core/sv.json
index 4a6565aff..4a6565aff 100644
--- a/MediaBrowser.Server.Implementations/Localization/Core/sv.json
+++ b/Emby.Server.Implementations/Localization/Core/sv.json
diff --git a/MediaBrowser.Server.Implementations/Localization/Core/tr.json b/Emby.Server.Implementations/Localization/Core/tr.json
index a691e9d02..a691e9d02 100644
--- a/MediaBrowser.Server.Implementations/Localization/Core/tr.json
+++ b/Emby.Server.Implementations/Localization/Core/tr.json
diff --git a/MediaBrowser.Server.Implementations/Localization/Core/uk.json b/Emby.Server.Implementations/Localization/Core/uk.json
index 0dc6afe8a..0dc6afe8a 100644
--- a/MediaBrowser.Server.Implementations/Localization/Core/uk.json
+++ b/Emby.Server.Implementations/Localization/Core/uk.json
diff --git a/MediaBrowser.Server.Implementations/Localization/Core/vi.json b/Emby.Server.Implementations/Localization/Core/vi.json
index 6ea1d1d3f..6ea1d1d3f 100644
--- a/MediaBrowser.Server.Implementations/Localization/Core/vi.json
+++ b/Emby.Server.Implementations/Localization/Core/vi.json
diff --git a/MediaBrowser.Server.Implementations/Localization/Core/zh-CN.json b/Emby.Server.Implementations/Localization/Core/zh-CN.json
index 580832a9e..580832a9e 100644
--- a/MediaBrowser.Server.Implementations/Localization/Core/zh-CN.json
+++ b/Emby.Server.Implementations/Localization/Core/zh-CN.json
diff --git a/MediaBrowser.Server.Implementations/Localization/Core/zh-HK.json b/Emby.Server.Implementations/Localization/Core/zh-HK.json
index a70e7a003..a70e7a003 100644
--- a/MediaBrowser.Server.Implementations/Localization/Core/zh-HK.json
+++ b/Emby.Server.Implementations/Localization/Core/zh-HK.json
diff --git a/MediaBrowser.Server.Implementations/Localization/Core/zh-TW.json b/Emby.Server.Implementations/Localization/Core/zh-TW.json
index b711aab1f..b711aab1f 100644
--- a/MediaBrowser.Server.Implementations/Localization/Core/zh-TW.json
+++ b/Emby.Server.Implementations/Localization/Core/zh-TW.json
diff --git a/MediaBrowser.Server.Implementations/Localization/LocalizationManager.cs b/Emby.Server.Implementations/Localization/LocalizationManager.cs
index e4db98b3f..120f445c2 100644
--- a/MediaBrowser.Server.Implementations/Localization/LocalizationManager.cs
+++ b/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);
+ }
}
diff --git a/MediaBrowser.Server.Implementations/Localization/Ratings/au.txt b/Emby.Server.Implementations/Localization/Ratings/au.txt
index fa60f5305..fa60f5305 100644
--- a/MediaBrowser.Server.Implementations/Localization/Ratings/au.txt
+++ b/Emby.Server.Implementations/Localization/Ratings/au.txt
diff --git a/MediaBrowser.Server.Implementations/Localization/Ratings/be.txt b/Emby.Server.Implementations/Localization/Ratings/be.txt
index 99a53f664..99a53f664 100644
--- a/MediaBrowser.Server.Implementations/Localization/Ratings/be.txt
+++ b/Emby.Server.Implementations/Localization/Ratings/be.txt
diff --git a/MediaBrowser.Server.Implementations/Localization/Ratings/br.txt b/Emby.Server.Implementations/Localization/Ratings/br.txt
index 62f00fb87..62f00fb87 100644
--- a/MediaBrowser.Server.Implementations/Localization/Ratings/br.txt
+++ b/Emby.Server.Implementations/Localization/Ratings/br.txt
diff --git a/MediaBrowser.Server.Implementations/Localization/Ratings/ca.txt b/Emby.Server.Implementations/Localization/Ratings/ca.txt
index 5a110648c..5a110648c 100644
--- a/MediaBrowser.Server.Implementations/Localization/Ratings/ca.txt
+++ b/Emby.Server.Implementations/Localization/Ratings/ca.txt
diff --git a/MediaBrowser.Server.Implementations/Localization/Ratings/co.txt b/Emby.Server.Implementations/Localization/Ratings/co.txt
index a694a0be6..a694a0be6 100644
--- a/MediaBrowser.Server.Implementations/Localization/Ratings/co.txt
+++ b/Emby.Server.Implementations/Localization/Ratings/co.txt
diff --git a/MediaBrowser.Server.Implementations/Localization/Ratings/de.txt b/Emby.Server.Implementations/Localization/Ratings/de.txt
index ad1f18619..ad1f18619 100644
--- a/MediaBrowser.Server.Implementations/Localization/Ratings/de.txt
+++ b/Emby.Server.Implementations/Localization/Ratings/de.txt
diff --git a/MediaBrowser.Server.Implementations/Localization/Ratings/dk.txt b/Emby.Server.Implementations/Localization/Ratings/dk.txt
index b9a085e01..b9a085e01 100644
--- a/MediaBrowser.Server.Implementations/Localization/Ratings/dk.txt
+++ b/Emby.Server.Implementations/Localization/Ratings/dk.txt
diff --git a/MediaBrowser.Server.Implementations/Localization/Ratings/fr.txt b/Emby.Server.Implementations/Localization/Ratings/fr.txt
index 2bb205b0d..2bb205b0d 100644
--- a/MediaBrowser.Server.Implementations/Localization/Ratings/fr.txt
+++ b/Emby.Server.Implementations/Localization/Ratings/fr.txt
diff --git a/MediaBrowser.Server.Implementations/Localization/Ratings/gb.txt b/Emby.Server.Implementations/Localization/Ratings/gb.txt
index c1f7d0452..c1f7d0452 100644
--- a/MediaBrowser.Server.Implementations/Localization/Ratings/gb.txt
+++ b/Emby.Server.Implementations/Localization/Ratings/gb.txt
diff --git a/MediaBrowser.Server.Implementations/Localization/Ratings/ie.txt b/Emby.Server.Implementations/Localization/Ratings/ie.txt
index 283f07767..283f07767 100644
--- a/MediaBrowser.Server.Implementations/Localization/Ratings/ie.txt
+++ b/Emby.Server.Implementations/Localization/Ratings/ie.txt
diff --git a/MediaBrowser.Server.Implementations/Localization/Ratings/jp.txt b/Emby.Server.Implementations/Localization/Ratings/jp.txt
index 2e1da30d8..2e1da30d8 100644
--- a/MediaBrowser.Server.Implementations/Localization/Ratings/jp.txt
+++ b/Emby.Server.Implementations/Localization/Ratings/jp.txt
diff --git a/MediaBrowser.Server.Implementations/Localization/Ratings/kz.txt b/Emby.Server.Implementations/Localization/Ratings/kz.txt
index b31e12d96..b31e12d96 100644
--- a/MediaBrowser.Server.Implementations/Localization/Ratings/kz.txt
+++ b/Emby.Server.Implementations/Localization/Ratings/kz.txt
diff --git a/MediaBrowser.Server.Implementations/Localization/Ratings/mx.txt b/Emby.Server.Implementations/Localization/Ratings/mx.txt
index 93b609c3d..93b609c3d 100644
--- a/MediaBrowser.Server.Implementations/Localization/Ratings/mx.txt
+++ b/Emby.Server.Implementations/Localization/Ratings/mx.txt
diff --git a/MediaBrowser.Server.Implementations/Localization/Ratings/nl.txt b/Emby.Server.Implementations/Localization/Ratings/nl.txt
index f69cc2bcc..f69cc2bcc 100644
--- a/MediaBrowser.Server.Implementations/Localization/Ratings/nl.txt
+++ b/Emby.Server.Implementations/Localization/Ratings/nl.txt
diff --git a/MediaBrowser.Server.Implementations/Localization/Ratings/nz.txt b/Emby.Server.Implementations/Localization/Ratings/nz.txt
index bc761dcab..bc761dcab 100644
--- a/MediaBrowser.Server.Implementations/Localization/Ratings/nz.txt
+++ b/Emby.Server.Implementations/Localization/Ratings/nz.txt
diff --git a/MediaBrowser.Server.Implementations/Localization/Ratings/ru.txt b/Emby.Server.Implementations/Localization/Ratings/ru.txt
index 1bc94affd..1bc94affd 100644
--- a/MediaBrowser.Server.Implementations/Localization/Ratings/ru.txt
+++ b/Emby.Server.Implementations/Localization/Ratings/ru.txt
diff --git a/MediaBrowser.Server.Implementations/Localization/Ratings/us.txt b/Emby.Server.Implementations/Localization/Ratings/us.txt
index 3f5311e0e..3f5311e0e 100644
--- a/MediaBrowser.Server.Implementations/Localization/Ratings/us.txt
+++ b/Emby.Server.Implementations/Localization/Ratings/us.txt
diff --git a/MediaBrowser.Server.Implementations/Localization/countries.json b/Emby.Server.Implementations/Localization/countries.json
index e671b3685..e671b3685 100644
--- a/MediaBrowser.Server.Implementations/Localization/countries.json
+++ b/Emby.Server.Implementations/Localization/countries.json
diff --git a/MediaBrowser.Server.Implementations/Localization/iso6392.txt b/Emby.Server.Implementations/Localization/iso6392.txt
index 665a5375e..665a5375e 100644
--- a/MediaBrowser.Server.Implementations/Localization/iso6392.txt
+++ b/Emby.Server.Implementations/Localization/iso6392.txt
diff --git a/MediaBrowser.Server.Implementations/Security/EncryptionManager.cs b/Emby.Server.Implementations/Security/EncryptionManager.cs
index cd9b9651e..271b0bbdb 100644
--- a/MediaBrowser.Server.Implementations/Security/EncryptionManager.cs
+++ b/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);
}
}
}
diff --git a/Emby.Server.Implementations/Security/MBLicenseFile.cs b/Emby.Server.Implementations/Security/MBLicenseFile.cs
index 454ee6026..7cb6165a5 100644
--- a/Emby.Server.Implementations/Security/MBLicenseFile.cs
+++ b/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])));
+ }
}
}
}
diff --git a/MediaBrowser.Server.Implementations/Udp/UdpServer.cs b/Emby.Server.Implementations/Udp/UdpServer.cs
index c2082f0d2..c15e0ee41 100644
--- a/MediaBrowser.Server.Implementations/Udp/UdpServer.cs
+++ b/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);
}
diff --git a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs
index 624eeb832..fbc2c0ccd 100644
--- a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs
+++ b/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;
diff --git a/MediaBrowser.Common/Net/INetworkManager.cs b/MediaBrowser.Common/Net/INetworkManager.cs
index 0a565f670..fe60c7ebf 100644
--- a/MediaBrowser.Common/Net/INetworkManager.cs
+++ b/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>
diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj
index 03bbafe60..52e477b1a 100644
--- a/MediaBrowser.Model/MediaBrowser.Model.csproj
+++ b/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" />
diff --git a/MediaBrowser.Model/Net/ISocketFactory.cs b/MediaBrowser.Model/Net/ISocketFactory.cs
index c0e0440c2..3f1ddf84f 100644
--- a/MediaBrowser.Model/Net/ISocketFactory.cs
+++ b/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);
}
}
diff --git a/MediaBrowser.Model/Net/IUdpSocket.cs b/MediaBrowser.Model/Net/IUdpSocket.cs
index cbeb8a995..ef090e010 100644
--- a/MediaBrowser.Model/Net/IUdpSocket.cs
+++ b/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);
}
} \ No newline at end of file
diff --git a/MediaBrowser.Model/Net/ReceivedUdpData.cs b/MediaBrowser.Model/Net/SocketReceiveResult.cs
index 1fdb22c93..0a2d04ad3 100644
--- a/MediaBrowser.Model/Net/ReceivedUdpData.cs
+++ b/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; }
}
}
diff --git a/MediaBrowser.Model/System/IEnvironmentInfo.cs b/MediaBrowser.Model/System/IEnvironmentInfo.cs
new file mode 100644
index 000000000..3fcacb30d
--- /dev/null
+++ b/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
+ }
+}
diff --git a/MediaBrowser.Mono.sln b/MediaBrowser.Mono.sln
index 90c6a3ce5..4e7a58bd1 100644
--- a/MediaBrowser.Mono.sln
+++ b/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
diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs
index f00c81766..805cb0353 100644
--- a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs
+++ b/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;
diff --git a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs
index 20d89d2eb..561934854 100644
--- a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs
+++ b/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;
diff --git a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpRequest.cs b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpRequest.cs
index 2546519f4..c56f62bec 100644
--- a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpRequest.cs
+++ b/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;
diff --git a/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs b/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs
index 49cb1e75f..a8363558d 100644
--- a/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs
+++ b/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);
}
diff --git a/MediaBrowser.Server.Implementations/Logging/PatternsLogger.cs b/MediaBrowser.Server.Implementations/Logging/PatternsLogger.cs
deleted file mode 100644
index 00b6cc5a8..000000000
--- a/MediaBrowser.Server.Implementations/Logging/PatternsLogger.cs
+++ /dev/null
@@ -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)
- {
- }
- }
-}
diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
index d6223c465..10ebe4ea6 100644
--- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
+++ b/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.
diff --git a/MediaBrowser.Server.Implementations/Udp/UdpMessageReceivedEventArgs.cs b/MediaBrowser.Server.Implementations/Udp/UdpMessageReceivedEventArgs.cs
deleted file mode 100644
index 5c83a1300..000000000
--- a/MediaBrowser.Server.Implementations/Udp/UdpMessageReceivedEventArgs.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using System;
-
-namespace MediaBrowser.Server.Implementations.Udp
-{
- /// <summary>
- /// Class UdpMessageReceivedEventArgs
- /// </summary>
- public class UdpMessageReceivedEventArgs : EventArgs
- {
- /// <summary>
- /// Gets or sets the bytes.
- /// </summary>
- /// <value>The bytes.</value>
- public byte[] Bytes { get; set; }
- /// <summary>
- /// Gets or sets the remote end point.
- /// </summary>
- /// <value>The remote end point.</value>
- public string RemoteEndPoint { get; set; }
- }
-}
diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
index 5f609de27..fd84940dd 100644
--- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
+++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
@@ -51,13 +51,9 @@ using MediaBrowser.Providers.Subtitles;
using MediaBrowser.Server.Implementations;
using MediaBrowser.Server.Implementations.Activity;
using MediaBrowser.Server.Implementations.Configuration;
-using MediaBrowser.Server.Implementations.Connect;
using MediaBrowser.Server.Implementations.Devices;
-using MediaBrowser.Server.Implementations.EntryPoints;
using MediaBrowser.Server.Implementations.HttpServer;
using MediaBrowser.Server.Implementations.IO;
-using MediaBrowser.Server.Implementations.LiveTv;
-using MediaBrowser.Server.Implementations.Localization;
using MediaBrowser.Server.Implementations.Notifications;
using MediaBrowser.Server.Implementations.Persistence;
using MediaBrowser.Server.Implementations.Security;
@@ -102,12 +98,15 @@ using Emby.Dlna.Ssdp;
using Emby.Server.Implementations.Activity;
using Emby.Server.Implementations.Channels;
using Emby.Server.Implementations.Collections;
+using Emby.Server.Implementations.Connect;
using Emby.Server.Implementations.Devices;
using Emby.Server.Implementations.Dto;
+using Emby.Server.Implementations.EntryPoints;
using Emby.Server.Implementations.FileOrganization;
using Emby.Server.Implementations.HttpServer.Security;
using Emby.Server.Implementations.Library;
using Emby.Server.Implementations.LiveTv;
+using Emby.Server.Implementations.Localization;
using Emby.Server.Implementations.MediaEncoder;
using Emby.Server.Implementations.Notifications;
using Emby.Server.Implementations.Persistence;
@@ -549,7 +548,10 @@ namespace MediaBrowser.Server.Startup.Common
RegisterSingleInstance(ServerConfigurationManager);
- LocalizationManager = new LocalizationManager(ServerConfigurationManager, FileSystemManager, JsonSerializer, LogManager.GetLogger("LocalizationManager"));
+ IAssemblyInfo assemblyInfo = new AssemblyInfo();
+ RegisterSingleInstance<IAssemblyInfo>(assemblyInfo);
+
+ LocalizationManager = new LocalizationManager(ServerConfigurationManager, FileSystemManager, JsonSerializer, LogManager.GetLogger("LocalizationManager"), assemblyInfo, new TextLocalizer());
StringExtensions.LocalizationManager = LocalizationManager;
RegisterSingleInstance(LocalizationManager);
@@ -559,8 +561,6 @@ namespace MediaBrowser.Server.Startup.Common
RegisterSingleInstance<IBlurayExaminer>(() => new BdInfoExaminer(FileSystemManager, textEncoding));
RegisterSingleInstance<IXmlReaderSettingsFactory>(new XmlReaderSettingsFactory());
- IAssemblyInfo assemblyInfo = new AssemblyInfo();
- RegisterSingleInstance<IAssemblyInfo>(assemblyInfo);
UserDataManager = new UserDataManager(LogManager, ServerConfigurationManager);
RegisterSingleInstance(UserDataManager);
@@ -593,7 +593,7 @@ namespace MediaBrowser.Server.Startup.Common
var musicManager = new MusicManager(LibraryManager);
RegisterSingleInstance<IMusicManager>(new MusicManager(LibraryManager));
- LibraryMonitor = new LibraryMonitor(LogManager, TaskManager, LibraryManager, ServerConfigurationManager, FileSystemManager, TimerFactory);
+ LibraryMonitor = new LibraryMonitor(LogManager, TaskManager, LibraryManager, ServerConfigurationManager, FileSystemManager, TimerFactory, SystemEvents, EnvironmentInfo);
RegisterSingleInstance(LibraryMonitor);
ProviderManager = new ProviderManager(HttpClient, ServerConfigurationManager, LibraryMonitor, LogManager, FileSystemManager, ApplicationPaths, () => LibraryManager, JsonSerializer, MemoryStreamProvider);
diff --git a/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj b/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj
index d30d892c9..aca30aa2c 100644
--- a/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj
+++ b/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj
@@ -89,6 +89,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="StartupOptions.cs" />
<Compile Include="SystemEvents.cs" />
+ <Compile Include="TextLocalizer.cs" />
<Compile Include="Threading\PeriodicTimer.cs" />
<Compile Include="UnhandledExceptionWriter.cs" />
</ItemGroup>
diff --git a/MediaBrowser.Server.Startup.Common/TextLocalizer.cs b/MediaBrowser.Server.Startup.Common/TextLocalizer.cs
new file mode 100644
index 000000000..c578199a0
--- /dev/null
+++ b/MediaBrowser.Server.Startup.Common/TextLocalizer.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using Emby.Server.Implementations.Localization;
+
+namespace MediaBrowser.Server.Startup.Common
+{
+ public class TextLocalizer : ITextLocalizer
+ {
+ public string RemoveDiacritics(string text)
+ {
+ return String.Concat(
+ text.Normalize(NormalizationForm.FormD)
+ .Where(ch => CharUnicodeInfo.GetUnicodeCategory(ch) !=
+ UnicodeCategory.NonSpacingMark)
+ ).Normalize(NormalizationForm.FormC);
+ }
+
+ public string NormalizeFormKD(string text)
+ {
+ return text.Normalize(NormalizationForm.FormKD);
+ }
+ }
+}
diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec
index c17450d2b..b94b54736 100644
--- a/Nuget/MediaBrowser.Common.nuspec
+++ b/Nuget/MediaBrowser.Common.nuspec
@@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>MediaBrowser.Common</id>
- <version>3.0.682</version>
+ <version>3.0.683</version>
<title>Emby.Common</title>
<authors>Emby Team</authors>
<owners>ebr,Luke,scottisafool</owners>
@@ -13,7 +13,7 @@
<copyright>Copyright © Emby 2013</copyright>
</metadata>
<files>
- <file src="dlls\MediaBrowser.Common.dll" target="lib\netstandard1.0\MediaBrowser.Common.dll" />
- <file src="dlls\MediaBrowser.Model.dll" target="lib\netstandard1.0\MediaBrowser.Model.dll" />
+ <file src="dlls\MediaBrowser.Common.dll" target="lib\portable-net45+win8+wpa81\MediaBrowser.Common.dll" />
+ <file src="dlls\MediaBrowser.Model.dll" target="lib\portable-net45+win8+wpa81\MediaBrowser.Model.dll" />
</files>
</package>
diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec
index dd0af3d3c..c0d5d2705 100644
--- a/Nuget/MediaBrowser.Server.Core.nuspec
+++ b/Nuget/MediaBrowser.Server.Core.nuspec
@@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>MediaBrowser.Server.Core</id>
- <version>3.0.681</version>
+ <version>3.0.683</version>
<title>Emby.Server.Core</title>
<authors>Emby Team</authors>
<owners>ebr,Luke,scottisafool</owners>
@@ -12,7 +12,7 @@
<description>Contains core components required to build plugins for Emby Server.</description>
<copyright>Copyright © Emby 2013</copyright>
<dependencies>
- <dependency id="MediaBrowser.Common" version="3.0.681" />
+ <dependency id="MediaBrowser.Common" version="3.0.683" />
</dependencies>
</metadata>
<files>
diff --git a/RSSDP/SsdpCommunicationsServer.cs b/RSSDP/SsdpCommunicationsServer.cs
index 64278fe4e..c0b9c6542 100644
--- a/RSSDP/SsdpCommunicationsServer.cs
+++ b/RSSDP/SsdpCommunicationsServer.cs
@@ -79,17 +79,6 @@ namespace Rssdp.Infrastructure
}
/// <summary>
- /// Partial constructor.
- /// </summary>
- /// <param name="socketFactory">An implementation of the <see cref="ISocketFactory"/> interface that can be used to make new unicast and multicast sockets. Cannot be null.</param>
- /// <param name="localPort">The specific local port to use for all sockets created by this instance. Specify zero to indicate the system should choose a free port itself.</param>
- /// <exception cref="System.ArgumentNullException">The <paramref name="socketFactory"/> argument is null.</exception>
- public SsdpCommunicationsServer(ISocketFactory socketFactory, int localPort)
- : this(socketFactory, localPort, SsdpConstants.SsdpDefaultMulticastTimeToLive)
- {
- }
-
- /// <summary>
/// Full constructor.
/// </summary>
/// <param name="socketFactory">An implementation of the <see cref="ISocketFactory"/> interface that can be used to make new unicast and multicast sockets. Cannot be null.</param>
@@ -170,7 +159,12 @@ namespace Rssdp.Infrastructure
EnsureSendSocketCreated();
// SSDP spec recommends sending messages multiple times (not more than 3) to account for possible packet loss over UDP.
- await Repeat(SsdpConstants.UdpResendCount, TimeSpan.FromMilliseconds(100), () => SendMessageIfSocketNotDisposed(messageData, destination)).ConfigureAwait(false);
+ for (var i = 0; i < SsdpConstants.UdpResendCount; i++)
+ {
+ await SendMessageIfSocketNotDisposed(messageData, destination).ConfigureAwait(false);
+
+ await Task.Delay(100).ConfigureAwait(false);
+ }
}
/// <summary>
@@ -188,8 +182,17 @@ namespace Rssdp.Infrastructure
EnsureSendSocketCreated();
// SSDP spec recommends sending messages multiple times (not more than 3) to account for possible packet loss over UDP.
- await Repeat(SsdpConstants.UdpResendCount, TimeSpan.FromMilliseconds(100),
- () => SendMessageIfSocketNotDisposed(messageData, new IpEndPointInfo() { IpAddress = new IpAddressInfo { Address = SsdpConstants.MulticastLocalAdminAddress }, Port = SsdpConstants.MulticastPort })).ConfigureAwait(false);
+ for (var i = 0; i < SsdpConstants.UdpResendCount; i++)
+ {
+ await SendMessageIfSocketNotDisposed(messageData, new IpEndPointInfo
+ {
+ IpAddress = new IpAddressInfo { Address = SsdpConstants.MulticastLocalAdminAddress },
+ Port = SsdpConstants.MulticastPort
+
+ }).ConfigureAwait(false);
+
+ await Task.Delay(100).ConfigureAwait(false);
+ }
}
/// <summary>
@@ -255,28 +258,16 @@ namespace Rssdp.Infrastructure
#region Private Methods
- private async Task SendMessageIfSocketNotDisposed(byte[] messageData, IpEndPointInfo destination)
+ private Task SendMessageIfSocketNotDisposed(byte[] messageData, IpEndPointInfo destination)
{
var socket = _SendSocket;
if (socket != null)
{
- await _SendSocket.SendTo(messageData, destination).ConfigureAwait(false);
- }
- else
- {
- ThrowIfDisposed();
+ return _SendSocket.SendAsync(messageData, messageData.Length, destination);
}
- }
-
- private static async Task Repeat(int repetitions, TimeSpan delay, Func<Task> work)
- {
- for (int cnt = 0; cnt < repetitions; cnt++)
- {
- await work().ConfigureAwait(false);
- if (delay != TimeSpan.Zero)
- await Task.Delay(delay).ConfigureAwait(false);
- }
+ ThrowIfDisposed();
+ return Task.FromResult(true);
}
private IUdpSocket ListenForBroadcastsAsync()
@@ -290,7 +281,7 @@ namespace Rssdp.Infrastructure
private IUdpSocket CreateSocketAndListenForResponsesAsync()
{
- _SendSocket = _SocketFactory.CreateUdpSocket(_LocalPort);
+ _SendSocket = _SocketFactory.CreateSsdpUdpSocket(_LocalPort);
ListenToSocket(_SendSocket);
@@ -316,7 +307,7 @@ namespace Rssdp.Infrastructure
// Strange cannot convert compiler error here if I don't explicitly
// assign or cast to Action first. Assignment is easier to read,
// so went with that.
- Action processWork = () => ProcessMessage(System.Text.UTF8Encoding.UTF8.GetString(result.Buffer, 0, result.ReceivedBytes), result.ReceivedFrom);
+ Action processWork = () => ProcessMessage(System.Text.UTF8Encoding.UTF8.GetString(result.Buffer, 0, result.ReceivedBytes), result.RemoteEndPoint);
var processTask = Task.Run(processWork);
}
}