IMediaSegmentManager.cs 4.0 KB

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