MediaEncoderHelpers.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. using MediaBrowser.Common.IO;
  2. using MediaBrowser.Common.MediaInfo;
  3. using MediaBrowser.Controller.Entities;
  4. using MediaBrowser.Model.Entities;
  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="item">The item.</param>
  62. /// <returns>InputType.</returns>
  63. public static InputType GetInputType(BaseItem item)
  64. {
  65. var type = InputType.AudioFile;
  66. var video = item as Video;
  67. if (video != null)
  68. {
  69. switch (video.VideoType)
  70. {
  71. case VideoType.BluRay:
  72. type = InputType.Bluray;
  73. break;
  74. case VideoType.Dvd:
  75. type = InputType.Dvd;
  76. break;
  77. case VideoType.Iso:
  78. if (video.IsoType.HasValue)
  79. {
  80. switch (video.IsoType.Value)
  81. {
  82. case IsoType.BluRay:
  83. type = InputType.Bluray;
  84. break;
  85. case IsoType.Dvd:
  86. type = InputType.Dvd;
  87. break;
  88. }
  89. }
  90. break;
  91. }
  92. }
  93. return type;
  94. }
  95. }
  96. }