MediaEncoderHelpers.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. using MediaBrowser.Common.IO;
  2. using MediaBrowser.Common.MediaInfo;
  3. using MediaBrowser.Controller.Entities;
  4. using MediaBrowser.Model.Entities;
  5. using MediaBrowser.Model.IO;
  6. namespace MediaBrowser.Controller.MediaInfo
  7. {
  8. /// <summary>
  9. /// Class MediaEncoderHelpers
  10. /// </summary>
  11. public static class MediaEncoderHelpers
  12. {
  13. /// <summary>
  14. /// Gets the input argument.
  15. /// </summary>
  16. /// <param name="video">The video.</param>
  17. /// <param name="isoMount">The iso mount.</param>
  18. /// <param name="type">The type.</param>
  19. /// <returns>System.String[][].</returns>
  20. public static string[] GetInputArgument(Video video, IIsoMount isoMount, out InputType type)
  21. {
  22. var inputPath = isoMount == null ? new[] { video.Path } : new[] { isoMount.MountedPath };
  23. type = InputType.VideoFile;
  24. switch (video.VideoType)
  25. {
  26. case VideoType.BluRay:
  27. type = InputType.Bluray;
  28. break;
  29. case VideoType.Dvd:
  30. type = InputType.Dvd;
  31. inputPath = video.GetPlayableStreamFiles(inputPath[0]).ToArray();
  32. break;
  33. case VideoType.Iso:
  34. if (video.IsoType.HasValue)
  35. {
  36. switch (video.IsoType.Value)
  37. {
  38. case IsoType.BluRay:
  39. type = InputType.Bluray;
  40. break;
  41. case IsoType.Dvd:
  42. type = InputType.Dvd;
  43. inputPath = video.GetPlayableStreamFiles(inputPath[0]).ToArray();
  44. break;
  45. }
  46. }
  47. break;
  48. case VideoType.VideoFile:
  49. {
  50. if (video.LocationType == LocationType.Remote)
  51. {
  52. type = InputType.Url;
  53. }
  54. break;
  55. }
  56. }
  57. return inputPath;
  58. }
  59. /// <summary>
  60. /// Gets the type of the input.
  61. /// </summary>
  62. /// <param name="item">The item.</param>
  63. /// <returns>InputType.</returns>
  64. public static InputType GetInputType(BaseItem item)
  65. {
  66. var type = InputType.AudioFile;
  67. var video = item as Video;
  68. if (video != null)
  69. {
  70. switch (video.VideoType)
  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 (video.IsoType.HasValue)
  80. {
  81. switch (video.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. }