AppSyncProvider.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. using MediaBrowser.Controller.Devices;
  2. using MediaBrowser.Controller.Sync;
  3. using MediaBrowser.Model.Devices;
  4. using MediaBrowser.Model.Dlna;
  5. using MediaBrowser.Model.Sync;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. namespace MediaBrowser.Server.Implementations.Sync
  9. {
  10. public class AppSyncProvider : ISyncProvider, IHasUniqueTargetIds, IHasSyncQuality
  11. {
  12. private readonly IDeviceManager _deviceManager;
  13. public AppSyncProvider(IDeviceManager deviceManager)
  14. {
  15. _deviceManager = deviceManager;
  16. }
  17. public IEnumerable<SyncTarget> GetSyncTargets(string userId)
  18. {
  19. return _deviceManager.GetDevices(new DeviceQuery
  20. {
  21. SupportsSync = true,
  22. UserId = userId
  23. }).Items.Select(i => new SyncTarget
  24. {
  25. Id = i.Id,
  26. Name = i.Name
  27. });
  28. }
  29. public DeviceProfile GetDeviceProfile(SyncTarget target, string profile, string quality)
  30. {
  31. var caps = _deviceManager.GetCapabilities(target.Id);
  32. var deviceProfile = caps == null || caps.DeviceProfile == null ? new DeviceProfile() : caps.DeviceProfile;
  33. deviceProfile.MaxStaticBitrate = SyncHelper.AdjustBitrate(deviceProfile.MaxStaticBitrate, quality);
  34. return deviceProfile;
  35. }
  36. public string Name
  37. {
  38. get { return "App Sync"; }
  39. }
  40. public IEnumerable<SyncTarget> GetAllSyncTargets()
  41. {
  42. return _deviceManager.GetDevices(new DeviceQuery
  43. {
  44. SupportsSync = true
  45. }).Items.Select(i => new SyncTarget
  46. {
  47. Id = i.Id,
  48. Name = i.Name
  49. });
  50. }
  51. public IEnumerable<SyncQualityOption> GetQualityOptions(SyncTarget target)
  52. {
  53. return new List<SyncQualityOption>
  54. {
  55. new SyncQualityOption
  56. {
  57. Name = "Original",
  58. Id = "original",
  59. Description = "Syncs original files as-is, regardless of whether the device is capable of playing them or not."
  60. },
  61. new SyncQualityOption
  62. {
  63. Name = "High",
  64. Id = "high",
  65. IsDefault = true
  66. },
  67. new SyncQualityOption
  68. {
  69. Name = "Medium",
  70. Id = "medium"
  71. },
  72. new SyncQualityOption
  73. {
  74. Name = "Low",
  75. Id = "low"
  76. }
  77. };
  78. }
  79. public IEnumerable<SyncProfileOption> GetProfileOptions(SyncTarget target)
  80. {
  81. return new List<SyncProfileOption>();
  82. }
  83. }
  84. }