2
0
Эх сурвалжийг харах

Merge pull request #2677 from MediaBrowser/beta

Beta
Luke 8 жил өмнө
parent
commit
91176d9ccc
100 өөрчлөгдсөн 2220 нэмэгдсэн , 1146 устгасан
  1. 9 51
      Emby.Common.Implementations/BaseApplicationHost.cs
  2. 5 2
      Emby.Common.Implementations/Diagnostics/CommonProcess.cs
  3. 381 0
      Emby.Common.Implementations/Emby.Common.Implementations.csproj
  4. 0 23
      Emby.Common.Implementations/Emby.Common.Implementations.xproj
  5. 4 42
      Emby.Common.Implementations/EnvironmentInfo/EnvironmentInfo.cs
  6. 1 37
      Emby.Common.Implementations/HttpClientManager/HttpClientManager.cs
  7. 31 1
      Emby.Common.Implementations/IO/ProgressStream.cs
  8. 27 18
      Emby.Common.Implementations/Net/NetAcceptSocket.cs
  9. 86 10
      Emby.Common.Implementations/Net/SocketFactory.cs
  10. 73 140
      Emby.Common.Implementations/Net/UdpSocket.cs
  11. 19 4
      Emby.Common.Implementations/Properties/AssemblyInfo.cs
  12. 0 6
      Emby.Common.Implementations/Reflection/AssemblyInfo.cs
  13. 1 9
      Emby.Common.Implementations/Serialization/XmlSerializer.cs
  14. 0 2
      Emby.Common.Implementations/Xml/XmlReaderSettingsFactory.cs
  15. 7 0
      Emby.Common.Implementations/packages.config
  16. 0 71
      Emby.Common.Implementations/project.json
  17. 34 24
      Emby.Dlna/ContentDirectory/ControlHandler.cs
  18. 12 9
      Emby.Dlna/Didl/DidlBuilder.cs
  19. 1 0
      Emby.Dlna/PlayTo/PlayToController.cs
  20. 12 0
      Emby.Dlna/Profiles/DefaultProfile.cs
  21. 2 0
      Emby.Dlna/Profiles/Xml/Default.xml
  22. 2 0
      Emby.Dlna/Profiles/Xml/Denon AVR.xml
  23. 2 0
      Emby.Dlna/Profiles/Xml/MediaMonkey.xml
  24. 2 0
      Emby.Dlna/Profiles/Xml/foobar2000.xml
  25. 11 7
      Emby.Drawing.ImageMagick/ImageMagickEncoder.cs
  26. 1 1
      Emby.Drawing.ImageMagick/PlayedIndicatorDrawer.cs
  27. 1 1
      Emby.Drawing.ImageMagick/StripCollageBuilder.cs
  28. 0 2
      Emby.Drawing.ImageMagick/UnplayedCountIndicator.cs
  29. 5 4
      Emby.Drawing.Skia/Emby.Drawing.Skia.csproj
  30. 1 1
      Emby.Drawing.Skia/PlayedIndicatorDrawer.cs
  31. 36 8
      Emby.Drawing.Skia/SkiaEncoder.cs
  32. 1 1
      Emby.Drawing.Skia/UnplayedCountIndicator.cs
  33. 1 1
      Emby.Drawing.Skia/packages.config
  34. 1 1
      Emby.Drawing/Common/ImageHeader.cs
  35. 85 24
      Emby.Drawing/ImageProcessor.cs
  36. 1 1
      Emby.Drawing/NullImageEncoder.cs
  37. 2 6
      Emby.Server.Core/ApplicationHost.cs
  38. 1 1
      Emby.Server.Core/ApplicationPathHelper.cs
  39. 2 1
      Emby.Server.Core/Cryptography/ASN1.cs
  40. 1 1
      Emby.Server.Core/Cryptography/ASN1Convert.cs
  41. 1 1
      Emby.Server.Core/Cryptography/BitConverterLE.cs
  42. 1 1
      Emby.Server.Core/Cryptography/CertificateGenerator.cs
  43. 1 1
      Emby.Server.Core/Cryptography/CryptoConvert.cs
  44. 1 1
      Emby.Server.Core/Cryptography/PKCS1.cs
  45. 1 1
      Emby.Server.Core/Cryptography/PKCS12.cs
  46. 1 1
      Emby.Server.Core/Cryptography/PKCS7.cs
  47. 1 1
      Emby.Server.Core/Cryptography/PKCS8.cs
  48. 1 1
      Emby.Server.Core/Cryptography/PfxGenerator.cs
  49. 1 1
      Emby.Server.Core/Cryptography/X501Name.cs
  50. 1 1
      Emby.Server.Core/Cryptography/X509Builder.cs
  51. 1 1
      Emby.Server.Core/Cryptography/X509Certificate.cs
  52. 1 1
      Emby.Server.Core/Cryptography/X509CertificateBuilder.cs
  53. 1 1
      Emby.Server.Core/Cryptography/X509CertificateCollection.cs
  54. 1 1
      Emby.Server.Core/Cryptography/X509Extension.cs
  55. 1 1
      Emby.Server.Core/Cryptography/X509Extensions.cs
  56. 1 1
      Emby.Server.Core/Cryptography/X520Attributes.cs
  57. 76 11
      Emby.Server.Core/Emby.Server.Core.csproj
  58. 0 33
      Emby.Server.Core/Emby.Server.Core.xproj
  59. 14 13
      Emby.Server.Core/HttpServerFactory.cs
  60. 1 1
      Emby.Server.Core/IO/MemoryStreamProvider.cs
  61. 19 4
      Emby.Server.Core/Properties/AssemblyInfo.cs
  62. 0 0
      Emby.Server.Core/SystemEvents.cs
  63. 11 0
      Emby.Server.Core/app.config
  64. 6 0
      Emby.Server.Core/packages.config
  65. 0 125
      Emby.Server.Core/project.json
  66. 8 8
      Emby.Server.Implementations/Channels/ChannelManager.cs
  67. 3 3
      Emby.Server.Implementations/Collections/CollectionImageProvider.cs
  68. 5 0
      Emby.Server.Implementations/Collections/CollectionManager.cs
  69. 1 1
      Emby.Server.Implementations/Collections/CollectionsDynamicFolder.cs
  70. 473 161
      Emby.Server.Implementations/Data/SqliteItemRepository.cs
  71. 1 1
      Emby.Server.Implementations/Devices/CameraUploadsDynamicFolder.cs
  72. 0 1
      Emby.Server.Implementations/Devices/DeviceManager.cs
  73. 84 65
      Emby.Server.Implementations/Dto/DtoService.cs
  74. 18 8
      Emby.Server.Implementations/Emby.Server.Implementations.csproj
  75. 1 1
      Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs
  76. 5 3
      Emby.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs
  77. 1 1
      Emby.Server.Implementations/FileOrganization/FileOrganizationService.cs
  78. 1 1
      Emby.Server.Implementations/FileOrganization/OrganizerScheduledTask.cs
  79. 1 1
      Emby.Server.Implementations/FileOrganization/TvFolderOrganizer.cs
  80. 3 5
      Emby.Server.Implementations/HttpServer/HttpListenerHost.cs
  81. 15 3
      Emby.Server.Implementations/HttpServer/HttpResultFactory.cs
  82. 2 1
      Emby.Server.Implementations/HttpServer/IHttpListener.cs
  83. 13 5
      Emby.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs
  84. 2 3
      Emby.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpRequest.cs
  85. 2 8
      Emby.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpResponse.cs
  86. 1 1
      Emby.Server.Implementations/HttpServer/StreamWriter.cs
  87. 459 0
      Emby.Server.Implementations/IO/AsyncStreamCopier.cs
  88. 8 8
      Emby.Server.Implementations/IO/FileRefresher.cs
  89. 1 1
      Emby.Server.Implementations/IO/MbLinkShortcutHandler.cs
  90. 16 43
      Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs
  91. 1 1
      Emby.Server.Implementations/Library/CoreResolutionIgnoreRule.cs
  92. 55 68
      Emby.Server.Implementations/Library/LibraryManager.cs
  93. 5 2
      Emby.Server.Implementations/Library/LocalTrailerPostScanTask.cs
  94. 26 22
      Emby.Server.Implementations/Library/MusicManager.cs
  95. 0 2
      Emby.Server.Implementations/Library/ResolverHelper.cs
  96. 1 1
      Emby.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs
  97. 1 1
      Emby.Server.Implementations/Library/Resolvers/Audio/MusicArtistResolver.cs
  98. 1 1
      Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs
  99. 1 1
      Emby.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs
  100. 1 1
      Emby.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs

+ 9 - 51
Emby.Common.Implementations/BaseApplicationHost.cs

@@ -31,7 +31,6 @@ using Emby.Common.Implementations.Net;
 using Emby.Common.Implementations.EnvironmentInfo;
 using Emby.Common.Implementations.EnvironmentInfo;
 using Emby.Common.Implementations.Threading;
 using Emby.Common.Implementations.Threading;
 using MediaBrowser.Common;
 using MediaBrowser.Common;
-using MediaBrowser.Common.IO;
 using MediaBrowser.Model.Cryptography;
 using MediaBrowser.Model.Cryptography;
 using MediaBrowser.Model.Diagnostics;
 using MediaBrowser.Model.Diagnostics;
 using MediaBrowser.Model.Net;
 using MediaBrowser.Model.Net;
@@ -39,10 +38,6 @@ using MediaBrowser.Model.System;
 using MediaBrowser.Model.Tasks;
 using MediaBrowser.Model.Tasks;
 using MediaBrowser.Model.Threading;
 using MediaBrowser.Model.Threading;
 
 
-#if NETSTANDARD1_6
-using System.Runtime.Loader;
-#endif
-
 namespace Emby.Common.Implementations
 namespace Emby.Common.Implementations
 {
 {
     /// <summary>
     /// <summary>
@@ -179,9 +174,15 @@ namespace Emby.Common.Implementations
             }
             }
         }
         }
 
 
-        public virtual PackageVersionClass SystemUpdateLevel
+        public PackageVersionClass SystemUpdateLevel
         {
         {
-            get { return PackageVersionClass.Release; }
+            get {
+
+#if BETA
+                return PackageVersionClass.Beta;
+#endif
+                return PackageVersionClass.Release;
+            }
         }
         }
 
 
         public virtual string OperatingSystemDisplayName
         public virtual string OperatingSystemDisplayName
@@ -306,7 +307,6 @@ namespace Emby.Common.Implementations
 
 
             builder.AppendLine(string.Format("Command line: {0}", string.Join(" ", Environment.GetCommandLineArgs())));
             builder.AppendLine(string.Format("Command line: {0}", string.Join(" ", Environment.GetCommandLineArgs())));
 
 
-#if NET46
             builder.AppendLine(string.Format("Operating system: {0}", Environment.OSVersion));
             builder.AppendLine(string.Format("Operating system: {0}", Environment.OSVersion));
             builder.AppendLine(string.Format("64-Bit OS: {0}", Environment.Is64BitOperatingSystem));
             builder.AppendLine(string.Format("64-Bit OS: {0}", Environment.Is64BitOperatingSystem));
             builder.AppendLine(string.Format("64-Bit Process: {0}", Environment.Is64BitProcess));
             builder.AppendLine(string.Format("64-Bit Process: {0}", Environment.Is64BitProcess));
@@ -320,7 +320,6 @@ namespace Emby.Common.Implementations
                     builder.AppendLine("Mono: " + displayName.Invoke(null, null));
                     builder.AppendLine("Mono: " + displayName.Invoke(null, null));
                 }
                 }
             }
             }
-#endif    
 
 
             builder.AppendLine(string.Format("Processor count: {0}", Environment.ProcessorCount));
             builder.AppendLine(string.Format("Processor count: {0}", Environment.ProcessorCount));
             builder.AppendLine(string.Format("Program data path: {0}", appPaths.ProgramDataPath));
             builder.AppendLine(string.Format("Program data path: {0}", appPaths.ProgramDataPath));
@@ -336,9 +335,7 @@ namespace Emby.Common.Implementations
             try
             try
             {
             {
                 // Increase the max http request limit
                 // Increase the max http request limit
-#if NET46
                 ServicePointManager.DefaultConnectionLimit = Math.Max(96, ServicePointManager.DefaultConnectionLimit);
                 ServicePointManager.DefaultConnectionLimit = Math.Max(96, ServicePointManager.DefaultConnectionLimit);
-#endif    
             }
             }
             catch (Exception ex)
             catch (Exception ex)
             {
             {
@@ -436,7 +433,6 @@ namespace Emby.Common.Implementations
 
 
                 if (assemblyPlugin != null)
                 if (assemblyPlugin != null)
                 {
                 {
-#if NET46
                     var assembly = plugin.GetType().Assembly;
                     var assembly = plugin.GetType().Assembly;
                     var assemblyName = assembly.GetName();
                     var assemblyName = assembly.GetName();
 
 
@@ -447,21 +443,6 @@ namespace Emby.Common.Implementations
                     var assemblyFilePath = Path.Combine(ApplicationPaths.PluginsPath, assemblyFileName);
                     var assemblyFilePath = Path.Combine(ApplicationPaths.PluginsPath, assemblyFileName);
 
 
                     assemblyPlugin.SetAttributes(assemblyFilePath, assemblyFileName, assemblyName.Version, assemblyId);
                     assemblyPlugin.SetAttributes(assemblyFilePath, assemblyFileName, assemblyName.Version, assemblyId);
-#elif NETSTANDARD1_6
-                    var typeInfo = plugin.GetType().GetTypeInfo();
-                    var assembly = typeInfo.Assembly;
-                    var assemblyName = assembly.GetName();
-
-                    var attribute = (GuidAttribute)assembly.GetCustomAttribute(typeof(GuidAttribute));
-                    var assemblyId = new Guid(attribute.Value);
-
-                    var assemblyFileName = assemblyName.Name + ".dll";
-                    var assemblyFilePath = Path.Combine(ApplicationPaths.PluginsPath, assemblyFileName);
-
-                    assemblyPlugin.SetAttributes(assemblyFilePath, assemblyFileName, assemblyName.Version, assemblyId);
-#else
-return null;
-#endif
                 }
                 }
 
 
                 var isFirstRun = !File.Exists(plugin.ConfigurationFilePath);
                 var isFirstRun = !File.Exists(plugin.ConfigurationFilePath);
@@ -492,17 +473,7 @@ return null;
 
 
             AllConcreteTypes = assemblies
             AllConcreteTypes = assemblies
                 .SelectMany(GetTypes)
                 .SelectMany(GetTypes)
-                .Where(t =>
-                {
-#if NET46
-                    return t.IsClass && !t.IsAbstract && !t.IsInterface && !t.IsGenericType;
-#endif    
-#if NETSTANDARD1_6
-                    var typeInfo = t.GetTypeInfo();
-                    return typeInfo.IsClass && !typeInfo.IsAbstract && !typeInfo.IsInterface && !typeInfo.IsGenericType;
-#endif
-                    return false;
-                })
+                .Where(t => t.IsClass && !t.IsAbstract && !t.IsInterface && !t.IsGenericType)
                 .ToArray();
                 .ToArray();
         }
         }
 
 
@@ -717,13 +688,7 @@ return null;
         {
         {
             try
             try
             {
             {
-#if NET46
                 return Assembly.Load(File.ReadAllBytes(file));
                 return Assembly.Load(File.ReadAllBytes(file));
-#elif NETSTANDARD1_6
-                
-                return AssemblyLoadContext.Default.LoadFromStream(new MemoryStream(File.ReadAllBytes(file)));
-#endif
-                return null;
             }
             }
             catch (Exception ex)
             catch (Exception ex)
             {
             {
@@ -742,14 +707,7 @@ return null;
         {
         {
             var currentType = typeof(T);
             var currentType = typeof(T);
 
 
-#if NET46
             return AllConcreteTypes.Where(currentType.IsAssignableFrom);
             return AllConcreteTypes.Where(currentType.IsAssignableFrom);
-#elif NETSTANDARD1_6
-            var currentTypeInfo = currentType.GetTypeInfo();
-
-            return AllConcreteTypes.Where(currentTypeInfo.IsAssignableFrom);
-#endif
-            return new List<Type>();
         }
         }
 
 
         /// <summary>
         /// <summary>

+ 5 - 2
Emby.Common.Implementations/Diagnostics/CommonProcess.cs

@@ -31,14 +31,12 @@ namespace Emby.Common.Implementations.Diagnostics
                 RedirectStandardOutput = options.RedirectStandardOutput
                 RedirectStandardOutput = options.RedirectStandardOutput
             };
             };
 
 
-#if NET46
             startInfo.ErrorDialog = options.ErrorDialog;
             startInfo.ErrorDialog = options.ErrorDialog;
 
 
             if (options.IsHidden)
             if (options.IsHidden)
             {
             {
                 startInfo.WindowStyle = ProcessWindowStyle.Hidden;
                 startInfo.WindowStyle = ProcessWindowStyle.Hidden;
             }
             }
-#endif    
 
 
             _process = new Process
             _process = new Process
             {
             {
@@ -100,6 +98,11 @@ namespace Emby.Common.Implementations.Diagnostics
             return _process.WaitForExit(timeMs);
             return _process.WaitForExit(timeMs);
         }
         }
 
 
+        public Task<bool> WaitForExitAsync(int timeMs)
+        {
+            return Task.FromResult(_process.WaitForExit(timeMs));
+        }
+
         public void Dispose()
         public void Dispose()
         {
         {
             _process.Dispose();
             _process.Dispose();

+ 381 - 0
Emby.Common.Implementations/Emby.Common.Implementations.csproj

@@ -0,0 +1,381 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{1E37A338-9F57-4B70-BD6D-BB9C591E319B}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Emby.Common.Implementations</RootNamespace>
+    <AssemblyName>Emby.Common.Implementations</AssemblyName>
+    <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <TargetFrameworkProfile />
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
+      <HintPath>..\packages\NLog.4.4.9\lib\net45\NLog.dll</HintPath>
+    </Reference>
+    <Reference Include="ServiceStack.Text, Version=4.5.8.0, Culture=neutral, processorArchitecture=MSIL">
+      <HintPath>..\packages\ServiceStack.Text.4.5.8\lib\net45\ServiceStack.Text.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
+    <Reference Include="SharpCompress, Version=0.14.0.0, Culture=neutral, processorArchitecture=MSIL">
+      <HintPath>..\packages\SharpCompress.0.14.0\lib\net45\SharpCompress.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
+    <Reference Include="SimpleInjector, Version=4.0.7.0, Culture=neutral, PublicKeyToken=984cb50dea722e99, processorArchitecture=MSIL">
+      <HintPath>..\packages\SimpleInjector.4.0.7\lib\net45\SimpleInjector.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Net.Http" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="..\SharedVersion.cs">
+      <Link>Properties\SharedVersion.cs</Link>
+    </Compile>
+    <Compile Include="Archiving\ZipClient.cs" />
+    <Compile Include="BaseApplicationHost.cs" />
+    <Compile Include="Cryptography\CryptographyProvider.cs" />
+    <Compile Include="Devices\DeviceId.cs" />
+    <Compile Include="Diagnostics\CommonProcess.cs" />
+    <Compile Include="Diagnostics\ProcessFactory.cs" />
+    <Compile Include="EnvironmentInfo\EnvironmentInfo.cs" />
+    <Compile Include="HttpClientManager\HttpClientInfo.cs" />
+    <Compile Include="HttpClientManager\HttpClientManager.cs" />
+    <Compile Include="IO\IsoManager.cs" />
+    <Compile Include="IO\LnkShortcutHandler.cs" />
+    <Compile Include="IO\ManagedFileSystem.cs" />
+    <Compile Include="IO\ProgressStream.cs" />
+    <Compile Include="IO\SharpCifsFileSystem.cs" />
+    <Compile Include="IO\SharpCifs\Config.cs" />
+    <Compile Include="IO\SharpCifs\Dcerpc\DcerpcBind.cs" />
+    <Compile Include="IO\SharpCifs\Dcerpc\DcerpcBinding.cs" />
+    <Compile Include="IO\SharpCifs\Dcerpc\DcerpcConstants.cs" />
+    <Compile Include="IO\SharpCifs\Dcerpc\DcerpcError.cs" />
+    <Compile Include="IO\SharpCifs\Dcerpc\DcerpcException.cs" />
+    <Compile Include="IO\SharpCifs\Dcerpc\DcerpcHandle.cs" />
+    <Compile Include="IO\SharpCifs\Dcerpc\DcerpcMessage.cs" />
+    <Compile Include="IO\SharpCifs\Dcerpc\DcerpcPipeHandle.cs" />
+    <Compile Include="IO\SharpCifs\Dcerpc\DcerpcSecurityProvider.cs" />
+    <Compile Include="IO\SharpCifs\Dcerpc\Msrpc\LsaPolicyHandle.cs" />
+    <Compile Include="IO\SharpCifs\Dcerpc\Msrpc\Lsarpc.cs" />
+    <Compile Include="IO\SharpCifs\Dcerpc\Msrpc\LsarSidArrayX.cs" />
+    <Compile Include="IO\SharpCifs\Dcerpc\Msrpc\MsrpcDfsRootEnum.cs" />
+    <Compile Include="IO\SharpCifs\Dcerpc\Msrpc\MsrpcEnumerateAliasesInDomain.cs" />
+    <Compile Include="IO\SharpCifs\Dcerpc\Msrpc\MsrpcGetMembersInAlias.cs" />
+    <Compile Include="IO\SharpCifs\Dcerpc\Msrpc\MsrpcLookupSids.cs" />
+    <Compile Include="IO\SharpCifs\Dcerpc\Msrpc\MsrpcLsarOpenPolicy2.cs" />
+    <Compile Include="IO\SharpCifs\Dcerpc\Msrpc\MsrpcQueryInformationPolicy.cs" />
+    <Compile Include="IO\SharpCifs\Dcerpc\Msrpc\MsrpcSamrConnect2.cs" />
+    <Compile Include="IO\SharpCifs\Dcerpc\Msrpc\MsrpcSamrConnect4.cs" />
+    <Compile Include="IO\SharpCifs\Dcerpc\Msrpc\MsrpcSamrOpenAlias.cs" />
+    <Compile Include="IO\SharpCifs\Dcerpc\Msrpc\MsrpcSamrOpenDomain.cs" />
+    <Compile Include="IO\SharpCifs\Dcerpc\Msrpc\MsrpcShareEnum.cs" />
+    <Compile Include="IO\SharpCifs\Dcerpc\Msrpc\MsrpcShareGetInfo.cs" />
+    <Compile Include="IO\SharpCifs\Dcerpc\Msrpc\Netdfs.cs" />
+    <Compile Include="IO\SharpCifs\Dcerpc\Msrpc\Samr.cs" />
+    <Compile Include="IO\SharpCifs\Dcerpc\Msrpc\SamrAliasHandle.cs" />
+    <Compile Include="IO\SharpCifs\Dcerpc\Msrpc\SamrDomainHandle.cs" />
+    <Compile Include="IO\SharpCifs\Dcerpc\Msrpc\SamrPolicyHandle.cs" />
+    <Compile Include="IO\SharpCifs\Dcerpc\Msrpc\Srvsvc.cs" />
+    <Compile Include="IO\SharpCifs\Dcerpc\Ndr\NdrBuffer.cs" />
+    <Compile Include="IO\SharpCifs\Dcerpc\Ndr\NdrException.cs" />
+    <Compile Include="IO\SharpCifs\Dcerpc\Ndr\NdrHyper.cs" />
+    <Compile Include="IO\SharpCifs\Dcerpc\Ndr\NdrLong.cs" />
+    <Compile Include="IO\SharpCifs\Dcerpc\Ndr\NdrObject.cs" />
+    <Compile Include="IO\SharpCifs\Dcerpc\Ndr\NdrShort.cs" />
+    <Compile Include="IO\SharpCifs\Dcerpc\Ndr\NdrSmall.cs" />
+    <Compile Include="IO\SharpCifs\Dcerpc\Rpc.cs" />
+    <Compile Include="IO\SharpCifs\Dcerpc\UnicodeString.cs" />
+    <Compile Include="IO\SharpCifs\Dcerpc\UUID.cs" />
+    <Compile Include="IO\SharpCifs\Netbios\Lmhosts.cs" />
+    <Compile Include="IO\SharpCifs\Netbios\Name.cs" />
+    <Compile Include="IO\SharpCifs\Netbios\NameQueryRequest.cs" />
+    <Compile Include="IO\SharpCifs\Netbios\NameQueryResponse.cs" />
+    <Compile Include="IO\SharpCifs\Netbios\NameServiceClient.cs" />
+    <Compile Include="IO\SharpCifs\Netbios\NameServicePacket.cs" />
+    <Compile Include="IO\SharpCifs\Netbios\NbtAddress.cs" />
+    <Compile Include="IO\SharpCifs\Netbios\NbtException.cs" />
+    <Compile Include="IO\SharpCifs\Netbios\NodeStatusRequest.cs" />
+    <Compile Include="IO\SharpCifs\Netbios\NodeStatusResponse.cs" />
+    <Compile Include="IO\SharpCifs\Netbios\SessionRequestPacket.cs" />
+    <Compile Include="IO\SharpCifs\Netbios\SessionRetargetResponsePacket.cs" />
+    <Compile Include="IO\SharpCifs\Netbios\SessionServicePacket.cs" />
+    <Compile Include="IO\SharpCifs\Ntlmssp\NtlmFlags.cs" />
+    <Compile Include="IO\SharpCifs\Ntlmssp\NtlmMessage.cs" />
+    <Compile Include="IO\SharpCifs\Ntlmssp\Type1Message.cs" />
+    <Compile Include="IO\SharpCifs\Ntlmssp\Type2Message.cs" />
+    <Compile Include="IO\SharpCifs\Ntlmssp\Type3Message.cs" />
+    <Compile Include="IO\SharpCifs\Smb\ACE.cs" />
+    <Compile Include="IO\SharpCifs\Smb\AllocInfo.cs" />
+    <Compile Include="IO\SharpCifs\Smb\AndXServerMessageBlock.cs" />
+    <Compile Include="IO\SharpCifs\Smb\BufferCache.cs" />
+    <Compile Include="IO\SharpCifs\Smb\Dfs.cs" />
+    <Compile Include="IO\SharpCifs\Smb\DfsReferral.cs" />
+    <Compile Include="IO\SharpCifs\Smb\DosError.cs" />
+    <Compile Include="IO\SharpCifs\Smb\DosFileFilter.cs" />
+    <Compile Include="IO\SharpCifs\Smb\FileEntry.cs" />
+    <Compile Include="IO\SharpCifs\Smb\IInfo.cs" />
+    <Compile Include="IO\SharpCifs\Smb\NetServerEnum2.cs" />
+    <Compile Include="IO\SharpCifs\Smb\NetServerEnum2Response.cs" />
+    <Compile Include="IO\SharpCifs\Smb\NetShareEnum.cs" />
+    <Compile Include="IO\SharpCifs\Smb\NetShareEnumResponse.cs" />
+    <Compile Include="IO\SharpCifs\Smb\NtlmAuthenticator.cs" />
+    <Compile Include="IO\SharpCifs\Smb\NtlmChallenge.cs" />
+    <Compile Include="IO\SharpCifs\Smb\NtlmContext.cs" />
+    <Compile Include="IO\SharpCifs\Smb\NtlmPasswordAuthentication.cs" />
+    <Compile Include="IO\SharpCifs\Smb\NtStatus.cs" />
+    <Compile Include="IO\SharpCifs\Smb\NtTransQuerySecurityDesc.cs" />
+    <Compile Include="IO\SharpCifs\Smb\NtTransQuerySecurityDescResponse.cs" />
+    <Compile Include="IO\SharpCifs\Smb\Principal.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SecurityDescriptor.cs" />
+    <Compile Include="IO\SharpCifs\Smb\ServerMessageBlock.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SID.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SigningDigest.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbAuthException.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbComBlankResponse.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbComClose.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbComCreateDirectory.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbComDelete.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbComDeleteDirectory.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbComFindClose2.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbComLogoffAndX.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbComNegotiate.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbComNegotiateResponse.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbComNTCreateAndX.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbComNTCreateAndXResponse.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbComNtTransaction.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbComNtTransactionResponse.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbComOpenAndX.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbComOpenAndXResponse.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbComQueryInformation.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbComQueryInformationResponse.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbComReadAndX.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbComReadAndXResponse.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbComRename.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbComSessionSetupAndX.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbComSessionSetupAndXResponse.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbComTransaction.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbComTransactionResponse.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbComTreeConnectAndX.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbComTreeConnectAndXResponse.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbComTreeDisconnect.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbComWrite.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbComWriteAndX.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbComWriteAndXResponse.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbComWriteResponse.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbConstants.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbException.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbFile.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbFileExtensions.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbFileFilter.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbFileInputStream.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbFilenameFilter.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbFileOutputStream.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbNamedPipe.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbRandomAccessFile.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbSession.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbShareInfo.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbTransport.cs" />
+    <Compile Include="IO\SharpCifs\Smb\SmbTree.cs" />
+    <Compile Include="IO\SharpCifs\Smb\Trans2FindFirst2.cs" />
+    <Compile Include="IO\SharpCifs\Smb\Trans2FindFirst2Response.cs" />
+    <Compile Include="IO\SharpCifs\Smb\Trans2FindNext2.cs" />
+    <Compile Include="IO\SharpCifs\Smb\Trans2GetDfsReferral.cs" />
+    <Compile Include="IO\SharpCifs\Smb\Trans2GetDfsReferralResponse.cs" />
+    <Compile Include="IO\SharpCifs\Smb\Trans2QueryFSInformation.cs" />
+    <Compile Include="IO\SharpCifs\Smb\Trans2QueryFSInformationResponse.cs" />
+    <Compile Include="IO\SharpCifs\Smb\Trans2QueryPathInformation.cs" />
+    <Compile Include="IO\SharpCifs\Smb\Trans2QueryPathInformationResponse.cs" />
+    <Compile Include="IO\SharpCifs\Smb\Trans2SetFileInformation.cs" />
+    <Compile Include="IO\SharpCifs\Smb\Trans2SetFileInformationResponse.cs" />
+    <Compile Include="IO\SharpCifs\Smb\TransactNamedPipeInputStream.cs" />
+    <Compile Include="IO\SharpCifs\Smb\TransactNamedPipeOutputStream.cs" />
+    <Compile Include="IO\SharpCifs\Smb\TransCallNamedPipe.cs" />
+    <Compile Include="IO\SharpCifs\Smb\TransCallNamedPipeResponse.cs" />
+    <Compile Include="IO\SharpCifs\Smb\TransPeekNamedPipe.cs" />
+    <Compile Include="IO\SharpCifs\Smb\TransPeekNamedPipeResponse.cs" />
+    <Compile Include="IO\SharpCifs\Smb\TransTransactNamedPipe.cs" />
+    <Compile Include="IO\SharpCifs\Smb\TransTransactNamedPipeResponse.cs" />
+    <Compile Include="IO\SharpCifs\Smb\TransWaitNamedPipe.cs" />
+    <Compile Include="IO\SharpCifs\Smb\TransWaitNamedPipeResponse.cs" />
+    <Compile Include="IO\SharpCifs\Smb\WinError.cs" />
+    <Compile Include="IO\SharpCifs\UniAddress.cs" />
+    <Compile Include="IO\SharpCifs\Util\Base64.cs" />
+    <Compile Include="IO\SharpCifs\Util\DES.cs" />
+    <Compile Include="IO\SharpCifs\Util\Encdec.cs" />
+    <Compile Include="IO\SharpCifs\Util\Hexdump.cs" />
+    <Compile Include="IO\SharpCifs\Util\HMACT64.cs" />
+    <Compile Include="IO\SharpCifs\Util\LogStream.cs" />
+    <Compile Include="IO\SharpCifs\Util\MD4.cs" />
+    <Compile Include="IO\SharpCifs\Util\RC4.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\AbstractMap.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\Arrays.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\BufferedReader.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\BufferedWriter.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\CharBuffer.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\CharSequence.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\Collections.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\ConcurrentHashMap.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\DateFormat.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\EnumeratorWrapper.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\Exceptions.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\Extensions.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\FileInputStream.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\FileOutputStream.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\FilePath.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\FileReader.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\FileWriter.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\FilterInputStream.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\FilterOutputStream.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\Hashtable.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\HttpURLConnection.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\ICallable.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\IConcurrentMap.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\IExecutor.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\IFilenameFilter.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\IFuture.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\InputStream.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\InputStreamReader.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\IPrivilegedAction.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\IRunnable.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\Iterator.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\LinkageError.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\Matcher.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\MD5.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\MD5Managed.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\MessageDigest.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\NetworkStream.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\ObjectInputStream.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\ObjectOutputStream.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\OutputStream.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\OutputStreamWriter.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\PipedInputStream.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\PipedOutputStream.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\PrintWriter.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\Properties.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\RandomAccessFile.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\ReentrantLock.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\Reference.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\Runtime.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\SimpleDateFormat.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\SocketEx.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\StringTokenizer.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\SynchronizedList.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\Thread.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\ThreadFactory.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\ThreadPoolExecutor.cs" />
+    <Compile Include="IO\SharpCifs\Util\Sharpen\WrappedSystemStream.cs" />
+    <Compile Include="IO\SharpCifs\Util\Transport\Request.cs" />
+    <Compile Include="IO\SharpCifs\Util\Transport\Response.cs" />
+    <Compile Include="IO\SharpCifs\Util\Transport\Transport.cs" />
+    <Compile Include="IO\SharpCifs\Util\Transport\TransportException.cs" />
+    <Compile Include="Logging\NLogger.cs" />
+    <Compile Include="Logging\NlogManager.cs" />
+    <Compile Include="Networking\NetworkManager.cs" />
+    <Compile Include="Net\DisposableManagedObjectBase.cs" />
+    <Compile Include="Net\NetAcceptSocket.cs" />
+    <Compile Include="Net\SocketAcceptor.cs" />
+    <Compile Include="Net\SocketFactory.cs" />
+    <Compile Include="Net\UdpSocket.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Reflection\AssemblyInfo.cs" />
+    <Compile Include="ScheduledTasks\DailyTrigger.cs" />
+    <Compile Include="ScheduledTasks\IntervalTrigger.cs" />
+    <Compile Include="ScheduledTasks\ScheduledTaskWorker.cs" />
+    <Compile Include="ScheduledTasks\StartupTrigger.cs" />
+    <Compile Include="ScheduledTasks\SystemEventTrigger.cs" />
+    <Compile Include="ScheduledTasks\TaskManager.cs" />
+    <Compile Include="ScheduledTasks\Tasks\DeleteCacheFileTask.cs" />
+    <Compile Include="ScheduledTasks\Tasks\DeleteLogFileTask.cs" />
+    <Compile Include="ScheduledTasks\Tasks\ReloadLoggerFileTask.cs" />
+    <Compile Include="ScheduledTasks\WeeklyTrigger.cs" />
+    <Compile Include="Serialization\JsonSerializer.cs" />
+    <Compile Include="Serialization\XmlSerializer.cs" />
+    <Compile Include="TextEncoding\TextEncoding.cs" />
+    <Compile Include="TextEncoding\TextEncodingDetect.cs" />
+    <Compile Include="TextEncoding\UniversalDetector\CharsetDetector.cs" />
+    <Compile Include="TextEncoding\UniversalDetector\Core\Big5Prober.cs" />
+    <Compile Include="TextEncoding\UniversalDetector\Core\BitPackage.cs" />
+    <Compile Include="TextEncoding\UniversalDetector\Core\CharDistributionAnalyser.cs" />
+    <Compile Include="TextEncoding\UniversalDetector\Core\CharsetProber.cs" />
+    <Compile Include="TextEncoding\UniversalDetector\Core\Charsets.cs" />
+    <Compile Include="TextEncoding\UniversalDetector\Core\CodingStateMachine.cs" />
+    <Compile Include="TextEncoding\UniversalDetector\Core\EscCharsetProber.cs" />
+    <Compile Include="TextEncoding\UniversalDetector\Core\EscSM.cs" />
+    <Compile Include="TextEncoding\UniversalDetector\Core\EUCJPProber.cs" />
+    <Compile Include="TextEncoding\UniversalDetector\Core\EUCKRProber.cs" />
+    <Compile Include="TextEncoding\UniversalDetector\Core\EUCTWProber.cs" />
+    <Compile Include="TextEncoding\UniversalDetector\Core\GB18030Prober.cs" />
+    <Compile Include="TextEncoding\UniversalDetector\Core\HebrewProber.cs" />
+    <Compile Include="TextEncoding\UniversalDetector\Core\JapaneseContextAnalyser.cs" />
+    <Compile Include="TextEncoding\UniversalDetector\Core\LangBulgarianModel.cs" />
+    <Compile Include="TextEncoding\UniversalDetector\Core\LangCyrillicModel.cs" />
+    <Compile Include="TextEncoding\UniversalDetector\Core\LangGreekModel.cs" />
+    <Compile Include="TextEncoding\UniversalDetector\Core\LangHebrewModel.cs" />
+    <Compile Include="TextEncoding\UniversalDetector\Core\LangHungarianModel.cs" />
+    <Compile Include="TextEncoding\UniversalDetector\Core\LangThaiModel.cs" />
+    <Compile Include="TextEncoding\UniversalDetector\Core\Latin1Prober.cs" />
+    <Compile Include="TextEncoding\UniversalDetector\Core\MBCSGroupProber.cs" />
+    <Compile Include="TextEncoding\UniversalDetector\Core\MBCSSM.cs" />
+    <Compile Include="TextEncoding\UniversalDetector\Core\SBCharsetProber.cs" />
+    <Compile Include="TextEncoding\UniversalDetector\Core\SBCSGroupProber.cs" />
+    <Compile Include="TextEncoding\UniversalDetector\Core\SequenceModel.cs" />
+    <Compile Include="TextEncoding\UniversalDetector\Core\SJISProber.cs" />
+    <Compile Include="TextEncoding\UniversalDetector\Core\SMModel.cs" />
+    <Compile Include="TextEncoding\UniversalDetector\Core\UniversalDetector.cs" />
+    <Compile Include="TextEncoding\UniversalDetector\Core\UTF8Prober.cs" />
+    <Compile Include="TextEncoding\UniversalDetector\DetectionConfidence.cs" />
+    <Compile Include="TextEncoding\UniversalDetector\ICharsetDetector.cs" />
+    <Compile Include="Threading\CommonTimer.cs" />
+    <Compile Include="Threading\TimerFactory.cs" />
+    <Compile Include="Xml\XmlReaderSettingsFactory.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\MediaBrowser.Common\MediaBrowser.Common.csproj">
+      <Project>{9142eefa-7570-41e1-bfcc-468bb571af2f}</Project>
+      <Name>MediaBrowser.Common</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\MediaBrowser.Model\MediaBrowser.Model.csproj">
+      <Project>{7eeeb4bb-f3e8-48fc-b4c5-70f0fff8329b}</Project>
+      <Name>MediaBrowser.Model</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="packages.config" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.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.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

+ 0 - 23
Emby.Common.Implementations/Emby.Common.Implementations.xproj

@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <PropertyGroup>
-    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
-    <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
-  </PropertyGroup>
-  <Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
-  <PropertyGroup Label="Globals">
-    <ProjectGuid>5a27010a-09c6-4e86-93ea-437484c10917</ProjectGuid>
-    <RootNamespace>Emby.Common.Implementations</RootNamespace>
-    <BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
-    <OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
-    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
-  </PropertyGroup>
-  <PropertyGroup>
-    <SchemaVersion>2.0</SchemaVersion>
-  </PropertyGroup>
-  <ItemGroup>
-    <ProjectReference Include="..\MediaBrowser.Common\MediaBrowser.Common.csproj" />
-    <ProjectReference Include="..\MediaBrowser.Model\MediaBrowser.Model.csproj" />
-  </ItemGroup>
-  <Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
-</Project>

+ 4 - 42
Emby.Common.Implementations/EnvironmentInfo/EnvironmentInfo.cs

@@ -10,7 +10,7 @@ namespace Emby.Common.Implementations.EnvironmentInfo
 {
 {
     public class EnvironmentInfo : IEnvironmentInfo
     public class EnvironmentInfo : IEnvironmentInfo
     {
     {
-        public MediaBrowser.Model.System.Architecture? CustomArchitecture { get; set; }
+        public Architecture? CustomArchitecture { get; set; }
         public MediaBrowser.Model.System.OperatingSystem? CustomOperatingSystem { get; set; }
         public MediaBrowser.Model.System.OperatingSystem? CustomOperatingSystem { get; set; }
 
 
         public virtual MediaBrowser.Model.System.OperatingSystem OperatingSystem
         public virtual MediaBrowser.Model.System.OperatingSystem OperatingSystem
@@ -22,7 +22,6 @@ namespace Emby.Common.Implementations.EnvironmentInfo
                     return CustomOperatingSystem.Value;
                     return CustomOperatingSystem.Value;
                 }
                 }
 
 
-#if NET46
                 switch (Environment.OSVersion.Platform)
                 switch (Environment.OSVersion.Platform)
                 {
                 {
                     case PlatformID.MacOSX:
                     case PlatformID.MacOSX:
@@ -32,20 +31,7 @@ namespace Emby.Common.Implementations.EnvironmentInfo
                     case PlatformID.Unix:
                     case PlatformID.Unix:
                         return MediaBrowser.Model.System.OperatingSystem.Linux;
                         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;
                 return MediaBrowser.Model.System.OperatingSystem.Windows;
             }
             }
         }
         }
@@ -54,12 +40,7 @@ namespace Emby.Common.Implementations.EnvironmentInfo
         {
         {
             get
             get
             {
             {
-#if NET46
                 return Environment.OSVersion.Platform.ToString();
                 return Environment.OSVersion.Platform.ToString();
-#elif NETSTANDARD1_6
-            return System.Runtime.InteropServices.RuntimeInformation.OSDescription;
-#endif
-                return "Operating System";
             }
             }
         }
         }
 
 
@@ -67,12 +48,7 @@ namespace Emby.Common.Implementations.EnvironmentInfo
         {
         {
             get
             get
             {
             {
-#if NET46
                 return Environment.OSVersion.Version.ToString() + " " + Environment.OSVersion.ServicePack.ToString();
                 return Environment.OSVersion.Version.ToString() + " " + Environment.OSVersion.ServicePack.ToString();
-#elif NETSTANDARD1_6
-            return System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription;
-#endif
-                return "1.0";
             }
             }
         }
         }
 
 
@@ -84,7 +60,7 @@ namespace Emby.Common.Implementations.EnvironmentInfo
             }
             }
         }
         }
 
 
-        public MediaBrowser.Model.System.Architecture SystemArchitecture
+        public Architecture SystemArchitecture
         {
         {
             get
             get
             {
             {
@@ -92,22 +68,8 @@ namespace Emby.Common.Implementations.EnvironmentInfo
                 {
                 {
                     return CustomArchitecture.Value;
                     return CustomArchitecture.Value;
                 }
                 }
-#if NET46
+
                 return Environment.Is64BitOperatingSystem ? MediaBrowser.Model.System.Architecture.X64 : MediaBrowser.Model.System.Architecture.X86;
                 return Environment.Is64BitOperatingSystem ? MediaBrowser.Model.System.Architecture.X64 : MediaBrowser.Model.System.Architecture.X86;
-#elif NETSTANDARD1_6
-                switch(System.Runtime.InteropServices.RuntimeInformation.OSArchitecture)
-                {
-                    case System.Runtime.InteropServices.Architecture.Arm:
-                        return MediaBrowser.Model.System.Architecture.Arm;
-                    case System.Runtime.InteropServices.Architecture.Arm64:
-                        return MediaBrowser.Model.System.Architecture.Arm64;
-                    case System.Runtime.InteropServices.Architecture.X64:
-                        return MediaBrowser.Model.System.Architecture.X64;
-                    case System.Runtime.InteropServices.Architecture.X86:
-                        return MediaBrowser.Model.System.Architecture.X86;
-                }
-#endif
-                return MediaBrowser.Model.System.Architecture.X64;
             }
             }
         }
         }
 
 

+ 1 - 37
Emby.Common.Implementations/HttpClientManager/HttpClientManager.cs

@@ -1,7 +1,6 @@
 using System.Net.Sockets;
 using System.Net.Sockets;
 using MediaBrowser.Common.Configuration;
 using MediaBrowser.Common.Configuration;
 using MediaBrowser.Common.Extensions;
 using MediaBrowser.Common.Extensions;
-using MediaBrowser.Common.IO;
 using MediaBrowser.Common.Net;
 using MediaBrowser.Common.Net;
 using MediaBrowser.Model.Logging;
 using MediaBrowser.Model.Logging;
 using MediaBrowser.Model.Net;
 using MediaBrowser.Model.Net;
@@ -17,6 +16,7 @@ using System.Text;
 using System.Threading;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using Emby.Common.Implementations.HttpClientManager;
 using Emby.Common.Implementations.HttpClientManager;
+using Emby.Common.Implementations.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Common;
 using MediaBrowser.Common;
 
 
@@ -66,13 +66,11 @@ namespace Emby.Common.Implementations.HttpClientManager
             _appPaths = appPaths;
             _appPaths = appPaths;
             _defaultUserAgentFn = defaultUserAgentFn;
             _defaultUserAgentFn = defaultUserAgentFn;
 
 
-#if NET46
             // http://stackoverflow.com/questions/566437/http-post-returns-the-error-417-expectation-failed-c
             // http://stackoverflow.com/questions/566437/http-post-returns-the-error-417-expectation-failed-c
             ServicePointManager.Expect100Continue = false;
             ServicePointManager.Expect100Continue = false;
 
 
             // Trakt requests sometimes fail without this
             // Trakt requests sometimes fail without this
             ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls;
             ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls;
-#endif    
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -129,7 +127,6 @@ namespace Emby.Common.Implementations.HttpClientManager
 
 
         private void AddIpv4Option(HttpWebRequest request, HttpRequestOptions options)
         private void AddIpv4Option(HttpWebRequest request, HttpRequestOptions options)
         {
         {
-#if NET46
             request.ServicePoint.BindIPEndPointDelegate = (servicePount, remoteEndPoint, retryCount) =>
             request.ServicePoint.BindIPEndPointDelegate = (servicePount, remoteEndPoint, retryCount) =>
             {
             {
                 if (remoteEndPoint.AddressFamily == AddressFamily.InterNetwork)
                 if (remoteEndPoint.AddressFamily == AddressFamily.InterNetwork)
@@ -138,7 +135,6 @@ namespace Emby.Common.Implementations.HttpClientManager
                 }
                 }
                 throw new InvalidOperationException("no IPv4 address");
                 throw new InvalidOperationException("no IPv4 address");
             };
             };
-#endif    
         }
         }
 
 
         private WebRequest GetRequest(HttpRequestOptions options, string method)
         private WebRequest GetRequest(HttpRequestOptions options, string method)
@@ -165,7 +161,6 @@ namespace Emby.Common.Implementations.HttpClientManager
 
 
                 AddRequestHeaders(httpWebRequest, options);
                 AddRequestHeaders(httpWebRequest, options);
 
 
-#if NET46
                 if (options.EnableHttpCompression)
                 if (options.EnableHttpCompression)
                 {
                 {
                     if (options.DecompressionMethod.HasValue)
                     if (options.DecompressionMethod.HasValue)
@@ -183,48 +178,33 @@ namespace Emby.Common.Implementations.HttpClientManager
                 {
                 {
                     httpWebRequest.AutomaticDecompression = DecompressionMethods.None;
                     httpWebRequest.AutomaticDecompression = DecompressionMethods.None;
                 }
                 }
-#endif    
             }
             }
 
 
 
 
 
 
-#if NET46
             request.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.BypassCache);
             request.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.BypassCache);
-#endif    
 
 
             if (httpWebRequest != null)
             if (httpWebRequest != null)
             {
             {
                 if (options.EnableKeepAlive)
                 if (options.EnableKeepAlive)
                 {
                 {
-#if NET46
                     httpWebRequest.KeepAlive = true;
                     httpWebRequest.KeepAlive = true;
-#endif    
                 }
                 }
             }
             }
 
 
             request.Method = method;
             request.Method = method;
-#if NET46
             request.Timeout = options.TimeoutMs;
             request.Timeout = options.TimeoutMs;
-#endif
 
 
             if (httpWebRequest != null)
             if (httpWebRequest != null)
             {
             {
                 if (!string.IsNullOrEmpty(options.Host))
                 if (!string.IsNullOrEmpty(options.Host))
                 {
                 {
-#if NET46
                     httpWebRequest.Host = options.Host;
                     httpWebRequest.Host = options.Host;
-#elif NETSTANDARD1_6
-                    httpWebRequest.Headers["Host"] = options.Host;
-#endif
                 }
                 }
 
 
                 if (!string.IsNullOrEmpty(options.Referer))
                 if (!string.IsNullOrEmpty(options.Referer))
                 {
                 {
-#if NET46
                     httpWebRequest.Referer = options.Referer;
                     httpWebRequest.Referer = options.Referer;
-#elif NETSTANDARD1_6
-                    httpWebRequest.Headers["Referer"] = options.Referer;
-#endif
                 }
                 }
             }
             }
 
 
@@ -235,9 +215,7 @@ namespace Emby.Common.Implementations.HttpClientManager
                 {
                 {
                     request.Credentials = GetCredential(url, parts[0], parts[1]);
                     request.Credentials = GetCredential(url, parts[0], parts[1]);
                     // TODO: .net core ??
                     // TODO: .net core ??
-#if NET46
                     request.PreAuthenticate = true;
                     request.PreAuthenticate = true;
-#endif
                 }
                 }
             }
             }
 
 
@@ -269,11 +247,7 @@ namespace Emby.Common.Implementations.HttpClientManager
                 }
                 }
                 else
                 else
                 {
                 {
-#if NET46
                     request.Headers.Set(header.Key, header.Value);
                     request.Headers.Set(header.Key, header.Value);
-#elif NETSTANDARD1_6
-                    request.Headers[header.Key] = header.Value;
-#endif
                 }
                 }
             }
             }
 
 
@@ -285,11 +259,7 @@ namespace Emby.Common.Implementations.HttpClientManager
 
 
         private void SetUserAgent(HttpWebRequest request, string userAgent)
         private void SetUserAgent(HttpWebRequest request, string userAgent)
         {
         {
-#if NET46
             request.UserAgent = userAgent;
             request.UserAgent = userAgent;
-#elif NETSTANDARD1_6
-                    request.Headers["User-Agent"] = userAgent;
-#endif
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -465,9 +435,7 @@ namespace Emby.Common.Implementations.HttpClientManager
 
 
                     httpWebRequest.ContentType = options.RequestContentType ?? "application/x-www-form-urlencoded";
                     httpWebRequest.ContentType = options.RequestContentType ?? "application/x-www-form-urlencoded";
 
 
-#if NET46
                     httpWebRequest.ContentLength = bytes.Length;
                     httpWebRequest.ContentLength = bytes.Length;
-#endif
                     (await httpWebRequest.GetRequestStreamAsync().ConfigureAwait(false)).Write(bytes, 0, bytes.Length);
                     (await httpWebRequest.GetRequestStreamAsync().ConfigureAwait(false)).Write(bytes, 0, bytes.Length);
                 }
                 }
                 catch (Exception ex)
                 catch (Exception ex)
@@ -950,7 +918,6 @@ namespace Emby.Common.Implementations.HttpClientManager
 
 
         private Task<WebResponse> GetResponseAsync(WebRequest request, TimeSpan timeout)
         private Task<WebResponse> GetResponseAsync(WebRequest request, TimeSpan timeout)
         {
         {
-#if NET46
             var taskCompletion = new TaskCompletionSource<WebResponse>();
             var taskCompletion = new TaskCompletionSource<WebResponse>();
 
 
             Task<WebResponse> asyncTask = Task.Factory.FromAsync<WebResponse>(request.BeginGetResponse, request.EndGetResponse, null);
             Task<WebResponse> asyncTask = Task.Factory.FromAsync<WebResponse>(request.BeginGetResponse, request.EndGetResponse, null);
@@ -963,9 +930,6 @@ namespace Emby.Common.Implementations.HttpClientManager
             asyncTask.ContinueWith(callback.OnError, TaskContinuationOptions.OnlyOnFaulted);
             asyncTask.ContinueWith(callback.OnError, TaskContinuationOptions.OnlyOnFaulted);
 
 
             return taskCompletion.Task;
             return taskCompletion.Task;
-#endif
-
-            return request.GetResponseAsync();
         }
         }
 
 
         private static void TimeoutCallback(object state, bool timedOut)
         private static void TimeoutCallback(object state, bool timedOut)

+ 31 - 1
MediaBrowser.Common/IO/ProgressStream.cs → Emby.Common.Implementations/IO/ProgressStream.cs

@@ -1,7 +1,7 @@
 using System;
 using System;
 using System.IO;
 using System.IO;
 
 
-namespace MediaBrowser.Common.IO
+namespace Emby.Common.Implementations.IO
 {
 {
     /// <summary>
     /// <summary>
     /// Measures progress when reading from a stream or writing to one
     /// Measures progress when reading from a stream or writing to one
@@ -155,6 +155,21 @@ namespace MediaBrowser.Common.IO
             return read;
             return read;
         }
         }
 
 
+        public override int EndRead(IAsyncResult asyncResult)
+        {
+            var read = base.EndRead(asyncResult);
+
+            BytesProcessed += read;
+
+            double percent = BytesProcessed;
+            percent /= ReadLength ?? BaseStream.Length;
+            percent *= 100;
+
+            ProgressAction(percent);
+
+            return read;
+        }
+
         /// <summary>
         /// <summary>
         /// When overridden in a derived class, sets the position within the current stream.
         /// When overridden in a derived class, sets the position within the current stream.
         /// </summary>
         /// </summary>
@@ -194,6 +209,21 @@ namespace MediaBrowser.Common.IO
             ProgressAction(percent);
             ProgressAction(percent);
         }
         }
 
 
+        public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
+        {
+            var result = base.BeginWrite(buffer, offset, count, callback, state);
+
+            BytesProcessed += count;
+
+            double percent = BytesProcessed;
+            percent /= WriteLength;
+            percent *= 100;
+
+            ProgressAction(percent);
+
+            return result;
+        }
+
         /// <summary>
         /// <summary>
         /// Releases the unmanaged resources used by the <see cref="T:System.IO.Stream" /> and optionally releases the managed resources.
         /// Releases the unmanaged resources used by the <see cref="T:System.IO.Stream" /> and optionally releases the managed resources.
         /// </summary>
         /// </summary>

+ 27 - 18
Emby.Common.Implementations/Net/NetAcceptSocket.cs

@@ -97,7 +97,6 @@ namespace Emby.Common.Implementations.Net
             _acceptor.StartAccept();
             _acceptor.StartAccept();
         }
         }
 
 
-#if NET46
         public Task SendFile(string path, byte[] preBuffer, byte[] postBuffer, CancellationToken cancellationToken)
         public Task SendFile(string path, byte[] preBuffer, byte[] postBuffer, CancellationToken cancellationToken)
         {
         {
             var options = TransmitFileOptions.UseDefaultWorkerThread;
             var options = TransmitFileOptions.UseDefaultWorkerThread;
@@ -109,6 +108,18 @@ namespace Emby.Common.Implementations.Net
             return completionSource.Task;
             return completionSource.Task;
         }
         }
 
 
+        public IAsyncResult BeginSendFile(string path, byte[] preBuffer, byte[] postBuffer, AsyncCallback callback, object state)
+        {
+            var options = TransmitFileOptions.UseDefaultWorkerThread;
+
+            return Socket.BeginSendFile(path, preBuffer, postBuffer, options, new AsyncCallback(FileSendCallback), state);
+        }
+
+        public void EndSendFile(IAsyncResult result)
+        {
+            Socket.EndSendFile(result);
+        }
+
         private void FileSendCallback(IAsyncResult ar)
         private void FileSendCallback(IAsyncResult ar)
         {
         {
             // Retrieve the socket from the state object.
             // Retrieve the socket from the state object.
@@ -117,25 +128,23 @@ namespace Emby.Common.Implementations.Net
             var client = data.Item1;
             var client = data.Item1;
             var path = data.Item2;
             var path = data.Item2;
             var taskCompletion = data.Item3;
             var taskCompletion = data.Item3;
-        
+
             // Complete sending the data to the remote device.
             // Complete sending the data to the remote device.
-        try {
-            client.EndSendFile(ar);
-        taskCompletion.TrySetResult(true);
-}
-        catch(SocketException ex){
-        _logger.Info("Socket.SendFile failed for {0}. error code {1}", path, ex.SocketErrorCode);
-        taskCompletion.TrySetException(ex);
-}catch(Exception ex){
-        taskCompletion.TrySetException(ex);
-}
-        }
-#else
-        public Task SendFile(string path, byte[] preBuffer, byte[] postBuffer, CancellationToken cancellationToken)
-        {
-            throw new NotImplementedException();
+            try
+            {
+                client.EndSendFile(ar);
+                taskCompletion.TrySetResult(true);
+            }
+            catch (SocketException ex)
+            {
+                _logger.Info("Socket.SendFile failed for {0}. error code {1}", path, ex.SocketErrorCode);
+                taskCompletion.TrySetException(ex);
+            }
+            catch (Exception ex)
+            {
+                taskCompletion.TrySetException(ex);
+            }
         }
         }
-#endif
 
 
         public void Dispose()
         public void Dispose()
         {
         {

+ 86 - 10
Emby.Common.Implementations/Net/SocketFactory.cs

@@ -1,5 +1,6 @@
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
+using System.IO;
 using System.Linq;
 using System.Linq;
 using System.Net;
 using System.Net;
 using System.Net.Sockets;
 using System.Net.Sockets;
@@ -188,16 +189,7 @@ namespace Emby.Common.Implementations.Net
 
 
             try
             try
             {
             {
-#if NET46
-				retVal.ExclusiveAddressUse = false;
-#else
-                // The ExclusiveAddressUse acceptSocket option is a Windows-specific option that, when set to "true," tells Windows not to allow another acceptSocket to use the same local address as this acceptSocket
-                // See https://github.com/dotnet/corefx/pull/11509 for more details
-                if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows))
-				{
-					retVal.ExclusiveAddressUse = false;
-				}
-#endif
+                retVal.ExclusiveAddressUse = false;
                 //retVal.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, true);
                 //retVal.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, true);
                 retVal.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
                 retVal.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
                 retVal.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, multicastTimeToLive);
                 retVal.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, multicastTimeToLive);
@@ -217,5 +209,89 @@ namespace Emby.Common.Implementations.Net
                 throw;
                 throw;
             }
             }
         }
         }
+
+        public Stream CreateNetworkStream(ISocket socket, bool ownsSocket)
+        {
+            var netSocket = (UdpSocket)socket;
+
+            return new SocketStream(netSocket.Socket, ownsSocket);
+        }
     }
     }
+
+    public class SocketStream : Stream
+    {
+        private readonly Socket _socket;
+
+        public SocketStream(Socket socket, bool ownsSocket)
+        {
+            _socket = socket;
+        }
+
+        public override void Flush()
+        {
+        }
+
+        public override bool CanRead
+        {
+            get { return true; }
+        }
+        public override bool CanSeek
+        {
+            get { return false; }
+        }
+        public override bool CanWrite
+        {
+            get { return true; }
+        }
+        public override long Length
+        {
+            get { throw new NotImplementedException(); }
+        }
+        public override long Position
+        {
+            get { throw new NotImplementedException(); }
+            set { throw new NotImplementedException(); }
+        }
+
+        public override void Write(byte[] buffer, int offset, int count)
+        {
+            _socket.Send(buffer, offset, count, SocketFlags.None);
+        }
+
+        public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
+        {
+            return _socket.BeginSend(buffer, offset, count, SocketFlags.None, callback, state);
+        }
+
+        public override void EndWrite(IAsyncResult asyncResult)
+        {
+            _socket.EndSend(asyncResult);
+        }
+
+        public override void SetLength(long value)
+        {
+            throw new NotImplementedException();
+        }
+
+        public override long Seek(long offset, SeekOrigin origin)
+        {
+            throw new NotImplementedException();
+        }
+
+        public override int Read(byte[] buffer, int offset, int count)
+        {
+            return _socket.Receive(buffer, offset, count, SocketFlags.None);
+        }
+
+        public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
+        {
+            return _socket.BeginReceive(buffer, offset, count, SocketFlags.None, callback, state);
+        }
+
+        public override int EndRead(IAsyncResult asyncResult)
+        {
+            return _socket.EndReceive(asyncResult);
+        }
+    }
+
 }
 }

+ 73 - 140
Emby.Common.Implementations/Net/UdpSocket.cs

@@ -14,11 +14,16 @@ namespace Emby.Common.Implementations.Net
     // THIS IS A LINKED FILE - SHARED AMONGST MULTIPLE PLATFORMS	
     // THIS IS A LINKED FILE - SHARED AMONGST MULTIPLE PLATFORMS	
     // Be careful to check any changes compile and work for all platform projects it is shared in.
     // Be careful to check any changes compile and work for all platform projects it is shared in.
 
 
-    internal sealed class UdpSocket : DisposableManagedObjectBase, ISocket
+    public sealed class UdpSocket : DisposableManagedObjectBase, ISocket
     {
     {
         private Socket _Socket;
         private Socket _Socket;
         private int _LocalPort;
         private int _LocalPort;
 
 
+        public Socket Socket
+        {
+            get { return _Socket; }
+        }
+
         private readonly SocketAsyncEventArgs _receiveSocketAsyncEventArgs = new SocketAsyncEventArgs()
         private readonly SocketAsyncEventArgs _receiveSocketAsyncEventArgs = new SocketAsyncEventArgs()
         {
         {
             SocketFlags = SocketFlags.None
             SocketFlags = SocketFlags.None
@@ -116,129 +121,104 @@ namespace Emby.Common.Implementations.Net
             private set;
             private set;
         }
         }
 
 
-        public Task<SocketReceiveResult> ReceiveAsync(CancellationToken cancellationToken)
+        public IAsyncResult BeginReceive(byte[] buffer, int offset, int count, AsyncCallback callback)
         {
         {
-            ThrowIfDisposed();
-            var tcs = new TaskCompletionSource<SocketReceiveResult>();
             EndPoint receivedFromEndPoint = new IPEndPoint(IPAddress.Any, 0);
             EndPoint receivedFromEndPoint = new IPEndPoint(IPAddress.Any, 0);
 
 
-            var state = new AsyncReceiveState(_Socket, receivedFromEndPoint);
-            state.TaskCompletionSource = tcs;
-
-            cancellationToken.Register(() => tcs.TrySetCanceled());
-
-            _receiveSocketAsyncEventArgs.RemoteEndPoint = receivedFromEndPoint;
-            _currentReceiveTaskCompletionSource = tcs;
-
-            try
-            {
-                var willRaiseEvent = _Socket.ReceiveFromAsync(_receiveSocketAsyncEventArgs);
-
-                if (!willRaiseEvent)
-                {
-                    _receiveSocketAsyncEventArgs_Completed(this, _receiveSocketAsyncEventArgs);
-                }
-            }
-            catch (Exception ex)
-            {
-                tcs.TrySetException(ex);
-            }
-
-            return tcs.Task;
+            return _Socket.BeginReceiveFrom(buffer, offset, count, SocketFlags.None, ref receivedFromEndPoint, callback, buffer);
         }
         }
 
 
-        public Task SendAsync(byte[] buffer, int size, IpEndPointInfo endPoint, CancellationToken cancellationToken)
+        public SocketReceiveResult EndReceive(IAsyncResult result)
         {
         {
-            ThrowIfDisposed();
-
-            if (buffer == null) throw new ArgumentNullException("messageData");
-            if (endPoint == null) throw new ArgumentNullException("endPoint");
+            IPEndPoint sender = new IPEndPoint(IPAddress.Any, 0);
+            EndPoint remoteEndPoint = (EndPoint)sender;
 
 
-            var ipEndPoint = NetworkManager.ToIPEndPoint(endPoint);
+            var receivedBytes = _Socket.EndReceiveFrom(result, ref remoteEndPoint);
 
 
-#if NETSTANDARD1_6
+            var buffer = (byte[]) result.AsyncState;
 
 
-            if (size != buffer.Length)
+            return new SocketReceiveResult
             {
             {
-                byte[] copy = new byte[size];
-                Buffer.BlockCopy(buffer, 0, copy, 0, size);
-                buffer = copy;
-            }
-
-            cancellationToken.ThrowIfCancellationRequested();
+                ReceivedBytes = receivedBytes,
+                RemoteEndPoint = ToIpEndPointInfo((IPEndPoint)remoteEndPoint),
+                Buffer = buffer,
+                LocalIPAddress = LocalIPAddress
+            };
+        }
 
 
-            _Socket.SendTo(buffer, ipEndPoint);
-            return Task.FromResult(true);
-#else
-            var taskSource = new TaskCompletionSource<bool>();
+        public Task<SocketReceiveResult> ReceiveAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
+        {
+            var taskCompletion = new TaskCompletionSource<SocketReceiveResult>();
 
 
-            try
+            Action<IAsyncResult> callback = callbackResult =>
             {
             {
-                _Socket.BeginSendTo(buffer, 0, size, SocketFlags.None, ipEndPoint, result =>
+                try
                 {
                 {
-                    if (cancellationToken.IsCancellationRequested)
-                    {
-                        taskSource.TrySetCanceled();
-                        return;
-                    }
-                    try
-                    {
-                        _Socket.EndSend(result);
-                        taskSource.TrySetResult(true);
-                    }
-                    catch (Exception ex)
-                    {
-                        taskSource.TrySetException(ex);
-                    }
+                    taskCompletion.TrySetResult(EndReceive(callbackResult));
+                }
+                catch (Exception ex)
+                {
+                    taskCompletion.TrySetException(ex);
+                }
+            };
 
 
-                }, null);
-            }
-            catch (Exception ex)
+            var result = BeginReceive(buffer, offset, count, new AsyncCallback(callback));
+
+            if (result.CompletedSynchronously)
             {
             {
-                taskSource.TrySetException(ex);
+                callback(result);
             }
             }
 
 
-            return taskSource.Task;
-#endif
-            //ThrowIfDisposed();
+            cancellationToken.Register(() => taskCompletion.TrySetCanceled());
+
+            return taskCompletion.Task;
+        }
 
 
-            //if (buffer == null) throw new ArgumentNullException("messageData");
-            //if (endPoint == null) throw new ArgumentNullException("endPoint");
+        public Task<SocketReceiveResult> ReceiveAsync(CancellationToken cancellationToken)
+        {
+            var buffer = new byte[8192];
 
 
-            //cancellationToken.ThrowIfCancellationRequested();
+            return ReceiveAsync(buffer, 0, buffer.Length, cancellationToken);
+        }
 
 
-            //var tcs = new TaskCompletionSource<int>();
+        public Task SendToAsync(byte[] buffer, int offset, int size, IpEndPointInfo endPoint, CancellationToken cancellationToken)
+        {
+            var taskCompletion = new TaskCompletionSource<int>();
 
 
-            //cancellationToken.Register(() => tcs.TrySetCanceled());
+            Action<IAsyncResult> callback = callbackResult =>
+            {
+                try
+                {
+                    taskCompletion.TrySetResult(EndSendTo(callbackResult));
+                }
+                catch (Exception ex)
+                {
+                    taskCompletion.TrySetException(ex);
+                }
+            };
 
 
-            //_sendSocketAsyncEventArgs.SetBuffer(buffer, 0, size);
-            //_sendSocketAsyncEventArgs.RemoteEndPoint = NetworkManager.ToIPEndPoint(endPoint);
-            //_currentSendTaskCompletionSource = tcs;
+            var result = BeginSendTo(buffer, offset, size, endPoint, new AsyncCallback(callback), null);
 
 
-            //var willRaiseEvent = _Socket.SendAsync(_sendSocketAsyncEventArgs);
+            if (result.CompletedSynchronously)
+            {
+                callback(result);
+            }
 
 
-            //if (!willRaiseEvent)
-            //{
-            //    _sendSocketAsyncEventArgs_Completed(this, _sendSocketAsyncEventArgs);
-            //}
+            cancellationToken.Register(() => taskCompletion.TrySetCanceled());
 
 
-            //return tcs.Task;
+            return taskCompletion.Task;
         }
         }
 
 
-        public async Task SendWithLockAsync(byte[] buffer, int size, IpEndPointInfo endPoint, CancellationToken cancellationToken)
+        public IAsyncResult BeginSendTo(byte[] buffer, int offset, int size, IpEndPointInfo endPoint, AsyncCallback callback, object state)
         {
         {
-            ThrowIfDisposed();
+            var ipEndPoint = NetworkManager.ToIPEndPoint(endPoint);
 
 
-            //await _sendLock.WaitAsync(cancellationToken).ConfigureAwait(false);
+            return _Socket.BeginSendTo(buffer, offset, size, SocketFlags.None, ipEndPoint, callback, state);
+        }
 
 
-            try
-            {
-                await SendAsync(buffer, size, endPoint, cancellationToken).ConfigureAwait(false);
-            }
-            finally
-            {
-                //_sendLock.Release();
-            }
+        public int EndSendTo(IAsyncResult result)
+        {
+            return _Socket.EndSendTo(result);
         }
         }
 
 
         protected override void Dispose(bool disposing)
         protected override void Dispose(bool disposing)
@@ -273,52 +253,5 @@ namespace Emby.Common.Implementations.Net
 
 
             return NetworkManager.ToIpEndPointInfo(endpoint);
             return NetworkManager.ToIpEndPointInfo(endpoint);
         }
         }
-
-        private void ProcessResponse(IAsyncResult asyncResult)
-        {
-#if NET46
-            var state = asyncResult.AsyncState as AsyncReceiveState;
-            try
-            {
-                var bytesRead = state.Socket.EndReceiveFrom(asyncResult, ref state.RemoteEndPoint);
-
-                var ipEndPoint = state.RemoteEndPoint as IPEndPoint;
-                state.TaskCompletionSource.SetResult(
-                    new SocketReceiveResult
-                    {
-                        Buffer = state.Buffer,
-                        ReceivedBytes = bytesRead,
-                        RemoteEndPoint = ToIpEndPointInfo(ipEndPoint),
-                        LocalIPAddress = LocalIPAddress
-                    }
-                );
-            }
-            catch (ObjectDisposedException)
-            {
-                state.TaskCompletionSource.SetCanceled();
-            }
-            catch (Exception ex)
-            {
-                state.TaskCompletionSource.SetException(ex);
-            }
-#endif
-        }
-
-        private class AsyncReceiveState
-        {
-            public AsyncReceiveState(Socket socket, EndPoint remoteEndPoint)
-            {
-                this.Socket = socket;
-                this.RemoteEndPoint = remoteEndPoint;
-            }
-
-            public EndPoint RemoteEndPoint;
-            public byte[] Buffer = new byte[8192];
-
-            public Socket Socket { get; private set; }
-
-            public TaskCompletionSource<SocketReceiveResult> TaskCompletionSource { get; set; }
-
-        }
     }
     }
 }
 }

+ 19 - 4
Emby.Common.Implementations/Properties/AssemblyInfo.cs

@@ -2,18 +2,33 @@
 using System.Runtime.CompilerServices;
 using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 using System.Runtime.InteropServices;
 
 
-// General Information about an assembly is controlled through the following
+// General Information about an assembly is controlled through the following 
 // set of attributes. Change these attribute values to modify the information
 // set of attributes. Change these attribute values to modify the information
 // associated with an assembly.
 // associated with an assembly.
+[assembly: AssemblyTitle("Emby.Common.Implementations")]
+[assembly: AssemblyDescription("")]
 [assembly: AssemblyConfiguration("")]
 [assembly: AssemblyConfiguration("")]
 [assembly: AssemblyCompany("")]
 [assembly: AssemblyCompany("")]
 [assembly: AssemblyProduct("Emby.Common.Implementations")]
 [assembly: AssemblyProduct("Emby.Common.Implementations")]
+[assembly: AssemblyCopyright("Copyright ©  2017")]
 [assembly: AssemblyTrademark("")]
 [assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
 
 
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components.  If you need to access a type in this assembly from
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
 // COM, set the ComVisible attribute to true on that type.
 // COM, set the ComVisible attribute to true on that type.
 [assembly: ComVisible(false)]
 [assembly: ComVisible(false)]
 
 
 // The following GUID is for the ID of the typelib if this project is exposed to COM
 // The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("5a27010a-09c6-4e86-93ea-437484c10917")]
+[assembly: Guid("1e37a338-9f57-4b70-bd6d-bb9c591e319b")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]

+ 0 - 6
Emby.Common.Implementations/Reflection/AssemblyInfo.cs

@@ -9,18 +9,12 @@ namespace Emby.Common.Implementations.Reflection
     {
     {
         public Stream GetManifestResourceStream(Type type, string resource)
         public Stream GetManifestResourceStream(Type type, string resource)
         {
         {
-#if NET46
             return type.Assembly.GetManifestResourceStream(resource);
             return type.Assembly.GetManifestResourceStream(resource);
-#endif
-            return type.GetTypeInfo().Assembly.GetManifestResourceStream(resource);
         }
         }
 
 
         public string[] GetManifestResourceNames(Type type)
         public string[] GetManifestResourceNames(Type type)
         {
         {
-#if NET46
             return type.Assembly.GetManifestResourceNames();
             return type.Assembly.GetManifestResourceNames();
-#endif
-            return type.GetTypeInfo().Assembly.GetManifestResourceNames();
         }
         }
 
 
         public Assembly[] GetCurrentAssemblies()
         public Assembly[] GetCurrentAssemblies()

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

@@ -5,7 +5,6 @@ using System.Collections.Generic;
 using System.IO;
 using System.IO;
 using System.Xml;
 using System.Xml;
 using System.Xml.Serialization;
 using System.Xml.Serialization;
-using MediaBrowser.Common.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.Logging;
 using MediaBrowser.Model.Logging;
 
 
@@ -78,18 +77,11 @@ namespace Emby.Common.Implementations.Serialization
         /// <param name="stream">The stream.</param>
         /// <param name="stream">The stream.</param>
         public void SerializeToStream(object obj, Stream stream)
         public void SerializeToStream(object obj, Stream stream)
         {
         {
-#if NET46
-            using (var writer = new XmlTextWriter(stream, null))            
+            using (var writer = new XmlTextWriter(stream, null))
             {
             {
                 writer.Formatting = Formatting.Indented;
                 writer.Formatting = Formatting.Indented;
                 SerializeToWriter(obj, writer);
                 SerializeToWriter(obj, writer);
             }
             }
-#else
-            using (var writer = XmlWriter.Create(stream))
-            {
-                SerializeToWriter(obj, writer);
-            }
-#endif
         }
         }
 
 
         /// <summary>
         /// <summary>

+ 0 - 2
Emby.Common.Implementations/Xml/XmlReaderSettingsFactory.cs

@@ -11,9 +11,7 @@ namespace Emby.Common.Implementations.Xml
 
 
             if (!enableValidation)
             if (!enableValidation)
             {
             {
-#if NET46
                 settings.ValidationType = ValidationType.None;
                 settings.ValidationType = ValidationType.None;
-#endif
             }
             }
 
 
             return settings;
             return settings;

+ 7 - 0
Emby.Common.Implementations/packages.config

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="NLog" version="4.4.9" targetFramework="net46" />
+  <package id="ServiceStack.Text" version="4.5.8" targetFramework="net462" />
+  <package id="SharpCompress" version="0.14.0" targetFramework="net462" />
+  <package id="SimpleInjector" version="4.0.7" targetFramework="net462" />
+</packages>

+ 0 - 71
Emby.Common.Implementations/project.json

@@ -1,71 +0,0 @@
-{
-  "version": "1.0.0-*",
-
-  "dependencies": {
-
-  },
-
-  "frameworks": {
-    "net46": {
-      "frameworkAssemblies": {
-        "System.Collections": "4.0.0.0",
-        "System.IO": "4.0.0.0",
-        "System.Net": "4.0.0.0",
-        "System.Net.Http": "4.0.0.0",
-        "System.Net.Primitives": "4.0.0.0",
-        "System.Net.Http.WebRequest": "4.0.0.0",
-        "System.Reflection": "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.ReaderWriter": "4.0.0"
-      },
-      "dependencies": {
-        "SimpleInjector": "3.2.4",
-        "ServiceStack.Text": "4.5.4",
-        "NLog": "4.4.0-betaV15",
-        "sharpcompress": "0.14.0",
-        "MediaBrowser.Model": {
-          "target": "project"
-        },
-        "MediaBrowser.Common": {
-          "target": "project"
-        }
-      }
-    },
-    "netstandard1.6": {
-      "imports": "dnxcore50",
-      "dependencies": {
-        "NETStandard.Library": "1.6.1",
-        "System.IO.FileSystem.DriveInfo": "4.3.0",
-        "System.Diagnostics.Process": "4.3.0",
-        "System.Threading.Timer": "4.3.0",
-        "System.Net.Requests": "4.3.0",
-        "System.Xml.ReaderWriter": "4.3.0",
-        "System.Xml.XmlSerializer": "4.3.0",
-        "System.Net.Http": "4.3.2",
-        "System.Net.Primitives": "4.3.0",
-        "System.Net.Sockets": "4.3.0",
-        "System.Net.NetworkInformation": "4.3.0",
-        "System.Net.NameResolution": "4.3.0",
-        "System.Runtime.InteropServices.RuntimeInformation": "4.3.0",
-        "System.Reflection": "4.3.0",
-        "System.Reflection.Primitives": "4.3.0",
-        "System.Runtime.Loader": "4.3.0",
-        "SimpleInjector": "3.2.4",
-        "ServiceStack.Text.Core": "1.0.27",
-        "NLog": "4.4.0-betaV15",
-        "sharpcompress": "0.14.0",
-		"System.AppDomain": "2.0.11",
-        "MediaBrowser.Model": {
-          "target": "project"
-        },
-        "MediaBrowser.Common": {
-          "target": "project"
-        }
-      }
-    }
-  }
-}

+ 34 - 24
Emby.Dlna/ContentDirectory/ControlHandler.cs

@@ -23,6 +23,7 @@ using System.Text;
 using System.Threading;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using System.Xml;
 using System.Xml;
+using MediaBrowser.Controller.Dto;
 using MediaBrowser.Controller.Entities.Audio;
 using MediaBrowser.Controller.Entities.Audio;
 using MediaBrowser.Controller.MediaEncoding;
 using MediaBrowser.Controller.MediaEncoding;
 using MediaBrowser.Model.Globalization;
 using MediaBrowser.Model.Globalization;
@@ -85,7 +86,7 @@ namespace Emby.Dlna.ContentDirectory
                 return HandleGetSystemUpdateID();
                 return HandleGetSystemUpdateID();
 
 
             if (string.Equals(methodName, "Browse", StringComparison.OrdinalIgnoreCase))
             if (string.Equals(methodName, "Browse", StringComparison.OrdinalIgnoreCase))
-                return HandleBrowse(methodParams, user, deviceId).Result;
+                return HandleBrowse(methodParams, user, deviceId);
 
 
             if (string.Equals(methodName, "X_GetFeatureList", StringComparison.OrdinalIgnoreCase))
             if (string.Equals(methodName, "X_GetFeatureList", StringComparison.OrdinalIgnoreCase))
                 return HandleXGetFeatureList();
                 return HandleXGetFeatureList();
@@ -97,10 +98,10 @@ namespace Emby.Dlna.ContentDirectory
                 return HandleXSetBookmark(methodParams, user);
                 return HandleXSetBookmark(methodParams, user);
 
 
             if (string.Equals(methodName, "Search", StringComparison.OrdinalIgnoreCase))
             if (string.Equals(methodName, "Search", StringComparison.OrdinalIgnoreCase))
-                return HandleSearch(methodParams, user, deviceId).Result;
+                return HandleSearch(methodParams, user, deviceId);
 
 
             if (string.Equals(methodName, "X_BrowseByLetter", StringComparison.OrdinalIgnoreCase))
             if (string.Equals(methodName, "X_BrowseByLetter", StringComparison.OrdinalIgnoreCase))
-                return HandleX_BrowseByLetter(methodParams, user, deviceId).Result;
+                return HandleX_BrowseByLetter(methodParams, user, deviceId);
 
 
             throw new ResourceNotFoundException("Unexpected control request name: " + methodName);
             throw new ResourceNotFoundException("Unexpected control request name: " + methodName);
         }
         }
@@ -202,7 +203,7 @@ namespace Emby.Dlna.ContentDirectory
             return defaultValue;
             return defaultValue;
         }
         }
 
 
-        private async Task<IEnumerable<KeyValuePair<string, string>>> HandleBrowse(IDictionary<string, string> sparams, User user, string deviceId)
+        private IEnumerable<KeyValuePair<string, string>> HandleBrowse(IDictionary<string, string> sparams, User user, string deviceId)
         {
         {
             var id = sparams["ObjectID"];
             var id = sparams["ObjectID"];
             var flag = sparams["BrowseFlag"];
             var flag = sparams["BrowseFlag"];
@@ -262,7 +263,7 @@ namespace Emby.Dlna.ContentDirectory
 
 
                     if (item.IsDisplayedAsFolder || serverItem.StubType.HasValue)
                     if (item.IsDisplayedAsFolder || serverItem.StubType.HasValue)
                     {
                     {
-                        var childrenResult = (await GetUserItems(item, serverItem.StubType, user, sortCriteria, start, requestedCount).ConfigureAwait(false));
+                        var childrenResult = (GetUserItems(item, serverItem.StubType, user, sortCriteria, start, requestedCount));
 
 
                         _didlBuilder.WriteFolderElement(writer, item, serverItem.StubType, null, childrenResult.TotalRecordCount, filter, id);
                         _didlBuilder.WriteFolderElement(writer, item, serverItem.StubType, null, childrenResult.TotalRecordCount, filter, id);
                     }
                     }
@@ -275,7 +276,7 @@ namespace Emby.Dlna.ContentDirectory
                 }
                 }
                 else
                 else
                 {
                 {
-                    var childrenResult = (await GetUserItems(item, serverItem.StubType, user, sortCriteria, start, requestedCount).ConfigureAwait(false));
+                    var childrenResult = (GetUserItems(item, serverItem.StubType, user, sortCriteria, start, requestedCount));
                     totalCount = childrenResult.TotalRecordCount;
                     totalCount = childrenResult.TotalRecordCount;
 
 
                     provided = childrenResult.Items.Length;
                     provided = childrenResult.Items.Length;
@@ -287,7 +288,7 @@ namespace Emby.Dlna.ContentDirectory
 
 
                         if (childItem.IsDisplayedAsFolder || displayStubType.HasValue)
                         if (childItem.IsDisplayedAsFolder || displayStubType.HasValue)
                         {
                         {
-                            var childCount = (await GetUserItems(childItem, displayStubType, user, sortCriteria, null, 0).ConfigureAwait(false))
+                            var childCount = (GetUserItems(childItem, displayStubType, user, sortCriteria, null, 0))
                                 .TotalRecordCount;
                                 .TotalRecordCount;
 
 
                             _didlBuilder.WriteFolderElement(writer, childItem, displayStubType, item, childCount, filter);
                             _didlBuilder.WriteFolderElement(writer, childItem, displayStubType, item, childCount, filter);
@@ -313,13 +314,13 @@ namespace Emby.Dlna.ContentDirectory
                 };
                 };
         }
         }
 
 
-        private Task<IEnumerable<KeyValuePair<string, string>>> HandleX_BrowseByLetter(IDictionary<string, string> sparams, User user, string deviceId)
+        private IEnumerable<KeyValuePair<string, string>> HandleX_BrowseByLetter(IDictionary<string, string> sparams, User user, string deviceId)
         {
         {
             // TODO: Implement this method
             // TODO: Implement this method
             return HandleSearch(sparams, user, deviceId);
             return HandleSearch(sparams, user, deviceId);
         }
         }
 
 
-        private async Task<IEnumerable<KeyValuePair<string, string>>> HandleSearch(IDictionary<string, string> sparams, User user, string deviceId)
+        private IEnumerable<KeyValuePair<string, string>> HandleSearch(IDictionary<string, string> sparams, User user, string deviceId)
         {
         {
             var searchCriteria = new SearchCriteria(GetValueOrDefault(sparams, "SearchCriteria", ""));
             var searchCriteria = new SearchCriteria(GetValueOrDefault(sparams, "SearchCriteria", ""));
             var sortCriteria = new SortCriteria(GetValueOrDefault(sparams, "SortCriteria", ""));
             var sortCriteria = new SortCriteria(GetValueOrDefault(sparams, "SortCriteria", ""));
@@ -373,7 +374,7 @@ namespace Emby.Dlna.ContentDirectory
 
 
                 var item = serverItem.Item;
                 var item = serverItem.Item;
 
 
-                var childrenResult = (await GetChildrenSorted(item, user, searchCriteria, sortCriteria, start, requestedCount).ConfigureAwait(false));
+                var childrenResult = (GetChildrenSorted(item, user, searchCriteria, sortCriteria, start, requestedCount));
 
 
                 totalCount = childrenResult.TotalRecordCount;
                 totalCount = childrenResult.TotalRecordCount;
 
 
@@ -383,7 +384,7 @@ namespace Emby.Dlna.ContentDirectory
                 {
                 {
                     if (i.IsDisplayedAsFolder)
                     if (i.IsDisplayedAsFolder)
                     {
                     {
-                        var childCount = (await GetChildrenSorted(i, user, searchCriteria, sortCriteria, null, 0).ConfigureAwait(false))
+                        var childCount = (GetChildrenSorted(i, user, searchCriteria, sortCriteria, null, 0))
                             .TotalRecordCount;
                             .TotalRecordCount;
 
 
                         _didlBuilder.WriteFolderElement(writer, i, null, item, childCount, filter);
                         _didlBuilder.WriteFolderElement(writer, i, null, item, childCount, filter);
@@ -409,7 +410,7 @@ namespace Emby.Dlna.ContentDirectory
                 };
                 };
         }
         }
 
 
-        private Task<QueryResult<BaseItem>> GetChildrenSorted(BaseItem item, User user, SearchCriteria search, SortCriteria sort, int? startIndex, int? limit)
+        private QueryResult<BaseItem> GetChildrenSorted(BaseItem item, User user, SearchCriteria search, SortCriteria sort, int? startIndex, int? limit)
         {
         {
             var folder = (Folder)item;
             var folder = (Folder)item;
 
 
@@ -459,11 +460,17 @@ namespace Emby.Dlna.ContentDirectory
                 IsMissing = false,
                 IsMissing = false,
                 ExcludeItemTypes = new[] { typeof(Game).Name, typeof(Book).Name },
                 ExcludeItemTypes = new[] { typeof(Game).Name, typeof(Book).Name },
                 IsFolder = isFolder,
                 IsFolder = isFolder,
-                MediaTypes = mediaTypes.ToArray()
+                MediaTypes = mediaTypes.ToArray(),
+                DtoOptions = GetDtoOptions()
             });
             });
         }
         }
 
 
-        private async Task<QueryResult<ServerItem>> GetUserItems(BaseItem item, StubType? stubType, User user, SortCriteria sort, int? startIndex, int? limit)
+        private DtoOptions GetDtoOptions()
+        {
+            return new DtoOptions(true);
+        }
+
+        private QueryResult<ServerItem> GetUserItems(BaseItem item, StubType? stubType, User user, SortCriteria sort, int? startIndex, int? limit)
         {
         {
             if (item is MusicGenre)
             if (item is MusicGenre)
             {
             {
@@ -511,14 +518,15 @@ namespace Emby.Dlna.ContentDirectory
                 StartIndex = startIndex,
                 StartIndex = startIndex,
                 User = user,
                 User = user,
                 IsMissing = false,
                 IsMissing = false,
-                PresetViews = new[] {CollectionType.Movies, CollectionType.TvShows, CollectionType.Music},
-                ExcludeItemTypes = new[] {typeof (Game).Name, typeof (Book).Name},
-                IsPlaceHolder = false
+                PresetViews = new[] { CollectionType.Movies, CollectionType.TvShows, CollectionType.Music },
+                ExcludeItemTypes = new[] { typeof(Game).Name, typeof(Book).Name },
+                IsPlaceHolder = false,
+                DtoOptions = GetDtoOptions()
             };
             };
 
 
             SetSorting(query, sort, folder.IsPreSorted);
             SetSorting(query, sort, folder.IsPreSorted);
 
 
-            var queryResult = await folder.GetItems(query).ConfigureAwait(false);
+            var queryResult = folder.GetItems(query);
 
 
             return ToResult(queryResult);
             return ToResult(queryResult);
         }
         }
@@ -532,7 +540,8 @@ namespace Emby.Dlna.ContentDirectory
                 ArtistIds = new[] { item.Id.ToString("N") },
                 ArtistIds = new[] { item.Id.ToString("N") },
                 IncludeItemTypes = new[] { typeof(MusicAlbum).Name },
                 IncludeItemTypes = new[] { typeof(MusicAlbum).Name },
                 Limit = limit,
                 Limit = limit,
-                StartIndex = startIndex
+                StartIndex = startIndex,
+                DtoOptions = GetDtoOptions()
             };
             };
 
 
             SetSorting(query, sort, false);
             SetSorting(query, sort, false);
@@ -548,10 +557,11 @@ namespace Emby.Dlna.ContentDirectory
             {
             {
                 Recursive = true,
                 Recursive = true,
                 ParentId = parentId,
                 ParentId = parentId,
-                GenreIds = new[] {item.Id.ToString("N")},
-                IncludeItemTypes = new[] {typeof (MusicAlbum).Name},
+                GenreIds = new[] { item.Id.ToString("N") },
+                IncludeItemTypes = new[] { typeof(MusicAlbum).Name },
                 Limit = limit,
                 Limit = limit,
-                StartIndex = startIndex
+                StartIndex = startIndex,
+                DtoOptions = GetDtoOptions()
             };
             };
 
 
             SetSorting(query, sort, false);
             SetSorting(query, sort, false);
@@ -595,8 +605,8 @@ namespace Emby.Dlna.ContentDirectory
                 IncludeItemTypes = new[] { typeof(Movie).Name, typeof(Series).Name, typeof(Trailer).Name },
                 IncludeItemTypes = new[] { typeof(Movie).Name, typeof(Series).Name, typeof(Trailer).Name },
                 SortBy = new[] { ItemSortBy.SortName },
                 SortBy = new[] { ItemSortBy.SortName },
                 Limit = limit,
                 Limit = limit,
-                StartIndex = startIndex
-
+                StartIndex = startIndex,
+                DtoOptions = GetDtoOptions()
             });
             });
 
 
             var serverItems = itemsResult.Items.Select(i => new ServerItem(i))
             var serverItems = itemsResult.Items.Select(i => new ServerItem(i))

+ 12 - 9
Emby.Dlna/Didl/DidlBuilder.cs

@@ -18,6 +18,7 @@ using System.Globalization;
 using System.IO;
 using System.IO;
 using System.Linq;
 using System.Linq;
 using System.Text;
 using System.Text;
+using System.Threading.Tasks;
 using System.Xml;
 using System.Xml;
 using MediaBrowser.Controller.MediaEncoding;
 using MediaBrowser.Controller.MediaEncoding;
 using MediaBrowser.Model.Configuration;
 using MediaBrowser.Model.Configuration;
@@ -111,14 +112,14 @@ namespace Emby.Dlna.Didl
             }
             }
         }
         }
 
 
-        public void WriteItemElement(DlnaOptions options, 
-            XmlWriter writer, 
-            BaseItem item, 
+        public void WriteItemElement(DlnaOptions options,
+            XmlWriter writer,
+            BaseItem item,
             User user,
             User user,
-            BaseItem context, 
-            StubType? contextStubType, 
-            string deviceId, 
-            Filter filter, 
+            BaseItem context,
+            StubType? contextStubType,
+            string deviceId,
+            Filter filter,
             StreamInfo streamInfo = null)
             StreamInfo streamInfo = null)
         {
         {
             var clientId = GetClientId(item, null);
             var clientId = GetClientId(item, null);
@@ -223,6 +224,7 @@ namespace Emby.Dlna.Didl
                 streamInfo.TargetPacketLength,
                 streamInfo.TargetPacketLength,
                 streamInfo.TranscodeSeekInfo,
                 streamInfo.TranscodeSeekInfo,
                 streamInfo.IsTargetAnamorphic,
                 streamInfo.IsTargetAnamorphic,
+                streamInfo.IsTargetInterlaced,
                 streamInfo.TargetRefFrames,
                 streamInfo.TargetRefFrames,
                 streamInfo.TargetVideoStreamCount,
                 streamInfo.TargetVideoStreamCount,
                 streamInfo.TargetAudioStreamCount,
                 streamInfo.TargetAudioStreamCount,
@@ -363,6 +365,7 @@ namespace Emby.Dlna.Didl
                 streamInfo.TargetPacketLength,
                 streamInfo.TargetPacketLength,
                 streamInfo.TargetTimestamp,
                 streamInfo.TargetTimestamp,
                 streamInfo.IsTargetAnamorphic,
                 streamInfo.IsTargetAnamorphic,
+                streamInfo.IsTargetInterlaced,
                 streamInfo.TargetRefFrames,
                 streamInfo.TargetRefFrames,
                 streamInfo.TargetVideoStreamCount,
                 streamInfo.TargetVideoStreamCount,
                 streamInfo.TargetAudioStreamCount,
                 streamInfo.TargetAudioStreamCount,
@@ -920,7 +923,7 @@ namespace Emby.Dlna.Didl
 
 
             if (item is Video)
             if (item is Video)
             {
             {
-                var userData = _userDataManager.GetUserDataDto(item, _user).Result;
+                var userData = _userDataManager.GetUserDataDto(item, _user);
 
 
                 playbackPercentage = Convert.ToInt32(userData.PlayedPercentage ?? 0);
                 playbackPercentage = Convert.ToInt32(userData.PlayedPercentage ?? 0);
                 if (playbackPercentage >= 100 || userData.Played)
                 if (playbackPercentage >= 100 || userData.Played)
@@ -930,7 +933,7 @@ namespace Emby.Dlna.Didl
             }
             }
             else if (item is Series || item is Season || item is BoxSet)
             else if (item is Series || item is Season || item is BoxSet)
             {
             {
-                var userData = _userDataManager.GetUserDataDto(item, _user).Result;
+                var userData = _userDataManager.GetUserDataDto(item, _user);
 
 
                 if (userData.Played)
                 if (userData.Played)
                 {
                 {

+ 1 - 0
Emby.Dlna/PlayTo/PlayToController.cs

@@ -556,6 +556,7 @@ namespace Emby.Dlna.PlayTo
                     streamInfo.TargetPacketLength,
                     streamInfo.TargetPacketLength,
                     streamInfo.TranscodeSeekInfo,
                     streamInfo.TranscodeSeekInfo,
                     streamInfo.IsTargetAnamorphic,
                     streamInfo.IsTargetAnamorphic,
+                    streamInfo.IsTargetInterlaced,
                     streamInfo.TargetRefFrames,
                     streamInfo.TargetRefFrames,
                     streamInfo.TargetVideoStreamCount,
                     streamInfo.TargetVideoStreamCount,
                     streamInfo.TargetAudioStreamCount,
                     streamInfo.TargetAudioStreamCount,

+ 12 - 0
Emby.Dlna/Profiles/DefaultProfile.cs

@@ -135,6 +135,18 @@ namespace Emby.Dlna.Profiles
                 {
                 {
                     Format = "sub",
                     Format = "sub",
                     Method = SubtitleDeliveryMethod.Embed
                     Method = SubtitleDeliveryMethod.Embed
+                },
+
+                new SubtitleProfile
+                {
+                    Format = "subrip",
+                    Method = SubtitleDeliveryMethod.Embed
+                },
+
+                new SubtitleProfile
+                {
+                    Format = "vtt",
+                    Method = SubtitleDeliveryMethod.Embed
                 }
                 }
             };
             };
 
 

+ 2 - 0
Emby.Dlna/Profiles/Xml/Default.xml

@@ -55,5 +55,7 @@
     <SubtitleProfile format="pgs" method="Embed" />
     <SubtitleProfile format="pgs" method="Embed" />
     <SubtitleProfile format="pgssub" method="Embed" />
     <SubtitleProfile format="pgssub" method="Embed" />
     <SubtitleProfile format="sub" method="Embed" />
     <SubtitleProfile format="sub" method="Embed" />
+    <SubtitleProfile format="subrip" method="Embed" />
+    <SubtitleProfile format="vtt" method="Embed" />
   </SubtitleProfiles>
   </SubtitleProfiles>
 </Profile>
 </Profile>

+ 2 - 0
Emby.Dlna/Profiles/Xml/Denon AVR.xml

@@ -55,5 +55,7 @@
     <SubtitleProfile format="pgs" method="Embed" />
     <SubtitleProfile format="pgs" method="Embed" />
     <SubtitleProfile format="pgssub" method="Embed" />
     <SubtitleProfile format="pgssub" method="Embed" />
     <SubtitleProfile format="sub" method="Embed" />
     <SubtitleProfile format="sub" method="Embed" />
+    <SubtitleProfile format="subrip" method="Embed" />
+    <SubtitleProfile format="vtt" method="Embed" />
   </SubtitleProfiles>
   </SubtitleProfiles>
 </Profile>
 </Profile>

+ 2 - 0
Emby.Dlna/Profiles/Xml/MediaMonkey.xml

@@ -61,5 +61,7 @@
     <SubtitleProfile format="pgs" method="Embed" />
     <SubtitleProfile format="pgs" method="Embed" />
     <SubtitleProfile format="pgssub" method="Embed" />
     <SubtitleProfile format="pgssub" method="Embed" />
     <SubtitleProfile format="sub" method="Embed" />
     <SubtitleProfile format="sub" method="Embed" />
+    <SubtitleProfile format="subrip" method="Embed" />
+    <SubtitleProfile format="vtt" method="Embed" />
   </SubtitleProfiles>
   </SubtitleProfiles>
 </Profile>
 </Profile>

+ 2 - 0
Emby.Dlna/Profiles/Xml/foobar2000.xml

@@ -61,5 +61,7 @@
     <SubtitleProfile format="pgs" method="Embed" />
     <SubtitleProfile format="pgs" method="Embed" />
     <SubtitleProfile format="pgssub" method="Embed" />
     <SubtitleProfile format="pgssub" method="Embed" />
     <SubtitleProfile format="sub" method="Embed" />
     <SubtitleProfile format="sub" method="Embed" />
+    <SubtitleProfile format="subrip" method="Embed" />
+    <SubtitleProfile format="vtt" method="Embed" />
   </SubtitleProfiles>
   </SubtitleProfiles>
 </Profile>
 </Profile>

+ 11 - 7
Emby.Drawing.ImageMagick/ImageMagickEncoder.cs

@@ -130,7 +130,7 @@ namespace Emby.Drawing.ImageMagick
                 string.Equals(ext, ".webp", StringComparison.OrdinalIgnoreCase);
                 string.Equals(ext, ".webp", StringComparison.OrdinalIgnoreCase);
         }
         }
 
 
-        public void EncodeImage(string inputPath, ImageSize? originalImageSize, string outputPath, bool autoOrient, int quality, ImageProcessingOptions options, ImageFormat selectedOutputFormat)
+        public string EncodeImage(string inputPath, DateTime dateModified, string outputPath, bool autoOrient, int quality, ImageProcessingOptions options, ImageFormat selectedOutputFormat)
         {
         {
             // Even if the caller specified 100, don't use it because it takes forever
             // Even if the caller specified 100, don't use it because it takes forever
             quality = Math.Min(quality, 99);
             quality = Math.Min(quality, 99);
@@ -144,9 +144,13 @@ namespace Emby.Drawing.ImageMagick
                         originalImage.CurrentImage.TrimImage(10);
                         originalImage.CurrentImage.TrimImage(10);
                     }
                     }
 
 
-                    if (options.CropWhiteSpace || !originalImageSize.HasValue)
+                    var originalImageSize = new ImageSize(originalImage.CurrentImage.Width, originalImage.CurrentImage.Height);
+                    ImageHelper.SaveImageSize(inputPath, dateModified, originalImageSize);
+
+                    if (!options.CropWhiteSpace && options.HasDefaultOptions(inputPath, originalImageSize))
                     {
                     {
-                        originalImageSize = new ImageSize(originalImage.CurrentImage.Width, originalImage.CurrentImage.Height);
+                        // Just spit out the original file if all the options are default
+                        return inputPath;
                     }
                     }
 
 
                     var newImageSize = ImageHelper.GetNewImageSize(options, originalImageSize);
                     var newImageSize = ImageHelper.GetNewImageSize(options, originalImageSize);
@@ -174,10 +178,8 @@ namespace Emby.Drawing.ImageMagick
             {
             {
                 using (var originalImage = new MagickWand(inputPath))
                 using (var originalImage = new MagickWand(inputPath))
                 {
                 {
-                    if (options.CropWhiteSpace || !originalImageSize.HasValue)
-                    {
-                        originalImageSize = new ImageSize(originalImage.CurrentImage.Width, originalImage.CurrentImage.Height);
-                    }
+                    var originalImageSize = new ImageSize(originalImage.CurrentImage.Width, originalImage.CurrentImage.Height);
+                    ImageHelper.SaveImageSize(inputPath, dateModified, originalImageSize);
 
 
                     var newImageSize = ImageHelper.GetNewImageSize(options, originalImageSize);
                     var newImageSize = ImageHelper.GetNewImageSize(options, originalImageSize);
 
 
@@ -205,6 +207,8 @@ namespace Emby.Drawing.ImageMagick
                     }
                     }
                 }
                 }
             }
             }
+
+            return outputPath;
         }
         }
 
 
         private void AddForegroundLayer(MagickWand wand, ImageProcessingOptions options)
         private void AddForegroundLayer(MagickWand wand, ImageProcessingOptions options)

+ 1 - 1
Emby.Drawing.ImageMagick/PlayedIndicatorDrawer.cs

@@ -5,7 +5,7 @@ using MediaBrowser.Model.Drawing;
 using System;
 using System;
 using System.IO;
 using System.IO;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
-using MediaBrowser.Common.IO;
+
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 
 

+ 1 - 1
Emby.Drawing.ImageMagick/StripCollageBuilder.cs

@@ -2,7 +2,7 @@
 using MediaBrowser.Common.Configuration;
 using MediaBrowser.Common.Configuration;
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
-using MediaBrowser.Common.IO;
+
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 
 

+ 0 - 2
Emby.Drawing.ImageMagick/UnplayedCountIndicator.cs

@@ -2,8 +2,6 @@
 using MediaBrowser.Common.Configuration;
 using MediaBrowser.Common.Configuration;
 using MediaBrowser.Model.Drawing;
 using MediaBrowser.Model.Drawing;
 using System.Globalization;
 using System.Globalization;
-using MediaBrowser.Common.IO;
-using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 
 
 namespace Emby.Drawing.ImageMagick
 namespace Emby.Drawing.ImageMagick

+ 5 - 4
Emby.Drawing.Skia/Emby.Drawing.Skia.csproj

@@ -60,13 +60,14 @@
     <Compile Include="UnplayedCountIndicator.cs" />
     <Compile Include="UnplayedCountIndicator.cs" />
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
-    <Reference Include="SkiaSharp, Version=1.57.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
-      <HintPath>..\packages\SkiaSharp.1.57.1\lib\portable-net45+win8+wpa81+wp8\SkiaSharp.dll</HintPath>
-      <Private>True</Private>
+    <EmbeddedResource Include="fonts\robotoregular.ttf" />
+  </ItemGroup>
+  <ItemGroup>
+    <Reference Include="SkiaSharp, Version=1.58.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
+      <HintPath>..\packages\SkiaSharp.1.58.0\lib\portable-net45+win8+wpa81+wp8\SkiaSharp.dll</HintPath>
     </Reference>
     </Reference>
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
-    <EmbeddedResource Include="fonts\robotoregular.ttf" />
     <None Include="packages.config" />
     <None Include="packages.config" />
   </ItemGroup>
   </ItemGroup>
   <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
   <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />

+ 1 - 1
Emby.Drawing.Skia/PlayedIndicatorDrawer.cs

@@ -5,7 +5,7 @@ using MediaBrowser.Model.Drawing;
 using System;
 using System;
 using System.IO;
 using System.IO;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
-using MediaBrowser.Common.IO;
+
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 using System.Reflection;
 using System.Reflection;

+ 36 - 8
Emby.Drawing.Skia/SkiaEncoder.cs

@@ -191,18 +191,18 @@ namespace Emby.Drawing.Skia
         }
         }
 
 
         private string[] TransparentImageTypes = new string[] { ".png", ".gif", ".webp" };
         private string[] TransparentImageTypes = new string[] { ".png", ".gif", ".webp" };
-        private SKBitmap Decode(string path)
+        private SKBitmap Decode(string path, bool forceCleanBitmap = false)
         {
         {
             var requiresTransparencyHack = TransparentImageTypes.Contains(Path.GetExtension(path) ?? string.Empty);
             var requiresTransparencyHack = TransparentImageTypes.Contains(Path.GetExtension(path) ?? string.Empty);
 
 
-            if (requiresTransparencyHack)
+            if (requiresTransparencyHack || forceCleanBitmap)
             {
             {
                 using (var stream = new SKFileStream(path))
                 using (var stream = new SKFileStream(path))
                 {
                 {
                     var codec = SKCodec.Create(stream);
                     var codec = SKCodec.Create(stream);
 
 
                     // create the bitmap
                     // create the bitmap
-                    var bitmap = new SKBitmap(codec.Info.Width, codec.Info.Height);
+                    var bitmap = new SKBitmap(codec.Info.Width, codec.Info.Height, !requiresTransparencyHack);
                     // decode
                     // decode
                     codec.GetPixels(bitmap.Info, bitmap.GetPixels());
                     codec.GetPixels(bitmap.Info, bitmap.GetPixels());
 
 
@@ -210,7 +210,23 @@ namespace Emby.Drawing.Skia
                 }
                 }
             }
             }
 
 
-            return SKBitmap.Decode(path);
+            var resultBitmap = SKBitmap.Decode(path);
+
+            if (resultBitmap == null)
+            {
+                return Decode(path, true);
+            }
+
+            // If we have to resize these they often end up distorted
+            if (resultBitmap.ColorType == SKColorType.Gray8)
+            {
+                using (resultBitmap)
+                {
+                    return Decode(path, true);
+                }
+            }
+
+            return resultBitmap;
         }
         }
 
 
         private SKBitmap GetBitmap(string path, bool cropWhitespace)
         private SKBitmap GetBitmap(string path, bool cropWhitespace)
@@ -226,7 +242,7 @@ namespace Emby.Drawing.Skia
             return Decode(path);
             return Decode(path);
         }
         }
 
 
-        public void EncodeImage(string inputPath, ImageSize? originalImageSize, string outputPath, bool autoOrient, int quality, ImageProcessingOptions options, ImageFormat selectedOutputFormat)
+        public string EncodeImage(string inputPath, DateTime dateModified, string outputPath, bool autoOrient, int quality, ImageProcessingOptions options, ImageFormat selectedOutputFormat)
         {
         {
             if (string.IsNullOrWhiteSpace(inputPath))
             if (string.IsNullOrWhiteSpace(inputPath))
             {
             {
@@ -246,9 +262,20 @@ namespace Emby.Drawing.Skia
 
 
             using (var bitmap = GetBitmap(inputPath, options.CropWhiteSpace))
             using (var bitmap = GetBitmap(inputPath, options.CropWhiteSpace))
             {
             {
-                if (options.CropWhiteSpace || !originalImageSize.HasValue)
+                if (bitmap == null)
+                {
+                    throw new Exception(string.Format("Skia unable to read image {0}", inputPath));
+                }
+
+                //_logger.Info("Color type {0}", bitmap.Info.ColorType);
+
+                var originalImageSize = new ImageSize(bitmap.Width, bitmap.Height);
+                ImageHelper.SaveImageSize(inputPath, dateModified, originalImageSize);
+
+                if (!options.CropWhiteSpace && options.HasDefaultOptions(inputPath, originalImageSize))
                 {
                 {
-                    originalImageSize = new ImageSize(bitmap.Width, bitmap.Height);
+                    // Just spit out the original file if all the options are default
+                    return inputPath;
                 }
                 }
 
 
                 var newImageSize = ImageHelper.GetNewImageSize(options, originalImageSize);
                 var newImageSize = ImageHelper.GetNewImageSize(options, originalImageSize);
@@ -269,7 +296,7 @@ namespace Emby.Drawing.Skia
                         using (var outputStream = new SKFileWStream(outputPath))
                         using (var outputStream = new SKFileWStream(outputPath))
                         {
                         {
                             resizedBitmap.Encode(outputStream, skiaOutputFormat, quality);
                             resizedBitmap.Encode(outputStream, skiaOutputFormat, quality);
-                            return;
+                            return outputPath;
                         }
                         }
                     }
                     }
 
 
@@ -326,6 +353,7 @@ namespace Emby.Drawing.Skia
                     }
                     }
                 }
                 }
             }
             }
+            return outputPath;
         }
         }
 
 
         public void CreateImageCollage(ImageCollageOptions options)
         public void CreateImageCollage(ImageCollageOptions options)

+ 1 - 1
Emby.Drawing.Skia/UnplayedCountIndicator.cs

@@ -4,7 +4,7 @@ using MediaBrowser.Common.Net;
 using MediaBrowser.Model.Drawing;
 using MediaBrowser.Model.Drawing;
 using System.Globalization;
 using System.Globalization;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
-using MediaBrowser.Common.IO;
+
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 
 

+ 1 - 1
Emby.Drawing.Skia/packages.config

@@ -1,4 +1,4 @@
 <?xml version="1.0" encoding="utf-8"?>
 <?xml version="1.0" encoding="utf-8"?>
 <packages>
 <packages>
-  <package id="SkiaSharp" version="1.57.1" targetFramework="portable45-net45+win8" />
+  <package id="SkiaSharp" version="1.58.0" targetFramework="portable45-net45+win8" />
 </packages>
 </packages>

+ 1 - 1
Emby.Drawing/Common/ImageHeader.cs

@@ -4,7 +4,7 @@ using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.IO;
 using System.IO;
 using System.Linq;
 using System.Linq;
-using MediaBrowser.Common.IO;
+
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 
 

+ 85 - 24
Emby.Drawing/ImageProcessor.cs

@@ -17,7 +17,7 @@ using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 using Emby.Drawing.Common;
 using Emby.Drawing.Common;
-using MediaBrowser.Common.IO;
+
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.Library;
 using MediaBrowser.Controller.Library;
 using MediaBrowser.Model.Net;
 using MediaBrowser.Model.Net;
@@ -75,6 +75,7 @@ namespace Emby.Drawing
 
 
             ImageEnhancers = new List<IImageEnhancer>();
             ImageEnhancers = new List<IImageEnhancer>();
             _saveImageSizeTimer = timerFactory.Create(SaveImageSizeCallback, null, Timeout.Infinite, Timeout.Infinite);
             _saveImageSizeTimer = timerFactory.Create(SaveImageSizeCallback, null, Timeout.Infinite, Timeout.Infinite);
+            ImageHelper.ImageProcessor = this;
 
 
             Dictionary<Guid, ImageSize> sizeDictionary;
             Dictionary<Guid, ImageSize> sizeDictionary;
 
 
@@ -178,10 +179,15 @@ namespace Emby.Drawing
             }
             }
 
 
             var originalImage = options.Image;
             var originalImage = options.Image;
+            IHasImages item = options.Item;
 
 
             if (!originalImage.IsLocalFile)
             if (!originalImage.IsLocalFile)
             {
             {
-                originalImage = await _libraryManager().ConvertImageToLocal(options.Item, originalImage, options.ImageIndex).ConfigureAwait(false);
+                if (item == null)
+                {
+                    item = _libraryManager().GetItemById(options.ItemId);
+                }
+                originalImage = await _libraryManager().ConvertImageToLocal(item, originalImage, options.ImageIndex).ConfigureAwait(false);
             }
             }
 
 
             var originalImagePath = originalImage.Path;
             var originalImagePath = originalImage.Path;
@@ -194,13 +200,18 @@ namespace Emby.Drawing
 
 
             if (options.Enhancers.Count > 0)
             if (options.Enhancers.Count > 0)
             {
             {
+                if (item == null)
+                {
+                    item = _libraryManager().GetItemById(options.ItemId);
+                }
+
                 var tuple = await GetEnhancedImage(new ItemImageInfo
                 var tuple = await GetEnhancedImage(new ItemImageInfo
                 {
                 {
                     DateModified = dateModified,
                     DateModified = dateModified,
                     Type = originalImage.Type,
                     Type = originalImage.Type,
                     Path = originalImagePath
                     Path = originalImagePath
 
 
-                }, options.Item, options.ImageIndex, options.Enhancers).ConfigureAwait(false);
+                }, item, options.ImageIndex, options.Enhancers).ConfigureAwait(false);
 
 
                 originalImagePath = tuple.Item1;
                 originalImagePath = tuple.Item1;
                 dateModified = tuple.Item2;
                 dateModified = tuple.Item2;
@@ -212,19 +223,12 @@ namespace Emby.Drawing
                 return new Tuple<string, string, DateTime>(originalImagePath, MimeTypes.GetMimeType(originalImagePath), dateModified);
                 return new Tuple<string, string, DateTime>(originalImagePath, MimeTypes.GetMimeType(originalImagePath), dateModified);
             }
             }
 
 
-            ImageSize? originalImageSize = null;
-            try
+            ImageSize? originalImageSize = GetSavedImageSize(originalImagePath, dateModified);
+            if (originalImageSize.HasValue && options.HasDefaultOptions(originalImagePath, originalImageSize.Value))
             {
             {
-                originalImageSize = GetImageSize(originalImagePath, dateModified, true);
-                if (options.HasDefaultOptions(originalImagePath, originalImageSize.Value))
-                {
-                    // Just spit out the original file if all the options are default
-                    return new Tuple<string, string, DateTime>(originalImagePath, MimeTypes.GetMimeType(originalImagePath), dateModified);
-                }
-            }
-            catch
-            {
-                originalImageSize = null;
+                // Just spit out the original file if all the options are default
+                _logger.Info("Returning original image {0}", originalImagePath);
+                return new Tuple<string, string, DateTime>(originalImagePath, MimeTypes.GetMimeType(originalImagePath), dateModified);
             }
             }
 
 
             var newSize = ImageHelper.GetNewImageSize(options, originalImageSize);
             var newSize = ImageHelper.GetNewImageSize(options, originalImageSize);
@@ -243,7 +247,18 @@ namespace Emby.Drawing
                     var tmpPath = Path.ChangeExtension(Path.Combine(_appPaths.TempDirectory, Guid.NewGuid().ToString("N")), Path.GetExtension(cacheFilePath));
                     var tmpPath = Path.ChangeExtension(Path.Combine(_appPaths.TempDirectory, Guid.NewGuid().ToString("N")), Path.GetExtension(cacheFilePath));
                     _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(tmpPath));
                     _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(tmpPath));
 
 
-                    _imageEncoder.EncodeImage(originalImagePath, originalImageSize, tmpPath, AutoOrient(options.Item), quality, options, outputFormat);
+                    if (item == null && string.Equals(options.ItemType, typeof(Photo).Name, StringComparison.OrdinalIgnoreCase))
+                    {
+                        item = _libraryManager().GetItemById(options.ItemId);
+                    }
+
+                    var resultPath =_imageEncoder.EncodeImage(originalImagePath, dateModified, tmpPath, AutoOrient(item), quality, options, outputFormat);
+
+                    if (string.Equals(resultPath, originalImagePath, StringComparison.OrdinalIgnoreCase))
+                    {
+                        return new Tuple<string, string, DateTime>(originalImagePath, MimeTypes.GetMimeType(originalImagePath), dateModified);
+                    }
+
                     CopyFile(tmpPath, cacheFilePath);
                     CopyFile(tmpPath, cacheFilePath);
 
 
                     return new Tuple<string, string, DateTime>(tmpPath, GetMimeType(outputFormat, cacheFilePath), _fileSystem.GetLastWriteTimeUtc(tmpPath));
                     return new Tuple<string, string, DateTime>(tmpPath, GetMimeType(outputFormat, cacheFilePath), _fileSystem.GetLastWriteTimeUtc(tmpPath));
@@ -422,24 +437,70 @@ namespace Emby.Drawing
                 throw new ArgumentNullException("path");
                 throw new ArgumentNullException("path");
             }
             }
 
 
-            var name = path + "datemodified=" + imageDateModified.Ticks;
-
             ImageSize size;
             ImageSize size;
 
 
-            var cacheHash = name.GetMD5();
+            var cacheHash = GetImageSizeKey(path, imageDateModified);
 
 
             if (!_cachedImagedSizes.TryGetValue(cacheHash, out size))
             if (!_cachedImagedSizes.TryGetValue(cacheHash, out size))
             {
             {
                 size = GetImageSizeInternal(path, allowSlowMethod);
                 size = GetImageSizeInternal(path, allowSlowMethod);
 
 
-                if (size.Width > 0 && size.Height > 0)
+                SaveImageSize(size, cacheHash, false);
+            }
+
+            return size;
+        }
+
+        public void SaveImageSize(string path, DateTime imageDateModified, ImageSize size)
+        {
+            var cacheHash = GetImageSizeKey(path, imageDateModified);
+            SaveImageSize(size, cacheHash, true);
+        }
+
+        private void SaveImageSize(ImageSize size, Guid cacheHash, bool checkExists)
+        {
+            if (size.Width <= 0 || size.Height <= 0)
+            {
+                return;
+            }
+
+            if (checkExists && _cachedImagedSizes.ContainsKey(cacheHash))
+            {
+                return;
+            }
+
+            if (checkExists)
+            {
+                if (_cachedImagedSizes.TryAdd(cacheHash, size))
                 {
                 {
                     StartSaveImageSizeTimer();
                     StartSaveImageSizeTimer();
-                    _cachedImagedSizes.AddOrUpdate(cacheHash, size, (keyName, oldValue) => size);
                 }
                 }
             }
             }
+            else
+            {
+                StartSaveImageSizeTimer();
+                _cachedImagedSizes.AddOrUpdate(cacheHash, size, (keyName, oldValue) => size);
+            }
+        }
 
 
-            return size;
+        private Guid GetImageSizeKey(string path, DateTime imageDateModified)
+        {
+            var name = path + "datemodified=" + imageDateModified.Ticks;
+            return name.GetMD5();
+        }
+
+        public ImageSize? GetSavedImageSize(string path, DateTime imageDateModified)
+        {
+            ImageSize size;
+
+            var cacheHash = GetImageSizeKey(path, imageDateModified);
+
+            if (_cachedImagedSizes.TryGetValue(cacheHash, out size))
+            {
+                return size;
+            }
+
+            return null;
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -624,7 +685,7 @@ namespace Emby.Drawing
                 var ehnancedImagePath = await GetEnhancedImageInternal(originalImagePath, item, imageType, imageIndex, enhancers, cacheGuid).ConfigureAwait(false);
                 var ehnancedImagePath = await GetEnhancedImageInternal(originalImagePath, item, imageType, imageIndex, enhancers, cacheGuid).ConfigureAwait(false);
 
 
                 // If the path changed update dateModified
                 // If the path changed update dateModified
-                if (!ehnancedImagePath.Equals(originalImagePath, StringComparison.OrdinalIgnoreCase))
+                if (!string.Equals(ehnancedImagePath, originalImagePath, StringComparison.OrdinalIgnoreCase))
                 {
                 {
                     return GetResult(ehnancedImagePath);
                     return GetResult(ehnancedImagePath);
                 }
                 }
@@ -783,7 +844,7 @@ namespace Emby.Drawing
             return Path.Combine(path, filename);
             return Path.Combine(path, filename);
         }
         }
 
 
-        public async Task CreateImageCollage(ImageCollageOptions options)
+        public void CreateImageCollage(ImageCollageOptions options)
         {
         {
             _logger.Info("Creating image collage and saving to {0}", options.OutputPath);
             _logger.Info("Creating image collage and saving to {0}", options.OutputPath);
 
 

+ 1 - 1
Emby.Drawing/NullImageEncoder.cs

@@ -32,7 +32,7 @@ namespace Emby.Drawing
             throw new NotImplementedException();
             throw new NotImplementedException();
         }
         }
 
 
-        public void EncodeImage(string inputPath, ImageSize? originalImageSize, string outputPath, bool autoOrient, int quality, ImageProcessingOptions options, ImageFormat selectedOutputFormat)
+        public string EncodeImage(string inputPath, DateTime dateModified, string outputPath, bool autoOrient, int quality, ImageProcessingOptions options, ImageFormat selectedOutputFormat)
         {
         {
             throw new NotImplementedException();
             throw new NotImplementedException();
         }
         }

+ 2 - 6
Emby.Server.Core/ApplicationHost.cs

@@ -492,7 +492,6 @@ namespace Emby.Server.Core
         {
         {
             var migrations = new List<IVersionMigration>
             var migrations = new List<IVersionMigration>
             {
             {
-                new UpdateLevelMigration(ServerConfigurationManager, this, HttpClient, JsonSerializer, _releaseAssetFilename, Logger)
             };
             };
 
 
             foreach (var task in migrations)
             foreach (var task in migrations)
@@ -589,7 +588,7 @@ namespace Emby.Server.Core
             FileOrganizationRepository = GetFileOrganizationRepository();
             FileOrganizationRepository = GetFileOrganizationRepository();
             RegisterSingleInstance(FileOrganizationRepository);
             RegisterSingleInstance(FileOrganizationRepository);
 
 
-            AuthenticationRepository = await GetAuthenticationRepository().ConfigureAwait(false);
+            AuthenticationRepository = GetAuthenticationRepository();
             RegisterSingleInstance(AuthenticationRepository);
             RegisterSingleInstance(AuthenticationRepository);
 
 
             UserManager = new UserManager(LogManager.GetLogger("UserManager"), ServerConfigurationManager, UserRepository, XmlSerializer, NetworkManager, () => ImageProcessor, () => DtoService, () => ConnectManager, this, JsonSerializer, FileSystemManager, CryptographyProvider, _defaultUserNameFactory());
             UserManager = new UserManager(LogManager.GetLogger("UserManager"), ServerConfigurationManager, UserRepository, XmlSerializer, NetworkManager, () => ImageProcessor, () => DtoService, () => ConnectManager, this, JsonSerializer, FileSystemManager, CryptographyProvider, _defaultUserNameFactory());
@@ -948,7 +947,7 @@ namespace Emby.Server.Core
             return repo;
             return repo;
         }
         }
 
 
-        private async Task<IAuthenticationRepository> GetAuthenticationRepository()
+        private IAuthenticationRepository GetAuthenticationRepository()
         {
         {
             var repo = new AuthenticationRepository(LogManager.GetLogger("AuthenticationRepository"), ServerConfigurationManager.ApplicationPaths);
             var repo = new AuthenticationRepository(LogManager.GetLogger("AuthenticationRepository"), ServerConfigurationManager.ApplicationPaths);
 
 
@@ -1278,9 +1277,6 @@ namespace Emby.Server.Core
             // Emby.Server implementations
             // Emby.Server implementations
             list.Add(GetAssembly(typeof(InstallationManager)));
             list.Add(GetAssembly(typeof(InstallationManager)));
 
 
-            // Emby.Server.Core
-            list.Add(GetAssembly(typeof(ApplicationHost)));
-
             // MediaEncoding
             // MediaEncoding
             list.Add(GetAssembly(typeof(MediaEncoder)));
             list.Add(GetAssembly(typeof(MediaEncoder)));
 
 

+ 1 - 1
MediaBrowser.Server.Startup.Common/ApplicationPathHelper.cs → Emby.Server.Core/ApplicationPathHelper.cs

@@ -2,7 +2,7 @@
 using System.Configuration;
 using System.Configuration;
 using System.IO;
 using System.IO;
 
 
-namespace MediaBrowser.Server.Startup.Common
+namespace Emby.Server.Core
 {
 {
     public static class ApplicationPathHelper
     public static class ApplicationPathHelper
     {
     {

+ 2 - 1
MediaBrowser.Server.Startup.Common/Cryptography/ASN1.cs → Emby.Server.Core/Cryptography/ASN1.cs

@@ -34,7 +34,8 @@ using System.Collections;
 using System.IO;
 using System.IO;
 using System.Text;
 using System.Text;
 
 
-namespace Emby.Common.Implementations.Security {
+namespace Emby.Server.Core.Cryptography
+{
 
 
 	// References:
 	// References:
 	// a.	ITU ASN.1 standards (free download)
 	// a.	ITU ASN.1 standards (free download)

+ 1 - 1
MediaBrowser.Server.Startup.Common/Cryptography/ASN1Convert.cs → Emby.Server.Core/Cryptography/ASN1Convert.cs

@@ -34,7 +34,7 @@ using System.Globalization;
 using System.Security.Cryptography;
 using System.Security.Cryptography;
 using System.Text;
 using System.Text;
 
 
-namespace Emby.Common.Implementations.Security
+namespace Emby.Server.Core.Cryptography
 {
 {
 
 
     // References:
     // References:

+ 1 - 1
MediaBrowser.Server.Startup.Common/Cryptography/BitConverterLE.cs → Emby.Server.Core/Cryptography/BitConverterLE.cs

@@ -29,7 +29,7 @@
 
 
 using System;
 using System;
 
 
-namespace Emby.Common.Implementations.Security
+namespace Emby.Server.Core.Cryptography
 {
 {
     internal sealed class BitConverterLE
     internal sealed class BitConverterLE
 	{
 	{

+ 1 - 1
MediaBrowser.Server.Startup.Common/Cryptography/CertificateGenerator.cs → Emby.Server.Core/Cryptography/CertificateGenerator.cs

@@ -3,7 +3,7 @@ using System;
 using System.Collections;
 using System.Collections;
 using System.Security.Cryptography;
 using System.Security.Cryptography;
 
 
-namespace Emby.Common.Implementations.Security
+namespace Emby.Server.Core.Cryptography
 {
 {
     public class CertificateGenerator
     public class CertificateGenerator
     {
     {

+ 1 - 1
MediaBrowser.Server.Startup.Common/Cryptography/CryptoConvert.cs → Emby.Server.Core/Cryptography/CryptoConvert.cs

@@ -32,7 +32,7 @@ using System.Globalization;
 using System.Security.Cryptography;
 using System.Security.Cryptography;
 using System.Text;
 using System.Text;
 
 
-namespace Emby.Common.Implementations.Security
+namespace Emby.Server.Core.Cryptography
 {
 {
 
 
     public sealed class CryptoConvert {
     public sealed class CryptoConvert {

+ 1 - 1
MediaBrowser.Server.Startup.Common/Cryptography/PKCS1.cs → Emby.Server.Core/Cryptography/PKCS1.cs

@@ -31,7 +31,7 @@
 using System;
 using System;
 using System.Security.Cryptography;
 using System.Security.Cryptography;
 
 
-namespace Emby.Common.Implementations.Security
+namespace Emby.Server.Core.Cryptography
 {
 {
 
 
     // References:
     // References:

+ 1 - 1
MediaBrowser.Server.Startup.Common/Cryptography/PKCS12.cs → Emby.Server.Core/Cryptography/PKCS12.cs

@@ -37,7 +37,7 @@ using System.IO;
 using System.Security.Cryptography;
 using System.Security.Cryptography;
 using System.Text;
 using System.Text;
 
 
-namespace Emby.Common.Implementations.Security
+namespace Emby.Server.Core.Cryptography
 {
 {
 
 
     public class PKCS5 {
     public class PKCS5 {

+ 1 - 1
MediaBrowser.Server.Startup.Common/Cryptography/PKCS7.cs → Emby.Server.Core/Cryptography/PKCS7.cs

@@ -33,7 +33,7 @@ using System;
 using System.Collections;
 using System.Collections;
 using System.Security.Cryptography;
 using System.Security.Cryptography;
 
 
-namespace Emby.Common.Implementations.Security
+namespace Emby.Server.Core.Cryptography
 {
 {
 
 
     public sealed class PKCS7 {
     public sealed class PKCS7 {

+ 1 - 1
MediaBrowser.Server.Startup.Common/Cryptography/PKCS8.cs → Emby.Server.Core/Cryptography/PKCS8.cs

@@ -33,7 +33,7 @@ using System;
 using System.Collections;
 using System.Collections;
 using System.Security.Cryptography;
 using System.Security.Cryptography;
 
 
-namespace Emby.Common.Implementations.Security
+namespace Emby.Server.Core.Cryptography
 {
 {
 
 
     public sealed class PKCS8 {
     public sealed class PKCS8 {

+ 1 - 1
MediaBrowser.Server.Startup.Common/Cryptography/PfxGenerator.cs → Emby.Server.Core/Cryptography/PfxGenerator.cs

@@ -2,7 +2,7 @@
 using System.Collections;
 using System.Collections;
 using System.Security.Cryptography;
 using System.Security.Cryptography;
 
 
-namespace Emby.Common.Implementations.Security
+namespace Emby.Server.Core.Cryptography
 {
 {
     public class PFXGenerator
     public class PFXGenerator
     {
     {

+ 1 - 1
MediaBrowser.Server.Startup.Common/Cryptography/X501Name.cs → Emby.Server.Core/Cryptography/X501Name.cs

@@ -31,7 +31,7 @@ using System;
 using System.Globalization;
 using System.Globalization;
 using System.Text;
 using System.Text;
 
 
-namespace Emby.Common.Implementations.Security
+namespace Emby.Server.Core.Cryptography
 {
 {
 
 
     // References:
     // References:

+ 1 - 1
MediaBrowser.Server.Startup.Common/Cryptography/X509Builder.cs → Emby.Server.Core/Cryptography/X509Builder.cs

@@ -33,7 +33,7 @@ using System;
 using System.Globalization;
 using System.Globalization;
 using System.Security.Cryptography;
 using System.Security.Cryptography;
 
 
-namespace Emby.Common.Implementations.Security
+namespace Emby.Server.Core.Cryptography
 {
 {
 
 
     public abstract class X509Builder {
     public abstract class X509Builder {

+ 1 - 1
MediaBrowser.Server.Startup.Common/Cryptography/X509Certificate.cs → Emby.Server.Core/Cryptography/X509Certificate.cs

@@ -34,7 +34,7 @@ using System.Security.Cryptography;
 using System.Security.Permissions;
 using System.Security.Permissions;
 using System.Text;
 using System.Text;
 
 
-namespace Emby.Common.Implementations.Security
+namespace Emby.Server.Core.Cryptography
 {
 {
 
 
     // References:
     // References:

+ 1 - 1
MediaBrowser.Server.Startup.Common/Cryptography/X509CertificateBuilder.cs → Emby.Server.Core/Cryptography/X509CertificateBuilder.cs

@@ -32,7 +32,7 @@
 using System;
 using System;
 using System.Security.Cryptography;
 using System.Security.Cryptography;
 
 
-namespace Emby.Common.Implementations.Security
+namespace Emby.Server.Core.Cryptography
 {
 {
     // From RFC3280
     // From RFC3280
     /*
     /*

+ 1 - 1
MediaBrowser.Server.Startup.Common/Cryptography/X509CertificateCollection.cs → Emby.Server.Core/Cryptography/X509CertificateCollection.cs

@@ -31,7 +31,7 @@
 using System;
 using System;
 using System.Collections;
 using System.Collections;
 
 
-namespace Emby.Common.Implementations.Security
+namespace Emby.Server.Core.Cryptography
 {
 {
 
 
     [Serializable]
     [Serializable]

+ 1 - 1
MediaBrowser.Server.Startup.Common/Cryptography/X509Extension.cs → Emby.Server.Core/Cryptography/X509Extension.cs

@@ -31,7 +31,7 @@ using System;
 using System.Globalization;
 using System.Globalization;
 using System.Text;
 using System.Text;
 
 
-namespace Emby.Common.Implementations.Security
+namespace Emby.Server.Core.Cryptography
 {
 {
     /*
     /*
 	 * Extension  ::=  SEQUENCE  {
 	 * Extension  ::=  SEQUENCE  {

+ 1 - 1
MediaBrowser.Server.Startup.Common/Cryptography/X509Extensions.cs → Emby.Server.Core/Cryptography/X509Extensions.cs

@@ -32,7 +32,7 @@
 using System;
 using System;
 using System.Collections;
 using System.Collections;
 
 
-namespace Emby.Common.Implementations.Security
+namespace Emby.Server.Core.Cryptography
 {
 {
     /*
     /*
 	 * Extensions  ::=  SEQUENCE SIZE (1..MAX) OF Extension
 	 * Extensions  ::=  SEQUENCE SIZE (1..MAX) OF Extension

+ 1 - 1
MediaBrowser.Server.Startup.Common/Cryptography/X520Attributes.cs → Emby.Server.Core/Cryptography/X520Attributes.cs

@@ -30,7 +30,7 @@
 using System;
 using System;
 using System.Text;
 using System.Text;
 
 
-namespace Emby.Common.Implementations.Security
+namespace Emby.Server.Core.Cryptography
 {
 {
 
 
     // References:
     // References:

+ 76 - 11
MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj → Emby.Server.Core/Emby.Server.Core.csproj

@@ -1,17 +1,16 @@
 <?xml version="1.0" encoding="utf-8"?>
 <?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
   <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
   <PropertyGroup>
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProjectGuid>{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}</ProjectGuid>
+    <ProjectGuid>{776B9F0C-5195-45E3-9A36-1CC1F0D8E0B0}</ProjectGuid>
     <OutputType>Library</OutputType>
     <OutputType>Library</OutputType>
     <AppDesignerFolder>Properties</AppDesignerFolder>
     <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace>MediaBrowser.Server.Startup.Common</RootNamespace>
-    <AssemblyName>MediaBrowser.Server.Startup.Common</AssemblyName>
+    <RootNamespace>Emby.Server.Core</RootNamespace>
+    <AssemblyName>Emby.Server.Core</AssemblyName>
     <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
     <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
     <FileAlignment>512</FileAlignment>
     <FileAlignment>512</FileAlignment>
-    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
     <TargetFrameworkProfile />
     <TargetFrameworkProfile />
   </PropertyGroup>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@@ -25,7 +24,7 @@
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
   </PropertyGroup>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <DebugType>None</DebugType>
+    <DebugType>pdbonly</DebugType>
     <Optimize>true</Optimize>
     <Optimize>true</Optimize>
     <OutputPath>bin\Release\</OutputPath>
     <OutputPath>bin\Release\</OutputPath>
     <DefineConstants>TRACE</DefineConstants>
     <DefineConstants>TRACE</DefineConstants>
@@ -34,13 +33,18 @@
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
   </PropertyGroup>
   </PropertyGroup>
   <ItemGroup>
   <ItemGroup>
-    <Reference Include="Emby.Server.Core">
-      <HintPath>..\ThirdParty\emby\Emby.Server.Core.dll</HintPath>
-    </Reference>
     <Reference Include="Microsoft.IO.RecyclableMemoryStream, Version=1.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
     <Reference Include="Microsoft.IO.RecyclableMemoryStream, Version=1.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
       <HintPath>..\packages\Microsoft.IO.RecyclableMemoryStream.1.2.2\lib\net45\Microsoft.IO.RecyclableMemoryStream.dll</HintPath>
       <HintPath>..\packages\Microsoft.IO.RecyclableMemoryStream.1.2.2\lib\net45\Microsoft.IO.RecyclableMemoryStream.dll</HintPath>
       <Private>True</Private>
       <Private>True</Private>
     </Reference>
     </Reference>
+    <Reference Include="ServiceStack.Text, Version=4.5.8.0, Culture=neutral, processorArchitecture=MSIL">
+      <HintPath>..\packages\ServiceStack.Text.4.5.8\lib\net45\ServiceStack.Text.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
+    <Reference Include="SimpleInjector, Version=4.0.7.0, Culture=neutral, PublicKeyToken=984cb50dea722e99, processorArchitecture=MSIL">
+      <HintPath>..\packages\SimpleInjector.4.0.7\lib\net45\SimpleInjector.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="System" />
     <Reference Include="System.Configuration" />
     <Reference Include="System.Configuration" />
     <Reference Include="System.Core" />
     <Reference Include="System.Core" />
@@ -48,12 +52,14 @@
     <Reference Include="System.Data.DataSetExtensions" />
     <Reference Include="System.Data.DataSetExtensions" />
     <Reference Include="Microsoft.CSharp" />
     <Reference Include="Microsoft.CSharp" />
     <Reference Include="System.Data" />
     <Reference Include="System.Data" />
+    <Reference Include="System.Net.Http" />
     <Reference Include="System.Xml" />
     <Reference Include="System.Xml" />
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <Compile Include="..\SharedVersion.cs">
     <Compile Include="..\SharedVersion.cs">
       <Link>Properties\SharedVersion.cs</Link>
       <Link>Properties\SharedVersion.cs</Link>
     </Compile>
     </Compile>
+    <Compile Include="ApplicationHost.cs" />
     <Compile Include="ApplicationPathHelper.cs" />
     <Compile Include="ApplicationPathHelper.cs" />
     <Compile Include="Cryptography\ASN1.cs" />
     <Compile Include="Cryptography\ASN1.cs" />
     <Compile Include="Cryptography\ASN1Convert.cs" />
     <Compile Include="Cryptography\ASN1Convert.cs" />
@@ -73,16 +79,40 @@
     <Compile Include="Cryptography\X509Extension.cs" />
     <Compile Include="Cryptography\X509Extension.cs" />
     <Compile Include="Cryptography\X509Extensions.cs" />
     <Compile Include="Cryptography\X509Extensions.cs" />
     <Compile Include="Cryptography\X520Attributes.cs" />
     <Compile Include="Cryptography\X520Attributes.cs" />
+    <Compile Include="EntryPoints\ExternalPortForwarding.cs" />
+    <Compile Include="HttpServerFactory.cs" />
+    <Compile Include="IO\LibraryMonitor.cs" />
     <Compile Include="IO\MemoryStreamProvider.cs" />
     <Compile Include="IO\MemoryStreamProvider.cs" />
+    <Compile Include="Localization\TextLocalizer.cs" />
+    <Compile Include="Logging\ConsoleLogger.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="SystemEvents.cs" />
     <Compile Include="SystemEvents.cs" />
-    <Compile Include="UpdateLevelHelper.cs" />
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
+    <ProjectReference Include="..\Emby.Common.Implementations\Emby.Common.Implementations.csproj">
+      <Project>{1e37a338-9f57-4b70-bd6d-bb9c591e319b}</Project>
+      <Name>Emby.Common.Implementations</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\Emby.Dlna\Emby.Dlna.csproj">
+      <Project>{805844ab-e92f-45e6-9d99-4f6d48d129a5}</Project>
+      <Name>Emby.Dlna</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\Emby.Drawing\Emby.Drawing.csproj">
+      <Project>{08fff49b-f175-4807-a2b5-73b0ebd9f716}</Project>
+      <Name>Emby.Drawing</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\Emby.Photos\Emby.Photos.csproj">
+      <Project>{89ab4548-770d-41fd-a891-8daff44f452c}</Project>
+      <Name>Emby.Photos</Name>
+    </ProjectReference>
     <ProjectReference Include="..\Emby.Server.Implementations\Emby.Server.Implementations.csproj">
     <ProjectReference Include="..\Emby.Server.Implementations\Emby.Server.Implementations.csproj">
       <Project>{e383961b-9356-4d5d-8233-9a1079d03055}</Project>
       <Project>{e383961b-9356-4d5d-8233-9a1079d03055}</Project>
       <Name>Emby.Server.Implementations</Name>
       <Name>Emby.Server.Implementations</Name>
     </ProjectReference>
     </ProjectReference>
+    <ProjectReference Include="..\MediaBrowser.Api\MediaBrowser.Api.csproj">
+      <Project>{4fd51ac5-2c16-4308-a993-c3a84f3b4582}</Project>
+      <Name>MediaBrowser.Api</Name>
+    </ProjectReference>
     <ProjectReference Include="..\MediaBrowser.Common\MediaBrowser.Common.csproj">
     <ProjectReference Include="..\MediaBrowser.Common\MediaBrowser.Common.csproj">
       <Project>{9142eefa-7570-41e1-bfcc-468bb571af2f}</Project>
       <Project>{9142eefa-7570-41e1-bfcc-468bb571af2f}</Project>
       <Name>MediaBrowser.Common</Name>
       <Name>MediaBrowser.Common</Name>
@@ -91,16 +121,51 @@
       <Project>{17e1f4e6-8abd-4fe5-9ecf-43d4b6087ba2}</Project>
       <Project>{17e1f4e6-8abd-4fe5-9ecf-43d4b6087ba2}</Project>
       <Name>MediaBrowser.Controller</Name>
       <Name>MediaBrowser.Controller</Name>
     </ProjectReference>
     </ProjectReference>
+    <ProjectReference Include="..\MediaBrowser.LocalMetadata\MediaBrowser.LocalMetadata.csproj">
+      <Project>{7ef9f3e0-697d-42f3-a08f-19deb5f84392}</Project>
+      <Name>MediaBrowser.LocalMetadata</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\MediaBrowser.MediaEncoding\MediaBrowser.MediaEncoding.csproj">
+      <Project>{0bd82fa6-eb8a-4452-8af5-74f9c3849451}</Project>
+      <Name>MediaBrowser.MediaEncoding</Name>
+    </ProjectReference>
     <ProjectReference Include="..\MediaBrowser.Model\MediaBrowser.Model.csproj">
     <ProjectReference Include="..\MediaBrowser.Model\MediaBrowser.Model.csproj">
       <Project>{7eeeb4bb-f3e8-48fc-b4c5-70f0fff8329b}</Project>
       <Project>{7eeeb4bb-f3e8-48fc-b4c5-70f0fff8329b}</Project>
       <Name>MediaBrowser.Model</Name>
       <Name>MediaBrowser.Model</Name>
     </ProjectReference>
     </ProjectReference>
+    <ProjectReference Include="..\MediaBrowser.Providers\MediaBrowser.Providers.csproj">
+      <Project>{442b5058-dcaf-4263-bb6a-f21e31120a1b}</Project>
+      <Name>MediaBrowser.Providers</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\MediaBrowser.Server.Implementations\MediaBrowser.Server.Implementations.csproj">
+      <Project>{2e781478-814d-4a48-9d80-bff206441a65}</Project>
+      <Name>MediaBrowser.Server.Implementations</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\MediaBrowser.WebDashboard\MediaBrowser.WebDashboard.csproj">
+      <Project>{5624b7b5-b5a7-41d8-9f10-cc5611109619}</Project>
+      <Name>MediaBrowser.WebDashboard</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\MediaBrowser.XbmcMetadata\MediaBrowser.XbmcMetadata.csproj">
+      <Project>{23499896-b135-4527-8574-c26e926ea99e}</Project>
+      <Name>MediaBrowser.XbmcMetadata</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\Mono.Nat\Mono.Nat.csproj">
+      <Project>{cb7f2326-6497-4a3d-ba03-48513b17a7be}</Project>
+      <Name>Mono.Nat</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\OpenSubtitlesHandler\OpenSubtitlesHandler.csproj">
+      <Project>{4a4402d4-e910-443b-b8fc-2c18286a2ca0}</Project>
+      <Name>OpenSubtitlesHandler</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\SocketHttpListener\SocketHttpListener.csproj">
+      <Project>{1d74413b-e7cf-455b-b021-f52bdf881542}</Project>
+      <Name>SocketHttpListener</Name>
+    </ProjectReference>
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <None Include="app.config" />
     <None Include="app.config" />
     <None Include="packages.config" />
     <None Include="packages.config" />
   </ItemGroup>
   </ItemGroup>
-  <ItemGroup />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
   <!-- 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.
        Other similar extension points exist, see Microsoft.Common.targets.

+ 0 - 33
Emby.Server.Core/Emby.Server.Core.xproj

@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <PropertyGroup>
-    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
-    <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
-  </PropertyGroup>
-  <Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
-  <PropertyGroup Label="Globals">
-    <ProjectGuid>65aa7d67-8059-40cd-91f1-16d02687226c</ProjectGuid>
-    <RootNamespace>Emby.Server.Core</RootNamespace>
-    <BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
-    <OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
-    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
-  </PropertyGroup>
-  <PropertyGroup>
-    <SchemaVersion>2.0</SchemaVersion>
-  </PropertyGroup>
-  <ItemGroup>
-    <ProjectReference Include="..\Emby.Drawing\Emby.Drawing.csproj" />
-    <ProjectReference Include="..\Emby.Photos\Emby.Photos.csproj" />
-    <ProjectReference Include="..\MediaBrowser.Api\MediaBrowser.Api.csproj" />
-    <ProjectReference Include="..\MediaBrowser.XbmcMetadata\MediaBrowser.XbmcMetadata.csproj" />
-    <ProjectReference Include="..\MediaBrowser.LocalMetadata\MediaBrowser.LocalMetadata.csproj" />
-    <ProjectReference Include="..\MediaBrowser.WebDashboard\MediaBrowser.WebDashboard.csproj" />
-    <ProjectReference Include="..\MediaBrowser.MediaEncoding\MediaBrowser.MediaEncoding.csproj" />
-    <ProjectReference Include="..\Emby.Dlna\Emby.Dlna.csproj" />
-    <ProjectReference Include="..\Emby.Server.Implementations\Emby.Server.Implementations.csproj" />
-    <ProjectReference Include="..\MediaBrowser.Controller\MediaBrowser.Controller.csproj" />
-    <ProjectReference Include="..\MediaBrowser.Common\MediaBrowser.Common.csproj" />
-    <ProjectReference Include="..\MediaBrowser.Model\MediaBrowser.Model.csproj" />
-  </ItemGroup>
-  <Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
-</Project>

+ 14 - 13
Emby.Server.Core/HttpServerFactory.cs

@@ -3,6 +3,7 @@ using System.IO;
 using System.Net.Security;
 using System.Net.Security;
 using System.Net.Sockets;
 using System.Net.Sockets;
 using System.Security.Cryptography.X509Certificates;
 using System.Security.Cryptography.X509Certificates;
+using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using Emby.Common.Implementations.Net;
 using Emby.Common.Implementations.Net;
 using Emby.Server.Implementations.HttpServer;
 using Emby.Server.Implementations.HttpServer;
@@ -33,10 +34,10 @@ namespace Emby.Server.Core
         /// <returns>IHttpServer.</returns>
         /// <returns>IHttpServer.</returns>
         public static IHttpServer CreateServer(IServerApplicationHost applicationHost,
         public static IHttpServer CreateServer(IServerApplicationHost applicationHost,
             ILogManager logManager,
             ILogManager logManager,
-            IServerConfigurationManager config, 
+            IServerConfigurationManager config,
             INetworkManager networkmanager,
             INetworkManager networkmanager,
             IMemoryStreamFactory streamProvider,
             IMemoryStreamFactory streamProvider,
-            string serverName, 
+            string serverName,
             string defaultRedirectpath,
             string defaultRedirectpath,
             ITextEncoding textEncoding,
             ITextEncoding textEncoding,
             ISocketFactory socketFactory,
             ISocketFactory socketFactory,
@@ -51,16 +52,16 @@ namespace Emby.Server.Core
             var logger = logManager.GetLogger("HttpServer");
             var logger = logManager.GetLogger("HttpServer");
 
 
             return new HttpListenerHost(applicationHost,
             return new HttpListenerHost(applicationHost,
-                logger, 
-                config, 
-                serverName, 
-                defaultRedirectpath, 
-                networkmanager, 
-                streamProvider, 
-                textEncoding, 
-                socketFactory, 
-                cryptoProvider, 
-                json, 
+                logger,
+                config,
+                serverName,
+                defaultRedirectpath,
+                networkmanager,
+                streamProvider,
+                textEncoding,
+                socketFactory,
+                cryptoProvider,
+                json,
                 xml,
                 xml,
                 environment,
                 environment,
                 certificate,
                 certificate,
@@ -82,7 +83,7 @@ namespace Emby.Server.Core
         {
         {
             var netSocket = (NetAcceptSocket)acceptSocket;
             var netSocket = (NetAcceptSocket)acceptSocket;
 
 
-            return new NetworkStream(netSocket.Socket, ownsSocket);
+            return new SocketStream(netSocket.Socket, ownsSocket);
         }
         }
 
 
         public Task AuthenticateSslStreamAsServer(Stream stream, ICertificate certificate)
         public Task AuthenticateSslStreamAsServer(Stream stream, ICertificate certificate)

+ 1 - 1
MediaBrowser.Server.Startup.Common/IO/MemoryStreamProvider.cs → Emby.Server.Core/IO/MemoryStreamProvider.cs

@@ -2,7 +2,7 @@
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 using Microsoft.IO;
 using Microsoft.IO;
 
 
-namespace MediaBrowser.Server.Startup.Common.IO
+namespace Emby.Server.Core.IO
 {
 {
     public class RecyclableMemoryStreamProvider : IMemoryStreamFactory
     public class RecyclableMemoryStreamProvider : IMemoryStreamFactory
     {
     {

+ 19 - 4
Emby.Server.Core/Properties/AssemblyInfo.cs

@@ -2,18 +2,33 @@
 using System.Runtime.CompilerServices;
 using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 using System.Runtime.InteropServices;
 
 
-// General Information about an assembly is controlled through the following
+// General Information about an assembly is controlled through the following 
 // set of attributes. Change these attribute values to modify the information
 // set of attributes. Change these attribute values to modify the information
 // associated with an assembly.
 // associated with an assembly.
+[assembly: AssemblyTitle("Emby.Server.Core")]
+[assembly: AssemblyDescription("")]
 [assembly: AssemblyConfiguration("")]
 [assembly: AssemblyConfiguration("")]
 [assembly: AssemblyCompany("")]
 [assembly: AssemblyCompany("")]
 [assembly: AssemblyProduct("Emby.Server.Core")]
 [assembly: AssemblyProduct("Emby.Server.Core")]
+[assembly: AssemblyCopyright("Copyright ©  2017")]
 [assembly: AssemblyTrademark("")]
 [assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
 
 
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components.  If you need to access a type in this assembly from
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
 // COM, set the ComVisible attribute to true on that type.
 // COM, set the ComVisible attribute to true on that type.
 [assembly: ComVisible(false)]
 [assembly: ComVisible(false)]
 
 
 // The following GUID is for the ID of the typelib if this project is exposed to COM
 // The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("65aa7d67-8059-40cd-91f1-16d02687226c")]
+[assembly: Guid("776b9f0c-5195-45e3-9a36-1cc1f0d8e0b0")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]

+ 0 - 0
MediaBrowser.Server.Startup.Common/SystemEvents.cs → Emby.Server.Core/SystemEvents.cs


+ 11 - 0
Emby.Server.Core/app.config

@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+  <runtime>
+    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+      <dependentAssembly>
+        <assemblyIdentity name="SimpleInjector" publicKeyToken="984cb50dea722e99" culture="neutral"/>
+        <bindingRedirect oldVersion="0.0.0.0-4.0.7.0" newVersion="4.0.7.0"/>
+      </dependentAssembly>
+    </assemblyBinding>
+  </runtime>
+<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/></startup></configuration>

+ 6 - 0
Emby.Server.Core/packages.config

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="Microsoft.IO.RecyclableMemoryStream" version="1.2.2" targetFramework="net462" />
+  <package id="ServiceStack.Text" version="4.5.8" targetFramework="net462" />
+  <package id="SimpleInjector" version="4.0.7" targetFramework="net462" />
+</packages>

+ 0 - 125
Emby.Server.Core/project.json

@@ -1,125 +0,0 @@
-{
-  "version": "1.0.0-*",
-
-  "dependencies": {
-
-  },
-
-  "frameworks": {
-    "net46": {
-      "frameworkAssemblies": {
-        "System.Runtime": "4.0.0"
-      },
-      "dependencies": {
-        "MediaBrowser.Model": {
-          "target": "project"
-        },
-        "MediaBrowser.Common": {
-          "target": "project"
-        },
-        "MediaBrowser.Controller": {
-          "target": "project"
-        },
-        "Emby.Common.Implementations": {
-          "target": "project"
-        },
-        "Mono.Nat": {
-          "target": "project"
-        },
-        "Emby.Server.Implementations": {
-          "target": "project"
-        },
-        "MediaBrowser.Server.Implementations": {
-          "target": "project"
-        },
-        "Emby.Dlna": {
-          "target": "project"
-        },
-        "Emby.Photos": {
-          "target": "project"
-        },
-        "MediaBrowser.Api": {
-          "target": "project"
-        },
-        "MediaBrowser.MediaEncoding": {
-          "target": "project"
-        },
-        "MediaBrowser.XbmcMetadata": {
-          "target": "project"
-        },
-        "MediaBrowser.LocalMetadata": {
-          "target": "project"
-        },
-        "MediaBrowser.WebDashboard": {
-          "target": "project"
-        },
-        "Emby.Drawing": {
-          "target": "project"
-        },
-        "SocketHttpListener.Portable": {
-          "target": "project"
-        }
-      }
-    },
-    "netstandard1.6": {
-      "imports": "dnxcore50",
-      "dependencies": {
-        "NETStandard.Library": "1.6.1",
-        "System.AppDomain": "2.0.11",
-        "System.Globalization.Extensions": "4.3.0",
-        "System.IO.FileSystem.Watcher": "4.3.0",
-        "System.Net.Security": "4.3.1",
-        "System.Security.Cryptography.X509Certificates": "4.3.0",
-        "System.Runtime.Extensions": "4.3.0",
-        "MediaBrowser.Model": {
-          "target": "project"
-        },
-        "MediaBrowser.Common": {
-          "target": "project"
-        },
-        "MediaBrowser.Controller": {
-          "target": "project"
-        },
-        "Emby.Common.Implementations": {
-          "target": "project"
-        },
-        "Mono.Nat": {
-          "target": "project"
-        },
-        "Emby.Server.Implementations": {
-          "target": "project"
-        },
-        "MediaBrowser.Server.Implementations": {
-          "target": "project"
-        },
-        "Emby.Dlna": {
-          "target": "project"
-        },
-        "Emby.Photos": {
-          "target": "project"
-        },
-        "MediaBrowser.Api": {
-          "target": "project"
-        },
-        "MediaBrowser.MediaEncoding": {
-          "target": "project"
-        },
-        "MediaBrowser.XbmcMetadata": {
-          "target": "project"
-        },
-        "MediaBrowser.LocalMetadata": {
-          "target": "project"
-        },
-        "MediaBrowser.WebDashboard": {
-          "target": "project"
-        },
-        "Emby.Drawing": {
-          "target": "project"
-        },
-        "SocketHttpListener.Portable": {
-          "target": "project"
-        }
-      }
-    }
-  }
-}

+ 8 - 8
Emby.Server.Implementations/Channels/ChannelManager.cs

@@ -23,7 +23,7 @@ using System.Linq;
 using System.Net;
 using System.Net;
 using System.Threading;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
-using MediaBrowser.Common.IO;
+
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Controller.Entities.Audio;
 using MediaBrowser.Controller.Entities.Audio;
 using MediaBrowser.Controller.Entities.Movies;
 using MediaBrowser.Controller.Entities.Movies;
@@ -120,7 +120,7 @@ namespace Emby.Server.Implementations.Channels
             if (query.IsFavorite.HasValue)
             if (query.IsFavorite.HasValue)
             {
             {
                 var val = query.IsFavorite.Value;
                 var val = query.IsFavorite.Value;
-                channels = channels.Where(i => _userDataManager.GetUserData(user,  i).IsFavorite == val)
+                channels = channels.Where(i => _userDataManager.GetUserData(user, i).IsFavorite == val)
                     .ToList();
                     .ToList();
             }
             }
 
 
@@ -263,7 +263,7 @@ namespace Emby.Server.Implementations.Channels
                 }
                 }
                 catch
                 catch
                 {
                 {
-                    
+
                 }
                 }
                 return;
                 return;
             }
             }
@@ -273,7 +273,7 @@ namespace Emby.Server.Implementations.Channels
             _jsonSerializer.SerializeToFile(mediaSources, path);
             _jsonSerializer.SerializeToFile(mediaSources, path);
         }
         }
 
 
-        public async Task<IEnumerable<MediaSourceInfo>> GetStaticMediaSources(BaseItem item, CancellationToken cancellationToken)
+        public IEnumerable<MediaSourceInfo> GetStaticMediaSources(BaseItem item, CancellationToken cancellationToken)
         {
         {
             IEnumerable<ChannelMediaInfo> results = GetSavedMediaSources(item);
             IEnumerable<ChannelMediaInfo> results = GetSavedMediaSources(item);
 
 
@@ -460,12 +460,12 @@ namespace Emby.Server.Implementations.Channels
 
 
         public IEnumerable<ChannelFeatures> GetAllChannelFeatures()
         public IEnumerable<ChannelFeatures> GetAllChannelFeatures()
         {
         {
-            return _libraryManager.GetItemList(new InternalItemsQuery
+            return _libraryManager.GetItemIds(new InternalItemsQuery
             {
             {
                 IncludeItemTypes = new[] { typeof(Channel).Name },
                 IncludeItemTypes = new[] { typeof(Channel).Name },
                 SortBy = new[] { ItemSortBy.SortName }
                 SortBy = new[] { ItemSortBy.SortName }
 
 
-            }).Select(i => GetChannelFeatures(i.Id.ToString("N")));
+            }).Select(i => GetChannelFeatures(i.ToString("N")));
         }
         }
 
 
         public ChannelFeatures GetChannelFeatures(string id)
         public ChannelFeatures GetChannelFeatures(string id)
@@ -963,7 +963,7 @@ namespace Emby.Server.Implementations.Channels
                 }
                 }
             }
             }
 
 
-            return await GetReturnItems(internalItems, providerTotalRecordCount, user, query).ConfigureAwait(false);
+            return GetReturnItems(internalItems, providerTotalRecordCount, user, query);
         }
         }
 
 
         public async Task<QueryResult<BaseItemDto>> GetChannelItems(ChannelItemQuery query, CancellationToken cancellationToken)
         public async Task<QueryResult<BaseItemDto>> GetChannelItems(ChannelItemQuery query, CancellationToken cancellationToken)
@@ -1154,7 +1154,7 @@ namespace Emby.Server.Implementations.Channels
                 filename + ".json");
                 filename + ".json");
         }
         }
 
 
-        private async Task<QueryResult<BaseItem>> GetReturnItems(IEnumerable<BaseItem> items,
+        private QueryResult<BaseItem> GetReturnItems(IEnumerable<BaseItem> items,
             int? totalCountFromProvider,
             int? totalCountFromProvider,
             User user,
             User user,
             ChannelItemQuery query)
             ChannelItemQuery query)

+ 3 - 3
Emby.Server.Implementations/Collections/CollectionImageProvider.cs

@@ -32,7 +32,7 @@ namespace Emby.Server.Implementations.Collections
             return base.Supports(item);
             return base.Supports(item);
         }
         }
 
 
-        protected override Task<List<BaseItem>> GetItemsWithImages(IHasImages item)
+        protected override List<BaseItem> GetItemsWithImages(IHasImages item)
         {
         {
             var playlist = (BoxSet)item;
             var playlist = (BoxSet)item;
 
 
@@ -73,10 +73,10 @@ namespace Emby.Server.Implementations.Collections
                 .DistinctBy(i => i.Id)
                 .DistinctBy(i => i.Id)
                 .ToList();
                 .ToList();
 
 
-            return Task.FromResult(GetFinalItems(items, 2));
+            return GetFinalItems(items, 2);
         }
         }
 
 
-        protected override Task<string> CreateImage(IHasImages item, List<BaseItem> itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex)
+        protected override string CreateImage(IHasImages item, List<BaseItem> itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex)
         {
         {
             return CreateSingleImage(itemsWithImages, outputPathWithoutExtension, ImageType.Primary);
             return CreateSingleImage(itemsWithImages, outputPathWithoutExtension, ImageType.Primary);
         }
         }

+ 5 - 0
Emby.Server.Implementations/Collections/CollectionManager.cs

@@ -170,6 +170,11 @@ namespace Emby.Server.Implementations.Collections
             {
             {
                 var item = _libraryManager.GetItemById(itemId);
                 var item = _libraryManager.GetItemById(itemId);
 
 
+                if (string.IsNullOrWhiteSpace(item.Path))
+                {
+                    continue;
+                }
+
                 if (item == null)
                 if (item == null)
                 {
                 {
                     throw new ArgumentException("No item exists with the supplied Id");
                     throw new ArgumentException("No item exists with the supplied Id");

+ 1 - 1
Emby.Server.Implementations/Collections/CollectionsDynamicFolder.cs

@@ -1,7 +1,7 @@
 using MediaBrowser.Common.Configuration;
 using MediaBrowser.Common.Configuration;
 using MediaBrowser.Controller.Entities;
 using MediaBrowser.Controller.Entities;
 using System.IO;
 using System.IO;
-using MediaBrowser.Common.IO;
+
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Controller.Collections;
 using MediaBrowser.Controller.Collections;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 473 - 161
Emby.Server.Implementations/Data/SqliteItemRepository.cs


+ 1 - 1
Emby.Server.Implementations/Devices/CameraUploadsDynamicFolder.cs

@@ -5,7 +5,7 @@ using System.IO;
 using System.Linq;
 using System.Linq;
 using System.Threading;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
-using MediaBrowser.Common.IO;
+
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Controller.Providers;
 using MediaBrowser.Controller.Providers;

+ 0 - 1
Emby.Server.Implementations/Devices/DeviceManager.cs

@@ -16,7 +16,6 @@ using System.Collections.Generic;
 using System.IO;
 using System.IO;
 using System.Linq;
 using System.Linq;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
-using MediaBrowser.Common.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Controller.Configuration;
 using MediaBrowser.Controller.Configuration;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;

+ 84 - 65
Emby.Server.Implementations/Dto/DtoService.cs

@@ -24,7 +24,7 @@ using System.Collections.Generic;
 using System.IO;
 using System.IO;
 using System.Linq;
 using System.Linq;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
-using MediaBrowser.Common.IO;
+
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.Extensions;
 using MediaBrowser.Model.Extensions;
@@ -107,7 +107,7 @@ namespace Emby.Server.Implementations.Dto
 
 
             foreach (var item in items)
             foreach (var item in items)
             {
             {
-                var dto = await GetBaseItemDtoInternal(item, options, user, owner).ConfigureAwait(false);
+                var dto = GetBaseItemDtoInternal(item, options, user, owner);
 
 
                 var tvChannel = item as LiveTvChannel;
                 var tvChannel = item as LiveTvChannel;
                 if (tvChannel != null)
                 if (tvChannel != null)
@@ -127,7 +127,11 @@ namespace Emby.Server.Implementations.Dto
                     {
                     {
                         var libraryItems = byName.GetTaggedItems(new InternalItemsQuery(user)
                         var libraryItems = byName.GetTaggedItems(new InternalItemsQuery(user)
                         {
                         {
-                            Recursive = true
+                            Recursive = true,
+                            DtoOptions = new DtoOptions(false)
+                            {
+                                EnableImages = false
+                            }
                         });
                         });
 
 
                         SetItemByNameInfo(item, dto, libraryItems.ToList(), user);
                         SetItemByNameInfo(item, dto, libraryItems.ToList(), user);
@@ -156,7 +160,7 @@ namespace Emby.Server.Implementations.Dto
         {
         {
             var syncDictionary = GetSyncedItemProgress(options);
             var syncDictionary = GetSyncedItemProgress(options);
 
 
-            var dto = GetBaseItemDtoInternal(item, options, user, owner).Result;
+            var dto = GetBaseItemDtoInternal(item, options, user, owner);
             var tvChannel = item as LiveTvChannel;
             var tvChannel = item as LiveTvChannel;
             if (tvChannel != null)
             if (tvChannel != null)
             {
             {
@@ -177,7 +181,11 @@ namespace Emby.Server.Implementations.Dto
             {
             {
                 if (options.Fields.Contains(ItemFields.ItemCounts))
                 if (options.Fields.Contains(ItemFields.ItemCounts))
                 {
                 {
-                    SetItemByNameInfo(item, dto, GetTaggedItems(byName, user), user);
+                    SetItemByNameInfo(item, dto, GetTaggedItems(byName, user, new DtoOptions(false)
+                    {
+                        EnableImages = false
+
+                    }), user);
                 }
                 }
 
 
                 FillSyncInfo(dto, item, options, user, syncDictionary);
                 FillSyncInfo(dto, item, options, user, syncDictionary);
@@ -189,11 +197,12 @@ namespace Emby.Server.Implementations.Dto
             return dto;
             return dto;
         }
         }
 
 
-        private List<BaseItem> GetTaggedItems(IItemByName byName, User user)
+        private List<BaseItem> GetTaggedItems(IItemByName byName, User user, DtoOptions options)
         {
         {
             var items = byName.GetTaggedItems(new InternalItemsQuery(user)
             var items = byName.GetTaggedItems(new InternalItemsQuery(user)
             {
             {
-                Recursive = true
+                Recursive = true,
+                DtoOptions = options
 
 
             }).ToList();
             }).ToList();
 
 
@@ -283,7 +292,7 @@ namespace Emby.Server.Implementations.Dto
             }
             }
         }
         }
 
 
-        private async Task<BaseItemDto> GetBaseItemDtoInternal(BaseItem item, DtoOptions options, User user = null, BaseItem owner = null)
+        private BaseItemDto GetBaseItemDtoInternal(BaseItem item, DtoOptions options, User user = null, BaseItem owner = null)
         {
         {
             var fields = options.Fields;
             var fields = options.Fields;
 
 
@@ -332,7 +341,7 @@ namespace Emby.Server.Implementations.Dto
 
 
             if (user != null)
             if (user != null)
             {
             {
-                await AttachUserSpecificInfo(dto, item, user, options).ConfigureAwait(false);
+                AttachUserSpecificInfo(dto, item, user, options);
             }
             }
 
 
             var hasMediaSources = item as IHasMediaSources;
             var hasMediaSources = item as IHasMediaSources;
@@ -393,7 +402,7 @@ namespace Emby.Server.Implementations.Dto
 
 
         public BaseItemDto GetItemByNameDto(BaseItem item, DtoOptions options, List<BaseItem> taggedItems, Dictionary<string, SyncedItemProgress> syncProgress, User user = null)
         public BaseItemDto GetItemByNameDto(BaseItem item, DtoOptions options, List<BaseItem> taggedItems, Dictionary<string, SyncedItemProgress> syncProgress, User user = null)
         {
         {
-            var dto = GetBaseItemDtoInternal(item, options, user).Result;
+            var dto = GetBaseItemDtoInternal(item, options, user);
 
 
             if (taggedItems != null && options.Fields.Contains(ItemFields.ItemCounts))
             if (taggedItems != null && options.Fields.Contains(ItemFields.ItemCounts))
             {
             {
@@ -446,7 +455,7 @@ namespace Emby.Server.Implementations.Dto
         /// <summary>
         /// <summary>
         /// Attaches the user specific info.
         /// Attaches the user specific info.
         /// </summary>
         /// </summary>
-        private async Task AttachUserSpecificInfo(BaseItemDto dto, BaseItem item, User user, DtoOptions dtoOptions)
+        private void AttachUserSpecificInfo(BaseItemDto dto, BaseItem item, User user, DtoOptions dtoOptions)
         {
         {
             var fields = dtoOptions.Fields;
             var fields = dtoOptions.Fields;
 
 
@@ -456,7 +465,7 @@ namespace Emby.Server.Implementations.Dto
 
 
                 if (dtoOptions.EnableUserData)
                 if (dtoOptions.EnableUserData)
                 {
                 {
-                    dto.UserData = await _userDataRepository.GetUserDataDto(item, dto, user, dtoOptions.Fields).ConfigureAwait(false);
+                    dto.UserData = _userDataRepository.GetUserDataDto(item, dto, user, dtoOptions.Fields);
                 }
                 }
 
 
                 if (!dto.ChildCount.HasValue && item.SourceType == SourceType.Library)
                 if (!dto.ChildCount.HasValue && item.SourceType == SourceType.Library)
@@ -488,7 +497,7 @@ namespace Emby.Server.Implementations.Dto
             {
             {
                 if (dtoOptions.EnableUserData)
                 if (dtoOptions.EnableUserData)
                 {
                 {
-                    dto.UserData = await _userDataRepository.GetUserDataDto(item, user).ConfigureAwait(false);
+                    dto.UserData = _userDataRepository.GetUserDataDto(item, user);
                 }
                 }
             }
             }
 
 
@@ -595,16 +604,17 @@ namespace Emby.Server.Implementations.Dto
         {
         {
             if (!string.IsNullOrEmpty(item.Album))
             if (!string.IsNullOrEmpty(item.Album))
             {
             {
-                var parentAlbum = _libraryManager.GetItemList(new InternalItemsQuery
+                var parentAlbumIds = _libraryManager.GetItemIds(new InternalItemsQuery
                 {
                 {
                     IncludeItemTypes = new[] { typeof(MusicAlbum).Name },
                     IncludeItemTypes = new[] { typeof(MusicAlbum).Name },
-                    Name = item.Album
+                    Name = item.Album,
+                    Limit = 1
 
 
-                }).FirstOrDefault();
+                });
 
 
-                if (parentAlbum != null)
+                if (parentAlbumIds.Count > 0)
                 {
                 {
-                    dto.AlbumId = GetDtoId(parentAlbum);
+                    dto.AlbumId = parentAlbumIds[0].ToString("N");
                 }
                 }
             }
             }
 
 
@@ -751,45 +761,41 @@ namespace Emby.Server.Implementations.Dto
         /// <returns>Task.</returns>
         /// <returns>Task.</returns>
         private void AttachStudios(BaseItemDto dto, BaseItem item)
         private void AttachStudios(BaseItemDto dto, BaseItem item)
         {
         {
-            var studios = item.Studios.ToList();
-
-            dto.Studios = new StudioDto[studios.Count];
-
-            var dictionary = studios.Distinct(StringComparer.OrdinalIgnoreCase).Select(name =>
-            {
-                try
-                {
-                    return _libraryManager.GetStudio(name);
-                }
-                catch (IOException ex)
+            dto.Studios = item.Studios
+                .Where(i => !string.IsNullOrWhiteSpace(i))
+                .Select(i => new NameIdPair
                 {
                 {
-                    _logger.ErrorException("Error getting studio {0}", ex, name);
-                    return null;
-                }
-            })
-            .Where(i => i != null)
-            .DistinctBy(i => i.Name, StringComparer.OrdinalIgnoreCase)
-            .ToDictionary(i => i.Name, StringComparer.OrdinalIgnoreCase);
-
-            for (var i = 0; i < studios.Count; i++)
-            {
-                var studio = studios[i];
+                    Name = i,
+                    Id = _libraryManager.GetStudioId(i).ToString("N")
+                })
+                .ToArray();
+        }
 
 
-                var studioDto = new StudioDto
+        private void AttachGenreItems(BaseItemDto dto, BaseItem item)
+        {
+            dto.GenreItems = item.Genres
+                .Where(i => !string.IsNullOrWhiteSpace(i))
+                .Select(i => new NameIdPair
                 {
                 {
-                    Name = studio
-                };
-
-                Studio entity;
+                    Name = i,
+                    Id = GetStudioId(i, item)
+                })
+                .ToArray();
+        }
 
 
-                if (dictionary.TryGetValue(studio, out entity))
-                {
-                    studioDto.Id = entity.Id.ToString("N");
-                    studioDto.PrimaryImageTag = GetImageCacheTag(entity, ImageType.Primary);
-                }
+        private string GetStudioId(string name, BaseItem owner)
+        {
+            if (owner is IHasMusicGenres)
+            {
+                return _libraryManager.GetGameGenreId(name).ToString("N");
+            }
 
 
-                dto.Studios[i] = studioDto;
+            if (owner is Game || owner is GameSystem)
+            {
+                return _libraryManager.GetGameGenreId(name).ToString("N");
             }
             }
+
+            return _libraryManager.GetGenreId(name).ToString("N");
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -901,6 +907,7 @@ namespace Emby.Server.Implementations.Dto
             if (fields.Contains(ItemFields.Genres))
             if (fields.Contains(ItemFields.Genres))
             {
             {
                 dto.Genres = item.Genres;
                 dto.Genres = item.Genres;
+                AttachGenreItems(dto, item);
             }
             }
 
 
             if (options.EnableImages)
             if (options.EnableImages)
@@ -1130,7 +1137,10 @@ namespace Emby.Server.Implementations.Dto
                             return null;
                             return null;
                         }
                         }
 
 
-                        var artist = _libraryManager.GetArtist(i);
+                        var artist = _libraryManager.GetArtist(i, new DtoOptions(false)
+                        {
+                            EnableImages = false
+                        });
                         if (artist != null)
                         if (artist != null)
                         {
                         {
                             return new NameIdPair
                             return new NameIdPair
@@ -1179,7 +1189,10 @@ namespace Emby.Server.Implementations.Dto
                             return null;
                             return null;
                         }
                         }
 
 
-                        var artist = _libraryManager.GetArtist(i);
+                        var artist = _libraryManager.GetArtist(i, new DtoOptions(false)
+                        {
+                            EnableImages = false
+                        });
                         if (artist != null)
                         if (artist != null)
                         {
                         {
                             return new NameIdPair
                             return new NameIdPair
@@ -1449,7 +1462,7 @@ namespace Emby.Server.Implementations.Dto
             var musicAlbum = item as MusicAlbum;
             var musicAlbum = item as MusicAlbum;
             if (musicAlbum != null)
             if (musicAlbum != null)
             {
             {
-                var artist = musicAlbum.MusicArtist;
+                var artist = musicAlbum.GetMusicArtist(new DtoOptions(false));
                 if (artist != null)
                 if (artist != null)
                 {
                 {
                     return artist;
                     return artist;
@@ -1582,24 +1595,30 @@ namespace Emby.Server.Implementations.Dto
 
 
             ImageSize size;
             ImageSize size;
 
 
-            if (supportedEnhancers.Count == 0)
-            {
-                var defaultAspectRatio = item.GetDefaultPrimaryImageAspectRatio();
+            var defaultAspectRatio = item.GetDefaultPrimaryImageAspectRatio();
 
 
-                if (defaultAspectRatio.HasValue)
+            if (defaultAspectRatio.HasValue)
+            {
+                if (supportedEnhancers.Count == 0)
                 {
                 {
                     return defaultAspectRatio.Value;
                     return defaultAspectRatio.Value;
                 }
                 }
-            }
 
 
-            try
-            {
-                size = _imageProcessor.GetImageSize(imageInfo);
+                double dummyWidth = 200;
+                double dummyHeight = dummyWidth / defaultAspectRatio.Value;
+                size = new ImageSize(dummyWidth, dummyHeight);
             }
             }
-            catch
+            else
             {
             {
-                //_logger.ErrorException("Failed to determine primary image aspect ratio for {0}", ex, path);
-                return null;
+                try
+                {
+                    size = _imageProcessor.GetImageSize(imageInfo);
+                }
+                catch
+                {
+                    //_logger.ErrorException("Failed to determine primary image aspect ratio for {0}", ex, path);
+                    return null;
+                }
             }
             }
 
 
             foreach (var enhancer in supportedEnhancers)
             foreach (var enhancer in supportedEnhancers)

+ 18 - 8
Emby.Server.Implementations/Emby.Server.Implementations.csproj

@@ -10,9 +10,8 @@
     <RootNamespace>Emby.Server.Implementations</RootNamespace>
     <RootNamespace>Emby.Server.Implementations</RootNamespace>
     <AssemblyName>Emby.Server.Implementations</AssemblyName>
     <AssemblyName>Emby.Server.Implementations</AssemblyName>
     <FileAlignment>512</FileAlignment>
     <FileAlignment>512</FileAlignment>
-    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
-    <TargetFrameworkProfile>Profile7</TargetFrameworkProfile>
-    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <TargetFrameworkProfile />
+    <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
   </PropertyGroup>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugSymbols>true</DebugSymbols>
     <DebugSymbols>true</DebugSymbols>
@@ -103,6 +102,7 @@
     <Compile Include="HttpServer\SocketSharp\WebSocketSharpResponse.cs" />
     <Compile Include="HttpServer\SocketSharp\WebSocketSharpResponse.cs" />
     <Compile Include="HttpServer\StreamWriter.cs" />
     <Compile Include="HttpServer\StreamWriter.cs" />
     <Compile Include="Images\BaseDynamicImageProvider.cs" />
     <Compile Include="Images\BaseDynamicImageProvider.cs" />
+    <Compile Include="IO\AsyncStreamCopier.cs" />
     <Compile Include="IO\FileRefresher.cs" />
     <Compile Include="IO\FileRefresher.cs" />
     <Compile Include="IO\MbLinkShortcutHandler.cs" />
     <Compile Include="IO\MbLinkShortcutHandler.cs" />
     <Compile Include="IO\ThrottledStream.cs" />
     <Compile Include="IO\ThrottledStream.cs" />
@@ -182,7 +182,6 @@
     <Compile Include="Migrations\IVersionMigration.cs" />
     <Compile Include="Migrations\IVersionMigration.cs" />
     <Compile Include="Migrations\LibraryScanMigration.cs" />
     <Compile Include="Migrations\LibraryScanMigration.cs" />
     <Compile Include="Migrations\GuideMigration.cs" />
     <Compile Include="Migrations\GuideMigration.cs" />
-    <Compile Include="Migrations\UpdateLevelMigration.cs" />
     <Compile Include="News\NewsEntryPoint.cs" />
     <Compile Include="News\NewsEntryPoint.cs" />
     <Compile Include="News\NewsService.cs" />
     <Compile Include="News\NewsService.cs" />
     <Compile Include="Notifications\CoreNotificationTypes.cs" />
     <Compile Include="Notifications\CoreNotificationTypes.cs" />
@@ -291,9 +290,9 @@
       <Project>{2e781478-814d-4a48-9d80-bff206441a65}</Project>
       <Project>{2e781478-814d-4a48-9d80-bff206441a65}</Project>
       <Name>MediaBrowser.Server.Implementations</Name>
       <Name>MediaBrowser.Server.Implementations</Name>
     </ProjectReference>
     </ProjectReference>
-    <ProjectReference Include="..\SocketHttpListener.Portable\SocketHttpListener.Portable.csproj">
-      <Project>{4f26d5d8-a7b0-42b3-ba42-7cb7d245934e}</Project>
-      <Name>SocketHttpListener.Portable</Name>
+    <ProjectReference Include="..\SocketHttpListener\SocketHttpListener.csproj">
+      <Project>{1d74413b-e7cf-455b-b021-f52bdf881542}</Project>
+      <Name>SocketHttpListener</Name>
     </ProjectReference>
     </ProjectReference>
     <Reference Include="Emby.XmlTv, Version=1.0.6299.28292, Culture=neutral, processorArchitecture=MSIL">
     <Reference Include="Emby.XmlTv, Version=1.0.6299.28292, Culture=neutral, processorArchitecture=MSIL">
       <HintPath>..\packages\Emby.XmlTv.1.0.8\lib\portable-net45+win8\Emby.XmlTv.dll</HintPath>
       <HintPath>..\packages\Emby.XmlTv.1.0.8\lib\portable-net45+win8\Emby.XmlTv.dll</HintPath>
@@ -312,6 +311,17 @@
       <Private>True</Private>
       <Private>True</Private>
     </Reference>
     </Reference>
   </ItemGroup>
   </ItemGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Runtime.Serialization" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Net.Http" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <EmbeddedResource Include="Localization\Core\ar.json" />
     <EmbeddedResource Include="Localization\Core\ar.json" />
     <EmbeddedResource Include="Localization\Core\bg-BG.json" />
     <EmbeddedResource Include="Localization\Core\bg-BG.json" />
@@ -410,7 +420,7 @@
   <ItemGroup>
   <ItemGroup>
     <EmbeddedResource Include="Localization\Ratings\uk.txt" />
     <EmbeddedResource Include="Localization\Ratings\uk.txt" />
   </ItemGroup>
   </ItemGroup>
-  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
   <!-- 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.
        Other similar extension points exist, see Microsoft.Common.targets.
   <Target Name="BeforeBuild">
   <Target Name="BeforeBuild">

+ 1 - 1
Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs

@@ -122,7 +122,7 @@ namespace Emby.Server.Implementations.EntryPoints
                         .DistinctBy(i => i.Id)
                         .DistinctBy(i => i.Id)
                         .Select(i =>
                         .Select(i =>
                         {
                         {
-                            var dto = _userDataManager.GetUserDataDto(i, user).Result;
+                            var dto = _userDataManager.GetUserDataDto(i, user);
                             dto.ItemId = i.Id.ToString("N");
                             dto.ItemId = i.Id.ToString("N");
                             return dto;
                             return dto;
                         })
                         })

+ 5 - 3
Emby.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs

@@ -15,7 +15,7 @@ using System.Linq;
 using System.Threading;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using Emby.Server.Implementations.Library;
 using Emby.Server.Implementations.Library;
-using MediaBrowser.Common.IO;
+using MediaBrowser.Controller.Dto;
 using MediaBrowser.Controller.Entities;
 using MediaBrowser.Controller.Entities;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
@@ -588,7 +588,8 @@ namespace Emby.Server.Implementations.FileOrganization
             var series = _libraryManager.GetItemList(new InternalItemsQuery
             var series = _libraryManager.GetItemList(new InternalItemsQuery
             {
             {
                 IncludeItemTypes = new[] { typeof(Series).Name },
                 IncludeItemTypes = new[] { typeof(Series).Name },
-                Recursive = true
+                Recursive = true,
+                DtoOptions = new DtoOptions(true)
             })
             })
                 .Cast<Series>()
                 .Cast<Series>()
                 .Select(i => NameUtils.GetMatchScore(nameWithoutYear, yearInName, i))
                 .Select(i => NameUtils.GetMatchScore(nameWithoutYear, yearInName, i))
@@ -607,7 +608,8 @@ namespace Emby.Server.Implementations.FileOrganization
                     {
                     {
                         IncludeItemTypes = new[] { typeof(Series).Name },
                         IncludeItemTypes = new[] { typeof(Series).Name },
                         Recursive = true,
                         Recursive = true,
-                        Name = info.ItemName
+                        Name = info.ItemName,
+                        DtoOptions = new DtoOptions(true)
 
 
                     }).Cast<Series>().FirstOrDefault();
                     }).Cast<Series>().FirstOrDefault();
                 }
                 }

+ 1 - 1
Emby.Server.Implementations/FileOrganization/FileOrganizationService.cs

@@ -17,7 +17,7 @@ using MediaBrowser.Model.IO;
 using MediaBrowser.Controller.Session;
 using MediaBrowser.Controller.Session;
 using MediaBrowser.Model.Events;
 using MediaBrowser.Model.Events;
 using MediaBrowser.Common.Events;
 using MediaBrowser.Common.Events;
-using MediaBrowser.Common.IO;
+
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.Tasks;
 using MediaBrowser.Model.Tasks;
 
 

+ 1 - 1
Emby.Server.Implementations/FileOrganization/OrganizerScheduledTask.cs

@@ -8,7 +8,7 @@ using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Threading;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
-using MediaBrowser.Common.IO;
+
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.Tasks;
 using MediaBrowser.Model.Tasks;

+ 1 - 1
Emby.Server.Implementations/FileOrganization/TvFolderOrganizer.cs

@@ -10,7 +10,7 @@ using System.IO;
 using System.Linq;
 using System.Linq;
 using System.Threading;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
-using MediaBrowser.Common.IO;
+
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 
 

+ 3 - 5
Emby.Server.Implementations/HttpServer/HttpListenerHost.cs

@@ -8,6 +8,7 @@ using System.IO;
 using System.Linq;
 using System.Linq;
 using System.Reflection;
 using System.Reflection;
 using System.Text;
 using System.Text;
+using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using Emby.Server.Implementations.HttpServer;
 using Emby.Server.Implementations.HttpServer;
 using Emby.Server.Implementations.HttpServer.SocketSharp;
 using Emby.Server.Implementations.HttpServer.SocketSharp;
@@ -445,10 +446,7 @@ namespace Emby.Server.Implementations.HttpServer
         /// <summary>
         /// <summary>
         /// Overridable method that can be used to implement a custom hnandler
         /// Overridable method that can be used to implement a custom hnandler
         /// </summary>
         /// </summary>
-        /// <param name="httpReq">The HTTP req.</param>
-        /// <param name="url">The URL.</param>
-        /// <returns>Task.</returns>
-        protected async Task RequestHandler(IHttpRequest httpReq, Uri url)
+        protected async Task RequestHandler(IHttpRequest httpReq, Uri url, CancellationToken cancellationToken)
         {
         {
             var date = DateTime.Now;
             var date = DateTime.Now;
             var httpRes = httpReq.Response;
             var httpRes = httpReq.Response;
@@ -589,7 +587,7 @@ namespace Emby.Server.Implementations.HttpServer
 
 
                 if (handler != null)
                 if (handler != null)
                 {
                 {
-                    await handler.ProcessRequestAsync(this, httpReq, httpRes, Logger, operationName).ConfigureAwait(false);
+                    await handler.ProcessRequestAsync(this, httpReq, httpRes, Logger, operationName, cancellationToken).ConfigureAwait(false);
                 }
                 }
                 else
                 else
                 {
                 {

+ 15 - 3
Emby.Server.Implementations/HttpServer/HttpResultFactory.cs

@@ -58,6 +58,18 @@ namespace Emby.Server.Implementations.HttpServer
             return GetHttpResult(content, contentType, true, responseHeaders);
             return GetHttpResult(content, contentType, true, responseHeaders);
         }
         }
 
 
+        public object GetRedirectResult(string url)
+        {
+            var responseHeaders = new Dictionary<string, string>();
+            responseHeaders["Location"] = url;
+
+            var result = new HttpResult(new byte[] { }, "text/plain", HttpStatusCode.Redirect);
+
+            AddResponseHeaders(result, responseHeaders);
+
+            return result;
+        }
+
         /// <summary>
         /// <summary>
         /// Gets the HTTP result.
         /// Gets the HTTP result.
         /// </summary>
         /// </summary>
@@ -599,9 +611,9 @@ namespace Emby.Server.Implementations.HttpServer
             }
             }
         }
         }
 
 
-        private async Task<IHasHeaders> GetCompressedResult(Stream stream, 
-            string requestedCompressionType, 
-            IDictionary<string,string> responseHeaders,
+        private async Task<IHasHeaders> GetCompressedResult(Stream stream,
+            string requestedCompressionType,
+            IDictionary<string, string> responseHeaders,
             bool isHeadRequest,
             bool isHeadRequest,
             string contentType)
             string contentType)
         {
         {

+ 2 - 1
Emby.Server.Implementations/HttpServer/IHttpListener.cs

@@ -1,6 +1,7 @@
 using MediaBrowser.Controller.Net;
 using MediaBrowser.Controller.Net;
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
+using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using MediaBrowser.Model.Services;
 using MediaBrowser.Model.Services;
 
 
@@ -18,7 +19,7 @@ namespace Emby.Server.Implementations.HttpServer
         /// Gets or sets the request handler.
         /// Gets or sets the request handler.
         /// </summary>
         /// </summary>
         /// <value>The request handler.</value>
         /// <value>The request handler.</value>
-        Func<IHttpRequest, Uri, Task> RequestHandler { get; set; }
+        Func<IHttpRequest, Uri, CancellationToken, Task> RequestHandler { get; set; }
 
 
         /// <summary>
         /// <summary>
         /// Gets or sets the web socket handler.
         /// Gets or sets the web socket handler.

+ 13 - 5
Emby.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs

@@ -4,6 +4,7 @@ using SocketHttpListener.Net;
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
+using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using MediaBrowser.Common.Net;
 using MediaBrowser.Common.Net;
 using MediaBrowser.Model.Cryptography;
 using MediaBrowser.Model.Cryptography;
@@ -33,6 +34,9 @@ namespace Emby.Server.Implementations.HttpServer.SocketSharp
         private readonly bool _enableDualMode;
         private readonly bool _enableDualMode;
         private readonly IEnvironmentInfo _environment;
         private readonly IEnvironmentInfo _environment;
 
 
+        private CancellationTokenSource _disposeCancellationTokenSource = new CancellationTokenSource();
+        private CancellationToken _disposeCancellationToken;
+
         public WebSocketSharpListener(ILogger logger, ICertificate certificate, IMemoryStreamFactory memoryStreamProvider, ITextEncoding textEncoding, INetworkManager networkManager, ISocketFactory socketFactory, ICryptoProvider cryptoProvider, IStreamFactory streamFactory, bool enableDualMode, Func<HttpListenerContext, IHttpRequest> httpRequestFactory, IFileSystem fileSystem, IEnvironmentInfo environment)
         public WebSocketSharpListener(ILogger logger, ICertificate certificate, IMemoryStreamFactory memoryStreamProvider, ITextEncoding textEncoding, INetworkManager networkManager, ISocketFactory socketFactory, ICryptoProvider cryptoProvider, IStreamFactory streamFactory, bool enableDualMode, Func<HttpListenerContext, IHttpRequest> httpRequestFactory, IFileSystem fileSystem, IEnvironmentInfo environment)
         {
         {
             _logger = logger;
             _logger = logger;
@@ -47,10 +51,12 @@ namespace Emby.Server.Implementations.HttpServer.SocketSharp
             _httpRequestFactory = httpRequestFactory;
             _httpRequestFactory = httpRequestFactory;
             _fileSystem = fileSystem;
             _fileSystem = fileSystem;
             _environment = environment;
             _environment = environment;
+
+            _disposeCancellationToken = _disposeCancellationTokenSource.Token;
         }
         }
 
 
         public Action<Exception, IRequest, bool> ErrorHandler { get; set; }
         public Action<Exception, IRequest, bool> ErrorHandler { get; set; }
-        public Func<IHttpRequest, Uri, Task> RequestHandler { get; set; }
+        public Func<IHttpRequest, Uri, CancellationToken, Task> RequestHandler { get; set; }
 
 
         public Action<WebSocketConnectingEventArgs> WebSocketConnecting { get; set; }
         public Action<WebSocketConnectingEventArgs> WebSocketConnecting { get; set; }
 
 
@@ -81,11 +87,11 @@ namespace Emby.Server.Implementations.HttpServer.SocketSharp
 
 
         private void ProcessContext(HttpListenerContext context)
         private void ProcessContext(HttpListenerContext context)
         {
         {
-            //Task.Factory.StartNew(() => InitTask(context), TaskCreationOptions.DenyChildAttach | TaskCreationOptions.PreferFairness);
-            Task.Run(() => InitTask(context));
+            InitTask(context, _disposeCancellationToken);
+            //Task.Run(() => InitTask(context, _disposeCancellationToken));
         }
         }
 
 
-        private Task InitTask(HttpListenerContext context)
+        private Task InitTask(HttpListenerContext context, CancellationToken cancellationToken)
         {
         {
             IHttpRequest httpReq = null;
             IHttpRequest httpReq = null;
             var request = context.Request;
             var request = context.Request;
@@ -111,7 +117,7 @@ namespace Emby.Server.Implementations.HttpServer.SocketSharp
                 return Task.FromResult(true);
                 return Task.FromResult(true);
             }
             }
 
 
-            return RequestHandler(httpReq, request.Url);
+            return RequestHandler(httpReq, request.Url, cancellationToken);
         }
         }
 
 
         private void ProcessWebSocketRequest(HttpListenerContext ctx)
         private void ProcessWebSocketRequest(HttpListenerContext ctx)
@@ -172,6 +178,8 @@ namespace Emby.Server.Implementations.HttpServer.SocketSharp
 
 
         public void Stop()
         public void Stop()
         {
         {
+            _disposeCancellationTokenSource.Cancel();
+
             if (_listener != null)
             if (_listener != null)
             {
             {
                 foreach (var prefix in _listener.Prefixes.ToList())
                 foreach (var prefix in _listener.Prefixes.ToList())

+ 2 - 3
Emby.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpRequest.cs

@@ -1,7 +1,6 @@
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.IO;
 using System.IO;
-using System.Net;
 using System.Text;
 using System.Text;
 using Emby.Server.Implementations.HttpServer;
 using Emby.Server.Implementations.HttpServer;
 using Emby.Server.Implementations.HttpServer.SocketSharp;
 using Emby.Server.Implementations.HttpServer.SocketSharp;
@@ -374,7 +373,7 @@ namespace Emby.Server.Implementations.HttpServer.SocketSharp
                         this.pathInfo = request.RawUrl;
                         this.pathInfo = request.RawUrl;
                     }
                     }
 
 
-                    this.pathInfo = WebUtility.UrlDecode(pathInfo);
+                    this.pathInfo = System.Net.WebUtility.UrlDecode(pathInfo);
                     this.pathInfo = NormalizePathInfo(pathInfo, mode);
                     this.pathInfo = NormalizePathInfo(pathInfo, mode);
                 }
                 }
                 return this.pathInfo;
                 return this.pathInfo;
@@ -440,7 +439,7 @@ namespace Emby.Server.Implementations.HttpServer.SocketSharp
                     cookies = new Dictionary<string, System.Net.Cookie>();
                     cookies = new Dictionary<string, System.Net.Cookie>();
                     foreach (var cookie in this.request.Cookies)
                     foreach (var cookie in this.request.Cookies)
                     {
                     {
-                        var httpCookie = (Cookie) cookie;
+                        var httpCookie = (System.Net.Cookie) cookie;
                         cookies[httpCookie.Name] = new System.Net.Cookie(httpCookie.Name, httpCookie.Value, httpCookie.Path, httpCookie.Domain);
                         cookies[httpCookie.Name] = new System.Net.Cookie(httpCookie.Name, httpCookie.Value, httpCookie.Path, httpCookie.Domain);
                     }
                     }
                 }
                 }

+ 2 - 8
Emby.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpResponse.cs

@@ -114,15 +114,9 @@ namespace Emby.Server.Implementations.HttpServer.SocketSharp
                 var outputStream = response.OutputStream;
                 var outputStream = response.OutputStream;
 
 
                 // This is needed with compression
                 // This is needed with compression
-                if (outputStream is ResponseStream)
-                {
-                    //if (!string.IsNullOrWhiteSpace(GetHeader("Content-Encoding")))
-                    {
-                        outputStream.Flush();
-                    }
+                outputStream.Flush();
+                outputStream.Dispose();
 
 
-                    outputStream.Dispose();
-                }
                 response.Close();
                 response.Close();
             }
             }
             catch (Exception ex)
             catch (Exception ex)

+ 1 - 1
Emby.Server.Implementations/HttpServer/StreamWriter.cs

@@ -5,7 +5,7 @@ using System.Globalization;
 using System.IO;
 using System.IO;
 using System.Threading;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
-using MediaBrowser.Common.IO;
+
 using MediaBrowser.Model.Services;
 using MediaBrowser.Model.Services;
 
 
 namespace Emby.Server.Implementations.HttpServer
 namespace Emby.Server.Implementations.HttpServer

+ 459 - 0
Emby.Server.Implementations/IO/AsyncStreamCopier.cs

@@ -0,0 +1,459 @@
+using System;
+using System.IO;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Emby.Server.Implementations.IO
+{
+    public class AsyncStreamCopier : IDisposable
+    {
+        // size in bytes of the buffers in the buffer pool
+        private const int DefaultBufferSize = 81920;
+        private readonly int _bufferSize;
+        // number of buffers in the pool
+        private const int DefaultBufferCount = 4;
+        private readonly int _bufferCount;
+
+        // indexes of the next buffer to read into/write from
+        private int _nextReadBuffer = -1;
+        private int _nextWriteBuffer = -1;
+
+        // the buffer pool, implemented as an array, and used in a cyclic way
+        private readonly byte[][] _buffers;
+        // sizes in bytes of the available (read) data in the buffers
+        private readonly int[] _sizes;
+        // the streams...
+        private Stream _source;
+        private Stream _target;
+        private readonly bool _closeStreamsOnEnd;
+
+        // number of buffers that are ready to be written
+        private int _buffersToWrite;
+        // flag indicating that there is still a read operation to be scheduled
+        // (source end of stream not reached)
+        private volatile bool _moreDataToRead;
+        // the result of the whole operation, returned by BeginCopy()
+        private AsyncResult _asyncResult;
+        // any exception that occurs during an async operation
+        // stored here for rethrow
+        private Exception _exception;
+
+        public TaskCompletionSource<long> TaskCompletionSource;
+        private long _bytesToRead;
+        private long _totalBytesWritten;
+        private CancellationToken _cancellationToken;
+        public int IndividualReadOffset = 0;
+
+        public AsyncStreamCopier(Stream source,
+                                 Stream target,
+                                 long bytesToRead,
+                                 CancellationToken cancellationToken,
+                                 bool closeStreamsOnEnd = false,
+                                 int bufferSize = DefaultBufferSize,
+                                 int bufferCount = DefaultBufferCount)
+        {
+            if (source == null)
+                throw new ArgumentNullException("source");
+            if (target == null)
+                throw new ArgumentNullException("target");
+            if (!source.CanRead)
+                throw new ArgumentException("Cannot copy from a non-readable stream.");
+            if (!target.CanWrite)
+                throw new ArgumentException("Cannot copy to a non-writable stream.");
+            _source = source;
+            _target = target;
+            _moreDataToRead = true;
+            _closeStreamsOnEnd = closeStreamsOnEnd;
+            _bufferSize = bufferSize;
+            _bufferCount = bufferCount;
+            _buffers = new byte[_bufferCount][];
+            _sizes = new int[_bufferCount];
+            _bytesToRead = bytesToRead;
+            _cancellationToken = cancellationToken;
+        }
+
+        ~AsyncStreamCopier()
+        {
+            // ensure any exception cannot be ignored
+            ThrowExceptionIfNeeded();
+        }
+
+        public static Task<long> CopyStream(Stream source, Stream target, int bufferSize, int bufferCount, CancellationToken cancellationToken)
+        {
+            return CopyStream(source, target, 0, bufferSize, bufferCount, cancellationToken);
+        }
+
+        public static Task<long> CopyStream(Stream source, Stream target, long size, int bufferSize, int bufferCount, CancellationToken cancellationToken)
+        {
+            var copier = new AsyncStreamCopier(source, target, size, cancellationToken, false, bufferSize, bufferCount);
+            var taskCompletion = new TaskCompletionSource<long>();
+
+            copier.TaskCompletionSource = taskCompletion;
+
+            var result = copier.BeginCopy(StreamCopyCallback, copier);
+
+            if (result.CompletedSynchronously)
+            {
+                StreamCopyCallback(result);
+            }
+
+            cancellationToken.Register(() => taskCompletion.TrySetCanceled());
+
+            return taskCompletion.Task;
+        }
+
+        private static void StreamCopyCallback(IAsyncResult result)
+        {
+            var copier = (AsyncStreamCopier)result.AsyncState;
+            var taskCompletion = copier.TaskCompletionSource;
+
+            try
+            {
+                copier.EndCopy(result);
+                taskCompletion.TrySetResult(copier._totalBytesWritten);
+            }
+            catch (Exception ex)
+            {
+                taskCompletion.TrySetException(ex);
+            }
+        }
+
+        public void Dispose()
+        {
+            if (_asyncResult != null)
+                _asyncResult.Dispose();
+            if (_closeStreamsOnEnd)
+            {
+                if (_source != null)
+                {
+                    _source.Dispose();
+                    _source = null;
+                }
+                if (_target != null)
+                {
+                    _target.Dispose();
+                    _target = null;
+                }
+            }
+            GC.SuppressFinalize(this);
+            ThrowExceptionIfNeeded();
+        }
+
+        public IAsyncResult BeginCopy(AsyncCallback callback, object state)
+        {
+            // avoid concurrent start of the copy on separate threads
+            if (Interlocked.CompareExchange(ref _asyncResult, new AsyncResult(callback, state), null) != null)
+                throw new InvalidOperationException("A copy operation has already been started on this object.");
+            // allocate buffers
+            for (int i = 0; i < _bufferCount; i++)
+                _buffers[i] = new byte[_bufferSize];
+
+            // we pass false to BeginRead() to avoid completing the async result
+            // immediately which would result in invoking the callback
+            // when the method fails synchronously
+            BeginRead(false);
+            // throw exception synchronously if there is one
+            ThrowExceptionIfNeeded();
+            return _asyncResult;
+        }
+
+        public void EndCopy(IAsyncResult ar)
+        {
+            if (ar != _asyncResult)
+                throw new InvalidOperationException("Invalid IAsyncResult object.");
+
+            if (!_asyncResult.IsCompleted)
+                _asyncResult.AsyncWaitHandle.WaitOne();
+
+            if (_closeStreamsOnEnd)
+            {
+                _source.Close();
+                _source = null;
+                _target.Close();
+                _target = null;
+            }
+
+            //_logger.Info("AsyncStreamCopier {0} bytes requested. {1} bytes transferred", _bytesToRead, _totalBytesWritten);
+            ThrowExceptionIfNeeded();
+        }
+
+        /// <summary>
+        /// Here we'll throw a pending exception if there is one, 
+        /// and remove it from our instance, so we know it has been consumed.
+        /// </summary>
+        private void ThrowExceptionIfNeeded()
+        {
+            if (_exception != null)
+            {
+                var exception = _exception;
+                _exception = null;
+                throw exception;
+            }
+        }
+
+        private void BeginRead(bool completeOnError = true)
+        {
+            if (!_moreDataToRead)
+            {
+                return;
+            }
+            if (_asyncResult.IsCompleted)
+                return;
+            int bufferIndex = Interlocked.Increment(ref _nextReadBuffer) % _bufferCount;
+
+            try
+            {
+                _source.BeginRead(_buffers[bufferIndex], 0, _bufferSize, EndRead, bufferIndex);
+            }
+            catch (Exception exception)
+            {
+                _exception = exception;
+                if (completeOnError)
+                    _asyncResult.Complete(false);
+            }
+        }
+
+        private void BeginWrite()
+        {
+            if (_asyncResult.IsCompleted)
+                return;
+            // this method can actually be called concurrently!!
+            // indeed, let's say we call a BeginWrite, and the thread gets interrupted 
+            // just after making the IO request.
+            // At that moment, the thread is still in the method. And then the IO request
+            // ends (extremely fast io, or caching...), EndWrite gets called
+            // on another thread, and calls BeginWrite again! There we have it!
+            // That is the reason why an Interlocked is needed here.
+            int bufferIndex = Interlocked.Increment(ref _nextWriteBuffer) % _bufferCount;
+
+            try
+            {
+                int bytesToWrite;
+                if (_bytesToRead > 0)
+                {
+                    var bytesLeftToWrite = _bytesToRead - _totalBytesWritten;
+                    bytesToWrite = Convert.ToInt32(Math.Min(_sizes[bufferIndex], bytesLeftToWrite));
+                }
+                else
+                {
+                    bytesToWrite = _sizes[bufferIndex];
+                }
+
+                _target.BeginWrite(_buffers[bufferIndex], IndividualReadOffset, bytesToWrite - IndividualReadOffset, EndWrite, null);
+
+                _totalBytesWritten += bytesToWrite;
+            }
+            catch (Exception exception)
+            {
+                _exception = exception;
+                _asyncResult.Complete(false);
+            }
+        }
+
+        private void EndRead(IAsyncResult ar)
+        {
+            try
+            {
+                int read = _source.EndRead(ar);
+                _moreDataToRead = read > 0;
+                var bufferIndex = (int)ar.AsyncState;
+                _sizes[bufferIndex] = read;
+            }
+            catch (Exception exception)
+            {
+                _exception = exception;
+                _asyncResult.Complete(false);
+                return;
+            }
+
+            if (_moreDataToRead && !_cancellationToken.IsCancellationRequested)
+            {
+                int usedBuffers = Interlocked.Increment(ref _buffersToWrite);
+                // if we incremented from zero to one, then it means we just 
+                // added the single buffer to write, so a writer could not 
+                // be busy, and we have to schedule one.
+                if (usedBuffers == 1)
+                    BeginWrite();
+                // test if there is at least a free buffer, and schedule
+                // a read, as we have read some data
+                if (usedBuffers < _bufferCount)
+                    BeginRead();
+            }
+            else
+            {
+                // we did not add a buffer, because no data was read, and 
+                // there is no buffer left to write so this is the end...
+                if (Thread.VolatileRead(ref _buffersToWrite) == 0)
+                {
+                    _asyncResult.Complete(false);
+                }
+            }
+        }
+
+        private void EndWrite(IAsyncResult ar)
+        {
+            try
+            {
+                _target.EndWrite(ar);
+            }
+            catch (Exception exception)
+            {
+                _exception = exception;
+                _asyncResult.Complete(false);
+                return;
+            }
+
+            int buffersLeftToWrite = Interlocked.Decrement(ref _buffersToWrite);
+            // no reader could be active if all buffers were full of data waiting to be written
+            bool noReaderIsBusy = buffersLeftToWrite == _bufferCount - 1;
+            // note that it is possible that both a reader and
+            // a writer see the end of the copy and call Complete
+            // on the _asyncResult object. That race condition is handled by
+            // Complete that ensures it is only executed fully once.
+
+            long bytesLeftToWrite;
+            if (_bytesToRead > 0)
+            {
+                bytesLeftToWrite = _bytesToRead - _totalBytesWritten;
+            }
+            else
+            {
+                bytesLeftToWrite = 1;
+            }
+
+            if (!_moreDataToRead || bytesLeftToWrite <= 0 || _cancellationToken.IsCancellationRequested)
+            {
+                // at this point we know no reader can schedule a read or write
+                if (Thread.VolatileRead(ref _buffersToWrite) == 0)
+                {
+                    // nothing left to write, so it is the end
+                    _asyncResult.Complete(false);
+                    return;
+                }
+            }
+            else
+                // here, we know we have something left to read, 
+                // so schedule a read if no read is busy
+                if (noReaderIsBusy)
+                BeginRead();
+
+            // also schedule a write if we are sure we did not write the last buffer
+            // note that if buffersLeftToWrite is zero and a reader has put another
+            // buffer to write between the time we decremented _buffersToWrite 
+            // and now, that reader will also schedule another write,
+            // as it will increment _buffersToWrite from zero to one
+            if (buffersLeftToWrite > 0)
+                BeginWrite();
+        }
+    }
+
+    internal class AsyncResult : IAsyncResult, IDisposable
+    {
+        // Fields set at construction which never change while
+        // operation is pending
+        private readonly AsyncCallback _asyncCallback;
+        private readonly object _asyncState;
+
+        // Fields set at construction which do change after
+        // operation completes
+        private const int StatePending = 0;
+        private const int StateCompletedSynchronously = 1;
+        private const int StateCompletedAsynchronously = 2;
+        private int _completedState = StatePending;
+
+        // Field that may or may not get set depending on usage
+        private ManualResetEvent _waitHandle;
+
+        internal AsyncResult(
+            AsyncCallback asyncCallback,
+            object state)
+        {
+            _asyncCallback = asyncCallback;
+            _asyncState = state;
+        }
+
+        internal bool Complete(bool completedSynchronously)
+        {
+            bool result = false;
+
+            // The _completedState field MUST be set prior calling the callback
+            int prevState = Interlocked.CompareExchange(ref _completedState,
+                completedSynchronously ? StateCompletedSynchronously :
+                StateCompletedAsynchronously, StatePending);
+            if (prevState == StatePending)
+            {
+                // If the event exists, set it
+                if (_waitHandle != null)
+                    _waitHandle.Set();
+
+                if (_asyncCallback != null)
+                    _asyncCallback(this);
+
+                result = true;
+            }
+
+            return result;
+        }
+
+        #region Implementation of IAsyncResult
+
+        public Object AsyncState { get { return _asyncState; } }
+
+        public bool CompletedSynchronously
+        {
+            get
+            {
+                return Thread.VolatileRead(ref _completedState) ==
+                    StateCompletedSynchronously;
+            }
+        }
+
+        public WaitHandle AsyncWaitHandle
+        {
+            get
+            {
+                if (_waitHandle == null)
+                {
+                    bool done = IsCompleted;
+                    var mre = new ManualResetEvent(done);
+                    if (Interlocked.CompareExchange(ref _waitHandle,
+                        mre, null) != null)
+                    {
+                        // Another thread created this object's event; dispose
+                        // the event we just created
+                        mre.Close();
+                    }
+                    else
+                    {
+                        if (!done && IsCompleted)
+                        {
+                            // If the operation wasn't done when we created
+                            // the event but now it is done, set the event
+                            _waitHandle.Set();
+                        }
+                    }
+                }
+                return _waitHandle;
+            }
+        }
+
+        public bool IsCompleted
+        {
+            get
+            {
+                return Thread.VolatileRead(ref _completedState) !=
+                    StatePending;
+            }
+        }
+        #endregion
+
+        public void Dispose()
+        {
+            if (_waitHandle != null)
+            {
+                _waitHandle.Dispose();
+                _waitHandle = null;
+            }
+        }
+    }
+}

+ 8 - 8
Emby.Server.Implementations/IO/FileRefresher.cs

@@ -6,7 +6,7 @@ using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Common.Events;
 using MediaBrowser.Common.Events;
-using MediaBrowser.Common.IO;
+
 using MediaBrowser.Controller.Configuration;
 using MediaBrowser.Controller.Configuration;
 using MediaBrowser.Controller.Entities;
 using MediaBrowser.Controller.Entities;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;
@@ -180,7 +180,7 @@ namespace Emby.Server.Implementations.IO
 
 
                 try
                 try
                 {
                 {
-                    await item.ChangedExternally().ConfigureAwait(false);
+                    item.ChangedExternally();
                 }
                 }
                 catch (IOException ex)
                 catch (IOException ex)
                 {
                 {
@@ -231,7 +231,7 @@ namespace Emby.Server.Implementations.IO
 
 
         private bool IsFileLocked(string path)
         private bool IsFileLocked(string path)
         {
         {
-            if (_environmentInfo.OperatingSystem != OperatingSystem.Windows)
+            if (_environmentInfo.OperatingSystem != MediaBrowser.Model.System.OperatingSystem.Windows)
             {
             {
                 // Causing lockups on linux
                 // Causing lockups on linux
                 return false;
                 return false;
@@ -282,11 +282,11 @@ namespace Emby.Server.Implementations.IO
                     return false;
                     return false;
                 }
                 }
             }
             }
-            //catch (DirectoryNotFoundException)
-            //{
-            //    // File may have been deleted
-            //    return false;
-            //}
+            catch (DirectoryNotFoundException)
+            {
+                // File may have been deleted
+                return false;
+            }
             catch (FileNotFoundException)
             catch (FileNotFoundException)
             {
             {
                 // File may have been deleted
                 // File may have been deleted

+ 1 - 1
Emby.Server.Implementations/IO/MbLinkShortcutHandler.cs

@@ -1,6 +1,6 @@
 using System;
 using System;
 using System.IO;
 using System.IO;
-using MediaBrowser.Common.IO;
+
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 
 

+ 16 - 43
Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs

@@ -12,7 +12,7 @@ using System.IO;
 using System.Linq;
 using System.Linq;
 using System.Threading;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
-using MediaBrowser.Common.IO;
+
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Controller.Entities.Audio;
 using MediaBrowser.Controller.Entities.Audio;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;
@@ -59,33 +59,6 @@ namespace Emby.Server.Implementations.Images
             //return GetSupportedImages(item).Where(i => IsEnabled(options, i, item)).ToList();
             //return GetSupportedImages(item).Where(i => IsEnabled(options, i, item)).ToList();
         }
         }
 
 
-        private bool IsEnabled(MetadataOptions options, ImageType type, IHasImages item)
-        {
-            if (type == ImageType.Backdrop)
-            {
-                if (item.LockedFields.Contains(MetadataFields.Backdrops))
-                {
-                    return false;
-                }
-            }
-            else if (type == ImageType.Screenshot)
-            {
-                if (item.LockedFields.Contains(MetadataFields.Screenshots))
-                {
-                    return false;
-                }
-            }
-            else
-            {
-                if (item.LockedFields.Contains(MetadataFields.Images))
-                {
-                    return false;
-                }
-            }
-
-            return options.IsEnabled(type);
-        }
-
         public async Task<ItemUpdateType> FetchAsync(T item, MetadataRefreshOptions options, CancellationToken cancellationToken)
         public async Task<ItemUpdateType> FetchAsync(T item, MetadataRefreshOptions options, CancellationToken cancellationToken)
         {
         {
             if (!Supports(item))
             if (!Supports(item))
@@ -128,7 +101,7 @@ namespace Emby.Server.Implementations.Images
                 }
                 }
             }
             }
 
 
-            var items = await GetItemsWithImages(item).ConfigureAwait(false);
+            var items = GetItemsWithImages(item);
 
 
             return await FetchToFileInternal(item, items, imageType, cancellationToken).ConfigureAwait(false);
             return await FetchToFileInternal(item, items, imageType, cancellationToken).ConfigureAwait(false);
         }
         }
@@ -140,7 +113,7 @@ namespace Emby.Server.Implementations.Images
         {
         {
             var outputPathWithoutExtension = Path.Combine(ApplicationPaths.TempDirectory, Guid.NewGuid().ToString("N"));
             var outputPathWithoutExtension = Path.Combine(ApplicationPaths.TempDirectory, Guid.NewGuid().ToString("N"));
             FileSystem.CreateDirectory(FileSystem.GetDirectoryName(outputPathWithoutExtension));
             FileSystem.CreateDirectory(FileSystem.GetDirectoryName(outputPathWithoutExtension));
-            string outputPath = await CreateImage(item, itemsWithImages, outputPathWithoutExtension, imageType, 0).ConfigureAwait(false);
+            string outputPath = CreateImage(item, itemsWithImages, outputPathWithoutExtension, imageType, 0);
 
 
             if (string.IsNullOrWhiteSpace(outputPath))
             if (string.IsNullOrWhiteSpace(outputPath))
             {
             {
@@ -159,9 +132,9 @@ namespace Emby.Server.Implementations.Images
             return ItemUpdateType.ImageUpdate;
             return ItemUpdateType.ImageUpdate;
         }
         }
 
 
-        protected abstract Task<List<BaseItem>> GetItemsWithImages(IHasImages item);
+        protected abstract List<BaseItem> GetItemsWithImages(IHasImages item);
 
 
-        protected Task<string> CreateThumbCollage(IHasImages primaryItem, List<BaseItem> items, string outputPath)
+        protected string CreateThumbCollage(IHasImages primaryItem, List<BaseItem> items, string outputPath)
         {
         {
             return CreateCollage(primaryItem, items, outputPath, 640, 360);
             return CreateCollage(primaryItem, items, outputPath, 640, 360);
         }
         }
@@ -188,22 +161,22 @@ namespace Emby.Server.Implementations.Images
                 .Where(i => !string.IsNullOrWhiteSpace(i));
                 .Where(i => !string.IsNullOrWhiteSpace(i));
         }
         }
 
 
-        protected Task<string> CreatePosterCollage(IHasImages primaryItem, List<BaseItem> items, string outputPath)
+        protected string CreatePosterCollage(IHasImages primaryItem, List<BaseItem> items, string outputPath)
         {
         {
             return CreateCollage(primaryItem, items, outputPath, 400, 600);
             return CreateCollage(primaryItem, items, outputPath, 400, 600);
         }
         }
 
 
-        protected Task<string> CreateSquareCollage(IHasImages primaryItem, List<BaseItem> items, string outputPath)
+        protected string CreateSquareCollage(IHasImages primaryItem, List<BaseItem> items, string outputPath)
         {
         {
             return CreateCollage(primaryItem, items, outputPath, 600, 600);
             return CreateCollage(primaryItem, items, outputPath, 600, 600);
         }
         }
 
 
-        protected Task<string> CreateThumbCollage(IHasImages primaryItem, List<BaseItem> items, string outputPath, int width, int height)
+        protected string CreateThumbCollage(IHasImages primaryItem, List<BaseItem> items, string outputPath, int width, int height)
         {
         {
             return CreateCollage(primaryItem, items, outputPath, width, height);
             return CreateCollage(primaryItem, items, outputPath, width, height);
         }
         }
 
 
-        private async Task<string> CreateCollage(IHasImages primaryItem, List<BaseItem> items, string outputPath, int width, int height)
+        private string CreateCollage(IHasImages primaryItem, List<BaseItem> items, string outputPath, int width, int height)
         {
         {
             FileSystem.CreateDirectory(FileSystem.GetDirectoryName(outputPath));
             FileSystem.CreateDirectory(FileSystem.GetDirectoryName(outputPath));
 
 
@@ -225,7 +198,7 @@ namespace Emby.Server.Implementations.Images
                 return null;
                 return null;
             }
             }
 
 
-            await ImageProcessor.CreateImageCollage(options).ConfigureAwait(false);
+            ImageProcessor.CreateImageCollage(options);
             return outputPath;
             return outputPath;
         }
         }
 
 
@@ -234,7 +207,7 @@ namespace Emby.Server.Implementations.Images
             get { return "Dynamic Image Provider"; }
             get { return "Dynamic Image Provider"; }
         }
         }
 
 
-        protected virtual async Task<string> CreateImage(IHasImages item,
+        protected virtual string CreateImage(IHasImages item,
             List<BaseItem> itemsWithImages,
             List<BaseItem> itemsWithImages,
             string outputPathWithoutExtension,
             string outputPathWithoutExtension,
             ImageType imageType,
             ImageType imageType,
@@ -249,20 +222,20 @@ namespace Emby.Server.Implementations.Images
 
 
             if (imageType == ImageType.Thumb)
             if (imageType == ImageType.Thumb)
             {
             {
-                return await CreateThumbCollage(item, itemsWithImages, outputPath).ConfigureAwait(false);
+                return CreateThumbCollage(item, itemsWithImages, outputPath);
             }
             }
 
 
             if (imageType == ImageType.Primary)
             if (imageType == ImageType.Primary)
             {
             {
                 if (item is UserView)
                 if (item is UserView)
                 {
                 {
-                    return await CreateSquareCollage(item, itemsWithImages, outputPath).ConfigureAwait(false);
+                    return CreateSquareCollage(item, itemsWithImages, outputPath);
                 }
                 }
                 if (item is Playlist || item is MusicGenre || item is Genre || item is GameGenre || item is PhotoAlbum)
                 if (item is Playlist || item is MusicGenre || item is Genre || item is GameGenre || item is PhotoAlbum)
                 {
                 {
-                    return await CreateSquareCollage(item, itemsWithImages, outputPath).ConfigureAwait(false);
+                    return CreateSquareCollage(item, itemsWithImages, outputPath);
                 }
                 }
-                return await CreatePosterCollage(item, itemsWithImages, outputPath).ConfigureAwait(false);
+                return CreatePosterCollage(item, itemsWithImages, outputPath);
             }
             }
 
 
             throw new ArgumentException("Unexpected image type");
             throw new ArgumentException("Unexpected image type");
@@ -346,7 +319,7 @@ namespace Emby.Server.Implementations.Images
             }
             }
         }
         }
 
 
-        protected async Task<string> CreateSingleImage(List<BaseItem> itemsWithImages, string outputPathWithoutExtension, ImageType imageType)
+        protected string CreateSingleImage(List<BaseItem> itemsWithImages, string outputPathWithoutExtension, ImageType imageType)
         {
         {
             var image = itemsWithImages
             var image = itemsWithImages
                 .Where(i => i.HasImage(imageType) && i.GetImageInfo(imageType, 0).IsLocalFile && Path.HasExtension(i.GetImagePath(imageType)))
                 .Where(i => i.HasImage(imageType) && i.GetImageInfo(imageType, 0).IsLocalFile && Path.HasExtension(i.GetImagePath(imageType)))

+ 1 - 1
Emby.Server.Implementations/Library/CoreResolutionIgnoreRule.cs

@@ -6,7 +6,7 @@ using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.IO;
 using System.IO;
 using System.Linq;
 using System.Linq;
-using MediaBrowser.Common.IO;
+
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.Logging;
 using MediaBrowser.Model.Logging;

+ 55 - 68
Emby.Server.Implementations/Library/LibraryManager.cs

@@ -40,7 +40,8 @@ using MediaBrowser.Model.Net;
 using SortOrder = MediaBrowser.Model.Entities.SortOrder;
 using SortOrder = MediaBrowser.Model.Entities.SortOrder;
 using VideoResolver = MediaBrowser.Naming.Video.VideoResolver;
 using VideoResolver = MediaBrowser.Naming.Video.VideoResolver;
 using MediaBrowser.Common.Configuration;
 using MediaBrowser.Common.Configuration;
-using MediaBrowser.Common.IO;
+
+using MediaBrowser.Controller.Dto;
 using MediaBrowser.Controller.LiveTv;
 using MediaBrowser.Controller.LiveTv;
 using MediaBrowser.Model.Tasks;
 using MediaBrowser.Model.Tasks;
 
 
@@ -313,7 +314,8 @@ namespace Emby.Server.Implementations.Library
             {
             {
                 IncludeItemTypes = new[] { typeof(Season).Name },
                 IncludeItemTypes = new[] { typeof(Season).Name },
                 Recursive = true,
                 Recursive = true,
-                IndexNumber = 0
+                IndexNumber = 0,
+                DtoOptions = new DtoOptions(true)
 
 
             }).Cast<Season>()
             }).Cast<Season>()
                 .Where(i => !string.Equals(i.Name, newName, StringComparison.Ordinal))
                 .Where(i => !string.Equals(i.Name, newName, StringComparison.Ordinal))
@@ -342,7 +344,7 @@ namespace Emby.Server.Implementations.Library
             }
             }
             if (item is IItemByName)
             if (item is IItemByName)
             {
             {
-                if (!(item is MusicArtist) && !(item is Studio))
+                if (!(item is MusicArtist))
                 {
                 {
                     return;
                     return;
                 }
                 }
@@ -862,13 +864,19 @@ namespace Emby.Server.Implementations.Library
             // If this returns multiple items it could be tricky figuring out which one is correct. 
             // If this returns multiple items it could be tricky figuring out which one is correct. 
             // In most cases, the newest one will be and the others obsolete but not yet cleaned up
             // In most cases, the newest one will be and the others obsolete but not yet cleaned up
 
 
+            if (string.IsNullOrWhiteSpace(path))
+            {
+                throw new ArgumentNullException("path");
+            }
+
             var query = new InternalItemsQuery
             var query = new InternalItemsQuery
             {
             {
                 Path = path,
                 Path = path,
                 IsFolder = isFolder,
                 IsFolder = isFolder,
                 SortBy = new[] { ItemSortBy.DateCreated },
                 SortBy = new[] { ItemSortBy.DateCreated },
                 SortOrder = SortOrder.Descending,
                 SortOrder = SortOrder.Descending,
-                Limit = 1
+                Limit = 1,
+                DtoOptions = new DtoOptions(true)
             };
             };
 
 
             return GetItemList(query)
             return GetItemList(query)
@@ -882,7 +890,7 @@ namespace Emby.Server.Implementations.Library
         /// <returns>Task{Person}.</returns>
         /// <returns>Task{Person}.</returns>
         public Person GetPerson(string name)
         public Person GetPerson(string name)
         {
         {
-            return CreateItemByName<Person>(Person.GetPath, name);
+            return CreateItemByName<Person>(Person.GetPath, name, new DtoOptions(true));
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -892,7 +900,27 @@ namespace Emby.Server.Implementations.Library
         /// <returns>Task{Studio}.</returns>
         /// <returns>Task{Studio}.</returns>
         public Studio GetStudio(string name)
         public Studio GetStudio(string name)
         {
         {
-            return CreateItemByName<Studio>(Studio.GetPath, name);
+            return CreateItemByName<Studio>(Studio.GetPath, name, new DtoOptions(true));
+        }
+
+        public Guid GetStudioId(string name)
+        {
+            return GetItemByNameId<Studio>(Studio.GetPath, name);
+        }
+
+        public Guid GetGenreId(string name)
+        {
+            return GetItemByNameId<Genre>(Genre.GetPath, name);
+        }
+
+        public Guid GetMusicGenreId(string name)
+        {
+            return GetItemByNameId<MusicGenre>(MusicGenre.GetPath, name);
+        }
+
+        public Guid GetGameGenreId(string name)
+        {
+            return GetItemByNameId<GameGenre>(GameGenre.GetPath, name);
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -902,7 +930,7 @@ namespace Emby.Server.Implementations.Library
         /// <returns>Task{Genre}.</returns>
         /// <returns>Task{Genre}.</returns>
         public Genre GetGenre(string name)
         public Genre GetGenre(string name)
         {
         {
-            return CreateItemByName<Genre>(Genre.GetPath, name);
+            return CreateItemByName<Genre>(Genre.GetPath, name, new DtoOptions(true));
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -912,7 +940,7 @@ namespace Emby.Server.Implementations.Library
         /// <returns>Task{MusicGenre}.</returns>
         /// <returns>Task{MusicGenre}.</returns>
         public MusicGenre GetMusicGenre(string name)
         public MusicGenre GetMusicGenre(string name)
         {
         {
-            return CreateItemByName<MusicGenre>(MusicGenre.GetPath, name);
+            return CreateItemByName<MusicGenre>(MusicGenre.GetPath, name, new DtoOptions(true));
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -922,7 +950,7 @@ namespace Emby.Server.Implementations.Library
         /// <returns>Task{GameGenre}.</returns>
         /// <returns>Task{GameGenre}.</returns>
         public GameGenre GetGameGenre(string name)
         public GameGenre GetGameGenre(string name)
         {
         {
-            return CreateItemByName<GameGenre>(GameGenre.GetPath, name);
+            return CreateItemByName<GameGenre>(GameGenre.GetPath, name, new DtoOptions(true));
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -940,7 +968,7 @@ namespace Emby.Server.Implementations.Library
 
 
             var name = value.ToString(CultureInfo.InvariantCulture);
             var name = value.ToString(CultureInfo.InvariantCulture);
 
 
-            return CreateItemByName<Year>(Year.GetPath, name);
+            return CreateItemByName<Year>(Year.GetPath, name, new DtoOptions(true));
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -950,10 +978,15 @@ namespace Emby.Server.Implementations.Library
         /// <returns>Task{Genre}.</returns>
         /// <returns>Task{Genre}.</returns>
         public MusicArtist GetArtist(string name)
         public MusicArtist GetArtist(string name)
         {
         {
-            return CreateItemByName<MusicArtist>(MusicArtist.GetPath, name);
+            return GetArtist(name, new DtoOptions(true));
+        }
+
+        public MusicArtist GetArtist(string name, DtoOptions options)
+        {
+            return CreateItemByName<MusicArtist>(MusicArtist.GetPath, name, options);
         }
         }
 
 
-        private T CreateItemByName<T>(Func<string, string> getPathFn, string name)
+        private T CreateItemByName<T>(Func<string, string> getPathFn, string name, DtoOptions options)
             where T : BaseItem, new()
             where T : BaseItem, new()
         {
         {
             if (typeof(T) == typeof(MusicArtist))
             if (typeof(T) == typeof(MusicArtist))
@@ -961,7 +994,8 @@ namespace Emby.Server.Implementations.Library
                 var existing = GetItemList(new InternalItemsQuery
                 var existing = GetItemList(new InternalItemsQuery
                 {
                 {
                     IncludeItemTypes = new[] { typeof(T).Name },
                     IncludeItemTypes = new[] { typeof(T).Name },
-                    Name = name
+                    Name = name,
+                    DtoOptions = options
 
 
                 }).Cast<MusicArtist>()
                 }).Cast<MusicArtist>()
                 .OrderBy(i => i.IsAccessedByName ? 1 : 0)
                 .OrderBy(i => i.IsAccessedByName ? 1 : 0)
@@ -974,14 +1008,13 @@ namespace Emby.Server.Implementations.Library
                 }
                 }
             }
             }
 
 
-            var path = getPathFn(name);
-            var forceCaseInsensitiveId = ConfigurationManager.Configuration.EnableNormalizedItemByNameIds;
-            var id = GetNewItemIdInternal(path, typeof(T), forceCaseInsensitiveId);
+            var id = GetItemByNameId<T>(getPathFn, name);
 
 
             var item = GetItemById(id) as T;
             var item = GetItemById(id) as T;
 
 
             if (item == null)
             if (item == null)
             {
             {
+                var path = getPathFn(name);
                 item = new T
                 item = new T
                 {
                 {
                     Name = name,
                     Name = name,
@@ -998,52 +1031,12 @@ namespace Emby.Server.Implementations.Library
             return item;
             return item;
         }
         }
 
 
-        public IEnumerable<MusicArtist> GetAlbumArtists(IEnumerable<IHasAlbumArtist> items)
-        {
-            var names = items
-                .SelectMany(i => i.AlbumArtists)
-                .DistinctNames()
-                .Select(i =>
-                {
-                    try
-                    {
-                        var artist = GetArtist(i);
-
-                        return artist;
-                    }
-                    catch
-                    {
-                        // Already logged at lower levels
-                        return null;
-                    }
-                })
-                .Where(i => i != null);
-
-            return names;
-        }
-
-        public IEnumerable<MusicArtist> GetArtists(IEnumerable<IHasArtist> items)
+        private Guid GetItemByNameId<T>(Func<string, string> getPathFn, string name)
+              where T : BaseItem, new()
         {
         {
-            var names = items
-                .SelectMany(i => i.AllArtists)
-                .DistinctNames()
-                .Select(i =>
-                {
-                    try
-                    {
-                        var artist = GetArtist(i);
-
-                        return artist;
-                    }
-                    catch
-                    {
-                        // Already logged at lower levels
-                        return null;
-                    }
-                })
-                .Where(i => i != null);
-
-            return names;
+            var path = getPathFn(name);
+            var forceCaseInsensitiveId = ConfigurationManager.Configuration.EnableNormalizedItemByNameIds;
+            return GetNewItemIdInternal(path, typeof(T), forceCaseInsensitiveId);
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -1098,12 +1091,6 @@ namespace Emby.Server.Implementations.Library
             try
             try
             {
             {
                 await PerformLibraryValidation(progress, cancellationToken).ConfigureAwait(false);
                 await PerformLibraryValidation(progress, cancellationToken).ConfigureAwait(false);
-
-                if (!ConfigurationManager.Configuration.EnableSeriesPresentationUniqueKey)
-                {
-                    ConfigurationManager.Configuration.EnableSeriesPresentationUniqueKey = true;
-                    ConfigurationManager.SaveConfiguration();
-                }
             }
             }
             finally
             finally
             {
             {
@@ -1558,7 +1545,7 @@ namespace Emby.Server.Implementations.Library
                 }
                 }
             }
             }
 
 
-            query.ParentId = null;
+            query.Parent = null;
         }
         }
 
 
         private void AddUserToQuery(InternalItemsQuery query, User user)
         private void AddUserToQuery(InternalItemsQuery query, User user)

+ 5 - 2
Emby.Server.Implementations/Library/LocalTrailerPostScanTask.cs

@@ -6,6 +6,7 @@ using System;
 using System.Linq;
 using System.Linq;
 using System.Threading;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
+using MediaBrowser.Controller.Dto;
 using MediaBrowser.Controller.Entities.Movies;
 using MediaBrowser.Controller.Entities.Movies;
 using MediaBrowser.Controller.Entities.TV;
 using MediaBrowser.Controller.Entities.TV;
 
 
@@ -27,7 +28,8 @@ namespace Emby.Server.Implementations.Library
             var items = _libraryManager.GetItemList(new InternalItemsQuery
             var items = _libraryManager.GetItemList(new InternalItemsQuery
             {
             {
                 IncludeItemTypes = new[] { typeof(BoxSet).Name, typeof(Game).Name, typeof(Movie).Name, typeof(Series).Name },
                 IncludeItemTypes = new[] { typeof(BoxSet).Name, typeof(Game).Name, typeof(Movie).Name, typeof(Series).Name },
-                Recursive = true
+                Recursive = true,
+                DtoOptions = new DtoOptions(true)
 
 
             }).OfType<IHasTrailers>().ToList();
             }).OfType<IHasTrailers>().ToList();
 
 
@@ -40,7 +42,8 @@ namespace Emby.Server.Implementations.Library
             {
             {
                 IncludeItemTypes = new[] { typeof(Trailer).Name },
                 IncludeItemTypes = new[] { typeof(Trailer).Name },
                 TrailerTypes = trailerTypes,
                 TrailerTypes = trailerTypes,
-                Recursive = true
+                Recursive = true,
+                DtoOptions = new DtoOptions(false)
 
 
             }).ToArray();
             }).ToArray();
 
 

+ 26 - 22
Emby.Server.Implementations/Library/MusicManager.cs

@@ -5,6 +5,7 @@ using MediaBrowser.Controller.Playlists;
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
+using MediaBrowser.Controller.Dto;
 using MediaBrowser.Model.Querying;
 using MediaBrowser.Model.Querying;
 
 
 namespace Emby.Server.Implementations.Library
 namespace Emby.Server.Implementations.Library
@@ -18,47 +19,48 @@ namespace Emby.Server.Implementations.Library
             _libraryManager = libraryManager;
             _libraryManager = libraryManager;
         }
         }
 
 
-        public IEnumerable<Audio> GetInstantMixFromSong(Audio item, User user)
+        public IEnumerable<Audio> GetInstantMixFromSong(Audio item, User user, DtoOptions dtoOptions)
         {
         {
             var list = new List<Audio>
             var list = new List<Audio>
             {
             {
                 item
                 item
             };
             };
 
 
-            return list.Concat(GetInstantMixFromGenres(item.Genres, user));
+            return list.Concat(GetInstantMixFromGenres(item.Genres, user, dtoOptions));
         }
         }
 
 
-        public IEnumerable<Audio> GetInstantMixFromArtist(MusicArtist item, User user)
+        public IEnumerable<Audio> GetInstantMixFromArtist(MusicArtist item, User user, DtoOptions dtoOptions)
         {
         {
-            return GetInstantMixFromGenres(item.Genres, user);
+            return GetInstantMixFromGenres(item.Genres, user, dtoOptions);
         }
         }
 
 
-        public IEnumerable<Audio> GetInstantMixFromAlbum(MusicAlbum item, User user)
+        public IEnumerable<Audio> GetInstantMixFromAlbum(MusicAlbum item, User user, DtoOptions dtoOptions)
         {
         {
-            return GetInstantMixFromGenres(item.Genres, user);
+            return GetInstantMixFromGenres(item.Genres, user, dtoOptions);
         }
         }
 
 
-        public IEnumerable<Audio> GetInstantMixFromFolder(Folder item, User user)
+        public IEnumerable<Audio> GetInstantMixFromFolder(Folder item, User user, DtoOptions dtoOptions)
         {
         {
             var genres = item
             var genres = item
                .GetRecursiveChildren(user, new InternalItemsQuery(user)
                .GetRecursiveChildren(user, new InternalItemsQuery(user)
                {
                {
-                   IncludeItemTypes = new[] { typeof(Audio).Name }
+                   IncludeItemTypes = new[] { typeof(Audio).Name },
+                   DtoOptions = dtoOptions
                })
                })
                .Cast<Audio>()
                .Cast<Audio>()
                .SelectMany(i => i.Genres)
                .SelectMany(i => i.Genres)
                .Concat(item.Genres)
                .Concat(item.Genres)
                .DistinctNames();
                .DistinctNames();
 
 
-            return GetInstantMixFromGenres(genres, user);
+            return GetInstantMixFromGenres(genres, user, dtoOptions);
         }
         }
 
 
-        public IEnumerable<Audio> GetInstantMixFromPlaylist(Playlist item, User user)
+        public IEnumerable<Audio> GetInstantMixFromPlaylist(Playlist item, User user, DtoOptions dtoOptions)
         {
         {
-            return GetInstantMixFromGenres(item.Genres, user);
+            return GetInstantMixFromGenres(item.Genres, user, dtoOptions);
         }
         }
 
 
-        public IEnumerable<Audio> GetInstantMixFromGenres(IEnumerable<string> genres, User user)
+        public IEnumerable<Audio> GetInstantMixFromGenres(IEnumerable<string> genres, User user, DtoOptions dtoOptions)
         {
         {
             var genreIds = genres.DistinctNames().Select(i =>
             var genreIds = genres.DistinctNames().Select(i =>
             {
             {
@@ -73,10 +75,10 @@ namespace Emby.Server.Implementations.Library
 
 
             }).Where(i => i != null);
             }).Where(i => i != null);
 
 
-            return GetInstantMixFromGenreIds(genreIds, user);
+            return GetInstantMixFromGenreIds(genreIds, user, dtoOptions);
         }
         }
 
 
-        public IEnumerable<Audio> GetInstantMixFromGenreIds(IEnumerable<string> genreIds, User user)
+        public IEnumerable<Audio> GetInstantMixFromGenreIds(IEnumerable<string> genreIds, User user, DtoOptions dtoOptions)
         {
         {
             return _libraryManager.GetItemList(new InternalItemsQuery(user)
             return _libraryManager.GetItemList(new InternalItemsQuery(user)
             {
             {
@@ -86,47 +88,49 @@ namespace Emby.Server.Implementations.Library
 
 
                 Limit = 200,
                 Limit = 200,
 
 
-                SortBy = new[] { ItemSortBy.Random }
+                SortBy = new[] { ItemSortBy.Random },
+
+                DtoOptions = dtoOptions
 
 
             }).Cast<Audio>();
             }).Cast<Audio>();
         }
         }
 
 
-        public IEnumerable<Audio> GetInstantMixFromItem(BaseItem item, User user)
+        public IEnumerable<Audio> GetInstantMixFromItem(BaseItem item, User user, DtoOptions dtoOptions)
         {
         {
             var genre = item as MusicGenre;
             var genre = item as MusicGenre;
             if (genre != null)
             if (genre != null)
             {
             {
-                return GetInstantMixFromGenreIds(new[] { item.Id.ToString("N") }, user);
+                return GetInstantMixFromGenreIds(new[] { item.Id.ToString("N") }, user, dtoOptions);
             }
             }
 
 
             var playlist = item as Playlist;
             var playlist = item as Playlist;
             if (playlist != null)
             if (playlist != null)
             {
             {
-                return GetInstantMixFromPlaylist(playlist, user);
+                return GetInstantMixFromPlaylist(playlist, user, dtoOptions);
             }
             }
 
 
             var album = item as MusicAlbum;
             var album = item as MusicAlbum;
             if (album != null)
             if (album != null)
             {
             {
-                return GetInstantMixFromAlbum(album, user);
+                return GetInstantMixFromAlbum(album, user, dtoOptions);
             }
             }
 
 
             var artist = item as MusicArtist;
             var artist = item as MusicArtist;
             if (artist != null)
             if (artist != null)
             {
             {
-                return GetInstantMixFromArtist(artist, user);
+                return GetInstantMixFromArtist(artist, user, dtoOptions);
             }
             }
 
 
             var song = item as Audio;
             var song = item as Audio;
             if (song != null)
             if (song != null)
             {
             {
-                return GetInstantMixFromSong(song, user);
+                return GetInstantMixFromSong(song, user, dtoOptions);
             }
             }
 
 
             var folder = item as Folder;
             var folder = item as Folder;
             if (folder != null)
             if (folder != null)
             {
             {
-                return GetInstantMixFromFolder(folder, user);
+                return GetInstantMixFromFolder(folder, user, dtoOptions);
             }
             }
 
 
             return new Audio[] { };
             return new Audio[] { };

+ 0 - 2
Emby.Server.Implementations/Library/ResolverHelper.cs

@@ -5,8 +5,6 @@ using System;
 using System.IO;
 using System.IO;
 using System.Linq;
 using System.Linq;
 using System.Text.RegularExpressions;
 using System.Text.RegularExpressions;
-using MediaBrowser.Common.IO;
-using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 
 
 namespace Emby.Server.Implementations.Library
 namespace Emby.Server.Implementations.Library

+ 1 - 1
Emby.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs

@@ -8,7 +8,7 @@ using MediaBrowser.Naming.Audio;
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.IO;
 using System.IO;
-using MediaBrowser.Common.IO;
+
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Controller.Configuration;
 using MediaBrowser.Controller.Configuration;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;

+ 1 - 1
Emby.Server.Implementations/Library/Resolvers/Audio/MusicArtistResolver.cs

@@ -6,7 +6,7 @@ using MediaBrowser.Model.Logging;
 using System;
 using System;
 using System.IO;
 using System.IO;
 using System.Linq;
 using System.Linq;
-using MediaBrowser.Common.IO;
+
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Controller.Configuration;
 using MediaBrowser.Controller.Configuration;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;

+ 1 - 1
Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs

@@ -11,7 +11,7 @@ using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.IO;
 using System.IO;
 using System.Linq;
 using System.Linq;
-using MediaBrowser.Common.IO;
+
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.Logging;
 using MediaBrowser.Model.Logging;

+ 1 - 1
Emby.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs

@@ -5,7 +5,7 @@ using MediaBrowser.Controller.Resolvers;
 using System;
 using System;
 using System.IO;
 using System.IO;
 using System.Linq;
 using System.Linq;
-using MediaBrowser.Common.IO;
+
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 
 

+ 1 - 1
Emby.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs

@@ -10,7 +10,7 @@ using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.IO;
 using System.IO;
 using System.Linq;
 using System.Linq;
-using MediaBrowser.Common.IO;
+
 using MediaBrowser.Model.IO;
 using MediaBrowser.Model.IO;
 using MediaBrowser.Controller.Configuration;
 using MediaBrowser.Controller.Configuration;
 using MediaBrowser.Controller.IO;
 using MediaBrowser.Controller.IO;

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно