jellyfin/MediaBrowser.Server.Implementations/Sync/AppSyncProvider.cs

114 lines
3.4 KiB
C#
Raw Normal View History

2014-12-14 22:49:04 -07:00
using MediaBrowser.Controller.Devices;
using MediaBrowser.Controller.Sync;
using MediaBrowser.Model.Devices;
2014-07-21 18:29:06 -07:00
using MediaBrowser.Model.Dlna;
using MediaBrowser.Model.Sync;
2015-03-15 12:10:27 -07:00
using System;
2014-07-21 18:29:06 -07:00
using System.Collections.Generic;
2014-12-14 22:49:04 -07:00
using System.Linq;
2014-07-21 18:29:06 -07:00
namespace MediaBrowser.Server.Implementations.Sync
{
2015-08-18 12:45:41 -07:00
public class AppSyncProvider : ISyncProvider, IHasUniqueTargetIds, IHasSyncQuality, IHasDuplicateCheck
2014-07-21 18:29:06 -07:00
{
2014-12-14 22:49:04 -07:00
private readonly IDeviceManager _deviceManager;
public AppSyncProvider(IDeviceManager deviceManager)
{
_deviceManager = deviceManager;
}
2014-12-30 23:24:49 -07:00
public IEnumerable<SyncTarget> GetSyncTargets(string userId)
{
return _deviceManager.GetDevices(new DeviceQuery
{
SupportsSync = true,
UserId = userId
}).Items.Select(i => new SyncTarget
{
Id = i.Id,
Name = i.Name
});
}
2015-03-14 18:42:09 -07:00
public DeviceProfile GetDeviceProfile(SyncTarget target, string profile, string quality)
2014-07-21 18:29:06 -07:00
{
2015-01-01 22:36:27 -07:00
var caps = _deviceManager.GetCapabilities(target.Id);
2015-03-14 18:42:09 -07:00
var deviceProfile = caps == null || caps.DeviceProfile == null ? new DeviceProfile() : caps.DeviceProfile;
2015-03-15 10:50:47 -07:00
deviceProfile.MaxStaticBitrate = SyncHelper.AdjustBitrate(deviceProfile.MaxStaticBitrate, quality);
2015-03-11 21:55:06 -07:00
2015-03-14 18:42:09 -07:00
return deviceProfile;
2014-07-21 18:29:06 -07:00
}
public string Name
{
2015-04-05 08:01:57 -07:00
get { return "Mobile Sync"; }
2014-07-21 18:29:06 -07:00
}
2015-02-28 07:35:12 -07:00
public IEnumerable<SyncTarget> GetAllSyncTargets()
{
return _deviceManager.GetDevices(new DeviceQuery
{
SupportsSync = true
}).Items.Select(i => new SyncTarget
{
Id = i.Id,
Name = i.Name
});
}
2015-03-11 21:47:16 -07:00
public IEnumerable<SyncQualityOption> GetQualityOptions(SyncTarget target)
{
return new List<SyncQualityOption>
{
new SyncQualityOption
{
2015-03-14 21:17:35 -07:00
Name = "Original",
Id = "original",
Description = "Syncs original files as-is, regardless of whether the device is capable of playing them or not."
2015-03-11 21:47:16 -07:00
},
new SyncQualityOption
{
2015-03-14 21:17:35 -07:00
Name = "High",
Id = "high",
2015-03-11 21:47:16 -07:00
IsDefault = true
},
new SyncQualityOption
{
2015-03-14 21:17:35 -07:00
Name = "Medium",
Id = "medium"
2015-03-11 21:47:16 -07:00
},
new SyncQualityOption
{
2015-03-14 21:17:35 -07:00
Name = "Low",
Id = "low"
2015-03-11 21:47:16 -07:00
}
};
}
2015-03-14 18:42:09 -07:00
2015-03-14 21:17:35 -07:00
public IEnumerable<SyncProfileOption> GetProfileOptions(SyncTarget target)
2015-03-14 18:42:09 -07:00
{
2015-03-14 21:17:35 -07:00
return new List<SyncProfileOption>();
2015-03-14 18:42:09 -07:00
}
2015-03-15 12:10:27 -07:00
public SyncJobOptions GetSyncJobOptions(SyncTarget target, string profile, string quality)
{
var isConverting = !string.Equals(quality, "original", StringComparison.OrdinalIgnoreCase);
return new SyncJobOptions
{
DeviceProfile = GetDeviceProfile(target, profile, quality),
IsConverting = isConverting
};
}
2015-08-18 12:45:41 -07:00
public bool AllowDuplicateJobItem(SyncJobItem original, SyncJobItem duplicate)
{
return false;
}
2014-07-21 18:29:06 -07:00
}
}