|
|
|
@ -81,7 +81,8 @@ namespace MediaBrowser.Model.Dlna
|
|
|
|
|
|
|
|
|
|
public bool IsDirectStream
|
|
|
|
|
{
|
|
|
|
|
get {
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return PlayMethod == PlayMethod.DirectStream ||
|
|
|
|
|
PlayMethod == PlayMethod.DirectPlay;
|
|
|
|
|
}
|
|
|
|
@ -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 (MediaStream stream in MediaSource.MediaStreams)
|
|
|
|
|
{
|
|
|
|
|
if (stream.Type == MediaStreamType.Subtitle && stream.Index == SubtitleStreamIndex.Value)
|
|
|
|
|
{
|
|
|
|
|
SubtitleStreamInfo info = GetSubtitleStreamInfo(stream);
|
|
|
|
|
|
|
|
|
|
if (info != null)
|
|
|
|
|
{
|
|
|
|
|
list.Add(info);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!includeSelectedTrackOnly)
|
|
|
|
|
{
|
|
|
|
|
foreach (MediaStream stream in MediaSource.MediaStreams)
|
|
|
|
|
{
|
|
|
|
|
if (stream.Type == MediaStreamType.Subtitle && (!SubtitleStreamIndex.HasValue || stream.Index != SubtitleStreamIndex.Value))
|
|
|
|
|
foreach (SubtitleStreamInfo stream in list)
|
|
|
|
|
{
|
|
|
|
|
SubtitleStreamInfo info = GetSubtitleStreamInfo(stream);
|
|
|
|
|
|
|
|
|
|
if (info != null)
|
|
|
|
|
if (stream.DeliveryMethod == SubtitleDeliveryMethod.External)
|
|
|
|
|
{
|
|
|
|
|
list.Add(info);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
newList.Add(stream);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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,13 +252,10 @@ namespace MediaBrowser.Model.Dlna
|
|
|
|
|
{
|
|
|
|
|
SubtitleStreamInfo info = GetSubtitleStreamInfo(stream, baseUrl, accessToken, startPositionTicks);
|
|
|
|
|
|
|
|
|
|
if (info != null)
|
|
|
|
|
{
|
|
|
|
|
list.Add(info);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!includeSelectedTrackOnly)
|
|
|
|
|
{
|
|
|
|
@ -295,13 +265,10 @@ namespace MediaBrowser.Model.Dlna
|
|
|
|
|
{
|
|
|
|
|
SubtitleStreamInfo info = GetSubtitleStreamInfo(stream, baseUrl, accessToken, startPositionTicks);
|
|
|
|
|
|
|
|
|
|
if (info != null)
|
|
|
|
|
{
|
|
|
|
|
list.Add(info);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
@ -310,7 +277,13 @@ namespace MediaBrowser.Model.Dlna
|
|
|
|
|
{
|
|
|
|
|
SubtitleStreamInfo info = GetSubtitleStreamInfo(stream);
|
|
|
|
|
|
|
|
|
|
if (info != null)
|
|
|
|
|
if (info.DeliveryMethod == SubtitleDeliveryMethod.External)
|
|
|
|
|
{
|
|
|
|
|
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,
|
|
|
|
@ -320,6 +293,7 @@ namespace MediaBrowser.Model.Dlna
|
|
|
|
|
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
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|