aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtiume <siderite@gmail.com>2019-12-15 23:57:58 -0500
committerGitHub <noreply@github.com>2019-12-15 23:57:58 -0500
commit1443583a414bcd16bf0af5cd05f631f32f26123e (patch)
treed3bb107d4e784c60271b015124b32e6dbe94cd4f
parent61b9845e0f72fc145a12dba38288d01baa6e03be (diff)
parentbe956dfd0270c010ef6ed6904b4bada628717155 (diff)
Merge pull request #1 from Artiume/branch1
Update MediaInfoService.cs
-rw-r--r--MediaBrowser.Api/Playback/MediaInfoService.cs141
1 files changed, 92 insertions, 49 deletions
diff --git a/MediaBrowser.Api/Playback/MediaInfoService.cs b/MediaBrowser.Api/Playback/MediaInfoService.cs
index c3032416b..1730db89a 100644
--- a/MediaBrowser.Api/Playback/MediaInfoService.cs
+++ b/MediaBrowser.Api/Playback/MediaInfoService.cs
@@ -407,8 +407,13 @@ namespace MediaBrowser.Api.Playback
if (mediaSource.SupportsDirectPlay)
{
- if (mediaSource.IsRemote && forceDirectPlayRemoteMediaSource)
+ if (mediaSource.IsRemote && forceDirectPlayRemoteMediaSource && user.Policy.ForceRemoteSourceTranscoding)
{
+ mediaSource.SupportsDirectPlay = false;
+ }
+ else if (mediaSource.IsRemote && user.Policy.ForceRemoteSourceTranscoding)
+ {
+ mediaSource.SupportsDirectPlay = false;
}
else
{
@@ -455,74 +460,112 @@ namespace MediaBrowser.Api.Playback
if (mediaSource.SupportsDirectStream)
{
- options.MaxBitrate = GetMaxBitrate(maxBitrate, user);
-
- if (item is Audio)
- {
- if (!user.Policy.EnableAudioPlaybackTranscoding)
- {
- options.ForceDirectStream = true;
- }
- }
- else if (item is Video)
+ if (mediaSource.IsRemote && forceDirectPlayRemoteMediaSource && user.Policy.ForceRemoteSourceTranscoding)
{
- if (!user.Policy.EnableAudioPlaybackTranscoding && !user.Policy.EnableVideoPlaybackTranscoding && !user.Policy.EnablePlaybackRemuxing)
- {
- options.ForceDirectStream = true;
- }
+ mediaSource.SupportsDirectStream = false;
}
-
- // 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)
+ else if (mediaSource.IsRemote && user.Policy.ForceRemoteSourceTranscoding)
{
mediaSource.SupportsDirectStream = false;
}
-
- if (streamInfo != null)
- {
- SetDeviceSpecificSubtitleInfo(streamInfo, mediaSource, auth.Token);
}
- }
+ 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)
{
- 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);
- 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('-');
-
- if (!allowVideoStreamCopy)
- {
- mediaSource.TranscodingUrl += "&allowVideoStreamCopy=false";
- }
- if (!allowAudioStreamCopy)
- {
- mediaSource.TranscodingUrl += "&allowAudioStreamCopy=false";
- }
+ 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 (streamInfo.PlayMethod == PlayMethod.Transcode)
+ {
+ 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;
+ }
+ // 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);
- }
- }
- }
+ }
+ }
private long? GetMaxBitrate(long? clientMaxBitrate, User user)
{