ITrickplayManager.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Threading;
  4. using System.Threading.Tasks;
  5. using Jellyfin.Database.Implementations.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. /// Deletes all trickplay info for an item.
  56. /// </summary>
  57. /// <param name="itemId">The item id.</param>
  58. /// <param name="cancellationToken">The cancellation token.</param>
  59. /// <returns>Task.</returns>
  60. Task DeleteTrickplayDataAsync(Guid itemId, CancellationToken cancellationToken);
  61. /// <summary>
  62. /// Gets all trickplay infos for all media streams of an item.
  63. /// </summary>
  64. /// <param name="item">The item.</param>
  65. /// <returns>A map of media source id to a map of tile width to trickplay info.</returns>
  66. Task<Dictionary<string, Dictionary<int, TrickplayInfo>>> GetTrickplayManifest(BaseItem item);
  67. /// <summary>
  68. /// Gets the path to a trickplay tile image.
  69. /// </summary>
  70. /// <param name="item">The item.</param>
  71. /// <param name="width">The width of a single thumbnail.</param>
  72. /// <param name="index">The tile's index.</param>
  73. /// <param name="saveWithMedia">Whether or not the tile should be saved next to the media file.</param>
  74. /// <returns>The absolute path.</returns>
  75. Task<string> GetTrickplayTilePathAsync(BaseItem item, int width, int index, bool saveWithMedia);
  76. /// <summary>
  77. /// Gets the path to a trickplay tile image.
  78. /// </summary>
  79. /// <param name="item">The item.</param>
  80. /// <param name="tileWidth">The amount of images for the tile width.</param>
  81. /// <param name="tileHeight">The amount of images for the tile height.</param>
  82. /// <param name="width">The width of a single thumbnail.</param>
  83. /// <param name="saveWithMedia">Whether or not the tile should be saved next to the media file.</param>
  84. /// <returns>The absolute path.</returns>
  85. string GetTrickplayDirectory(BaseItem item, int tileWidth, int tileHeight, int width, bool saveWithMedia = false);
  86. /// <summary>
  87. /// Migrates trickplay images between local and media directories.
  88. /// </summary>
  89. /// <param name="video">The video.</param>
  90. /// <param name="libraryOptions">The library options.</param>
  91. /// <param name="cancellationToken">CancellationToken to use for operation.</param>
  92. /// <returns>Task.</returns>
  93. Task MoveGeneratedTrickplayDataAsync(Video video, LibraryOptions libraryOptions, CancellationToken cancellationToken);
  94. /// <summary>
  95. /// Gets the trickplay HLS playlist.
  96. /// </summary>
  97. /// <param name="itemId">The item.</param>
  98. /// <param name="width">The width of a single thumbnail.</param>
  99. /// <param name="apiKey">Optional api key of the requesting user.</param>
  100. /// <returns>The text content of the .m3u8 playlist.</returns>
  101. Task<string?> GetHlsPlaylist(Guid itemId, int width, string? apiKey);
  102. }