2015-04-04 12:35:29 -07:00
|
|
|
|
using MediaBrowser.Model.IO;
|
2014-06-16 18:56:23 -07:00
|
|
|
|
using MediaBrowser.Model.MediaInfo;
|
2014-02-20 09:37:41 -07:00
|
|
|
|
using System;
|
2013-12-19 14:51:32 -07:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
2013-04-07 13:55:05 -07:00
|
|
|
|
|
2014-02-20 09:37:41 -07:00
|
|
|
|
namespace MediaBrowser.Controller.MediaEncoding
|
2013-04-07 13:55:05 -07:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class MediaEncoderHelpers
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static class MediaEncoderHelpers
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the input argument.
|
|
|
|
|
/// </summary>
|
2013-12-19 14:51:32 -07:00
|
|
|
|
/// <param name="videoPath">The video path.</param>
|
2014-06-16 18:56:23 -07:00
|
|
|
|
/// <param name="protocol">The protocol.</param>
|
2013-04-07 13:55:05 -07:00
|
|
|
|
/// <param name="isoMount">The iso mount.</param>
|
2013-12-19 14:51:32 -07:00
|
|
|
|
/// <param name="playableStreamFileNames">The playable stream file names.</param>
|
2013-04-07 13:55:05 -07:00
|
|
|
|
/// <returns>System.String[][].</returns>
|
2014-06-16 18:56:23 -07:00
|
|
|
|
public static string[] GetInputArgument(string videoPath, MediaProtocol protocol, IIsoMount isoMount, List<string> playableStreamFileNames)
|
2013-04-07 13:55:05 -07:00
|
|
|
|
{
|
2014-06-16 18:56:23 -07:00
|
|
|
|
if (playableStreamFileNames.Count > 0)
|
2013-04-07 13:55:05 -07:00
|
|
|
|
{
|
2014-06-16 18:56:23 -07:00
|
|
|
|
if (isoMount == null)
|
|
|
|
|
{
|
|
|
|
|
return GetPlayableStreamFiles(videoPath, playableStreamFileNames).ToArray();
|
|
|
|
|
}
|
|
|
|
|
return GetPlayableStreamFiles(isoMount.MountedPath, playableStreamFileNames).ToArray();
|
2013-04-07 13:55:05 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-16 18:56:23 -07:00
|
|
|
|
return new[] {videoPath};
|
2013-04-07 13:55:05 -07:00
|
|
|
|
}
|
|
|
|
|
|
2013-12-19 14:51:32 -07:00
|
|
|
|
public static List<string> GetPlayableStreamFiles(string rootPath, IEnumerable<string> 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();
|
|
|
|
|
}
|
2013-04-07 13:55:05 -07:00
|
|
|
|
}
|
|
|
|
|
}
|