using MediaBrowser.Model.IO;
using MediaBrowser.Model.MediaInfo;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace MediaBrowser.Controller.MediaEncoding
{
///
/// Class MediaEncoderHelpers
///
public static class MediaEncoderHelpers
{
///
/// Gets the input argument.
///
/// The video path.
/// The protocol.
/// The iso mount.
/// The playable stream file names.
/// System.String[][].
public static string[] GetInputArgument(string videoPath, MediaProtocol protocol, IIsoMount isoMount, List playableStreamFileNames)
{
if (playableStreamFileNames.Count > 0)
{
if (isoMount == null)
{
return GetPlayableStreamFiles(videoPath, playableStreamFileNames).ToArray();
}
return GetPlayableStreamFiles(isoMount.MountedPath, playableStreamFileNames).ToArray();
}
return new[] {videoPath};
}
public static List GetPlayableStreamFiles(string rootPath, IEnumerable filenames)
{
var allFiles = Directory
.EnumerateFiles(rootPath, "*", SearchOption.AllDirectories)
.ToList();
return filenames.Select(name => allFiles.FirstOrDefault(f => string.Equals(Path.GetFileName(f), name, StringComparison.OrdinalIgnoreCase)))
.Where(f => !string.IsNullOrEmpty(f))
.ToList();
}
}
}