sync updates
This commit is contained in:
parent
5f044cfd68
commit
07de09f350
|
@ -296,7 +296,7 @@ namespace MediaBrowser.Api
|
|||
// TODO: Lower this hls timeout
|
||||
var timerDuration = job.Type == TranscodingJobType.Progressive ?
|
||||
1000 :
|
||||
14400000;
|
||||
7200000;
|
||||
|
||||
if (job.KillTimer == null)
|
||||
{
|
||||
|
|
|
@ -272,6 +272,11 @@ namespace MediaBrowser.Api.Playback
|
|||
|
||||
// Set this back to what it was
|
||||
mediaSource.SupportsDirectStream = supportsDirectStream;
|
||||
|
||||
if (streamInfo != null)
|
||||
{
|
||||
SetDeviceSpecificSubtitleInfo(streamInfo, mediaSource, auth.Token);
|
||||
}
|
||||
}
|
||||
|
||||
if (mediaSource.SupportsDirectStream)
|
||||
|
@ -285,6 +290,11 @@ namespace MediaBrowser.Api.Playback
|
|||
{
|
||||
mediaSource.SupportsDirectStream = false;
|
||||
}
|
||||
|
||||
if (streamInfo != null)
|
||||
{
|
||||
SetDeviceSpecificSubtitleInfo(streamInfo, mediaSource, auth.Token);
|
||||
}
|
||||
}
|
||||
|
||||
if (mediaSource.SupportsTranscoding)
|
||||
|
@ -297,10 +307,36 @@ namespace MediaBrowser.Api.Playback
|
|||
if (streamInfo != null && streamInfo.PlayMethod == PlayMethod.Transcode)
|
||||
{
|
||||
streamInfo.StartPositionTicks = startTimeTicks;
|
||||
mediaSource.TranscodingUrl = streamInfo.ToUrl("-", auth.Token).Substring(1);
|
||||
mediaSource.TranscodingUrl = streamInfo.ToUrl("-", auth.Token).TrimStart('-');
|
||||
mediaSource.TranscodingContainer = streamInfo.Container;
|
||||
mediaSource.TranscodingSubProtocol = streamInfo.SubProtocol;
|
||||
}
|
||||
|
||||
if (streamInfo != null)
|
||||
{
|
||||
SetDeviceSpecificSubtitleInfo(streamInfo, mediaSource, auth.Token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SetDeviceSpecificSubtitleInfo(StreamInfo info, MediaSourceInfo mediaSource, string accessToken)
|
||||
{
|
||||
var profiles = info.GetSubtitleProfiles(false, "-", accessToken);
|
||||
|
||||
foreach (var profile in profiles)
|
||||
{
|
||||
foreach (var stream in mediaSource.MediaStreams)
|
||||
{
|
||||
if (stream.Type == MediaStreamType.Subtitle && stream.Index == profile.Index)
|
||||
{
|
||||
stream.DeliveryMethod = profile.DeliveryMethod;
|
||||
|
||||
if (profile.DeliveryMethod == SubtitleDeliveryMethod.External)
|
||||
{
|
||||
stream.DeliveryUrl = profile.Url.TrimStart('-');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -167,9 +167,12 @@ namespace MediaBrowser.Dlna.Didl
|
|||
AddVideoResource(container, video, deviceId, filter, contentFeature, streamInfo);
|
||||
}
|
||||
|
||||
foreach (var subtitle in streamInfo.GetExternalSubtitles(_serverAddress, _accessToken, false))
|
||||
foreach (var subtitle in streamInfo.GetSubtitleProfiles(false, _serverAddress, _accessToken))
|
||||
{
|
||||
AddSubtitleElement(container, subtitle);
|
||||
if (subtitle.DeliveryMethod == SubtitleDeliveryMethod.External)
|
||||
{
|
||||
AddSubtitleElement(container, subtitle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace MediaBrowser.Model.Dlna
|
|||
|
||||
public int? MaxVideoBitDepth { get; set; }
|
||||
public int? MaxRefFrames { get; set; }
|
||||
|
||||
|
||||
public float? MaxFramerate { get; set; }
|
||||
|
||||
public DeviceProfile DeviceProfile { get; set; }
|
||||
|
@ -81,7 +81,8 @@ namespace MediaBrowser.Model.Dlna
|
|||
|
||||
public bool IsDirectStream
|
||||
{
|
||||
get {
|
||||
get
|
||||
{
|
||||
return PlayMethod == PlayMethod.DirectStream ||
|
||||
PlayMethod == PlayMethod.DirectPlay;
|
||||
}
|
||||
|
@ -175,7 +176,7 @@ namespace MediaBrowser.Model.Dlna
|
|||
{
|
||||
list.Add(pair.Value);
|
||||
}
|
||||
|
||||
|
||||
return string.Format("Params={0}", string.Join(";", list.ToArray()));
|
||||
}
|
||||
|
||||
|
@ -199,7 +200,7 @@ namespace MediaBrowser.Model.Dlna
|
|||
list.Add(new NameValuePair("MaxHeight", item.MaxHeight.HasValue ? StringHelper.ToStringCultureInvariant(item.MaxHeight.Value) : string.Empty));
|
||||
list.Add(new NameValuePair("StartTimeTicks", StringHelper.ToStringCultureInvariant(item.StartPositionTicks)));
|
||||
list.Add(new NameValuePair("Level", item.VideoLevel.HasValue ? StringHelper.ToStringCultureInvariant(item.VideoLevel.Value) : string.Empty));
|
||||
|
||||
|
||||
list.Add(new NameValuePair("ClientTime", item.IsDirectStream ? string.Empty : DateTime.UtcNow.Ticks.ToString(CultureInfo.InvariantCulture)));
|
||||
list.Add(new NameValuePair("MaxRefFrames", item.MaxRefFrames.HasValue ? StringHelper.ToStringCultureInvariant(item.MaxRefFrames.Value) : string.Empty));
|
||||
list.Add(new NameValuePair("MaxVideoBitDepth", item.MaxVideoBitDepth.HasValue ? StringHelper.ToStringCultureInvariant(item.MaxVideoBitDepth.Value) : string.Empty));
|
||||
|
@ -216,53 +217,25 @@ namespace MediaBrowser.Model.Dlna
|
|||
return list;
|
||||
}
|
||||
|
||||
public List<SubtitleStreamInfo> GetExternalSubtitles(bool includeSelectedTrackOnly)
|
||||
public List<SubtitleStreamInfo> GetExternalSubtitles(bool includeSelectedTrackOnly, string baseUrl, string accessToken)
|
||||
{
|
||||
List<SubtitleStreamInfo> list = new List<SubtitleStreamInfo>();
|
||||
List<SubtitleStreamInfo> list = GetSubtitleProfiles(includeSelectedTrackOnly, baseUrl, accessToken);
|
||||
List<SubtitleStreamInfo> newList = new List<SubtitleStreamInfo>();
|
||||
|
||||
// First add the selected track
|
||||
if (SubtitleStreamIndex.HasValue)
|
||||
foreach (SubtitleStreamInfo stream in list)
|
||||
{
|
||||
foreach (MediaStream stream in MediaSource.MediaStreams)
|
||||
if (stream.DeliveryMethod == SubtitleDeliveryMethod.External)
|
||||
{
|
||||
if (stream.Type == MediaStreamType.Subtitle && stream.Index == SubtitleStreamIndex.Value)
|
||||
{
|
||||
SubtitleStreamInfo info = GetSubtitleStreamInfo(stream);
|
||||
|
||||
if (info != null)
|
||||
{
|
||||
list.Add(info);
|
||||
}
|
||||
}
|
||||
newList.Add(stream);
|
||||
}
|
||||
}
|
||||
|
||||
if (!includeSelectedTrackOnly)
|
||||
{
|
||||
foreach (MediaStream stream in MediaSource.MediaStreams)
|
||||
{
|
||||
if (stream.Type == MediaStreamType.Subtitle && (!SubtitleStreamIndex.HasValue || stream.Index != SubtitleStreamIndex.Value))
|
||||
{
|
||||
SubtitleStreamInfo info = GetSubtitleStreamInfo(stream);
|
||||
|
||||
if (info != null)
|
||||
{
|
||||
list.Add(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
return newList;
|
||||
}
|
||||
|
||||
public List<SubtitleStreamInfo> GetExternalSubtitles(string baseUrl, string accessToken, bool includeSelectedTrackOnly)
|
||||
public List<SubtitleStreamInfo> GetSubtitleProfiles(bool includeSelectedTrackOnly, string baseUrl, string accessToken)
|
||||
{
|
||||
if (string.IsNullOrEmpty(baseUrl))
|
||||
{
|
||||
throw new ArgumentNullException(baseUrl);
|
||||
}
|
||||
|
||||
List<SubtitleStreamInfo> list = new List<SubtitleStreamInfo>();
|
||||
|
||||
// HLS will preserve timestamps so we can just grab the full subtitle stream
|
||||
|
@ -279,10 +252,7 @@ namespace MediaBrowser.Model.Dlna
|
|||
{
|
||||
SubtitleStreamInfo info = GetSubtitleStreamInfo(stream, baseUrl, accessToken, startPositionTicks);
|
||||
|
||||
if (info != null)
|
||||
{
|
||||
list.Add(info);
|
||||
}
|
||||
list.Add(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -295,14 +265,11 @@ namespace MediaBrowser.Model.Dlna
|
|||
{
|
||||
SubtitleStreamInfo info = GetSubtitleStreamInfo(stream, baseUrl, accessToken, startPositionTicks);
|
||||
|
||||
if (info != null)
|
||||
{
|
||||
list.Add(info);
|
||||
}
|
||||
list.Add(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
@ -310,15 +277,22 @@ namespace MediaBrowser.Model.Dlna
|
|||
{
|
||||
SubtitleStreamInfo info = GetSubtitleStreamInfo(stream);
|
||||
|
||||
if (info != null)
|
||||
if (info.DeliveryMethod == SubtitleDeliveryMethod.External)
|
||||
{
|
||||
info.Url = string.Format("{0}/Videos/{1}/{2}/Subtitles/{3}/{4}/Stream.{5}",
|
||||
baseUrl,
|
||||
ItemId,
|
||||
MediaSourceId,
|
||||
StringHelper.ToStringCultureInvariant(stream.Index),
|
||||
StringHelper.ToStringCultureInvariant(startPositionTicks),
|
||||
SubtitleFormat);
|
||||
if (MediaSource.Protocol == MediaProtocol.Http)
|
||||
{
|
||||
info.Url = stream.Path;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(baseUrl))
|
||||
{
|
||||
info.Url = string.Format("{0}/Videos/{1}/{2}/Subtitles/{3}/{4}/Stream.{5}",
|
||||
baseUrl,
|
||||
ItemId,
|
||||
MediaSourceId,
|
||||
StringHelper.ToStringCultureInvariant(stream.Index),
|
||||
StringHelper.ToStringCultureInvariant(startPositionTicks),
|
||||
SubtitleFormat);
|
||||
}
|
||||
}
|
||||
|
||||
return info;
|
||||
|
@ -328,18 +302,14 @@ namespace MediaBrowser.Model.Dlna
|
|||
{
|
||||
SubtitleProfile subtitleProfile = StreamBuilder.GetSubtitleProfile(stream, DeviceProfile.SubtitleProfiles, Context);
|
||||
|
||||
if (subtitleProfile.Method != SubtitleDeliveryMethod.External)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new SubtitleStreamInfo
|
||||
{
|
||||
IsForced = stream.IsForced,
|
||||
Language = stream.Language,
|
||||
Name = stream.Language ?? "Unknown",
|
||||
Format = SubtitleFormat,
|
||||
Index = stream.Index
|
||||
Index = stream.Index,
|
||||
DeliveryMethod = subtitleProfile.Method
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -8,5 +8,6 @@ namespace MediaBrowser.Model.Dlna
|
|||
public bool IsForced { get; set; }
|
||||
public string Format { get; set; }
|
||||
public int Index { get; set; }
|
||||
public SubtitleDeliveryMethod DeliveryMethod { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using MediaBrowser.Model.Extensions;
|
||||
using MediaBrowser.Model.Dlna;
|
||||
using MediaBrowser.Model.Extensions;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace MediaBrowser.Model.Entities
|
||||
|
@ -135,6 +136,17 @@ namespace MediaBrowser.Model.Entities
|
|||
/// <value><c>true</c> if this instance is external; otherwise, <c>false</c>.</value>
|
||||
public bool IsExternal { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the method.
|
||||
/// </summary>
|
||||
/// <value>The method.</value>
|
||||
public SubtitleDeliveryMethod? DeliveryMethod { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the delivery URL.
|
||||
/// </summary>
|
||||
/// <value>The delivery URL.</value>
|
||||
public string DeliveryUrl { get; set; }
|
||||
|
||||
public bool IsTextSubtitleStream
|
||||
{
|
||||
get
|
||||
|
|
|
@ -227,6 +227,11 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
{
|
||||
Format = "srt",
|
||||
Method = SubtitleDeliveryMethod.External
|
||||
},
|
||||
new SubtitleProfile
|
||||
{
|
||||
Format = "vtt",
|
||||
Method = SubtitleDeliveryMethod.External
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -495,7 +495,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
// 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(false);
|
||||
streamInfo.GetExternalSubtitles(false, null, null);
|
||||
|
||||
// Mark as requiring conversion if transcoding the video, or if any subtitles need to be extracted
|
||||
var requiresVideoTranscoding = streamInfo.PlayMethod == PlayMethod.Transcode && jobOptions.IsConverting;
|
||||
|
|
|
@ -677,7 +677,6 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
syncedItem.Item.MediaSources = new List<MediaSourceInfo>();
|
||||
|
||||
syncedItem.OriginalFileName = Path.GetFileName(libraryItem.Path);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(syncedItem.OriginalFileName))
|
||||
{
|
||||
syncedItem.OriginalFileName = Path.GetFileName(mediaSource.Path);
|
||||
|
@ -686,6 +685,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||
// This will be null for items that are not audio/video
|
||||
if (mediaSource != null)
|
||||
{
|
||||
syncedItem.OriginalFileName = Path.ChangeExtension(syncedItem.OriginalFileName, Path.GetExtension(mediaSource.Path));
|
||||
syncedItem.Item.MediaSources.Add(mediaSource);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user