change sync job quality to a string

pull/702/head
Luke Pulverenti 10 years ago
parent 8f90e54faf
commit cf6c46c6a6

@ -24,7 +24,7 @@ namespace MediaBrowser.Model.Sync
/// Gets or sets the quality. /// Gets or sets the quality.
/// </summary> /// </summary>
/// <value>The quality.</value> /// <value>The quality.</value>
public SyncQuality Quality { get; set; } public string Quality { get; set; }
/// <summary> /// <summary>
/// Gets or sets the category. /// Gets or sets the category.
/// </summary> /// </summary>
@ -98,7 +98,6 @@ namespace MediaBrowser.Model.Sync
public SyncJob() public SyncJob()
{ {
RequestedItemIds = new List<string>(); RequestedItemIds = new List<string>();
Quality = SyncQuality.High;
} }
} }
} }

@ -485,6 +485,12 @@ namespace MediaBrowser.Server.Implementations.Sync
} }
} }
private bool IsOriginalQuality(SyncJob job)
{
return string.IsNullOrWhiteSpace(job.Quality) ||
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, DeviceProfile profile, bool enableConversion, IProgress<double> progress, CancellationToken cancellationToken)
{ {
var options = _syncManager.GetVideoOptions(jobItem, job); var options = _syncManager.GetVideoOptions(jobItem, job);
@ -504,7 +510,7 @@ namespace MediaBrowser.Server.Implementations.Sync
streamInfo.GetExternalSubtitles(false); streamInfo.GetExternalSubtitles(false);
// Mark as requiring conversion if transcoding the video, or if any subtitles need to be extracted // Mark as requiring conversion if transcoding the video, or if any subtitles need to be extracted
var requiresVideoTranscoding = streamInfo.PlayMethod == PlayMethod.Transcode && job.Quality != SyncQuality.Original; var requiresVideoTranscoding = streamInfo.PlayMethod == PlayMethod.Transcode && IsOriginalQuality(job);
var requiresConversion = requiresVideoTranscoding || externalSubs.Any(i => RequiresExtraction(i, mediaSource)); var requiresConversion = requiresVideoTranscoding || externalSubs.Any(i => RequiresExtraction(i, mediaSource));
if (requiresConversion && !enableConversion) if (requiresConversion && !enableConversion)
@ -692,7 +698,7 @@ namespace MediaBrowser.Server.Implementations.Sync
jobItem.MediaSourceId = streamInfo.MediaSourceId; jobItem.MediaSourceId = streamInfo.MediaSourceId;
jobItem.TemporaryPath = GetTemporaryPath(jobItem); jobItem.TemporaryPath = GetTemporaryPath(jobItem);
if (streamInfo.PlayMethod == PlayMethod.Transcode && job.Quality != SyncQuality.Original) if (streamInfo.PlayMethod == PlayMethod.Transcode && !IsOriginalQuality(job))
{ {
if (!enableConversion) if (!enableConversion)
{ {

@ -150,14 +150,10 @@ namespace MediaBrowser.Server.Implementations.Sync
SyncNewContent = request.SyncNewContent, SyncNewContent = request.SyncNewContent,
ItemCount = items.Count, ItemCount = items.Count,
Category = request.Category, Category = request.Category,
ParentId = request.ParentId ParentId = request.ParentId,
Quality = request.Quality
}; };
if (!string.IsNullOrWhiteSpace(request.Quality))
{
job.Quality = (SyncQuality)Enum.Parse(typeof(SyncQuality), request.Quality, true);
}
if (!request.Category.HasValue && request.ItemIds != null) if (!request.Category.HasValue && request.ItemIds != null)
{ {
var requestedItems = request.ItemIds var requestedItems = request.ItemIds
@ -565,34 +561,6 @@ namespace MediaBrowser.Server.Implementations.Sync
return item.Name; return item.Name;
} }
public DeviceProfile GetDeviceProfile(string targetId)
{
foreach (var provider in _providers)
{
foreach (var target in GetSyncTargets(provider))
{
if (string.Equals(target.Id, targetId, StringComparison.OrdinalIgnoreCase))
{
return GetDeviceProfile(provider, target);
}
}
}
return null;
}
public DeviceProfile GetDeviceProfile(ISyncProvider provider, SyncTarget target)
{
var hasProfile = provider as IHasSyncProfile;
if (hasProfile != null)
{
return hasProfile.GetDeviceProfile(target);
}
return new CloudSyncProfile(true, false);
}
public async Task ReportSyncJobItemTransferred(string id) public async Task ReportSyncJobItemTransferred(string id)
{ {
var jobItem = _repo.GetJobItem(id); var jobItem = _repo.GetJobItem(id);
@ -1021,11 +989,11 @@ namespace MediaBrowser.Server.Implementations.Sync
if (maxBitrate.HasValue) if (maxBitrate.HasValue)
{ {
if (job.Quality == SyncQuality.Medium) if (string.Equals(job.Quality, "high", StringComparison.OrdinalIgnoreCase))
{ {
maxBitrate = Convert.ToInt32(maxBitrate.Value * .75); maxBitrate = Convert.ToInt32(maxBitrate.Value * .75);
} }
else if (job.Quality == SyncQuality.Low) else if (string.Equals(job.Quality, "medium", StringComparison.OrdinalIgnoreCase))
{ {
maxBitrate = Convert.ToInt32(maxBitrate.Value * .5); maxBitrate = Convert.ToInt32(maxBitrate.Value * .5);
} }
@ -1037,5 +1005,33 @@ namespace MediaBrowser.Server.Implementations.Sync
MaxBitrate = maxBitrate MaxBitrate = maxBitrate
}; };
} }
public DeviceProfile GetDeviceProfile(string targetId)
{
foreach (var provider in _providers)
{
foreach (var target in GetSyncTargets(provider))
{
if (string.Equals(target.Id, targetId, StringComparison.OrdinalIgnoreCase))
{
return GetDeviceProfile(provider, target);
}
}
}
return null;
}
public DeviceProfile GetDeviceProfile(ISyncProvider provider, SyncTarget target)
{
var hasProfile = provider as IHasSyncProfile;
if (hasProfile != null)
{
return hasProfile.GetDeviceProfile(target);
}
return new CloudSyncProfile(true, false);
}
} }
} }

@ -210,7 +210,7 @@ namespace MediaBrowser.Server.Implementations.Sync
if (!reader.IsDBNull(3)) if (!reader.IsDBNull(3))
{ {
info.Quality = (SyncQuality)Enum.Parse(typeof(SyncQuality), reader.GetString(3), true); info.Quality = reader.GetString(3);
} }
if (!reader.IsDBNull(4)) if (!reader.IsDBNull(4))

Loading…
Cancel
Save