Update MediaInfoService.cs

This commit is contained in:
Artiume 2019-12-16 14:53:42 -05:00 committed by GitHub
parent 5a9e08e0de
commit b31f4ccbc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -407,13 +407,8 @@ namespace MediaBrowser.Api.Playback
if (mediaSource.SupportsDirectPlay) if (mediaSource.SupportsDirectPlay)
{ {
if (mediaSource.IsRemote && forceDirectPlayRemoteMediaSource && user.Policy.ForceRemoteSourceTranscoding) if (mediaSource.IsRemote && forceDirectPlayRemoteMediaSource)
{ {
mediaSource.SupportsDirectPlay = false;
}
else if (mediaSource.IsRemote && user.Policy.ForceRemoteSourceTranscoding)
{
mediaSource.SupportsDirectPlay = false;
} }
else else
{ {
@ -460,111 +455,72 @@ namespace MediaBrowser.Api.Playback
if (mediaSource.SupportsDirectStream) if (mediaSource.SupportsDirectStream)
{ {
if (mediaSource.IsRemote && forceDirectPlayRemoteMediaSource && user.Policy.ForceRemoteSourceTranscoding) options.MaxBitrate = GetMaxBitrate(maxBitrate, user);
{
mediaSource.SupportsDirectStream = false;
}
else if (mediaSource.IsRemote && user.Policy.ForceRemoteSourceTranscoding)
{
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)
{
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);
if (streamInfo == null || !streamInfo.IsDirectStream)
{
mediaSource.SupportsDirectStream = false;
}
if (streamInfo != null)
{
SetDeviceSpecificSubtitleInfo(streamInfo, mediaSource, auth.Token);
}
}
}
if (mediaSource.SupportsTranscoding) if (item is Audio)
{ {
if (mediaSource.IsRemote && user.Policy.ForceRemoteSourceTranscoding) if (!user.Policy.EnableAudioPlaybackTranscoding)
{ {
if (GetMaxBitrate(maxBitrate, user) < mediaSource.Bitrate) options.ForceDirectStream = true;
{ }
options.MaxBitrate = GetMaxBitrate(maxBitrate, user); }
} else if (item is Video)
else {
{ if (!user.Policy.EnableAudioPlaybackTranscoding && !user.Policy.EnableVideoPlaybackTranscoding && !user.Policy.EnablePlaybackRemuxing)
options.MaxBitrate = mediaSource.Bitrate; {
} options.ForceDirectStream = true;
} }
else }
{
options.MaxBitrate = GetMaxBitrate(maxBitrate, user);
}
// The MediaSource supports direct stream, now test to see if the client supports it // The MediaSource supports direct stream, now test to see if the client supports it
var streamInfo = string.Equals(item.MediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase) ? var streamInfo = string.Equals(item.MediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase) ?
streamBuilder.BuildAudioItem(options) : streamBuilder.BuildAudioItem(options) :
streamBuilder.BuildVideoItem(options); streamBuilder.BuildVideoItem(options);
if (mediaSource.IsRemote && user.Policy.ForceRemoteSourceTranscoding) if (streamInfo == null || !streamInfo.IsDirectStream)
{ {
if (streamInfo != null) mediaSource.SupportsDirectStream = false;
}
if (streamInfo != null)
{
SetDeviceSpecificSubtitleInfo(streamInfo, mediaSource, auth.Token);
}
}
if (mediaSource.SupportsTranscoding)
{
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);
if (streamInfo != null)
{
streamInfo.PlaySessionId = playSessionId;
if (streamInfo.PlayMethod == PlayMethod.Transcode)
{ {
streamInfo.PlaySessionId = playSessionId;
streamInfo.StartPositionTicks = startTimeTicks; streamInfo.StartPositionTicks = startTimeTicks;
mediaSource.TranscodingUrl = streamInfo.ToUrl("-", auth.Token).TrimStart('-'); mediaSource.TranscodingUrl = streamInfo.ToUrl("-", auth.Token).TrimStart('-');
mediaSource.TranscodingUrl += "&allowVideoStreamCopy=false";
mediaSource.TranscodingUrl += "&allowAudioStreamCopy=false"; if (!allowVideoStreamCopy)
{
mediaSource.TranscodingUrl += "&allowVideoStreamCopy=false";
}
if (!allowAudioStreamCopy)
{
mediaSource.TranscodingUrl += "&allowAudioStreamCopy=false";
}
mediaSource.TranscodingContainer = streamInfo.Container; mediaSource.TranscodingContainer = streamInfo.Container;
mediaSource.TranscodingSubProtocol = streamInfo.SubProtocol; 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 (streamInfo.PlayMethod == PlayMethod.Transcode)
{
streamInfo.StartPositionTicks = startTimeTicks;
mediaSource.TranscodingUrl = streamInfo.ToUrl("-", auth.Token).TrimStart('-');
if (!allowVideoStreamCopy) // Do this after the above so that StartPositionTicks is set
{ SetDeviceSpecificSubtitleInfo(streamInfo, mediaSource, auth.Token);
mediaSource.TranscodingUrl += "&allowVideoStreamCopy=false"; }
}
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);
}
}
} }
} }