Browse Source

check audio stream for null

Luke Pulverenti 7 years ago
parent
commit
e208ef19b0
2 changed files with 30 additions and 21 deletions
  1. 1 1
      MediaBrowser.Model/Dlna/ContainerProfile.cs
  2. 29 20
      MediaBrowser.Model/Dlna/StreamBuilder.cs

+ 1 - 1
MediaBrowser.Model/Dlna/ContainerProfile.cs

@@ -24,7 +24,7 @@ namespace MediaBrowser.Model.Dlna
             return SplitValue(Container);
         }
 
-        private static List<string> SplitValue(string value)
+        public static List<string> SplitValue(string value)
         {
             List<string> list = new List<string>();
             foreach (string i in (value ?? string.Empty).Split(','))

+ 29 - 20
MediaBrowser.Model/Dlna/StreamBuilder.cs

@@ -1231,21 +1231,27 @@ namespace MediaBrowser.Model.Dlna
 
         private static bool IsSubtitleEmbedSupported(MediaStream subtitleStream, SubtitleProfile subtitleProfile, string transcodingSubProtocol, string transcodingContainer)
         {
-            if (string.Equals(transcodingContainer, "ts", StringComparison.OrdinalIgnoreCase))
+            if (!string.IsNullOrWhiteSpace(transcodingContainer))
             {
-                return false;
-            }
-            if (string.Equals(transcodingContainer, "mpegts", StringComparison.OrdinalIgnoreCase))
-            {
-                return false;
-            }
-            if (string.Equals(transcodingContainer, "mp4", StringComparison.OrdinalIgnoreCase))
-            {
-                return false;
-            }
-            if (string.Equals(transcodingContainer, "mkv", StringComparison.OrdinalIgnoreCase))
-            {
-                return true;
+                var normalizedContainers = ContainerProfile.SplitValue(transcodingContainer);
+
+                if (ContainerProfile.ContainsContainer(normalizedContainers, "ts"))
+                {
+                    return false;
+                }
+                if (ContainerProfile.ContainsContainer(normalizedContainers, "mpegts"))
+                {
+                    return false;
+                }
+                if (ContainerProfile.ContainsContainer(normalizedContainers, "mp4"))
+                {
+                    return false;
+                }
+                if (ContainerProfile.ContainsContainer(normalizedContainers, "mkv") ||
+                    ContainerProfile.ContainsContainer(normalizedContainers, "matroska"))
+                {
+                    return true;
+                }
             }
 
             return false;
@@ -1572,14 +1578,17 @@ namespace MediaBrowser.Model.Dlna
             }
 
             // Check audio codec
-            List<string> audioCodecs = profile.GetAudioCodecs();
-            if (audioCodecs.Count > 0)
+            if (audioStream != null)
             {
-                // Check audio codecs
-                string audioCodec = audioStream == null ? null : audioStream.Codec;
-                if (string.IsNullOrEmpty(audioCodec) || !ListHelper.ContainsIgnoreCase(audioCodecs, audioCodec))
+                List<string> audioCodecs = profile.GetAudioCodecs();
+                if (audioCodecs.Count > 0)
                 {
-                    return false;
+                    // Check audio codecs
+                    string audioCodec = audioStream == null ? null : audioStream.Codec;
+                    if (string.IsNullOrEmpty(audioCodec) || !ListHelper.ContainsIgnoreCase(audioCodecs, audioCodec))
+                    {
+                        return false;
+                    }
                 }
             }