The Free Software Media System - Server Backend & API
Merge remote-tracking branch 'jellyfin/master'
artiume918df5e35288
diff --cc MediaBrowser.Api/Playback/MediaInfoService.csindex 24f6b6408b,15880a9a16..d60d9bfe72--- a/MediaBrowser.Api/Playback/MediaInfoService.cs+++ b/MediaBrowser.Api/Playback/MediaInfoService.cs@@@ -461,116 -464,74 +470,124 @@@ namespace MediaBrowser.Api.Playbacif (mediaSource.SupportsDirectStream){- options.MaxBitrate = GetMaxBitrate(maxBitrate, user);-- if (item is Audio)+ if (mediaSource.IsRemote && forceDirectPlayRemoteMediaSource && user.Policy.ForceRemoteSourceTranscoding){- if (!user.Policy.EnableAudioPlaybackTranscoding)- {- options.ForceDirectStream = true;- }+ mediaSource.SupportsDirectStream = false;}- else if (item is Video)+ else if (mediaSource.IsRemote && user.Policy.ForceRemoteSourceTranscoding){- if (!user.Policy.EnableAudioPlaybackTranscoding && !user.Policy.EnableVideoPlaybackTranscoding && !user.Policy.EnablePlaybackRemuxing)+ mediaSource.SupportsDirectStream = false;+ }+ else+ {+ options.MaxBitrate = GetMaxBitrate(maxBitrate, user);++ if (item is Audio)+ {+ if (!user.Policy.EnableAudioPlaybackTranscoding)+ {+ options.ForceDirectStream = true;+ }+ }+ else if (item is Video){- options.ForceDirectStream = true;+ if (!user.Policy.EnableAudioPlaybackTranscoding && !user.Policy.EnableVideoPlaybackTranscoding && !user.Policy.EnablePlaybackRemuxing)+ {+ options.ForceDirectStream = true;+ }}- }- // The MediaSource supports direct stream, now test to see if the client supports it- var streamInfo = string.Equals(item.MediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase) ?- streamBuilder.BuildAudioItem(options) :- streamBuilder.BuildVideoItem(options);+ // The MediaSource supports direct stream, now test to see if the client supports it+ var streamInfo = string.Equals(item.MediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase)+ ? streamBuilder.BuildAudioItem(options)+ : streamBuilder.BuildVideoItem(options);- if (streamInfo == null || !streamInfo.IsDirectStream)- {- mediaSource.SupportsDirectStream = false;- }+ if (streamInfo == null || !streamInfo.IsDirectStream)+ {+ mediaSource.SupportsDirectStream = false;+ }- if (streamInfo != null)- {- SetDeviceSpecificSubtitleInfo(streamInfo, mediaSource, auth.Token);- }+ if (streamInfo != null)+ {+ SetDeviceSpecificSubtitleInfo(streamInfo, mediaSource, auth.Token);+ }+ }}if (mediaSource.SupportsTranscoding){- options.MaxBitrate = GetMaxBitrate(maxBitrate, user);-+ if (mediaSource.IsRemote && user.Policy.ForceRemoteSourceTranscoding)+ {+ if (GetMaxBitrate(maxBitrate, user) < mediaSource.Bitrate)+ {+ options.MaxBitrate = GetMaxBitrate(maxBitrate, user);+ }+ else+ {+ options.MaxBitrate = mediaSource.Bitrate;+ }+ }+ else+ {+ options.MaxBitrate = GetMaxBitrate(maxBitrate, user);+ }+// The MediaSource supports direct stream, now test to see if the client supports it- var streamInfo = string.Equals(item.MediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase) ?- streamBuilder.BuildAudioItem(options) :- streamBuilder.BuildVideoItem(options);+ var streamInfo = string.Equals(item.MediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase)+ ? streamBuilder.BuildAudioItem(options)+ : streamBuilder.BuildVideoItem(options);- if (streamInfo != null)- {- streamInfo.PlaySessionId = playSessionId;-- if (streamInfo.PlayMethod == PlayMethod.Transcode)+ if (mediaSource.IsRemote && user.Policy.ForceRemoteSourceTranscoding)+ {+ if (streamInfo != null){+ streamInfo.PlaySessionId = playSessionId;streamInfo.StartPositionTicks = startTimeTicks;mediaSource.TranscodingUrl = streamInfo.ToUrl("-", auth.Token).TrimStart('-');+ mediaSource.TranscodingUrl += "&allowVideoStreamCopy=false";+ mediaSource.TranscodingUrl += "&allowAudioStreamCopy=false";+ mediaSource.TranscodingContainer = streamInfo.Container;+ mediaSource.TranscodingSubProtocol = streamInfo.SubProtocol;++ // Do this after the above so that StartPositionTicks is set+ SetDeviceSpecificSubtitleInfo(streamInfo, mediaSource, auth.Token);+ }+ }+ else+ {+ if (streamInfo != null)+ {+ streamInfo.PlaySessionId = playSessionId;- if (!allowVideoStreamCopy)+ if (streamInfo.PlayMethod == PlayMethod.Transcode){- mediaSource.TranscodingUrl += "&allowVideoStreamCopy=false";+ streamInfo.StartPositionTicks = startTimeTicks;+ mediaSource.TranscodingUrl = streamInfo.ToUrl("-", auth.Token).TrimStart('-');++ if (!allowVideoStreamCopy)+ {+ mediaSource.TranscodingUrl += "&allowVideoStreamCopy=false";+ }+ if (!allowAudioStreamCopy)+ {+ mediaSource.TranscodingUrl += "&allowAudioStreamCopy=false";+ }+ mediaSource.TranscodingContainer = streamInfo.Container;+ mediaSource.TranscodingSubProtocol = streamInfo.SubProtocol;}+ if (!allowAudioStreamCopy)+ {+ mediaSource.TranscodingUrl += "&allowAudioStreamCopy=false";+ }++ mediaSource.TranscodingContainer = streamInfo.Container;+ mediaSource.TranscodingSubProtocol = streamInfo.SubProtocol;- }+- // Do this after the above so that StartPositionTicks is set- SetDeviceSpecificSubtitleInfo(streamInfo, mediaSource, auth.Token);- }+ // Do this after the above so that StartPositionTicks is set+ SetDeviceSpecificSubtitleInfo(streamInfo, mediaSource, auth.Token);+ }+ }}foreach (var attachment in mediaSource.MediaAttachments)