The Free Software Media System - Server Backend & API
add quality methods
Luke Pulverenti1a81da5a8f2a
diff --git a/MediaBrowser.Server.Implementations/Sync/AppSyncProvider.cs b/MediaBrowser.Server.Implementations/Sync/AppSyncProvider.csindex e6af28c7dd..c86549cb3d 100644--- a/MediaBrowser.Server.Implementations/Sync/AppSyncProvider.cs+++ b/MediaBrowser.Server.Implementations/Sync/AppSyncProvider.cs@@ -3,6 +3,7 @@ using MediaBrowser.Controller.Sync;using MediaBrowser.Model.Devices;using MediaBrowser.Model.Dlna;using MediaBrowser.Model.Sync;+using System;using System.Collections.Generic;using System.Linq;@@ -31,11 +32,28 @@ namespace MediaBrowser.Server.Implementations.Sync});}- public DeviceProfile GetDeviceProfile(SyncTarget target)+ public DeviceProfile GetDeviceProfile(SyncTarget target, string quality){var caps = _deviceManager.GetCapabilities(target.Id);- return caps == null || caps.DeviceProfile == null ? new DeviceProfile() : caps.DeviceProfile;+ var profile = caps == null || caps.DeviceProfile == null ? new DeviceProfile() : caps.DeviceProfile;+ var maxBitrate = profile.MaxStaticBitrate;++ if (maxBitrate.HasValue)+ {+ if (string.Equals(quality, "medium", StringComparison.OrdinalIgnoreCase))+ {+ maxBitrate = Convert.ToInt32(maxBitrate.Value * .75);+ }+ else if (string.Equals(quality, "low", StringComparison.OrdinalIgnoreCase))+ {+ maxBitrate = Convert.ToInt32(maxBitrate.Value * .5);+ }++ profile.MaxStaticBitrate = maxBitrate;+ }++ return profile;}public string Namediff --git a/MediaBrowser.Server.Implementations/Sync/IHasSyncQuality.cs b/MediaBrowser.Server.Implementations/Sync/IHasSyncQuality.csindex 9b45e66e12..fa73a1cac3 100644--- a/MediaBrowser.Server.Implementations/Sync/IHasSyncQuality.cs+++ b/MediaBrowser.Server.Implementations/Sync/IHasSyncQuality.cs@@ -10,9 +10,10 @@ namespace MediaBrowser.Server.Implementations.Sync/// Gets the device profile./// </summary>/// <param name="target">The target.</param>+ /// <param name="quality">The quality.</param>/// <returns>DeviceProfile.</returns>- DeviceProfile GetDeviceProfile(SyncTarget target);-+ DeviceProfile GetDeviceProfile(SyncTarget target, string quality);+/// <summary>/// Gets the quality options./// </summary>diff --git a/MediaBrowser.Server.Implementations/Sync/SyncManager.cs b/MediaBrowser.Server.Implementations/Sync/SyncManager.csindex c02a54f901..0051447c0b 100644--- a/MediaBrowser.Server.Implementations/Sync/SyncManager.cs+++ b/MediaBrowser.Server.Implementations/Sync/SyncManager.cs@@ -974,7 +974,7 @@ namespace MediaBrowser.Server.Implementations.Syncpublic AudioOptions GetAudioOptions(SyncJobItem jobItem, SyncJob job){- var profile = GetDeviceProfile(jobItem.TargetId, job.Quality);+ var profile = GetDeviceProfile(jobItem.TargetId, null);return new AudioOptions{@@ -985,24 +985,10 @@ namespace MediaBrowser.Server.Implementations.Syncpublic VideoOptions GetVideoOptions(SyncJobItem jobItem, SyncJob job){var profile = GetDeviceProfile(jobItem.TargetId, job.Quality);- var maxBitrate = profile.MaxStaticBitrate;-- if (maxBitrate.HasValue)- {- if (string.Equals(job.Quality, "medium", StringComparison.OrdinalIgnoreCase))- {- maxBitrate = Convert.ToInt32(maxBitrate.Value * .75);- }- else if (string.Equals(job.Quality, "low", StringComparison.OrdinalIgnoreCase))- {- maxBitrate = Convert.ToInt32(maxBitrate.Value * .5);- }- }return new VideoOptions{- Profile = profile,- MaxBitrate = maxBitrate+ Profile = profile};}@@ -1028,7 +1014,7 @@ namespace MediaBrowser.Server.Implementations.Syncif (hasProfile != null){- return hasProfile.GetDeviceProfile(target);+ return hasProfile.GetDeviceProfile(target, quality);}return new CloudSyncProfile(true, false);