Merge pull request #2677 from MediaBrowser/beta

Beta
This commit is contained in:
Luke 2017-05-31 15:40:34 -04:00 committed by GitHub
commit 91176d9ccc
483 changed files with 6802 additions and 6720 deletions

View file

@ -31,7 +31,6 @@ using Emby.Common.Implementations.Net;
using Emby.Common.Implementations.EnvironmentInfo;
using Emby.Common.Implementations.Threading;
using MediaBrowser.Common;
using MediaBrowser.Common.IO;
using MediaBrowser.Model.Cryptography;
using MediaBrowser.Model.Diagnostics;
using MediaBrowser.Model.Net;
@ -39,10 +38,6 @@ using MediaBrowser.Model.System;
using MediaBrowser.Model.Tasks;
using MediaBrowser.Model.Threading;
#if NETSTANDARD1_6
using System.Runtime.Loader;
#endif
namespace Emby.Common.Implementations
{
/// <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
@ -306,7 +307,6 @@ namespace Emby.Common.Implementations
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("64-Bit OS: {0}", Environment.Is64BitOperatingSystem));
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));
}
}
#endif
builder.AppendLine(string.Format("Processor count: {0}", Environment.ProcessorCount));
builder.AppendLine(string.Format("Program data path: {0}", appPaths.ProgramDataPath));
@ -336,9 +335,7 @@ namespace Emby.Common.Implementations
try
{
// Increase the max http request limit
#if NET46
ServicePointManager.DefaultConnectionLimit = Math.Max(96, ServicePointManager.DefaultConnectionLimit);
#endif
}
catch (Exception ex)
{
@ -436,7 +433,6 @@ namespace Emby.Common.Implementations
if (assemblyPlugin != null)
{
#if NET46
var assembly = plugin.GetType().Assembly;
var assemblyName = assembly.GetName();
@ -447,21 +443,6 @@ namespace Emby.Common.Implementations
var assemblyFilePath = Path.Combine(ApplicationPaths.PluginsPath, assemblyFileName);
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);
@ -492,17 +473,7 @@ return null;
AllConcreteTypes = assemblies
.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();
}
@ -717,13 +688,7 @@ return null;
{
try
{
#if NET46
return Assembly.Load(File.ReadAllBytes(file));
#elif NETSTANDARD1_6
return AssemblyLoadContext.Default.LoadFromStream(new MemoryStream(File.ReadAllBytes(file)));
#endif
return null;
}
catch (Exception ex)
{
@ -742,14 +707,7 @@ return null;
{
var currentType = typeof(T);
#if NET46
return AllConcreteTypes.Where(currentType.IsAssignableFrom);
#elif NETSTANDARD1_6
var currentTypeInfo = currentType.GetTypeInfo();
return AllConcreteTypes.Where(currentTypeInfo.IsAssignableFrom);
#endif
return new List<Type>();
}
/// <summary>

View file

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

View file

@ -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>

View file

@ -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>

View file

@ -10,7 +10,7 @@ namespace Emby.Common.Implementations.EnvironmentInfo
{
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 virtual MediaBrowser.Model.System.OperatingSystem OperatingSystem
@ -22,7 +22,6 @@ namespace Emby.Common.Implementations.EnvironmentInfo
return CustomOperatingSystem.Value;
}
#if NET46
switch (Environment.OSVersion.Platform)
{
case PlatformID.MacOSX:
@ -32,20 +31,7 @@ namespace Emby.Common.Implementations.EnvironmentInfo
case PlatformID.Unix:
return MediaBrowser.Model.System.OperatingSystem.Linux;
}
#elif NETSTANDARD1_6
if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
return OperatingSystem.OSX;
}
if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return OperatingSystem.Windows;
}
if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
return OperatingSystem.Linux;
}
#endif
return MediaBrowser.Model.System.OperatingSystem.Windows;
}
}
@ -54,12 +40,7 @@ namespace Emby.Common.Implementations.EnvironmentInfo
{
get
{
#if NET46
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
{
#if NET46
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
{
@ -92,22 +68,8 @@ namespace Emby.Common.Implementations.EnvironmentInfo
{
return CustomArchitecture.Value;
}
#if NET46
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;
}
}

View file

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

View file

@ -1,7 +1,7 @@
using System;
using System.IO;
namespace MediaBrowser.Common.IO
namespace Emby.Common.Implementations.IO
{
/// <summary>
/// Measures progress when reading from a stream or writing to one
@ -155,6 +155,21 @@ namespace MediaBrowser.Common.IO
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>
/// When overridden in a derived class, sets the position within the current stream.
/// </summary>
@ -194,6 +209,21 @@ namespace MediaBrowser.Common.IO
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>
/// Releases the unmanaged resources used by the <see cref="T:System.IO.Stream" /> and optionally releases the managed resources.
/// </summary>

View file

@ -97,7 +97,6 @@ namespace Emby.Common.Implementations.Net
_acceptor.StartAccept();
}
#if NET46
public Task SendFile(string path, byte[] preBuffer, byte[] postBuffer, CancellationToken cancellationToken)
{
var options = TransmitFileOptions.UseDefaultWorkerThread;
@ -109,6 +108,18 @@ namespace Emby.Common.Implementations.Net
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)
{
// Retrieve the socket from the state object.
@ -117,25 +128,23 @@ namespace Emby.Common.Implementations.Net
var client = data.Item1;
var path = data.Item2;
var taskCompletion = data.Item3;
// 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);
}
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();
}
#endif
public void Dispose()
{

View file

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Sockets;
@ -188,16 +189,7 @@ namespace Emby.Common.Implementations.Net
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.ReuseAddress, true);
retVal.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, multicastTimeToLive);
@ -217,5 +209,89 @@ namespace Emby.Common.Implementations.Net
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);
}
}
}

View file

@ -14,11 +14,16 @@ namespace Emby.Common.Implementations.Net
// 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.
internal sealed class UdpSocket : DisposableManagedObjectBase, ISocket
public sealed class UdpSocket : DisposableManagedObjectBase, ISocket
{
private Socket _Socket;
private int _LocalPort;
public Socket Socket
{
get { return _Socket; }
}
private readonly SocketAsyncEventArgs _receiveSocketAsyncEventArgs = new SocketAsyncEventArgs()
{
SocketFlags = SocketFlags.None
@ -116,129 +121,104 @@ namespace Emby.Common.Implementations.Net
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);
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();
IPEndPoint sender = new IPEndPoint(IPAddress.Any, 0);
EndPoint remoteEndPoint = (EndPoint)sender;
if (buffer == null) throw new ArgumentNullException("messageData");
if (endPoint == null) throw new ArgumentNullException("endPoint");
var receivedBytes = _Socket.EndReceiveFrom(result, ref remoteEndPoint);
var buffer = (byte[]) result.AsyncState;
return new SocketReceiveResult
{
ReceivedBytes = receivedBytes,
RemoteEndPoint = ToIpEndPointInfo((IPEndPoint)remoteEndPoint),
Buffer = buffer,
LocalIPAddress = LocalIPAddress
};
}
public Task<SocketReceiveResult> ReceiveAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
{
var taskCompletion = new TaskCompletionSource<SocketReceiveResult>();
Action<IAsyncResult> callback = callbackResult =>
{
try
{
taskCompletion.TrySetResult(EndReceive(callbackResult));
}
catch (Exception ex)
{
taskCompletion.TrySetException(ex);
}
};
var result = BeginReceive(buffer, offset, count, new AsyncCallback(callback));
if (result.CompletedSynchronously)
{
callback(result);
}
cancellationToken.Register(() => taskCompletion.TrySetCanceled());
return taskCompletion.Task;
}
public Task<SocketReceiveResult> ReceiveAsync(CancellationToken cancellationToken)
{
var buffer = new byte[8192];
return ReceiveAsync(buffer, 0, buffer.Length, cancellationToken);
}
public Task SendToAsync(byte[] buffer, int offset, int size, IpEndPointInfo endPoint, CancellationToken cancellationToken)
{
var taskCompletion = new TaskCompletionSource<int>();
Action<IAsyncResult> callback = callbackResult =>
{
try
{
taskCompletion.TrySetResult(EndSendTo(callbackResult));
}
catch (Exception ex)
{
taskCompletion.TrySetException(ex);
}
};
var result = BeginSendTo(buffer, offset, size, endPoint, new AsyncCallback(callback), null);
if (result.CompletedSynchronously)
{
callback(result);
}
cancellationToken.Register(() => taskCompletion.TrySetCanceled());
return taskCompletion.Task;
}
public IAsyncResult BeginSendTo(byte[] buffer, int offset, int size, IpEndPointInfo endPoint, AsyncCallback callback, object state)
{
var ipEndPoint = NetworkManager.ToIPEndPoint(endPoint);
#if NETSTANDARD1_6
if (size != buffer.Length)
{
byte[] copy = new byte[size];
Buffer.BlockCopy(buffer, 0, copy, 0, size);
buffer = copy;
}
cancellationToken.ThrowIfCancellationRequested();
_Socket.SendTo(buffer, ipEndPoint);
return Task.FromResult(true);
#else
var taskSource = new TaskCompletionSource<bool>();
try
{
_Socket.BeginSendTo(buffer, 0, size, SocketFlags.None, ipEndPoint, result =>
{
if (cancellationToken.IsCancellationRequested)
{
taskSource.TrySetCanceled();
return;
}
try
{
_Socket.EndSend(result);
taskSource.TrySetResult(true);
}
catch (Exception ex)
{
taskSource.TrySetException(ex);
}
}, null);
}
catch (Exception ex)
{
taskSource.TrySetException(ex);
}
return taskSource.Task;
#endif
//ThrowIfDisposed();
//if (buffer == null) throw new ArgumentNullException("messageData");
//if (endPoint == null) throw new ArgumentNullException("endPoint");
//cancellationToken.ThrowIfCancellationRequested();
//var tcs = new TaskCompletionSource<int>();
//cancellationToken.Register(() => tcs.TrySetCanceled());
//_sendSocketAsyncEventArgs.SetBuffer(buffer, 0, size);
//_sendSocketAsyncEventArgs.RemoteEndPoint = NetworkManager.ToIPEndPoint(endPoint);
//_currentSendTaskCompletionSource = tcs;
//var willRaiseEvent = _Socket.SendAsync(_sendSocketAsyncEventArgs);
//if (!willRaiseEvent)
//{
// _sendSocketAsyncEventArgs_Completed(this, _sendSocketAsyncEventArgs);
//}
//return tcs.Task;
return _Socket.BeginSendTo(buffer, offset, size, SocketFlags.None, ipEndPoint, callback, state);
}
public async Task SendWithLockAsync(byte[] buffer, int size, IpEndPointInfo endPoint, CancellationToken cancellationToken)
public int EndSendTo(IAsyncResult result)
{
ThrowIfDisposed();
//await _sendLock.WaitAsync(cancellationToken).ConfigureAwait(false);
try
{
await SendAsync(buffer, size, endPoint, cancellationToken).ConfigureAwait(false);
}
finally
{
//_sendLock.Release();
}
return _Socket.EndSendTo(result);
}
protected override void Dispose(bool disposing)
@ -273,52 +253,5 @@ namespace Emby.Common.Implementations.Net
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; }
}
}
}

View file

@ -2,18 +2,33 @@
using System.Runtime.CompilerServices;
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
// associated with an assembly.
[assembly: AssemblyTitle("Emby.Common.Implementations")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Emby.Common.Implementations")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[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.
[assembly: ComVisible(false)]
// 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.*")]

View file

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

View file

@ -5,7 +5,6 @@ using System.Collections.Generic;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using MediaBrowser.Common.IO;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Logging;
@ -78,18 +77,11 @@ namespace Emby.Common.Implementations.Serialization
/// <param name="stream">The stream.</param>
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;
SerializeToWriter(obj, writer);
}
#else
using (var writer = XmlWriter.Create(stream))
{
SerializeToWriter(obj, writer);
}
#endif
}
/// <summary>

View file

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

View file

@ -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>

View file

@ -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"
}
}
}
}
}

View file

@ -23,6 +23,7 @@ using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Xml;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Model.Globalization;
@ -85,7 +86,7 @@ namespace Emby.Dlna.ContentDirectory
return HandleGetSystemUpdateID();
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))
return HandleXGetFeatureList();
@ -97,10 +98,10 @@ namespace Emby.Dlna.ContentDirectory
return HandleXSetBookmark(methodParams, user);
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))
return HandleX_BrowseByLetter(methodParams, user, deviceId).Result;
return HandleX_BrowseByLetter(methodParams, user, deviceId);
throw new ResourceNotFoundException("Unexpected control request name: " + methodName);
}
@ -202,7 +203,7 @@ namespace Emby.Dlna.ContentDirectory
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 flag = sparams["BrowseFlag"];
@ -262,7 +263,7 @@ namespace Emby.Dlna.ContentDirectory
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);
}
@ -275,7 +276,7 @@ namespace Emby.Dlna.ContentDirectory
}
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;
provided = childrenResult.Items.Length;
@ -287,7 +288,7 @@ namespace Emby.Dlna.ContentDirectory
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;
_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
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 sortCriteria = new SortCriteria(GetValueOrDefault(sparams, "SortCriteria", ""));
@ -373,7 +374,7 @@ namespace Emby.Dlna.ContentDirectory
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;
@ -383,7 +384,7 @@ namespace Emby.Dlna.ContentDirectory
{
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;
_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;
@ -459,11 +460,17 @@ namespace Emby.Dlna.ContentDirectory
IsMissing = false,
ExcludeItemTypes = new[] { typeof(Game).Name, typeof(Book).Name },
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)
{
@ -511,14 +518,15 @@ namespace Emby.Dlna.ContentDirectory
StartIndex = startIndex,
User = user,
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);
var queryResult = await folder.GetItems(query).ConfigureAwait(false);
var queryResult = folder.GetItems(query);
return ToResult(queryResult);
}
@ -532,7 +540,8 @@ namespace Emby.Dlna.ContentDirectory
ArtistIds = new[] { item.Id.ToString("N") },
IncludeItemTypes = new[] { typeof(MusicAlbum).Name },
Limit = limit,
StartIndex = startIndex
StartIndex = startIndex,
DtoOptions = GetDtoOptions()
};
SetSorting(query, sort, false);
@ -548,10 +557,11 @@ namespace Emby.Dlna.ContentDirectory
{
Recursive = true,
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,
StartIndex = startIndex
StartIndex = startIndex,
DtoOptions = GetDtoOptions()
};
SetSorting(query, sort, false);
@ -595,8 +605,8 @@ namespace Emby.Dlna.ContentDirectory
IncludeItemTypes = new[] { typeof(Movie).Name, typeof(Series).Name, typeof(Trailer).Name },
SortBy = new[] { ItemSortBy.SortName },
Limit = limit,
StartIndex = startIndex
StartIndex = startIndex,
DtoOptions = GetDtoOptions()
});
var serverItems = itemsResult.Items.Select(i => new ServerItem(i))

View file

@ -18,6 +18,7 @@ using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using MediaBrowser.Controller.MediaEncoding;
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,
BaseItem context,
StubType? contextStubType,
string deviceId,
Filter filter,
BaseItem context,
StubType? contextStubType,
string deviceId,
Filter filter,
StreamInfo streamInfo = null)
{
var clientId = GetClientId(item, null);
@ -223,6 +224,7 @@ namespace Emby.Dlna.Didl
streamInfo.TargetPacketLength,
streamInfo.TranscodeSeekInfo,
streamInfo.IsTargetAnamorphic,
streamInfo.IsTargetInterlaced,
streamInfo.TargetRefFrames,
streamInfo.TargetVideoStreamCount,
streamInfo.TargetAudioStreamCount,
@ -363,6 +365,7 @@ namespace Emby.Dlna.Didl
streamInfo.TargetPacketLength,
streamInfo.TargetTimestamp,
streamInfo.IsTargetAnamorphic,
streamInfo.IsTargetInterlaced,
streamInfo.TargetRefFrames,
streamInfo.TargetVideoStreamCount,
streamInfo.TargetAudioStreamCount,
@ -920,7 +923,7 @@ namespace Emby.Dlna.Didl
if (item is Video)
{
var userData = _userDataManager.GetUserDataDto(item, _user).Result;
var userData = _userDataManager.GetUserDataDto(item, _user);
playbackPercentage = Convert.ToInt32(userData.PlayedPercentage ?? 0);
if (playbackPercentage >= 100 || userData.Played)
@ -930,7 +933,7 @@ namespace Emby.Dlna.Didl
}
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)
{

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -130,7 +130,7 @@ namespace Emby.Drawing.ImageMagick
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
quality = Math.Min(quality, 99);
@ -144,9 +144,13 @@ namespace Emby.Drawing.ImageMagick
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);
@ -174,10 +178,8 @@ namespace Emby.Drawing.ImageMagick
{
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);
@ -205,6 +207,8 @@ namespace Emby.Drawing.ImageMagick
}
}
}
return outputPath;
}
private void AddForegroundLayer(MagickWand wand, ImageProcessingOptions options)

View file

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

View file

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

View file

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

View file

@ -60,13 +60,14 @@
<Compile Include="UnplayedCountIndicator.cs" />
</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>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="fonts\robotoregular.ttf" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />

View file

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

View file

@ -191,18 +191,18 @@ namespace Emby.Drawing.Skia
}
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);
if (requiresTransparencyHack)
if (requiresTransparencyHack || forceCleanBitmap)
{
using (var stream = new SKFileStream(path))
{
var codec = SKCodec.Create(stream);
// 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
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)
@ -226,7 +242,7 @@ namespace Emby.Drawing.Skia
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))
{
@ -246,9 +262,20 @@ namespace Emby.Drawing.Skia
using (var bitmap = GetBitmap(inputPath, options.CropWhiteSpace))
{
if (options.CropWhiteSpace || !originalImageSize.HasValue)
if (bitmap == null)
{
originalImageSize = new ImageSize(bitmap.Width, bitmap.Height);
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))
{
// Just spit out the original file if all the options are default
return inputPath;
}
var newImageSize = ImageHelper.GetNewImageSize(options, originalImageSize);
@ -269,7 +296,7 @@ namespace Emby.Drawing.Skia
using (var outputStream = new SKFileWStream(outputPath))
{
resizedBitmap.Encode(outputStream, skiaOutputFormat, quality);
return;
return outputPath;
}
}
@ -326,6 +353,7 @@ namespace Emby.Drawing.Skia
}
}
}
return outputPath;
}
public void CreateImageCollage(ImageCollageOptions options)

View file

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

View file

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

View file

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

View file

@ -17,7 +17,7 @@ using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Model.IO;
using Emby.Drawing.Common;
using MediaBrowser.Common.IO;
using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Net;
@ -75,6 +75,7 @@ namespace Emby.Drawing
ImageEnhancers = new List<IImageEnhancer>();
_saveImageSizeTimer = timerFactory.Create(SaveImageSizeCallback, null, Timeout.Infinite, Timeout.Infinite);
ImageHelper.ImageProcessor = this;
Dictionary<Guid, ImageSize> sizeDictionary;
@ -178,10 +179,15 @@ namespace Emby.Drawing
}
var originalImage = options.Image;
IHasImages item = options.Item;
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;
@ -194,13 +200,18 @@ namespace Emby.Drawing
if (options.Enhancers.Count > 0)
{
if (item == null)
{
item = _libraryManager().GetItemById(options.ItemId);
}
var tuple = await GetEnhancedImage(new ItemImageInfo
{
DateModified = dateModified,
Type = originalImage.Type,
Path = originalImagePath
}, options.Item, options.ImageIndex, options.Enhancers).ConfigureAwait(false);
}, item, options.ImageIndex, options.Enhancers).ConfigureAwait(false);
originalImagePath = tuple.Item1;
dateModified = tuple.Item2;
@ -212,19 +223,12 @@ namespace Emby.Drawing
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);
@ -243,7 +247,18 @@ namespace Emby.Drawing
var tmpPath = Path.ChangeExtension(Path.Combine(_appPaths.TempDirectory, Guid.NewGuid().ToString("N")), Path.GetExtension(cacheFilePath));
_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);
return new Tuple<string, string, DateTime>(tmpPath, GetMimeType(outputFormat, cacheFilePath), _fileSystem.GetLastWriteTimeUtc(tmpPath));
@ -422,26 +437,72 @@ namespace Emby.Drawing
throw new ArgumentNullException("path");
}
var name = path + "datemodified=" + imageDateModified.Ticks;
ImageSize size;
var cacheHash = name.GetMD5();
var cacheHash = GetImageSizeKey(path, imageDateModified);
if (!_cachedImagedSizes.TryGetValue(cacheHash, out size))
{
size = GetImageSizeInternal(path, allowSlowMethod);
if (size.Width > 0 && size.Height > 0)
{
StartSaveImageSizeTimer();
_cachedImagedSizes.AddOrUpdate(cacheHash, size, (keyName, oldValue) => size);
}
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();
}
}
else
{
StartSaveImageSizeTimer();
_cachedImagedSizes.AddOrUpdate(cacheHash, size, (keyName, oldValue) => 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>
/// Gets the image size internal.
/// </summary>
@ -624,7 +685,7 @@ namespace Emby.Drawing
var ehnancedImagePath = await GetEnhancedImageInternal(originalImagePath, item, imageType, imageIndex, enhancers, cacheGuid).ConfigureAwait(false);
// If the path changed update dateModified
if (!ehnancedImagePath.Equals(originalImagePath, StringComparison.OrdinalIgnoreCase))
if (!string.Equals(ehnancedImagePath, originalImagePath, StringComparison.OrdinalIgnoreCase))
{
return GetResult(ehnancedImagePath);
}
@ -783,7 +844,7 @@ namespace Emby.Drawing
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);

View file

@ -32,7 +32,7 @@ namespace Emby.Drawing
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();
}

View file

@ -492,7 +492,6 @@ namespace Emby.Server.Core
{
var migrations = new List<IVersionMigration>
{
new UpdateLevelMigration(ServerConfigurationManager, this, HttpClient, JsonSerializer, _releaseAssetFilename, Logger)
};
foreach (var task in migrations)
@ -589,7 +588,7 @@ namespace Emby.Server.Core
FileOrganizationRepository = GetFileOrganizationRepository();
RegisterSingleInstance(FileOrganizationRepository);
AuthenticationRepository = await GetAuthenticationRepository().ConfigureAwait(false);
AuthenticationRepository = GetAuthenticationRepository();
RegisterSingleInstance(AuthenticationRepository);
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;
}
private async Task<IAuthenticationRepository> GetAuthenticationRepository()
private IAuthenticationRepository GetAuthenticationRepository()
{
var repo = new AuthenticationRepository(LogManager.GetLogger("AuthenticationRepository"), ServerConfigurationManager.ApplicationPaths);
@ -1278,9 +1277,6 @@ namespace Emby.Server.Core
// Emby.Server implementations
list.Add(GetAssembly(typeof(InstallationManager)));
// Emby.Server.Core
list.Add(GetAssembly(typeof(ApplicationHost)));
// MediaEncoding
list.Add(GetAssembly(typeof(MediaEncoder)));

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,17 +1,16 @@
<?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')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{B90AB8F2-1BFF-4568-A3FD-2A338A435A75}</ProjectGuid>
<ProjectGuid>{776B9F0C-5195-45E3-9A36-1CC1F0D8E0B0}</ProjectGuid>
<OutputType>Library</OutputType>
<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>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@ -25,7 +24,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>None</DebugType>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
@ -34,13 +33,18 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<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">
<HintPath>..\packages\Microsoft.IO.RecyclableMemoryStream.1.2.2\lib\net45\Microsoft.IO.RecyclableMemoryStream.dll</HintPath>
<Private>True</Private>
</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.Configuration" />
<Reference Include="System.Core" />
@ -48,12 +52,14 @@
<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="ApplicationHost.cs" />
<Compile Include="ApplicationPathHelper.cs" />
<Compile Include="Cryptography\ASN1.cs" />
<Compile Include="Cryptography\ASN1Convert.cs" />
@ -73,16 +79,40 @@
<Compile Include="Cryptography\X509Extension.cs" />
<Compile Include="Cryptography\X509Extensions.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="Localization\TextLocalizer.cs" />
<Compile Include="Logging\ConsoleLogger.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SystemEvents.cs" />
<Compile Include="UpdateLevelHelper.cs" />
</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">
<Project>{e383961b-9356-4d5d-8233-9a1079d03055}</Project>
<Name>Emby.Server.Implementations</Name>
</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">
<Project>{9142eefa-7570-41e1-bfcc-468bb571af2f}</Project>
<Name>MediaBrowser.Common</Name>
@ -91,16 +121,51 @@
<Project>{17e1f4e6-8abd-4fe5-9ecf-43d4b6087ba2}</Project>
<Name>MediaBrowser.Controller</Name>
</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">
<Project>{7eeeb4bb-f3e8-48fc-b4c5-70f0fff8329b}</Project>
<Name>MediaBrowser.Model</Name>
</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>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View file

@ -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>

View file

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

View file

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

View file

@ -2,18 +2,33 @@
using System.Runtime.CompilerServices;
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
// associated with an assembly.
[assembly: AssemblyTitle("Emby.Server.Core")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Emby.Server.Core")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[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.
[assembly: ComVisible(false)]
// 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.*")]

View file

@ -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>

View file

@ -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>

View file

@ -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"
}
}
}
}
}

View file

@ -23,7 +23,7 @@ using System.Linq;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Common.IO;
using MediaBrowser.Model.IO;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Entities.Movies;
@ -120,7 +120,7 @@ namespace Emby.Server.Implementations.Channels
if (query.IsFavorite.HasValue)
{
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();
}
@ -263,7 +263,7 @@ namespace Emby.Server.Implementations.Channels
}
catch
{
}
return;
}
@ -273,7 +273,7 @@ namespace Emby.Server.Implementations.Channels
_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);
@ -460,12 +460,12 @@ namespace Emby.Server.Implementations.Channels
public IEnumerable<ChannelFeatures> GetAllChannelFeatures()
{
return _libraryManager.GetItemList(new InternalItemsQuery
return _libraryManager.GetItemIds(new InternalItemsQuery
{
IncludeItemTypes = new[] { typeof(Channel).Name },
SortBy = new[] { ItemSortBy.SortName }
}).Select(i => GetChannelFeatures(i.Id.ToString("N")));
}).Select(i => GetChannelFeatures(i.ToString("N")));
}
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)
@ -1154,7 +1154,7 @@ namespace Emby.Server.Implementations.Channels
filename + ".json");
}
private async Task<QueryResult<BaseItem>> GetReturnItems(IEnumerable<BaseItem> items,
private QueryResult<BaseItem> GetReturnItems(IEnumerable<BaseItem> items,
int? totalCountFromProvider,
User user,
ChannelItemQuery query)

View file

@ -32,7 +32,7 @@ namespace Emby.Server.Implementations.Collections
return base.Supports(item);
}
protected override Task<List<BaseItem>> GetItemsWithImages(IHasImages item)
protected override List<BaseItem> GetItemsWithImages(IHasImages item)
{
var playlist = (BoxSet)item;
@ -73,10 +73,10 @@ namespace Emby.Server.Implementations.Collections
.DistinctBy(i => i.Id)
.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);
}

View file

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

View file

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

File diff suppressed because it is too large Load diff

View file

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

View file

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

View file

@ -24,7 +24,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using MediaBrowser.Common.IO;
using MediaBrowser.Controller.IO;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Extensions;
@ -107,7 +107,7 @@ namespace Emby.Server.Implementations.Dto
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;
if (tvChannel != null)
@ -127,7 +127,11 @@ namespace Emby.Server.Implementations.Dto
{
var libraryItems = byName.GetTaggedItems(new InternalItemsQuery(user)
{
Recursive = true
Recursive = true,
DtoOptions = new DtoOptions(false)
{
EnableImages = false
}
});
SetItemByNameInfo(item, dto, libraryItems.ToList(), user);
@ -156,7 +160,7 @@ namespace Emby.Server.Implementations.Dto
{
var syncDictionary = GetSyncedItemProgress(options);
var dto = GetBaseItemDtoInternal(item, options, user, owner).Result;
var dto = GetBaseItemDtoInternal(item, options, user, owner);
var tvChannel = item as LiveTvChannel;
if (tvChannel != null)
{
@ -177,7 +181,11 @@ namespace Emby.Server.Implementations.Dto
{
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);
@ -189,11 +197,12 @@ namespace Emby.Server.Implementations.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)
{
Recursive = true
Recursive = true,
DtoOptions = options
}).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;
@ -332,7 +341,7 @@ namespace Emby.Server.Implementations.Dto
if (user != null)
{
await AttachUserSpecificInfo(dto, item, user, options).ConfigureAwait(false);
AttachUserSpecificInfo(dto, item, user, options);
}
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)
{
var dto = GetBaseItemDtoInternal(item, options, user).Result;
var dto = GetBaseItemDtoInternal(item, options, user);
if (taggedItems != null && options.Fields.Contains(ItemFields.ItemCounts))
{
@ -446,7 +455,7 @@ namespace Emby.Server.Implementations.Dto
/// <summary>
/// Attaches the user specific info.
/// </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;
@ -456,7 +465,7 @@ namespace Emby.Server.Implementations.Dto
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)
@ -488,7 +497,7 @@ namespace Emby.Server.Implementations.Dto
{
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))
{
var parentAlbum = _libraryManager.GetItemList(new InternalItemsQuery
var parentAlbumIds = _libraryManager.GetItemIds(new InternalItemsQuery
{
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>
private void AttachStudios(BaseItemDto dto, BaseItem item)
{
var studios = item.Studios.ToList();
dto.Studios = item.Studios
.Where(i => !string.IsNullOrWhiteSpace(i))
.Select(i => new NameIdPair
{
Name = i,
Id = _libraryManager.GetStudioId(i).ToString("N")
})
.ToArray();
}
dto.Studios = new StudioDto[studios.Count];
private void AttachGenreItems(BaseItemDto dto, BaseItem item)
{
dto.GenreItems = item.Genres
.Where(i => !string.IsNullOrWhiteSpace(i))
.Select(i => new NameIdPair
{
Name = i,
Id = GetStudioId(i, item)
})
.ToArray();
}
var dictionary = studios.Distinct(StringComparer.OrdinalIgnoreCase).Select(name =>
private string GetStudioId(string name, BaseItem owner)
{
if (owner is IHasMusicGenres)
{
try
{
return _libraryManager.GetStudio(name);
}
catch (IOException ex)
{
_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];
var studioDto = new StudioDto
{
Name = studio
};
Studio entity;
if (dictionary.TryGetValue(studio, out entity))
{
studioDto.Id = entity.Id.ToString("N");
studioDto.PrimaryImageTag = GetImageCacheTag(entity, ImageType.Primary);
}
dto.Studios[i] = studioDto;
return _libraryManager.GetGameGenreId(name).ToString("N");
}
if (owner is Game || owner is GameSystem)
{
return _libraryManager.GetGameGenreId(name).ToString("N");
}
return _libraryManager.GetGenreId(name).ToString("N");
}
/// <summary>
@ -901,6 +907,7 @@ namespace Emby.Server.Implementations.Dto
if (fields.Contains(ItemFields.Genres))
{
dto.Genres = item.Genres;
AttachGenreItems(dto, item);
}
if (options.EnableImages)
@ -1130,7 +1137,10 @@ namespace Emby.Server.Implementations.Dto
return null;
}
var artist = _libraryManager.GetArtist(i);
var artist = _libraryManager.GetArtist(i, new DtoOptions(false)
{
EnableImages = false
});
if (artist != null)
{
return new NameIdPair
@ -1179,7 +1189,10 @@ namespace Emby.Server.Implementations.Dto
return null;
}
var artist = _libraryManager.GetArtist(i);
var artist = _libraryManager.GetArtist(i, new DtoOptions(false)
{
EnableImages = false
});
if (artist != null)
{
return new NameIdPair
@ -1449,7 +1462,7 @@ namespace Emby.Server.Implementations.Dto
var musicAlbum = item as MusicAlbum;
if (musicAlbum != null)
{
var artist = musicAlbum.MusicArtist;
var artist = musicAlbum.GetMusicArtist(new DtoOptions(false));
if (artist != null)
{
return artist;
@ -1582,24 +1595,30 @@ namespace Emby.Server.Implementations.Dto
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;
}
}
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)

View file

@ -10,9 +10,8 @@
<RootNamespace>Emby.Server.Implementations</RootNamespace>
<AssemblyName>Emby.Server.Implementations</AssemblyName>
<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 Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -103,6 +102,7 @@
<Compile Include="HttpServer\SocketSharp\WebSocketSharpResponse.cs" />
<Compile Include="HttpServer\StreamWriter.cs" />
<Compile Include="Images\BaseDynamicImageProvider.cs" />
<Compile Include="IO\AsyncStreamCopier.cs" />
<Compile Include="IO\FileRefresher.cs" />
<Compile Include="IO\MbLinkShortcutHandler.cs" />
<Compile Include="IO\ThrottledStream.cs" />
@ -182,7 +182,6 @@
<Compile Include="Migrations\IVersionMigration.cs" />
<Compile Include="Migrations\LibraryScanMigration.cs" />
<Compile Include="Migrations\GuideMigration.cs" />
<Compile Include="Migrations\UpdateLevelMigration.cs" />
<Compile Include="News\NewsEntryPoint.cs" />
<Compile Include="News\NewsService.cs" />
<Compile Include="Notifications\CoreNotificationTypes.cs" />
@ -291,9 +290,9 @@
<Project>{2e781478-814d-4a48-9d80-bff206441a65}</Project>
<Name>MediaBrowser.Server.Implementations</Name>
</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>
<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>
@ -312,6 +311,17 @@
<Private>True</Private>
</Reference>
</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>
<EmbeddedResource Include="Localization\Core\ar.json" />
<EmbeddedResource Include="Localization\Core\bg-BG.json" />
@ -410,7 +420,7 @@
<ItemGroup>
<EmbeddedResource Include="Localization\Ratings\uk.txt" />
</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.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -8,6 +8,7 @@ using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Emby.Server.Implementations.HttpServer;
using Emby.Server.Implementations.HttpServer.SocketSharp;
@ -445,10 +446,7 @@ namespace Emby.Server.Implementations.HttpServer
/// <summary>
/// Overridable method that can be used to implement a custom hnandler
/// </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 httpRes = httpReq.Response;
@ -589,7 +587,7 @@ namespace Emby.Server.Implementations.HttpServer
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
{

View file

@ -58,6 +58,18 @@ namespace Emby.Server.Implementations.HttpServer
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>
/// Gets the HTTP result.
/// </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,
string contentType)
{

View file

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

View file

@ -4,6 +4,7 @@ using SocketHttpListener.Net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Common.Net;
using MediaBrowser.Model.Cryptography;
@ -33,6 +34,9 @@ namespace Emby.Server.Implementations.HttpServer.SocketSharp
private readonly bool _enableDualMode;
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)
{
_logger = logger;
@ -47,10 +51,12 @@ namespace Emby.Server.Implementations.HttpServer.SocketSharp
_httpRequestFactory = httpRequestFactory;
_fileSystem = fileSystem;
_environment = environment;
_disposeCancellationToken = _disposeCancellationTokenSource.Token;
}
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; }
@ -81,11 +87,11 @@ namespace Emby.Server.Implementations.HttpServer.SocketSharp
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;
var request = context.Request;
@ -111,7 +117,7 @@ namespace Emby.Server.Implementations.HttpServer.SocketSharp
return Task.FromResult(true);
}
return RequestHandler(httpReq, request.Url);
return RequestHandler(httpReq, request.Url, cancellationToken);
}
private void ProcessWebSocketRequest(HttpListenerContext ctx)
@ -172,6 +178,8 @@ namespace Emby.Server.Implementations.HttpServer.SocketSharp
public void Stop()
{
_disposeCancellationTokenSource.Cancel();
if (_listener != null)
{
foreach (var prefix in _listener.Prefixes.ToList())

View file

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text;
using Emby.Server.Implementations.HttpServer;
using Emby.Server.Implementations.HttpServer.SocketSharp;
@ -374,7 +373,7 @@ namespace Emby.Server.Implementations.HttpServer.SocketSharp
this.pathInfo = request.RawUrl;
}
this.pathInfo = WebUtility.UrlDecode(pathInfo);
this.pathInfo = System.Net.WebUtility.UrlDecode(pathInfo);
this.pathInfo = NormalizePathInfo(pathInfo, mode);
}
return this.pathInfo;
@ -440,7 +439,7 @@ namespace Emby.Server.Implementations.HttpServer.SocketSharp
cookies = new Dictionary<string, System.Net.Cookie>();
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);
}
}

View file

@ -114,15 +114,9 @@ namespace Emby.Server.Implementations.HttpServer.SocketSharp
var outputStream = response.OutputStream;
// 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();
}
catch (Exception ex)

View file

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

View file

@ -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;
}
}
}
}

View file

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

View file

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

View file

@ -12,7 +12,7 @@ using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Common.IO;
using MediaBrowser.Model.IO;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.IO;
@ -59,33 +59,6 @@ namespace Emby.Server.Implementations.Images
//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)
{
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);
}
@ -140,7 +113,7 @@ namespace Emby.Server.Implementations.Images
{
var outputPathWithoutExtension = Path.Combine(ApplicationPaths.TempDirectory, Guid.NewGuid().ToString("N"));
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))
{
@ -159,9 +132,9 @@ namespace Emby.Server.Implementations.Images
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);
}
@ -188,22 +161,22 @@ namespace Emby.Server.Implementations.Images
.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);
}
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);
}
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);
}
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));
@ -225,7 +198,7 @@ namespace Emby.Server.Implementations.Images
return null;
}
await ImageProcessor.CreateImageCollage(options).ConfigureAwait(false);
ImageProcessor.CreateImageCollage(options);
return outputPath;
}
@ -234,7 +207,7 @@ namespace Emby.Server.Implementations.Images
get { return "Dynamic Image Provider"; }
}
protected virtual async Task<string> CreateImage(IHasImages item,
protected virtual string CreateImage(IHasImages item,
List<BaseItem> itemsWithImages,
string outputPathWithoutExtension,
ImageType imageType,
@ -249,20 +222,20 @@ namespace Emby.Server.Implementations.Images
if (imageType == ImageType.Thumb)
{
return await CreateThumbCollage(item, itemsWithImages, outputPath).ConfigureAwait(false);
return CreateThumbCollage(item, itemsWithImages, outputPath);
}
if (imageType == ImageType.Primary)
{
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)
{
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");
@ -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
.Where(i => i.HasImage(imageType) && i.GetImageInfo(imageType, 0).IsLocalFile && Path.HasExtension(i.GetImagePath(imageType)))

View file

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

View file

@ -40,7 +40,8 @@ using MediaBrowser.Model.Net;
using SortOrder = MediaBrowser.Model.Entities.SortOrder;
using VideoResolver = MediaBrowser.Naming.Video.VideoResolver;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.IO;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Model.Tasks;
@ -313,7 +314,8 @@ namespace Emby.Server.Implementations.Library
{
IncludeItemTypes = new[] { typeof(Season).Name },
Recursive = true,
IndexNumber = 0
IndexNumber = 0,
DtoOptions = new DtoOptions(true)
}).Cast<Season>()
.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 MusicArtist) && !(item is Studio))
if (!(item is MusicArtist))
{
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.
// 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
{
Path = path,
IsFolder = isFolder,
SortBy = new[] { ItemSortBy.DateCreated },
SortOrder = SortOrder.Descending,
Limit = 1
Limit = 1,
DtoOptions = new DtoOptions(true)
};
return GetItemList(query)
@ -882,7 +890,7 @@ namespace Emby.Server.Implementations.Library
/// <returns>Task{Person}.</returns>
public Person GetPerson(string name)
{
return CreateItemByName<Person>(Person.GetPath, name);
return CreateItemByName<Person>(Person.GetPath, name, new DtoOptions(true));
}
/// <summary>
@ -892,7 +900,27 @@ namespace Emby.Server.Implementations.Library
/// <returns>Task{Studio}.</returns>
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>
@ -902,7 +930,7 @@ namespace Emby.Server.Implementations.Library
/// <returns>Task{Genre}.</returns>
public Genre GetGenre(string name)
{
return CreateItemByName<Genre>(Genre.GetPath, name);
return CreateItemByName<Genre>(Genre.GetPath, name, new DtoOptions(true));
}
/// <summary>
@ -912,7 +940,7 @@ namespace Emby.Server.Implementations.Library
/// <returns>Task{MusicGenre}.</returns>
public MusicGenre GetMusicGenre(string name)
{
return CreateItemByName<MusicGenre>(MusicGenre.GetPath, name);
return CreateItemByName<MusicGenre>(MusicGenre.GetPath, name, new DtoOptions(true));
}
/// <summary>
@ -922,7 +950,7 @@ namespace Emby.Server.Implementations.Library
/// <returns>Task{GameGenre}.</returns>
public GameGenre GetGameGenre(string name)
{
return CreateItemByName<GameGenre>(GameGenre.GetPath, name);
return CreateItemByName<GameGenre>(GameGenre.GetPath, name, new DtoOptions(true));
}
/// <summary>
@ -940,7 +968,7 @@ namespace Emby.Server.Implementations.Library
var name = value.ToString(CultureInfo.InvariantCulture);
return CreateItemByName<Year>(Year.GetPath, name);
return CreateItemByName<Year>(Year.GetPath, name, new DtoOptions(true));
}
/// <summary>
@ -950,10 +978,15 @@ namespace Emby.Server.Implementations.Library
/// <returns>Task{Genre}.</returns>
public MusicArtist GetArtist(string name)
{
return CreateItemByName<MusicArtist>(MusicArtist.GetPath, name);
return GetArtist(name, new DtoOptions(true));
}
private T CreateItemByName<T>(Func<string, string> getPathFn, string name)
public MusicArtist GetArtist(string name, DtoOptions options)
{
return CreateItemByName<MusicArtist>(MusicArtist.GetPath, name, options);
}
private T CreateItemByName<T>(Func<string, string> getPathFn, string name, DtoOptions options)
where T : BaseItem, new()
{
if (typeof(T) == typeof(MusicArtist))
@ -961,7 +994,8 @@ namespace Emby.Server.Implementations.Library
var existing = GetItemList(new InternalItemsQuery
{
IncludeItemTypes = new[] { typeof(T).Name },
Name = name
Name = name,
DtoOptions = options
}).Cast<MusicArtist>()
.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;
if (item == null)
{
var path = getPathFn(name);
item = new T
{
Name = name,
@ -998,52 +1031,12 @@ namespace Emby.Server.Implementations.Library
return item;
}
public IEnumerable<MusicArtist> GetAlbumArtists(IEnumerable<IHasAlbumArtist> items)
private Guid GetItemByNameId<T>(Func<string, string> getPathFn, string name)
where T : BaseItem, new()
{
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)
{
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>
@ -1098,12 +1091,6 @@ namespace Emby.Server.Implementations.Library
try
{
await PerformLibraryValidation(progress, cancellationToken).ConfigureAwait(false);
if (!ConfigurationManager.Configuration.EnableSeriesPresentationUniqueKey)
{
ConfigurationManager.Configuration.EnableSeriesPresentationUniqueKey = true;
ConfigurationManager.SaveConfiguration();
}
}
finally
{
@ -1558,7 +1545,7 @@ namespace Emby.Server.Implementations.Library
}
}
query.ParentId = null;
query.Parent = null;
}
private void AddUserToQuery(InternalItemsQuery query, User user)

View file

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

View file

@ -5,6 +5,7 @@ using MediaBrowser.Controller.Playlists;
using System;
using System.Collections.Generic;
using System.Linq;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Model.Querying;
namespace Emby.Server.Implementations.Library
@ -18,47 +19,48 @@ namespace Emby.Server.Implementations.Library
_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>
{
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
.GetRecursiveChildren(user, new InternalItemsQuery(user)
{
IncludeItemTypes = new[] { typeof(Audio).Name }
IncludeItemTypes = new[] { typeof(Audio).Name },
DtoOptions = dtoOptions
})
.Cast<Audio>()
.SelectMany(i => i.Genres)
.Concat(item.Genres)
.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 =>
{
@ -73,10 +75,10 @@ namespace Emby.Server.Implementations.Library
}).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)
{
@ -86,47 +88,49 @@ namespace Emby.Server.Implementations.Library
Limit = 200,
SortBy = new[] { ItemSortBy.Random }
SortBy = new[] { ItemSortBy.Random },
DtoOptions = dtoOptions
}).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;
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;
if (playlist != null)
{
return GetInstantMixFromPlaylist(playlist, user);
return GetInstantMixFromPlaylist(playlist, user, dtoOptions);
}
var album = item as MusicAlbum;
if (album != null)
{
return GetInstantMixFromAlbum(album, user);
return GetInstantMixFromAlbum(album, user, dtoOptions);
}
var artist = item as MusicArtist;
if (artist != null)
{
return GetInstantMixFromArtist(artist, user);
return GetInstantMixFromArtist(artist, user, dtoOptions);
}
var song = item as Audio;
if (song != null)
{
return GetInstantMixFromSong(song, user);
return GetInstantMixFromSong(song, user, dtoOptions);
}
var folder = item as Folder;
if (folder != null)
{
return GetInstantMixFromFolder(folder, user);
return GetInstantMixFromFolder(folder, user, dtoOptions);
}
return new Audio[] { };

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

Some files were not shown because too many files have changed in this diff Show more