MediaEncoderHelpers.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. using MediaBrowser.Common.MediaInfo;
  2. using MediaBrowser.Controller.Entities;
  3. using MediaBrowser.Model.Entities;
  4. using MediaBrowser.Model.IO;
  5. namespace MediaBrowser.Controller.MediaInfo
  6. {
  7. /// <summary>
  8. /// Class MediaEncoderHelpers
  9. /// </summary>
  10. public static class MediaEncoderHelpers
  11. {
  12. /// <summary>
  13. /// Gets the input argument.
  14. /// </summary>
  15. /// <param name="video">The video.</param>
  16. /// <param name="isoMount">The iso mount.</param>
  17. /// <param name="type">The type.</param>
  18. /// <returns>System.String[][].</returns>
  19. public static string[] GetInputArgument(Video video, IIsoMount isoMount, out InputType type)
  20. {
  21. var inputPath = isoMount == null ? new[] { video.Path } : new[] { isoMount.MountedPath };
  22. type = InputType.VideoFile;
  23. switch (video.VideoType)
  24. {
  25. case VideoType.BluRay:
  26. type = InputType.Bluray;
  27. break;
  28. case VideoType.Dvd:
  29. type = InputType.Dvd;
  30. inputPath = video.GetPlayableStreamFiles(inputPath[0]).ToArray();
  31. break;
  32. case VideoType.Iso:
  33. if (video.IsoType.HasValue)
  34. {
  35. switch (video.IsoType.Value)
  36. {
  37. case IsoType.BluRay:
  38. type = InputType.Bluray;
  39. break;
  40. case IsoType.Dvd:
  41. type = InputType.Dvd;
  42. inputPath = video.GetPlayableStreamFiles(inputPath[0]).ToArray();
  43. break;
  44. }
  45. }
  46. break;
  47. case VideoType.VideoFile:
  48. {
  49. if (video.LocationType == LocationType.Remote)
  50. {
  51. type = InputType.Url;
  52. }
  53. break;
  54. }
  55. }
  56. return inputPath;
  57. }
  58. /// <summary>
  59. /// Gets the type of the input.
  60. /// </summary>
  61. /// <param name="path">The path.</param>
  62. /// <param name="videoType">Type of the video.</param>
  63. /// <param name="isoType">Type of the iso.</param>
  64. /// <returns>InputType.</returns>
  65. public static InputType GetInputType(string path, VideoType? videoType, IsoType? isoType)
  66. {
  67. var type = InputType.AudioFile;
  68. if (videoType.HasValue)
  69. {
  70. switch (videoType.Value)
  71. {
  72. case VideoType.BluRay:
  73. type = InputType.Bluray;
  74. break;
  75. case VideoType.Dvd:
  76. type = InputType.Dvd;
  77. break;
  78. case VideoType.Iso:
  79. if (isoType.HasValue)
  80. {
  81. switch (isoType.Value)
  82. {
  83. case IsoType.BluRay:
  84. type = InputType.Bluray;
  85. break;
  86. case IsoType.Dvd:
  87. type = InputType.Dvd;
  88. break;
  89. }
  90. }
  91. break;
  92. }
  93. }
  94. return type;
  95. }
  96. }
  97. }