StreamBuilder tweaks (#5668)

Co-authored-by: Cody Robibero <cody@robibe.ro>
This commit is contained in:
Max Rumpf 2021-04-01 19:18:14 +02:00 committed by GitHub
parent 7c51d0a50e
commit 21e7ceae8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -674,7 +674,7 @@ namespace MediaBrowser.Model.Dlna
var videoStream = item.VideoStream; var videoStream = item.VideoStream;
// TODO: This doesn't accout for situation of device being able to handle media bitrate, but wifi connection not fast enough // TODO: This doesn't account for situations where the device is able to handle the media's bitrate, but the connection isn't fast enough
var directPlayEligibilityResult = IsEligibleForDirectPlay(item, GetBitrateForDirectPlayCheck(item, options, true) ?? 0, subtitleStream, options, PlayMethod.DirectPlay); var directPlayEligibilityResult = IsEligibleForDirectPlay(item, GetBitrateForDirectPlayCheck(item, options, true) ?? 0, subtitleStream, options, PlayMethod.DirectPlay);
var directStreamEligibilityResult = IsEligibleForDirectPlay(item, options.GetMaxBitrate(false) ?? 0, subtitleStream, options, PlayMethod.DirectStream); var directStreamEligibilityResult = IsEligibleForDirectPlay(item, options.GetMaxBitrate(false) ?? 0, subtitleStream, options, PlayMethod.DirectStream);
bool isEligibleForDirectPlay = options.EnableDirectPlay && (options.ForceDirectPlay || directPlayEligibilityResult.Item1); bool isEligibleForDirectPlay = options.EnableDirectPlay && (options.ForceDirectPlay || directPlayEligibilityResult.Item1);
@ -1017,14 +1017,15 @@ namespace MediaBrowser.Model.Dlna
} }
DeviceProfile profile = options.Profile; DeviceProfile profile = options.Profile;
string container = mediaSource.Container;
// See if it can be direct played // See if it can be direct played
DirectPlayProfile directPlay = null; DirectPlayProfile directPlay = null;
foreach (var i in profile.DirectPlayProfiles) foreach (var p in profile.DirectPlayProfiles)
{ {
if (i.Type == DlnaProfileType.Video && IsVideoDirectPlaySupported(i, mediaSource, videoStream, audioStream)) if (p.Type == DlnaProfileType.Video && IsVideoDirectPlaySupported(p, container, videoStream, audioStream))
{ {
directPlay = i; directPlay = p;
break; break;
} }
} }
@ -1032,23 +1033,23 @@ namespace MediaBrowser.Model.Dlna
if (directPlay == null) if (directPlay == null)
{ {
_logger.LogInformation( _logger.LogInformation(
"Profile: {0}, No video direct play profiles found for {1} with codec {2}", "Container: {Container}, Video: {Video}, Audio: {Audio} cannot be direct played by profile: {Profile} for path: {Path}",
profile?.Name ?? "Unknown Profile", container,
mediaSource?.Path ?? "Unknown path", videoStream?.Codec ?? "no video",
videoStream?.Codec ?? "Unknown codec"); audioStream?.Codec ?? "no audio",
profile.Name ?? "unknown profile",
mediaSource.Path ?? "unknown path");
return (null, GetTranscodeReasonsFromDirectPlayProfile(mediaSource, videoStream, audioStream, profile.DirectPlayProfiles)); return (null, GetTranscodeReasonsFromDirectPlayProfile(mediaSource, videoStream, audioStream, profile.DirectPlayProfiles));
} }
string container = mediaSource.Container;
var conditions = new List<ProfileCondition>(); var conditions = new List<ProfileCondition>();
foreach (var i in profile.ContainerProfiles) foreach (var p in profile.ContainerProfiles)
{ {
if (i.Type == DlnaProfileType.Video if (p.Type == DlnaProfileType.Video
&& i.ContainsContainer(container)) && p.ContainsContainer(container))
{ {
foreach (var c in i.Conditions) foreach (var c in p.Conditions)
{ {
conditions.Add(c); conditions.Add(c);
} }
@ -1896,10 +1897,10 @@ namespace MediaBrowser.Model.Dlna
return true; return true;
} }
private bool IsVideoDirectPlaySupported(DirectPlayProfile profile, MediaSourceInfo item, MediaStream videoStream, MediaStream audioStream) private bool IsVideoDirectPlaySupported(DirectPlayProfile profile, string container, MediaStream videoStream, MediaStream audioStream)
{ {
// Check container type // Check container type
if (!profile.SupportsContainer(item.Container)) if (!profile.SupportsContainer(container))
{ {
return false; return false;
} }