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

114 lines
3.4 KiB
C#
Raw Normal View History

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