Use filtered codecs to build appliedConditions

Signed-off-by: nyanmisaka <nst799610810@gmail.com>
This commit is contained in:
nyanmisaka 2024-09-01 21:44:23 +08:00
parent 2fe13f54ea
commit 8095d39954

View File

@ -858,7 +858,7 @@ namespace MediaBrowser.Model.Dlna
{
audioStream = directAudioStream;
playlistItem.AudioStreamIndex = audioStream.Index;
playlistItem.AudioCodecs = new[] { audioStream.Codec };
playlistItem.AudioCodecs = audioCodecs = new[] { audioStream.Codec };
// Copy matching audio codec options
playlistItem.AudioSampleRate = audioStream.SampleRate;
@ -897,15 +897,14 @@ namespace MediaBrowser.Model.Dlna
var appliedVideoConditions = options.Profile.CodecProfiles
.Where(i => i.Type == CodecType.Video &&
i.ContainsAnyCodec(videoCodec, container) &&
i.ContainsAnyCodec(videoCodecs, container) &&
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();
foreach (var i in appliedVideoConditions)
{
var transcodingVideoCodecs = ContainerProfile.SplitValue(videoCodec);
foreach (var transcodingVideoCodec in transcodingVideoCodecs)
foreach (var transcodingVideoCodec in videoCodecs)
{
if (i.ContainsAnyCodec(transcodingVideoCodec, container))
{
@ -930,15 +929,14 @@ namespace MediaBrowser.Model.Dlna
var appliedAudioConditions = options.Profile.CodecProfiles
.Where(i => i.Type == CodecType.VideoAudio &&
i.ContainsAnyCodec(audioCodec, container) &&
i.ContainsAnyCodec(audioCodecs, container) &&
i.ApplyConditions.All(applyCondition => ConditionProcessor.IsVideoAudioConditionSatisfied(applyCondition, audioChannels, inputAudioBitrate, inputAudioSampleRate, inputAudioBitDepth, audioProfile, isSecondaryAudio)))
// Reverse codec profiles for backward compatibility - first codec profile has higher priority
.Reverse();
foreach (var codecProfile in appliedAudioConditions)
{
var transcodingAudioCodecs = ContainerProfile.SplitValue(audioCodec);
foreach (var transcodingAudioCodec in transcodingAudioCodecs)
foreach (var transcodingAudioCodec in audioCodecs)
{
if (codecProfile.ContainsAnyCodec(transcodingAudioCodec, container))
{