浏览代码

comply with dotnet-5

nyanmisaka 4 年之前
父节点
当前提交
099563cd6b
共有 2 个文件被更改,包括 4 次插入3 次删除
  1. 2 2
      Jellyfin.Api/Helpers/DynamicHlsHelper.cs
  2. 2 1
      Jellyfin.Api/Helpers/HlsHelpers.cs

+ 2 - 2
Jellyfin.Api/Helpers/DynamicHlsHelper.cs

@@ -515,7 +515,7 @@ namespace Jellyfin.Api.Helpers
                 && state.VideoStream != null
                 && state.VideoStream != null
                 && state.VideoStream.Level.HasValue)
                 && state.VideoStream.Level.HasValue)
             {
             {
-                levelString = state.VideoStream.Level.ToString();
+                levelString = state.VideoStream.Level.ToString() ?? string.Empty;
             }
             }
             else
             else
             {
             {
@@ -557,7 +557,7 @@ namespace Jellyfin.Api.Helpers
             }
             }
             else if (!string.IsNullOrEmpty(codec))
             else if (!string.IsNullOrEmpty(codec))
             {
             {
-                profileString = state.GetRequestedProfiles(codec).FirstOrDefault();
+                profileString = state.GetRequestedProfiles(codec).FirstOrDefault() ?? string.Empty;
                 if (string.Equals(state.ActualOutputVideoCodec, "h264", StringComparison.OrdinalIgnoreCase))
                 if (string.Equals(state.ActualOutputVideoCodec, "h264", StringComparison.OrdinalIgnoreCase))
                 {
                 {
                     profileString = profileString ?? "high";
                     profileString = profileString ?? "high";

+ 2 - 1
Jellyfin.Api/Helpers/HlsHelpers.cs

@@ -100,8 +100,9 @@ namespace Jellyfin.Api.Helpers
         /// <returns>The string text of #EXT-X-MAP.</returns>
         /// <returns>The string text of #EXT-X-MAP.</returns>
         public static string GetFmp4InitFileName(string outputPath, StreamState state, bool isOsDepends)
         public static string GetFmp4InitFileName(string outputPath, StreamState state, bool isOsDepends)
         {
         {
+            var directory = Path.GetDirectoryName(outputPath) ?? throw new ArgumentException($"Provided path ({outputPath}) is not valid.", nameof(outputPath));
             var outputFileNameWithoutExtension = Path.GetFileNameWithoutExtension(outputPath);
             var outputFileNameWithoutExtension = Path.GetFileNameWithoutExtension(outputPath);
-            var outputPrefix = Path.Combine(Path.GetDirectoryName(outputPath), outputFileNameWithoutExtension);
+            var outputPrefix = Path.Combine(directory, outputFileNameWithoutExtension);
             var outputExtension = GetSegmentFileExtension(state.Request.SegmentContainer);
             var outputExtension = GetSegmentFileExtension(state.Request.SegmentContainer);
 
 
             // on Linux/Unix
             // on Linux/Unix