IMediaSegmentManager.cs 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 Jellyfin.Database.Implementations.Enums;
  7. using MediaBrowser.Controller.Entities;
  8. using MediaBrowser.Model.Configuration;
  9. using MediaBrowser.Model.MediaSegments;
  10. namespace MediaBrowser.Controller.MediaSegments;
  11. /// <summary>
  12. /// Defines methods for interacting with media segments.
  13. /// </summary>
  14. public interface IMediaSegmentManager
  15. {
  16. /// <summary>
  17. /// Uses all segment providers enabled for the <see cref="BaseItem"/>'s library to get the Media Segments.
  18. /// </summary>
  19. /// <param name="baseItem">The Item to evaluate.</param>
  20. /// <param name="libraryOptions">The library options.</param>
  21. /// <param name="overwrite">If set, will remove existing segments and replace it with new ones otherwise will check for existing segments and if found any, stops.</param>
  22. /// <param name="cancellationToken">The cancellation token.</param>
  23. /// <returns>A task that indicates the Operation is finished.</returns>
  24. Task RunSegmentPluginProviders(BaseItem baseItem, LibraryOptions libraryOptions, bool overwrite, CancellationToken cancellationToken);
  25. /// <summary>
  26. /// Returns if this item supports media segments.
  27. /// </summary>
  28. /// <param name="baseItem">The base Item to check.</param>
  29. /// <returns>True if supported otherwise false.</returns>
  30. bool IsTypeSupported(BaseItem baseItem);
  31. /// <summary>
  32. /// Creates a new Media Segment associated with an Item.
  33. /// </summary>
  34. /// <param name="mediaSegment">The segment to create.</param>
  35. /// <param name="segmentProviderId">The id of the Provider who created this segment.</param>
  36. /// <returns>The created Segment entity.</returns>
  37. Task<MediaSegmentDto> CreateSegmentAsync(MediaSegmentDto mediaSegment, string segmentProviderId);
  38. /// <summary>
  39. /// Deletes a single media segment.
  40. /// </summary>
  41. /// <param name="segmentId">The <see cref="MediaSegment.Id"/> to delete.</param>
  42. /// <returns>a task.</returns>
  43. Task DeleteSegmentAsync(Guid segmentId);
  44. /// <summary>
  45. /// Deletes all media segments of an item.
  46. /// </summary>
  47. /// <param name="itemId">The <see cref="BaseItem.Id"/> to delete all segments for.</param>
  48. /// <param name="cancellationToken">The cancellation token.</param>
  49. /// <returns>a task.</returns>
  50. Task DeleteSegmentsAsync(Guid itemId, CancellationToken cancellationToken);
  51. /// <summary>
  52. /// Obtains all segments associated with the itemId.
  53. /// </summary>
  54. /// <param name="item">The <see cref="BaseItem"/>.</param>
  55. /// <param name="typeFilter">filters all media segments of the given type to be included. If null all types are included.</param>
  56. /// <param name="libraryOptions">The library options.</param>
  57. /// <param name="filterByProvider">When set filters the segments to only return those that which providers are currently enabled on their library.</param>
  58. /// <returns>An enumerator of <see cref="MediaSegmentDto"/>'s.</returns>
  59. Task<IEnumerable<MediaSegmentDto>> GetSegmentsAsync(BaseItem item, IEnumerable<MediaSegmentType>? typeFilter, LibraryOptions libraryOptions, bool filterByProvider = true);
  60. /// <summary>
  61. /// Gets information about any media segments stored for the given itemId.
  62. /// </summary>
  63. /// <param name="itemId">The id of the <see cref="BaseItem"/>.</param>
  64. /// <returns>True if there are any segments stored for the item, otherwise false.</returns>
  65. /// TODO: this should be async but as the only caller BaseItem.GetVersionInfo isn't async, this is also not. Venson.
  66. bool HasSegments(Guid itemId);
  67. /// <summary>
  68. /// Gets a list of all registered Segment Providers and their IDs.
  69. /// </summary>
  70. /// <param name="item">The media item that should be tested for providers.</param>
  71. /// <returns>A list of all providers for the tested item.</returns>
  72. IEnumerable<(string Name, string Id)> GetSupportedProviders(BaseItem item);
  73. }