Merge pull request #12420 from gnattu/codec-profile-subcontainer

Add SubContainer support to CodecProfile
This commit is contained in:
Niels van Velzen 2024-09-06 22:04:10 +02:00 committed by GitHub
commit d250f7bd95
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 8 deletions

View File

@ -28,24 +28,28 @@ namespace MediaBrowser.Model.Dlna
[XmlAttribute("container")]
public string Container { get; set; }
[XmlAttribute("subcontainer")]
public string SubContainer { get; set; }
public string[] GetCodecs()
{
return ContainerProfile.SplitValue(Codec);
}
private bool ContainsContainer(string container)
private bool ContainsContainer(string container, bool useSubContainer = false)
{
return ContainerProfile.ContainsContainer(Container, container);
var containerToCheck = useSubContainer && string.Equals(Container, "hls", StringComparison.OrdinalIgnoreCase) ? SubContainer : Container;
return ContainerProfile.ContainsContainer(containerToCheck, container);
}
public bool ContainsAnyCodec(string codec, string container)
public bool ContainsAnyCodec(string codec, string container, bool useSubContainer = false)
{
return ContainsAnyCodec(ContainerProfile.SplitValue(codec), container);
return ContainsAnyCodec(ContainerProfile.SplitValue(codec), container, useSubContainer);
}
public bool ContainsAnyCodec(string[] codec, string container)
public bool ContainsAnyCodec(string[] codec, string container, bool useSubContainer = false)
{
if (!ContainsContainer(container))
if (!ContainsContainer(container, useSubContainer))
{
return false;
}

View File

@ -962,9 +962,11 @@ namespace MediaBrowser.Model.Dlna
int? numAudioStreams = item.GetStreamCount(MediaStreamType.Audio);
int? numVideoStreams = item.GetStreamCount(MediaStreamType.Video);
var useSubContainer = playlistItem.SubProtocol == MediaStreamProtocol.hls;
var appliedVideoConditions = options.Profile.CodecProfiles
.Where(i => i.Type == CodecType.Video &&
i.ContainsAnyCodec(videoStream?.Codec, container) &&
i.ContainsAnyCodec(videoStream?.Codec, container, useSubContainer) &&
i.ApplyConditions.All(applyCondition => ConditionProcessor.IsVideoConditionSatisfied(applyCondition, width, height, bitDepth, videoBitrate, videoProfile, videoRangeType, videoLevel, videoFramerate, packetLength, timestamp, isAnamorphic, isInterlaced, refFrames, numVideoStreams, numAudioStreams, videoCodecTag, isAvc)))
// Reverse codec profiles for backward compatibility - first codec profile has higher priority
.Reverse();
@ -974,7 +976,7 @@ namespace MediaBrowser.Model.Dlna
var transcodingVideoCodecs = ContainerProfile.SplitValue(videoCodec);
foreach (var transcodingVideoCodec in transcodingVideoCodecs)
{
if (i.ContainsAnyCodec(transcodingVideoCodec, container))
if (i.ContainsAnyCodec(transcodingVideoCodec, container, useSubContainer))
{
ApplyTranscodingConditions(playlistItem, i.Conditions, transcodingVideoCodec, true, true);
continue;