< Summary - Jellyfin

Information
Class: MediaBrowser.MediaEncoding.Encoder.EncodingUtils
Assembly: MediaBrowser.MediaEncoding
File(s): /srv/git/jellyfin/MediaBrowser.MediaEncoding/Encoder/EncodingUtils.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 15
Coverable lines: 15
Total lines: 84
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 8
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
GetInputArgument(...)0%620%
GetInputArgument(...)0%620%
GetConcatInputArgument(...)0%620%
GetFileInputArgument(...)0%620%
NormalizePath(...)100%210%

File(s)

/srv/git/jellyfin/MediaBrowser.MediaEncoding/Encoder/EncodingUtils.cs

#LineLine coverage
 1#pragma warning disable CS1591
 2
 3using System;
 4using System.Collections.Generic;
 5using System.Globalization;
 6using System.Linq;
 7using MediaBrowser.Model.MediaInfo;
 8
 9namespace MediaBrowser.MediaEncoding.Encoder
 10{
 11    public static class EncodingUtils
 12    {
 13        public static string GetInputArgument(string inputPrefix, string inputFile, MediaProtocol protocol)
 14        {
 015            if (protocol != MediaProtocol.File)
 16            {
 017                return string.Format(CultureInfo.InvariantCulture, "\"{0}\"", inputFile);
 18            }
 19
 020            return GetFileInputArgument(inputFile, inputPrefix);
 21        }
 22
 23        public static string GetInputArgument(string inputPrefix, IReadOnlyList<string> inputFiles, MediaProtocol protoc
 24        {
 025            if (protocol != MediaProtocol.File)
 26            {
 027                return string.Format(CultureInfo.InvariantCulture, "\"{0}\"", inputFiles[0]);
 28            }
 29
 030            return GetConcatInputArgument(inputFiles, inputPrefix);
 31        }
 32
 33        /// <summary>
 34        /// Gets the concat input argument.
 35        /// </summary>
 36        /// <param name="inputFiles">The input files.</param>
 37        /// <param name="inputPrefix">The input prefix.</param>
 38        /// <returns>System.String.</returns>
 39        private static string GetConcatInputArgument(IReadOnlyList<string> inputFiles, string inputPrefix)
 40        {
 41            // Get all streams
 42            // If there's more than one we'll need to use the concat command
 043            if (inputFiles.Count > 1)
 44            {
 045                var files = string.Join('|', inputFiles.Select(NormalizePath));
 46
 047                return string.Format(CultureInfo.InvariantCulture, "concat:\"{0}\"", files);
 48            }
 49
 50            // Determine the input path for video files
 051            return GetFileInputArgument(inputFiles[0], inputPrefix);
 52        }
 53
 54        /// <summary>
 55        /// Gets the file input argument.
 56        /// </summary>
 57        /// <param name="path">The path.</param>
 58        /// <param name="inputPrefix">The path prefix.</param>
 59        /// <returns>System.String.</returns>
 60        private static string GetFileInputArgument(string path, string inputPrefix)
 61        {
 062            if (path.Contains("://", StringComparison.Ordinal))
 63            {
 064                return string.Format(CultureInfo.InvariantCulture, "\"{0}\"", path);
 65            }
 66
 67            // Quotes are valid path characters in linux and they need to be escaped here with a leading \
 068            path = NormalizePath(path);
 69
 070            return string.Format(CultureInfo.InvariantCulture, "{1}:\"{0}\"", path, inputPrefix);
 71        }
 72
 73        /// <summary>
 74        /// Normalizes the path.
 75        /// </summary>
 76        /// <param name="path">The path.</param>
 77        /// <returns>System.String.</returns>
 78        public static string NormalizePath(string path)
 79        {
 80            // Quotes are valid path characters in linux and they need to be escaped here with a leading \
 081            return path.Replace("\"", "\\\"", StringComparison.Ordinal);
 82        }
 83    }
 84}