sync updates
This commit is contained in:
parent
cf37c5cac1
commit
7fd4b97481
|
@ -1,4 +1,5 @@
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
|
using MediaBrowser.Controller.Entities.Audio;
|
||||||
using MediaBrowser.Model.Dlna;
|
using MediaBrowser.Model.Dlna;
|
||||||
using MediaBrowser.Model.Events;
|
using MediaBrowser.Model.Events;
|
||||||
using MediaBrowser.Model.Querying;
|
using MediaBrowser.Model.Querying;
|
||||||
|
@ -149,5 +150,20 @@ namespace MediaBrowser.Controller.Sync
|
||||||
/// <param name="query">The query.</param>
|
/// <param name="query">The query.</param>
|
||||||
/// <returns>QueryResult<System.String>.</returns>
|
/// <returns>QueryResult<System.String>.</returns>
|
||||||
QueryResult<string> GetLibraryItemIds(SyncJobItemQuery query);
|
QueryResult<string> GetLibraryItemIds(SyncJobItemQuery query);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the audio options.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="jobItem">The job item.</param>
|
||||||
|
/// <returns>AudioOptions.</returns>
|
||||||
|
AudioOptions GetAudioOptions(SyncJobItem jobItem);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the video options.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="jobItem">The job item.</param>
|
||||||
|
/// <param name="job">The job.</param>
|
||||||
|
/// <returns>VideoOptions.</returns>
|
||||||
|
VideoOptions GetVideoOptions(SyncJobItem jobItem, SyncJob job);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -421,7 +421,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
var video = item as Video;
|
var video = item as Video;
|
||||||
if (video != null)
|
if (video != null)
|
||||||
{
|
{
|
||||||
await Sync(jobItem, video, user, deviceProfile, enableConversion, progress, cancellationToken).ConfigureAwait(false);
|
await Sync(jobItem, job, video, user, deviceProfile, enableConversion, progress, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (item is Audio)
|
else if (item is Audio)
|
||||||
|
@ -436,24 +436,27 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await SyncGeneric(jobItem, item, deviceProfile, cancellationToken).ConfigureAwait(false);
|
await SyncGeneric(jobItem, item, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Sync(SyncJobItem jobItem, Video item, User user, DeviceProfile profile, bool enableConversion, IProgress<double> progress, CancellationToken cancellationToken)
|
private async Task Sync(SyncJobItem jobItem, SyncJob job, Video item, User user, DeviceProfile profile, bool enableConversion, IProgress<double> progress, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var options = new VideoOptions
|
var options = _syncManager.GetVideoOptions(jobItem, job);
|
||||||
{
|
|
||||||
Context = EncodingContext.Static,
|
options.DeviceId = jobItem.TargetId;
|
||||||
ItemId = item.Id.ToString("N"),
|
options.Context = EncodingContext.Static;
|
||||||
DeviceId = jobItem.TargetId,
|
options.Profile = profile;
|
||||||
Profile = profile,
|
options.ItemId = item.Id.ToString("N");
|
||||||
MediaSources = item.GetMediaSources(false, user).ToList()
|
options.MediaSources = item.GetMediaSources(false, user).ToList();
|
||||||
};
|
|
||||||
|
|
||||||
var streamInfo = new StreamBuilder().BuildVideoItem(options);
|
var streamInfo = new StreamBuilder().BuildVideoItem(options);
|
||||||
var mediaSource = streamInfo.MediaSource;
|
var mediaSource = streamInfo.MediaSource;
|
||||||
var externalSubs = streamInfo.GetExternalSubtitles("dummy", false);
|
|
||||||
|
// No sense creating external subs if we're already burning one into the video
|
||||||
|
var externalSubs = streamInfo.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode ?
|
||||||
|
new List<SubtitleStreamInfo>() :
|
||||||
|
streamInfo.GetExternalSubtitles("dummy", false);
|
||||||
|
|
||||||
// Mark as requiring conversion if transcoding the video, or if any subtitles need to be extracted
|
// Mark as requiring conversion if transcoding the video, or if any subtitles need to be extracted
|
||||||
var requiresConversion = streamInfo.PlayMethod == PlayMethod.Transcode || externalSubs.Any(i => RequiresExtraction(i, mediaSource));
|
var requiresConversion = streamInfo.PlayMethod == PlayMethod.Transcode || externalSubs.Any(i => RequiresExtraction(i, mediaSource));
|
||||||
|
@ -610,14 +613,13 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
|
|
||||||
private async Task Sync(SyncJobItem jobItem, Audio item, User user, DeviceProfile profile, bool enableConversion, IProgress<double> progress, CancellationToken cancellationToken)
|
private async Task Sync(SyncJobItem jobItem, Audio item, User user, DeviceProfile profile, bool enableConversion, IProgress<double> progress, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var options = new AudioOptions
|
var options = _syncManager.GetAudioOptions(jobItem);
|
||||||
{
|
|
||||||
Context = EncodingContext.Static,
|
options.DeviceId = jobItem.TargetId;
|
||||||
ItemId = item.Id.ToString("N"),
|
options.Context = EncodingContext.Static;
|
||||||
DeviceId = jobItem.TargetId,
|
options.Profile = profile;
|
||||||
Profile = profile,
|
options.ItemId = item.Id.ToString("N");
|
||||||
MediaSources = item.GetMediaSources(false, user).ToList()
|
options.MediaSources = item.GetMediaSources(false, user).ToList();
|
||||||
};
|
|
||||||
|
|
||||||
var streamInfo = new StreamBuilder().BuildAudioItem(options);
|
var streamInfo = new StreamBuilder().BuildAudioItem(options);
|
||||||
var mediaSource = streamInfo.MediaSource;
|
var mediaSource = streamInfo.MediaSource;
|
||||||
|
@ -693,7 +695,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
await _syncRepo.Update(jobItem).ConfigureAwait(false);
|
await _syncRepo.Update(jobItem).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SyncGeneric(SyncJobItem jobItem, BaseItem item, DeviceProfile profile, CancellationToken cancellationToken)
|
private async Task SyncGeneric(SyncJobItem jobItem, BaseItem item, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
jobItem.OutputPath = item.Path;
|
jobItem.OutputPath = item.Path;
|
||||||
|
|
||||||
|
|
|
@ -103,14 +103,14 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
|
|
||||||
var target = GetSyncTargets(request.UserId)
|
var target = GetSyncTargets(request.UserId)
|
||||||
.FirstOrDefault(i => string.Equals(request.TargetId, i.Id));
|
.FirstOrDefault(i => string.Equals(request.TargetId, i.Id));
|
||||||
|
|
||||||
if (target == null)
|
if (target == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("Sync target not found.");
|
throw new ArgumentException("Sync target not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
var jobId = Guid.NewGuid().ToString("N");
|
var jobId = Guid.NewGuid().ToString("N");
|
||||||
|
|
||||||
var job = new SyncJob
|
var job = new SyncJob
|
||||||
{
|
{
|
||||||
Id = jobId,
|
Id = jobId,
|
||||||
|
@ -748,5 +748,39 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
{
|
{
|
||||||
return _repo.GetLibraryItemIds(query);
|
return _repo.GetLibraryItemIds(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AudioOptions GetAudioOptions(SyncJobItem jobItem)
|
||||||
|
{
|
||||||
|
var profile = GetDeviceProfile(jobItem.TargetId);
|
||||||
|
|
||||||
|
return new AudioOptions
|
||||||
|
{
|
||||||
|
Profile = profile
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public VideoOptions GetVideoOptions(SyncJobItem jobItem, SyncJob job)
|
||||||
|
{
|
||||||
|
var profile = GetDeviceProfile(jobItem.TargetId);
|
||||||
|
var maxBitrate = profile.MaxStaticBitrate;
|
||||||
|
|
||||||
|
if (maxBitrate.HasValue)
|
||||||
|
{
|
||||||
|
if (job.Quality == SyncQuality.Medium)
|
||||||
|
{
|
||||||
|
maxBitrate = Convert.ToInt32(maxBitrate.Value * .75);
|
||||||
|
}
|
||||||
|
else if (job.Quality == SyncQuality.Low)
|
||||||
|
{
|
||||||
|
maxBitrate = Convert.ToInt32(maxBitrate.Value * .5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new VideoOptions
|
||||||
|
{
|
||||||
|
Profile = profile,
|
||||||
|
MaxBitrate = maxBitrate
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user