2020-08-22 19:56:24 +00:00
|
|
|
#pragma warning disable CS1591
|
|
|
|
|
2019-01-13 20:01:16 +00:00
|
|
|
using System;
|
2019-09-01 16:39:23 +00:00
|
|
|
using System.Collections.Generic;
|
2018-12-27 23:27:57 +00:00
|
|
|
using System.IO;
|
|
|
|
using System.Linq;
|
2019-01-13 19:25:32 +00:00
|
|
|
using MediaBrowser.Model.IO;
|
2018-12-27 23:27:57 +00:00
|
|
|
|
|
|
|
namespace MediaBrowser.Controller.MediaEncoding
|
|
|
|
{
|
|
|
|
/// <summary>
|
2020-06-15 22:37:52 +00:00
|
|
|
/// Class MediaEncoderHelpers.
|
2018-12-27 23:27:57 +00:00
|
|
|
/// </summary>
|
|
|
|
public static class MediaEncoderHelpers
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the input argument.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="fileSystem">The file system.</param>
|
|
|
|
/// <param name="videoPath">The video path.</param>
|
|
|
|
/// <param name="isoMount">The iso mount.</param>
|
|
|
|
/// <param name="playableStreamFileNames">The playable stream file names.</param>
|
2019-09-01 16:39:23 +00:00
|
|
|
/// <returns>string[].</returns>
|
|
|
|
public static string[] GetInputArgument(IFileSystem fileSystem, string videoPath, IIsoMount isoMount, IReadOnlyCollection<string> playableStreamFileNames)
|
2018-12-27 23:27:57 +00:00
|
|
|
{
|
2019-09-01 16:39:23 +00:00
|
|
|
if (playableStreamFileNames.Count > 0)
|
2018-12-27 23:27:57 +00:00
|
|
|
{
|
|
|
|
if (isoMount == null)
|
|
|
|
{
|
|
|
|
return GetPlayableStreamFiles(fileSystem, videoPath, playableStreamFileNames);
|
|
|
|
}
|
2019-09-01 16:39:23 +00:00
|
|
|
|
2018-12-27 23:27:57 +00:00
|
|
|
return GetPlayableStreamFiles(fileSystem, isoMount.MountedPath, playableStreamFileNames);
|
|
|
|
}
|
|
|
|
|
2019-01-13 19:25:32 +00:00
|
|
|
return new[] { videoPath };
|
2018-12-27 23:27:57 +00:00
|
|
|
}
|
|
|
|
|
2019-09-01 16:39:23 +00:00
|
|
|
private static string[] GetPlayableStreamFiles(IFileSystem fileSystem, string rootPath, IEnumerable<string> filenames)
|
2018-12-27 23:27:57 +00:00
|
|
|
{
|
|
|
|
var allFiles = fileSystem
|
|
|
|
.GetFilePaths(rootPath, true)
|
|
|
|
.ToArray();
|
|
|
|
|
|
|
|
return filenames.Select(name => allFiles.FirstOrDefault(f => string.Equals(Path.GetFileName(f), name, StringComparison.OrdinalIgnoreCase)))
|
|
|
|
.Where(f => !string.IsNullOrEmpty(f))
|
|
|
|
.ToArray();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|