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

119 lines
3.5 KiB
C#
Raw Normal View History

2014-12-15 05:49:04 +00:00
using MediaBrowser.Controller.Devices;
using MediaBrowser.Controller.Sync;
using MediaBrowser.Model.Devices;
2014-07-22 01:29:06 +00:00
using MediaBrowser.Model.Dlna;
using MediaBrowser.Model.Sync;
2015-03-15 19:10:27 +00:00
using System;
2014-07-22 01:29:06 +00:00
using System.Collections.Generic;
2014-12-15 05:49:04 +00:00
using System.Linq;
2014-07-22 01:29:06 +00:00
2016-11-03 22:34:16 +00:00
namespace Emby.Server.Implementations.Sync
2014-07-22 01:29:06 +00:00
{
2015-08-18 19:45:41 +00:00
public class AppSyncProvider : ISyncProvider, IHasUniqueTargetIds, IHasSyncQuality, IHasDuplicateCheck
2014-07-22 01:29:06 +00:00
{
2014-12-15 05:49:04 +00:00
private readonly IDeviceManager _deviceManager;
public AppSyncProvider(IDeviceManager deviceManager)
{
_deviceManager = deviceManager;
}
2014-12-31 06:24:49 +00: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-15 01:42:09 +00:00
public DeviceProfile GetDeviceProfile(SyncTarget target, string profile, string quality)
2014-07-22 01:29:06 +00:00
{
2015-01-02 05:36:27 +00:00
var caps = _deviceManager.GetCapabilities(target.Id);
2015-03-15 01:42:09 +00:00
var deviceProfile = caps == null || caps.DeviceProfile == null ? new DeviceProfile() : caps.DeviceProfile;
2015-03-15 17:50:47 +00:00
deviceProfile.MaxStaticBitrate = SyncHelper.AdjustBitrate(deviceProfile.MaxStaticBitrate, quality);
2015-03-12 04:55:06 +00:00
2015-03-15 01:42:09 +00:00
return deviceProfile;
2014-07-22 01:29:06 +00:00
}
public string Name
{
2015-04-05 15:01:57 +00:00
get { return "Mobile Sync"; }
2014-07-22 01:29:06 +00:00
}
2015-02-28 14:35:12 +00: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-12 04:47:16 +00:00
public IEnumerable<SyncQualityOption> GetQualityOptions(SyncTarget target)
{
return new List<SyncQualityOption>
{
new SyncQualityOption
{
2015-03-15 04:17:35 +00: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-12 04:47:16 +00:00
},
new SyncQualityOption
{
2015-03-15 04:17:35 +00:00
Name = "High",
Id = "high",
2015-03-12 04:47:16 +00:00
IsDefault = true
},
new SyncQualityOption
{
2015-03-15 04:17:35 +00:00
Name = "Medium",
Id = "medium"
2015-03-12 04:47:16 +00:00
},
new SyncQualityOption
{
2015-03-15 04:17:35 +00:00
Name = "Low",
Id = "low"
2016-08-23 05:08:07 +00:00
},
new SyncQualityOption
{
Name = "Custom",
Id = "custom"
2015-03-12 04:47:16 +00:00
}
};
}
2015-03-15 01:42:09 +00:00
2015-03-15 04:17:35 +00:00
public IEnumerable<SyncProfileOption> GetProfileOptions(SyncTarget target)
2015-03-15 01:42:09 +00:00
{
2015-03-15 04:17:35 +00:00
return new List<SyncProfileOption>();
2015-03-15 01:42:09 +00:00
}
2015-03-15 19:10:27 +00: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 19:45:41 +00:00
public bool AllowDuplicateJobItem(SyncJobItem original, SyncJobItem duplicate)
{
return false;
}
2014-07-22 01:29:06 +00:00
}
}