Add SubContainer support to CodecProfile

Currently, when specifying codec profiles, the client can only specify profiles applied to direct containers, with no way to apply a profile specifically to HLS or a specific HLS container. This limitation is not suitable for more complex client codec support scenarios.

To address this, a SubContainer field is added to CodecProfile. The client can now specify the main container as "hls" to apply the profile exclusively to HLS streams. Additionally, the SubContainer field allows the profile to be applied to a specific HLS container.

Currently, this is only used in StreamBuilder for HLS streams. Further changes may be required to extend its usage.

Signed-off-by: gnattu <gnattuoc@me.com>
pull/12420/head
gnattu 7 months ago
parent ca4bd57b8d
commit e31c6d3934

@ -28,24 +28,28 @@ namespace MediaBrowser.Model.Dlna
[XmlAttribute("container")]
public string Container { get; set; }
[XmlAttribute("container")]
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;
}

@ -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;

Loading…
Cancel
Save