mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-05-02 23:06:31 +01:00
some initial work on cloud sync
This commit is contained in:
@@ -108,7 +108,8 @@ namespace MediaBrowser.Model.Dlna
|
||||
MediaType = DlnaProfileType.Audio,
|
||||
MediaSource = item,
|
||||
RunTimeTicks = item.RunTimeTicks,
|
||||
Context = options.Context
|
||||
Context = options.Context,
|
||||
DeviceProfile = options.Profile
|
||||
};
|
||||
|
||||
int? maxBitrateSetting = options.GetMaxBitrate();
|
||||
@@ -240,7 +241,8 @@ namespace MediaBrowser.Model.Dlna
|
||||
MediaType = DlnaProfileType.Video,
|
||||
MediaSource = item,
|
||||
RunTimeTicks = item.RunTimeTicks,
|
||||
Context = options.Context
|
||||
Context = options.Context,
|
||||
DeviceProfile = options.Profile
|
||||
};
|
||||
|
||||
int? audioStreamIndex = options.AudioStreamIndex ?? item.DefaultAudioStreamIndex;
|
||||
@@ -265,7 +267,7 @@ namespace MediaBrowser.Model.Dlna
|
||||
|
||||
if (subtitleStream != null)
|
||||
{
|
||||
SubtitleProfile subtitleProfile = GetSubtitleProfile(subtitleStream, options);
|
||||
SubtitleProfile subtitleProfile = GetSubtitleProfile(subtitleStream, options.Profile);
|
||||
|
||||
playlistItem.SubtitleDeliveryMethod = subtitleProfile.Method;
|
||||
playlistItem.SubtitleFormat = subtitleProfile.Format;
|
||||
@@ -290,7 +292,7 @@ namespace MediaBrowser.Model.Dlna
|
||||
{
|
||||
if (subtitleStream != null)
|
||||
{
|
||||
SubtitleProfile subtitleProfile = GetSubtitleProfile(subtitleStream, options);
|
||||
SubtitleProfile subtitleProfile = GetSubtitleProfile(subtitleStream, options.Profile);
|
||||
|
||||
playlistItem.SubtitleDeliveryMethod = subtitleProfile.Method;
|
||||
playlistItem.SubtitleFormat = subtitleProfile.Format;
|
||||
@@ -524,7 +526,7 @@ namespace MediaBrowser.Model.Dlna
|
||||
{
|
||||
if (subtitleStream != null)
|
||||
{
|
||||
SubtitleProfile subtitleProfile = GetSubtitleProfile(subtitleStream, options);
|
||||
SubtitleProfile subtitleProfile = GetSubtitleProfile(subtitleStream, options.Profile);
|
||||
|
||||
if (subtitleProfile.Method != SubtitleDeliveryMethod.External && subtitleProfile.Method != SubtitleDeliveryMethod.Embed)
|
||||
{
|
||||
@@ -535,10 +537,10 @@ namespace MediaBrowser.Model.Dlna
|
||||
return IsAudioEligibleForDirectPlay(item, maxBitrate);
|
||||
}
|
||||
|
||||
private SubtitleProfile GetSubtitleProfile(MediaStream subtitleStream, VideoOptions options)
|
||||
public static SubtitleProfile GetSubtitleProfile(MediaStream subtitleStream, DeviceProfile deviceProfile)
|
||||
{
|
||||
// Look for an external profile that matches the stream type (text/graphical)
|
||||
foreach (SubtitleProfile profile in options.Profile.SubtitleProfiles)
|
||||
foreach (SubtitleProfile profile in deviceProfile.SubtitleProfiles)
|
||||
{
|
||||
if (profile.Method == SubtitleDeliveryMethod.External && subtitleStream.IsTextSubtitleStream == MediaStream.IsTextFormat(profile.Format))
|
||||
{
|
||||
@@ -546,13 +548,11 @@ namespace MediaBrowser.Model.Dlna
|
||||
}
|
||||
}
|
||||
|
||||
if (subtitleStream.IsTextSubtitleStream)
|
||||
foreach (SubtitleProfile profile in deviceProfile.SubtitleProfiles)
|
||||
{
|
||||
SubtitleProfile embedProfile = GetSubtitleProfile(options.Profile.SubtitleProfiles, SubtitleDeliveryMethod.Embed);
|
||||
|
||||
if (embedProfile != null)
|
||||
if (profile.Method == SubtitleDeliveryMethod.Embed && subtitleStream.IsTextSubtitleStream == MediaStream.IsTextFormat(profile.Format))
|
||||
{
|
||||
return embedProfile;
|
||||
return profile;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -563,19 +563,6 @@ namespace MediaBrowser.Model.Dlna
|
||||
};
|
||||
}
|
||||
|
||||
private SubtitleProfile GetSubtitleProfile(SubtitleProfile[] profiles, SubtitleDeliveryMethod method)
|
||||
{
|
||||
foreach (SubtitleProfile profile in profiles)
|
||||
{
|
||||
if (method == profile.Method)
|
||||
{
|
||||
return profile;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private bool IsAudioEligibleForDirectPlay(MediaSourceInfo item, int? maxBitrate)
|
||||
{
|
||||
// Honor the max bitrate setting
|
||||
|
||||
@@ -54,6 +54,7 @@ namespace MediaBrowser.Model.Dlna
|
||||
|
||||
public float? MaxFramerate { get; set; }
|
||||
|
||||
public DeviceProfile DeviceProfile { get; set; }
|
||||
public string DeviceProfileId { get; set; }
|
||||
public string DeviceId { get; set; }
|
||||
|
||||
@@ -160,11 +161,6 @@ namespace MediaBrowser.Model.Dlna
|
||||
|
||||
List<SubtitleStreamInfo> list = new List<SubtitleStreamInfo>();
|
||||
|
||||
if (SubtitleDeliveryMethod != SubtitleDeliveryMethod.External)
|
||||
{
|
||||
return list;
|
||||
}
|
||||
|
||||
// HLS will preserve timestamps so we can just grab the full subtitle stream
|
||||
long startPositionTicks = StringHelper.EqualsIgnoreCase(Protocol, "hls")
|
||||
? 0
|
||||
@@ -175,7 +171,7 @@ namespace MediaBrowser.Model.Dlna
|
||||
{
|
||||
foreach (MediaStream stream in MediaSource.MediaStreams)
|
||||
{
|
||||
if (stream.Type == MediaStreamType.Subtitle && stream.IsTextSubtitleStream && stream.Index == SubtitleStreamIndex.Value)
|
||||
if (stream.Type == MediaStreamType.Subtitle && stream.Index == SubtitleStreamIndex.Value)
|
||||
{
|
||||
AddSubtitle(list, stream, baseUrl, startPositionTicks);
|
||||
}
|
||||
@@ -186,7 +182,7 @@ namespace MediaBrowser.Model.Dlna
|
||||
{
|
||||
foreach (MediaStream stream in MediaSource.MediaStreams)
|
||||
{
|
||||
if (stream.Type == MediaStreamType.Subtitle && stream.IsTextSubtitleStream && (!SubtitleStreamIndex.HasValue || stream.Index != SubtitleStreamIndex.Value))
|
||||
if (stream.Type == MediaStreamType.Subtitle && (!SubtitleStreamIndex.HasValue || stream.Index != SubtitleStreamIndex.Value))
|
||||
{
|
||||
AddSubtitle(list, stream, baseUrl, startPositionTicks);
|
||||
}
|
||||
@@ -198,6 +194,13 @@ namespace MediaBrowser.Model.Dlna
|
||||
|
||||
private void AddSubtitle(List<SubtitleStreamInfo> list, MediaStream stream, string baseUrl, long startPositionTicks)
|
||||
{
|
||||
var subtitleProfile = StreamBuilder.GetSubtitleProfile(stream, DeviceProfile);
|
||||
|
||||
if (subtitleProfile.Method != SubtitleDeliveryMethod.External)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string url = string.Format("{0}/Videos/{1}/{2}/Subtitles/{3}/{4}/Stream.{5}",
|
||||
baseUrl,
|
||||
ItemId,
|
||||
|
||||
Reference in New Issue
Block a user