jellyfin-server/MediaBrowser.Controller/MediaInfo/MediaEncoderHelpers.cs

105 lines
3.6 KiB
C#
Raw Normal View History

using MediaBrowser.Common.MediaInfo;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Entities;
2013-08-10 01:16:31 +00:00
using MediaBrowser.Model.IO;
2013-06-09 16:47:28 +00:00
namespace MediaBrowser.Controller.MediaInfo
{
/// <summary>
/// Class MediaEncoderHelpers
/// </summary>
public static class MediaEncoderHelpers
{
/// <summary>
/// Gets the input argument.
/// </summary>
/// <param name="video">The video.</param>
/// <param name="isoMount">The iso mount.</param>
/// <param name="type">The type.</param>
/// <returns>System.String[][].</returns>
public static string[] GetInputArgument(Video video, IIsoMount isoMount, out InputType type)
{
var inputPath = isoMount == null ? new[] { video.Path } : new[] { isoMount.MountedPath };
type = InputType.VideoFile;
switch (video.VideoType)
{
case VideoType.BluRay:
type = InputType.Bluray;
break;
case VideoType.Dvd:
type = InputType.Dvd;
inputPath = video.GetPlayableStreamFiles(inputPath[0]).ToArray();
break;
case VideoType.Iso:
if (video.IsoType.HasValue)
{
switch (video.IsoType.Value)
{
case IsoType.BluRay:
type = InputType.Bluray;
break;
case IsoType.Dvd:
type = InputType.Dvd;
inputPath = video.GetPlayableStreamFiles(inputPath[0]).ToArray();
break;
}
}
break;
2013-05-01 20:07:20 +00:00
case VideoType.VideoFile:
{
if (video.LocationType == LocationType.Remote)
{
type = InputType.Url;
}
break;
}
}
return inputPath;
}
/// <summary>
/// Gets the type of the input.
/// </summary>
/// <param name="path">The path.</param>
/// <param name="videoType">Type of the video.</param>
/// <param name="isoType">Type of the iso.</param>
/// <returns>InputType.</returns>
public static InputType GetInputType(string path, VideoType? videoType, IsoType? isoType)
{
var type = InputType.AudioFile;
if (videoType.HasValue)
{
switch (videoType.Value)
{
case VideoType.BluRay:
type = InputType.Bluray;
break;
case VideoType.Dvd:
type = InputType.Dvd;
break;
case VideoType.Iso:
if (isoType.HasValue)
{
switch (isoType.Value)
{
case IsoType.BluRay:
type = InputType.Bluray;
break;
case IsoType.Dvd:
type = InputType.Dvd;
break;
}
}
break;
}
}
return type;
}
}
}