Bläddra i källkod

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>
gnattu 10 månader sedan
förälder
incheckning
e31c6d3934
2 ändrade filer med 14 tillägg och 8 borttagningar
  1. 10 6
      MediaBrowser.Model/Dlna/CodecProfile.cs
  2. 4 2
      MediaBrowser.Model/Dlna/StreamBuilder.cs

+ 10 - 6
MediaBrowser.Model/Dlna/CodecProfile.cs

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

+ 4 - 2
MediaBrowser.Model/Dlna/StreamBuilder.cs

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