ITrickplayManager.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Threading;
  4. using System.Threading.Tasks;
  5. using Jellyfin.Data.Entities;
  6. using MediaBrowser.Controller.Entities;
  7. using MediaBrowser.Model.Configuration;
  8. namespace MediaBrowser.Controller.Trickplay;
  9. /// <summary>
  10. /// Interface ITrickplayManager.
  11. /// </summary>
  12. public interface ITrickplayManager
  13. {
  14. /// <summary>
  15. /// Generates new trickplay images and metadata.
  16. /// </summary>
  17. /// <param name="video">The video.</param>
  18. /// <param name="replace">Whether or not existing data should be replaced.</param>
  19. /// <param name="libraryOptions">The library options.</param>
  20. /// <param name="cancellationToken">CancellationToken to use for operation.</param>
  21. /// <returns>Task.</returns>
  22. Task RefreshTrickplayDataAsync(Video video, bool replace, LibraryOptions? libraryOptions, CancellationToken cancellationToken);
  23. /// <summary>
  24. /// Creates trickplay tiles out of individual thumbnails.
  25. /// </summary>
  26. /// <param name="images">Ordered file paths of the thumbnails to be used.</param>
  27. /// <param name="width">The width of a single thumbnail.</param>
  28. /// <param name="options">The trickplay options.</param>
  29. /// <param name="outputDir">The output directory.</param>
  30. /// <returns>The associated trickplay information.</returns>
  31. /// <remarks>
  32. /// The output directory will be DELETED and replaced if it already exists.
  33. /// </remarks>
  34. TrickplayInfo CreateTiles(IReadOnlyList<string> images, int width, TrickplayOptions options, string outputDir);
  35. /// <summary>
  36. /// Get available trickplay resolutions and corresponding info.
  37. /// </summary>
  38. /// <param name="itemId">The item.</param>
  39. /// <returns>Map of width resolutions to trickplay tiles info.</returns>
  40. Task<Dictionary<int, TrickplayInfo>> GetTrickplayResolutions(Guid itemId);
  41. /// <summary>
  42. /// Gets the item ids of all items with trickplay info.
  43. /// </summary>
  44. /// <param name="limit">The limit of items to return.</param>
  45. /// <param name="offset">The offset to start the query at.</param>
  46. /// <returns>The list of item ids that have trickplay info.</returns>
  47. Task<IReadOnlyList<TrickplayInfo>> GetTrickplayItemsAsync(int limit, int offset);
  48. /// <summary>
  49. /// Saves trickplay info.
  50. /// </summary>
  51. /// <param name="info">The trickplay info.</param>
  52. /// <returns>Task.</returns>
  53. Task SaveTrickplayInfo(TrickplayInfo info);
  54. /// <summary>
  55. /// Gets all trickplay infos for all media streams of an item.
  56. /// </summary>
  57. /// <param name="item">The item.</param>
  58. /// <returns>A map of media source id to a map of tile width to trickplay info.</returns>
  59. Task<Dictionary<string, Dictionary<int, TrickplayInfo>>> GetTrickplayManifest(BaseItem item);
  60. /// <summary>
  61. /// Gets the path to a trickplay tile image.
  62. /// </summary>
  63. /// <param name="item">The item.</param>
  64. /// <param name="width">The width of a single thumbnail.</param>
  65. /// <param name="index">The tile's index.</param>
  66. /// <param name="saveWithMedia">Whether or not the tile should be saved next to the media file.</param>
  67. /// <returns>The absolute path.</returns>
  68. Task<string> GetTrickplayTilePathAsync(BaseItem item, int width, int index, bool saveWithMedia);
  69. /// <summary>
  70. /// Gets the path to a trickplay tile image.
  71. /// </summary>
  72. /// <param name="item">The item.</param>
  73. /// <param name="tileWidth">The amount of images for the tile width.</param>
  74. /// <param name="tileHeight">The amount of images for the tile height.</param>
  75. /// <param name="width">The width of a single thumbnail.</param>
  76. /// <param name="saveWithMedia">Whether or not the tile should be saved next to the media file.</param>
  77. /// <returns>The absolute path.</returns>
  78. string GetTrickplayDirectory(BaseItem item, int tileWidth, int tileHeight, int width, bool saveWithMedia = false);
  79. /// <summary>
  80. /// Migrates trickplay images between local and media directories.
  81. /// </summary>
  82. /// <param name="video">The video.</param>
  83. /// <param name="libraryOptions">The library options.</param>
  84. /// <param name="cancellationToken">CancellationToken to use for operation.</param>
  85. /// <returns>Task.</returns>
  86. Task MoveGeneratedTrickplayDataAsync(Video video, LibraryOptions? libraryOptions, CancellationToken cancellationToken);
  87. /// <summary>
  88. /// Gets the trickplay HLS playlist.
  89. /// </summary>
  90. /// <param name="itemId">The item.</param>
  91. /// <param name="width">The width of a single thumbnail.</param>
  92. /// <param name="apiKey">Optional api key of the requesting user.</param>
  93. /// <returns>The text content of the .m3u8 playlist.</returns>
  94. Task<string?> GetHlsPlaylist(Guid itemId, int width, string? apiKey);
  95. }