mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-07-22 05:30:46 +02:00
add methods to get quality options
This commit is contained in:
parent
cf6c46c6a6
commit
6384c5bab0
|
@ -27,6 +27,13 @@ namespace MediaBrowser.Api.Sync
|
||||||
public string Id { get; set; }
|
public string Id { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Route("/Sync/QualityOptions", "GET", Summary = "Gets quality options for a sync target.")]
|
||||||
|
public class GetQualityOptions : IReturn<List<SyncQualityOption>>
|
||||||
|
{
|
||||||
|
[ApiMember(Name = "TargetId", Description = "TargetId", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||||
|
public string TargetId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
[Route("/Sync/Jobs/{Id}", "POST", Summary = "Updates a sync job.")]
|
[Route("/Sync/Jobs/{Id}", "POST", Summary = "Updates a sync job.")]
|
||||||
public class UpdateSyncJob : SyncJob, IReturnVoid
|
public class UpdateSyncJob : SyncJob, IReturnVoid
|
||||||
{
|
{
|
||||||
|
@ -222,6 +229,13 @@ namespace MediaBrowser.Api.Sync
|
||||||
return ToStaticFileResult(jobItem.OutputPath);
|
return ToStaticFileResult(jobItem.OutputPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public object Get(GetQualityOptions request)
|
||||||
|
{
|
||||||
|
return ToOptimizedResult(_syncManager
|
||||||
|
.GetQualityOptions(request.TargetId)
|
||||||
|
.ToList());
|
||||||
|
}
|
||||||
|
|
||||||
public object Get(GetSyncDialogOptions request)
|
public object Get(GetSyncDialogOptions request)
|
||||||
{
|
{
|
||||||
var result = new SyncDialogOptions();
|
var result = new SyncDialogOptions();
|
||||||
|
@ -234,6 +248,10 @@ namespace MediaBrowser.Api.Sync
|
||||||
result.Targets = result.Targets
|
result.Targets = result.Targets
|
||||||
.Where(i => string.Equals(i.Id, request.TargetId, StringComparison.OrdinalIgnoreCase))
|
.Where(i => string.Equals(i.Id, request.TargetId, StringComparison.OrdinalIgnoreCase))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
|
result.QualityOptions = _syncManager
|
||||||
|
.GetQualityOptions(request.TargetId)
|
||||||
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.Category.HasValue)
|
if (request.Category.HasValue)
|
||||||
|
@ -264,30 +282,6 @@ namespace MediaBrowser.Api.Sync
|
||||||
result.Options = SyncHelper.GetSyncOptions(dtos);
|
result.Options = SyncHelper.GetSyncOptions(dtos);
|
||||||
}
|
}
|
||||||
|
|
||||||
result.QualityOptions = new List<SyncQualityOption>
|
|
||||||
{
|
|
||||||
new SyncQualityOption
|
|
||||||
{
|
|
||||||
Name = SyncQuality.Original.ToString(),
|
|
||||||
Id = SyncQuality.Original.ToString()
|
|
||||||
},
|
|
||||||
new SyncQualityOption
|
|
||||||
{
|
|
||||||
Name = SyncQuality.High.ToString(),
|
|
||||||
Id = SyncQuality.High.ToString()
|
|
||||||
},
|
|
||||||
new SyncQualityOption
|
|
||||||
{
|
|
||||||
Name = SyncQuality.Medium.ToString(),
|
|
||||||
Id = SyncQuality.Medium.ToString()
|
|
||||||
},
|
|
||||||
new SyncQualityOption
|
|
||||||
{
|
|
||||||
Name = SyncQuality.Low.ToString(),
|
|
||||||
Id = SyncQuality.Low.ToString()
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return ToOptimizedResult(result);
|
return ToOptimizedResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,13 +90,6 @@ namespace MediaBrowser.Controller.Sync
|
||||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
||||||
bool SupportsSync(BaseItem item);
|
bool SupportsSync(BaseItem item);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the device profile.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="targetId">The target identifier.</param>
|
|
||||||
/// <returns>DeviceProfile.</returns>
|
|
||||||
DeviceProfile GetDeviceProfile(string targetId);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reports the synchronize job item transferred.
|
/// Reports the synchronize job item transferred.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -153,21 +146,6 @@ namespace MediaBrowser.Controller.Sync
|
||||||
/// <returns>QueryResult<System.String>.</returns>
|
/// <returns>QueryResult<System.String>.</returns>
|
||||||
QueryResult<string> GetLibraryItemIds(SyncJobItemQuery query);
|
QueryResult<string> GetLibraryItemIds(SyncJobItemQuery query);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the audio options.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="jobItem">The job item.</param>
|
|
||||||
/// <returns>AudioOptions.</returns>
|
|
||||||
AudioOptions GetAudioOptions(SyncJobItem jobItem);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the video options.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="jobItem">The job item.</param>
|
|
||||||
/// <param name="job">The job.</param>
|
|
||||||
/// <returns>VideoOptions.</returns>
|
|
||||||
VideoOptions GetVideoOptions(SyncJobItem jobItem, SyncJob job);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reports the synchronize job item transfer beginning.
|
/// Reports the synchronize job item transfer beginning.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -181,5 +159,12 @@ namespace MediaBrowser.Controller.Sync
|
||||||
/// <param name="id">The identifier.</param>
|
/// <param name="id">The identifier.</param>
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
Task ReportSyncJobItemTransferFailed(string id);
|
Task ReportSyncJobItemTransferFailed(string id);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the quality options.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="targetId">The target identifier.</param>
|
||||||
|
/// <returns>IEnumerable<SyncQualityOption>.</returns>
|
||||||
|
IEnumerable<SyncQualityOption> GetQualityOptions(string targetId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,5 +13,10 @@ namespace MediaBrowser.Model.Sync
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The identifier.</value>
|
/// <value>The identifier.</value>
|
||||||
public string Id { get; set; }
|
public string Id { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether this instance is default.
|
||||||
|
/// </summary>
|
||||||
|
/// <value><c>true</c> if this instance is default; otherwise, <c>false</c>.</value>
|
||||||
|
public bool IsDefault { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -307,7 +307,7 @@
|
||||||
<Compile Include="Sorting\VideoBitRateComparer.cs" />
|
<Compile Include="Sorting\VideoBitRateComparer.cs" />
|
||||||
<Compile Include="Sync\AppSyncProvider.cs" />
|
<Compile Include="Sync\AppSyncProvider.cs" />
|
||||||
<Compile Include="Sync\CloudSyncProfile.cs" />
|
<Compile Include="Sync\CloudSyncProfile.cs" />
|
||||||
<Compile Include="Sync\IHasSyncProfile.cs" />
|
<Compile Include="Sync\IHasSyncQuality.cs" />
|
||||||
<Compile Include="Sync\MediaSync.cs" />
|
<Compile Include="Sync\MediaSync.cs" />
|
||||||
<Compile Include="Sync\MultiProviderSync.cs" />
|
<Compile Include="Sync\MultiProviderSync.cs" />
|
||||||
<Compile Include="Sync\ServerSyncScheduledTask.cs" />
|
<Compile Include="Sync\ServerSyncScheduledTask.cs" />
|
||||||
|
|
|
@ -8,7 +8,7 @@ using System.Linq;
|
||||||
|
|
||||||
namespace MediaBrowser.Server.Implementations.Sync
|
namespace MediaBrowser.Server.Implementations.Sync
|
||||||
{
|
{
|
||||||
public class AppSyncProvider : ISyncProvider, IHasUniqueTargetIds, IHasSyncProfile
|
public class AppSyncProvider : ISyncProvider, IHasUniqueTargetIds, IHasSyncQuality
|
||||||
{
|
{
|
||||||
private readonly IDeviceManager _deviceManager;
|
private readonly IDeviceManager _deviceManager;
|
||||||
|
|
||||||
|
@ -55,5 +55,33 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
Name = i.Name
|
Name = i.Name
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEnumerable<SyncQualityOption> GetQualityOptions(SyncTarget target)
|
||||||
|
{
|
||||||
|
return new List<SyncQualityOption>
|
||||||
|
{
|
||||||
|
new SyncQualityOption
|
||||||
|
{
|
||||||
|
Name = SyncQuality.Original.ToString(),
|
||||||
|
Id = SyncQuality.Original.ToString()
|
||||||
|
},
|
||||||
|
new SyncQualityOption
|
||||||
|
{
|
||||||
|
Name = SyncQuality.High.ToString(),
|
||||||
|
Id = SyncQuality.High.ToString(),
|
||||||
|
IsDefault = true
|
||||||
|
},
|
||||||
|
new SyncQualityOption
|
||||||
|
{
|
||||||
|
Name = SyncQuality.Medium.ToString(),
|
||||||
|
Id = SyncQuality.Medium.ToString()
|
||||||
|
},
|
||||||
|
new SyncQualityOption
|
||||||
|
{
|
||||||
|
Name = SyncQuality.Low.ToString(),
|
||||||
|
Id = SyncQuality.Low.ToString()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
using MediaBrowser.Model.Dlna;
|
using MediaBrowser.Model.Dlna;
|
||||||
using MediaBrowser.Model.Sync;
|
using MediaBrowser.Model.Sync;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace MediaBrowser.Server.Implementations.Sync
|
namespace MediaBrowser.Server.Implementations.Sync
|
||||||
{
|
{
|
||||||
public interface IHasSyncProfile
|
public interface IHasSyncQuality
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the device profile.
|
/// Gets the device profile.
|
||||||
|
@ -11,5 +12,12 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
/// <param name="target">The target.</param>
|
/// <param name="target">The target.</param>
|
||||||
/// <returns>DeviceProfile.</returns>
|
/// <returns>DeviceProfile.</returns>
|
||||||
DeviceProfile GetDeviceProfile(SyncTarget target);
|
DeviceProfile GetDeviceProfile(SyncTarget target);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the quality options.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="target">The target.</param>
|
||||||
|
/// <returns>IEnumerable<SyncQualityOption>.</returns>
|
||||||
|
IEnumerable<SyncQualityOption> GetQualityOptions(SyncTarget target);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -450,15 +450,6 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var deviceProfile = _syncManager.GetDeviceProfile(jobItem.TargetId);
|
|
||||||
if (deviceProfile == null)
|
|
||||||
{
|
|
||||||
jobItem.Status = SyncJobItemStatus.Failed;
|
|
||||||
_logger.Error("Unable to locate SyncTarget for JobItem {0}, SyncTargetId {1}", jobItem.Id, jobItem.TargetId);
|
|
||||||
await _syncManager.UpdateSyncJobItemInternal(jobItem).ConfigureAwait(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
jobItem.Progress = 0;
|
jobItem.Progress = 0;
|
||||||
|
|
||||||
var user = _userManager.GetUserById(job.UserId);
|
var user = _userManager.GetUserById(job.UserId);
|
||||||
|
@ -466,17 +457,17 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
var video = item as Video;
|
var video = item as Video;
|
||||||
if (video != null)
|
if (video != null)
|
||||||
{
|
{
|
||||||
await Sync(jobItem, job, video, user, deviceProfile, enableConversion, progress, cancellationToken).ConfigureAwait(false);
|
await Sync(jobItem, job, video, user, enableConversion, progress, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (item is Audio)
|
else if (item is Audio)
|
||||||
{
|
{
|
||||||
await Sync(jobItem, job, (Audio)item, user, deviceProfile, enableConversion, progress, cancellationToken).ConfigureAwait(false);
|
await Sync(jobItem, job, (Audio)item, user, enableConversion, progress, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (item is Photo)
|
else if (item is Photo)
|
||||||
{
|
{
|
||||||
await Sync(jobItem, (Photo)item, deviceProfile, cancellationToken).ConfigureAwait(false);
|
await Sync(jobItem, (Photo)item, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
@ -491,13 +482,12 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
string.Equals(job.Quality, "original", StringComparison.OrdinalIgnoreCase);
|
string.Equals(job.Quality, "original", StringComparison.OrdinalIgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Sync(SyncJobItem jobItem, SyncJob job, Video item, User user, DeviceProfile profile, bool enableConversion, IProgress<double> progress, CancellationToken cancellationToken)
|
private async Task Sync(SyncJobItem jobItem, SyncJob job, Video item, User user, bool enableConversion, IProgress<double> progress, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var options = _syncManager.GetVideoOptions(jobItem, job);
|
var options = _syncManager.GetVideoOptions(jobItem, job);
|
||||||
|
|
||||||
options.DeviceId = jobItem.TargetId;
|
options.DeviceId = jobItem.TargetId;
|
||||||
options.Context = EncodingContext.Static;
|
options.Context = EncodingContext.Static;
|
||||||
options.Profile = profile;
|
|
||||||
options.ItemId = item.Id.ToString("N");
|
options.ItemId = item.Id.ToString("N");
|
||||||
options.MediaSources = _mediaSourceManager.GetStaticMediaSources(item, false, user).ToList();
|
options.MediaSources = _mediaSourceManager.GetStaticMediaSources(item, false, user).ToList();
|
||||||
|
|
||||||
|
@ -548,7 +538,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
jobItem.OutputPath = await _mediaEncoder.EncodeVideo(new EncodingJobOptions(streamInfo, profile)
|
jobItem.OutputPath = await _mediaEncoder.EncodeVideo(new EncodingJobOptions(streamInfo, options.Profile)
|
||||||
{
|
{
|
||||||
OutputDirectory = jobItem.TemporaryPath
|
OutputDirectory = jobItem.TemporaryPath
|
||||||
|
|
||||||
|
@ -682,13 +672,12 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
|
|
||||||
private const int DatabaseProgressUpdateIntervalSeconds = 2;
|
private const int DatabaseProgressUpdateIntervalSeconds = 2;
|
||||||
|
|
||||||
private async Task Sync(SyncJobItem jobItem, SyncJob job, Audio item, User user, DeviceProfile profile, bool enableConversion, IProgress<double> progress, CancellationToken cancellationToken)
|
private async Task Sync(SyncJobItem jobItem, SyncJob job, Audio item, User user, bool enableConversion, IProgress<double> progress, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var options = _syncManager.GetAudioOptions(jobItem);
|
var options = _syncManager.GetAudioOptions(jobItem, job);
|
||||||
|
|
||||||
options.DeviceId = jobItem.TargetId;
|
options.DeviceId = jobItem.TargetId;
|
||||||
options.Context = EncodingContext.Static;
|
options.Context = EncodingContext.Static;
|
||||||
options.Profile = profile;
|
|
||||||
options.ItemId = item.Id.ToString("N");
|
options.ItemId = item.Id.ToString("N");
|
||||||
options.MediaSources = _mediaSourceManager.GetStaticMediaSources(item, false, user).ToList();
|
options.MediaSources = _mediaSourceManager.GetStaticMediaSources(item, false, user).ToList();
|
||||||
|
|
||||||
|
@ -725,7 +714,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
jobItem.OutputPath = await _mediaEncoder.EncodeAudio(new EncodingJobOptions(streamInfo, profile)
|
jobItem.OutputPath = await _mediaEncoder.EncodeAudio(new EncodingJobOptions(streamInfo, options.Profile)
|
||||||
{
|
{
|
||||||
OutputDirectory = jobItem.TemporaryPath
|
OutputDirectory = jobItem.TemporaryPath
|
||||||
|
|
||||||
|
@ -773,7 +762,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
await _syncManager.UpdateSyncJobItemInternal(jobItem).ConfigureAwait(false);
|
await _syncManager.UpdateSyncJobItemInternal(jobItem).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Sync(SyncJobItem jobItem, Photo item, DeviceProfile profile, CancellationToken cancellationToken)
|
private async Task Sync(SyncJobItem jobItem, Photo item, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
jobItem.OutputPath = item.Path;
|
jobItem.OutputPath = item.Path;
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
|
|
||||||
private readonly ConcurrentDictionary<string, ISyncDataProvider> _dataProviders =
|
private readonly ConcurrentDictionary<string, ISyncDataProvider> _dataProviders =
|
||||||
new ConcurrentDictionary<string, ISyncDataProvider>(StringComparer.OrdinalIgnoreCase);
|
new ConcurrentDictionary<string, ISyncDataProvider>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
public ISyncDataProvider GetDataProvider(IServerSyncProvider provider, SyncTarget target)
|
public ISyncDataProvider GetDataProvider(IServerSyncProvider provider, SyncTarget target)
|
||||||
{
|
{
|
||||||
return _dataProviders.GetOrAdd(target.Id, key => new TargetDataProvider(provider, target, _appHost.SystemId, _logger, _json, _fileSystem, _config.CommonApplicationPaths));
|
return _dataProviders.GetOrAdd(target.Id, key => new TargetDataProvider(provider, target, _appHost.SystemId, _logger, _json, _fileSystem, _config.CommonApplicationPaths));
|
||||||
|
@ -972,9 +972,9 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
return _repo.GetLibraryItemIds(query);
|
return _repo.GetLibraryItemIds(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AudioOptions GetAudioOptions(SyncJobItem jobItem)
|
public AudioOptions GetAudioOptions(SyncJobItem jobItem, SyncJob job)
|
||||||
{
|
{
|
||||||
var profile = GetDeviceProfile(jobItem.TargetId);
|
var profile = GetDeviceProfile(jobItem.TargetId, job.Quality);
|
||||||
|
|
||||||
return new AudioOptions
|
return new AudioOptions
|
||||||
{
|
{
|
||||||
|
@ -984,16 +984,16 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
|
|
||||||
public VideoOptions GetVideoOptions(SyncJobItem jobItem, SyncJob job)
|
public VideoOptions GetVideoOptions(SyncJobItem jobItem, SyncJob job)
|
||||||
{
|
{
|
||||||
var profile = GetDeviceProfile(jobItem.TargetId);
|
var profile = GetDeviceProfile(jobItem.TargetId, job.Quality);
|
||||||
var maxBitrate = profile.MaxStaticBitrate;
|
var maxBitrate = profile.MaxStaticBitrate;
|
||||||
|
|
||||||
if (maxBitrate.HasValue)
|
if (maxBitrate.HasValue)
|
||||||
{
|
{
|
||||||
if (string.Equals(job.Quality, "high", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(job.Quality, "medium", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
maxBitrate = Convert.ToInt32(maxBitrate.Value * .75);
|
maxBitrate = Convert.ToInt32(maxBitrate.Value * .75);
|
||||||
}
|
}
|
||||||
else if (string.Equals(job.Quality, "medium", StringComparison.OrdinalIgnoreCase))
|
else if (string.Equals(job.Quality, "low", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
maxBitrate = Convert.ToInt32(maxBitrate.Value * .5);
|
maxBitrate = Convert.ToInt32(maxBitrate.Value * .5);
|
||||||
}
|
}
|
||||||
|
@ -1006,7 +1006,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeviceProfile GetDeviceProfile(string targetId)
|
public DeviceProfile GetDeviceProfile(string targetId, string quality)
|
||||||
{
|
{
|
||||||
foreach (var provider in _providers)
|
foreach (var provider in _providers)
|
||||||
{
|
{
|
||||||
|
@ -1014,7 +1014,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
{
|
{
|
||||||
if (string.Equals(target.Id, targetId, StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(target.Id, targetId, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
return GetDeviceProfile(provider, target);
|
return GetDeviceProfile(provider, target, quality);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1022,9 +1022,9 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeviceProfile GetDeviceProfile(ISyncProvider provider, SyncTarget target)
|
private DeviceProfile GetDeviceProfile(ISyncProvider provider, SyncTarget target, string quality)
|
||||||
{
|
{
|
||||||
var hasProfile = provider as IHasSyncProfile;
|
var hasProfile = provider as IHasSyncQuality;
|
||||||
|
|
||||||
if (hasProfile != null)
|
if (hasProfile != null)
|
||||||
{
|
{
|
||||||
|
@ -1033,5 +1033,56 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
|
|
||||||
return new CloudSyncProfile(true, false);
|
return new CloudSyncProfile(true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEnumerable<SyncQualityOption> GetQualityOptions(string targetId)
|
||||||
|
{
|
||||||
|
foreach (var provider in _providers)
|
||||||
|
{
|
||||||
|
foreach (var target in GetSyncTargets(provider))
|
||||||
|
{
|
||||||
|
if (string.Equals(target.Id, targetId, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return GetQualityOptions(provider, target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new List<SyncQualityOption>();
|
||||||
|
}
|
||||||
|
|
||||||
|
private IEnumerable<SyncQualityOption> GetQualityOptions(ISyncProvider provider, SyncTarget target)
|
||||||
|
{
|
||||||
|
var hasQuality = provider as IHasSyncQuality;
|
||||||
|
if (hasQuality != null)
|
||||||
|
{
|
||||||
|
return hasQuality.GetQualityOptions(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default options for providers that don't override
|
||||||
|
return new List<SyncQualityOption>
|
||||||
|
{
|
||||||
|
new SyncQualityOption
|
||||||
|
{
|
||||||
|
Name = SyncQuality.Original.ToString(),
|
||||||
|
Id = SyncQuality.Original.ToString()
|
||||||
|
},
|
||||||
|
new SyncQualityOption
|
||||||
|
{
|
||||||
|
Name = SyncQuality.High.ToString(),
|
||||||
|
Id = SyncQuality.High.ToString(),
|
||||||
|
IsDefault = true
|
||||||
|
},
|
||||||
|
new SyncQualityOption
|
||||||
|
{
|
||||||
|
Name = SyncQuality.Medium.ToString(),
|
||||||
|
Id = SyncQuality.Medium.ToString()
|
||||||
|
},
|
||||||
|
new SyncQualityOption
|
||||||
|
{
|
||||||
|
Name = SyncQuality.Low.ToString(),
|
||||||
|
Id = SyncQuality.Low.ToString()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue