MediaEncoderHelpers.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. using MediaBrowser.Common.IO;
  2. using MediaBrowser.Common.MediaInfo;
  3. using MediaBrowser.Controller.Entities;
  4. using MediaBrowser.Model.Entities;
  5. namespace MediaBrowser.Controller.Providers.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. }
  48. return inputPath;
  49. }
  50. /// <summary>
  51. /// Gets the type of the input.
  52. /// </summary>
  53. /// <param name="item">The item.</param>
  54. /// <returns>InputType.</returns>
  55. public static InputType GetInputType(BaseItem item)
  56. {
  57. var type = InputType.AudioFile;
  58. var video = item as Video;
  59. if (video != null)
  60. {
  61. switch (video.VideoType)
  62. {
  63. case VideoType.BluRay:
  64. type = InputType.Bluray;
  65. break;
  66. case VideoType.Dvd:
  67. type = InputType.Dvd;
  68. break;
  69. case VideoType.Iso:
  70. if (video.IsoType.HasValue)
  71. {
  72. switch (video.IsoType.Value)
  73. {
  74. case IsoType.BluRay:
  75. type = InputType.Bluray;
  76. break;
  77. case IsoType.Dvd:
  78. type = InputType.Dvd;
  79. break;
  80. }
  81. }
  82. break;
  83. }
  84. }
  85. return type;
  86. }
  87. }
  88. }