From 75c0371835c900b598e7178e43faa8dfe6e267e2 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 13 Jul 2016 15:16:51 -0400 Subject: [PATCH] update hls subtitles --- MediaBrowser.Api/Playback/BaseStreamingService.cs | 8 ++++++++ MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs | 8 +++++++- MediaBrowser.Model/Dlna/StreamBuilder.cs | 1 + MediaBrowser.Model/Dlna/StreamInfo.cs | 2 ++ MediaBrowser.Model/Dlna/TranscodingProfile.cs | 3 +++ 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 27b675294..0b4e5efe8 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -1554,6 +1554,13 @@ namespace MediaBrowser.Api.Playback { request.TranscodingMaxAudioChannels = int.Parse(val, UsCulture); } + else if (i == 28) + { + if (videoRequest != null) + { + videoRequest.EnableSubtitlesInManifest = string.Equals("true", val, StringComparison.OrdinalIgnoreCase); + } + } } } @@ -2126,6 +2133,7 @@ namespace MediaBrowser.Api.Playback { state.VideoRequest.CopyTimestamps = transcodingProfile.CopyTimestamps; state.VideoRequest.ForceLiveStream = transcodingProfile.ForceLiveStream; + state.VideoRequest.EnableSubtitlesInManifest = transcodingProfile.EnableSubtitlesInManifest; } } } diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs index 36ab20f0f..f4ecf3693 100644 --- a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs @@ -525,10 +525,16 @@ namespace MediaBrowser.Api.Playback.Hls var subtitleGroup = subtitleStreams.Count > 0 && request is GetMasterHlsVideoPlaylist && - (((GetMasterHlsVideoPlaylist)request).SubtitleMethod == SubtitleDeliveryMethod.Hls || ((GetMasterHlsVideoPlaylist)request).EnableSubtitlesInManifest) ? + (state.VideoRequest.SubtitleMethod == SubtitleDeliveryMethod.Hls || state.VideoRequest.EnableSubtitlesInManifest) ? "subs" : null; + // If we're burning in subtitles then don't add additional subs to the manifest + if (state.SubtitleStream != null && state.VideoRequest.SubtitleMethod == SubtitleDeliveryMethod.Encode) + { + subtitleGroup = null; + } + if (!string.IsNullOrWhiteSpace(subtitleGroup)) { AddSubtitles(state, subtitleStreams, builder); diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.cs index 41efa51b9..b204cf14e 100644 --- a/MediaBrowser.Model/Dlna/StreamBuilder.cs +++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs @@ -452,6 +452,7 @@ namespace MediaBrowser.Model.Dlna playlistItem.VideoCodec = transcodingProfile.VideoCodec; playlistItem.CopyTimestamps = transcodingProfile.CopyTimestamps; playlistItem.ForceLiveStream = transcodingProfile.ForceLiveStream; + playlistItem.EnableSubtitlesInManifest = transcodingProfile.EnableSubtitlesInManifest; if (!string.IsNullOrEmpty(transcodingProfile.MaxAudioChannels)) { diff --git a/MediaBrowser.Model/Dlna/StreamInfo.cs b/MediaBrowser.Model/Dlna/StreamInfo.cs index 43a31f649..f95c6a070 100644 --- a/MediaBrowser.Model/Dlna/StreamInfo.cs +++ b/MediaBrowser.Model/Dlna/StreamInfo.cs @@ -37,6 +37,7 @@ namespace MediaBrowser.Model.Dlna public bool CopyTimestamps { get; set; } public bool ForceLiveStream { get; set; } + public bool EnableSubtitlesInManifest { get; set; } public string[] AudioCodecs { get; set; } public int? AudioStreamIndex { get; set; } @@ -249,6 +250,7 @@ namespace MediaBrowser.Model.Dlna list.Add(new NameValuePair("SubtitleMethod", item.SubtitleStreamIndex.HasValue && item.SubtitleDeliveryMethod != SubtitleDeliveryMethod.External ? item.SubtitleDeliveryMethod.ToString() : string.Empty)); list.Add(new NameValuePair("TranscodingMaxAudioChannels", item.TranscodingMaxAudioChannels.HasValue ? StringHelper.ToStringCultureInvariant(item.TranscodingMaxAudioChannels.Value) : string.Empty)); + list.Add(new NameValuePair("EnableSubtitlesInManifest", item.EnableSubtitlesInManifest.ToString().ToLower())); return list; } diff --git a/MediaBrowser.Model/Dlna/TranscodingProfile.cs b/MediaBrowser.Model/Dlna/TranscodingProfile.cs index d1314c17b..19caf85eb 100644 --- a/MediaBrowser.Model/Dlna/TranscodingProfile.cs +++ b/MediaBrowser.Model/Dlna/TranscodingProfile.cs @@ -38,6 +38,9 @@ namespace MediaBrowser.Model.Dlna [XmlAttribute("forceLiveStream")] public bool ForceLiveStream { get; set; } + [XmlAttribute("enableSubtitlesInManifest")] + public bool EnableSubtitlesInManifest { get; set; } + [XmlAttribute("maxAudioChannels")] public string MaxAudioChannels { get; set; }