IMediaSegmentManager.cs 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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.Data.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 accociated with the itemId.
  44. /// </summary>
  45. /// <param name="itemId">The id of the <see cref="BaseItem"/>.</param>
  46. /// <param name="typeFilter">filteres all media segments of the given type to be included. If null all types are included.</param>
  47. /// <returns>An enumerator of <see cref="MediaSegmentDto"/>'s.</returns>
  48. Task<IEnumerable<MediaSegmentDto>> GetSegmentsAsync(Guid itemId, IEnumerable<MediaSegmentType>? typeFilter);
  49. /// <summary>
  50. /// Gets information about any media segments stored for the given itemId.
  51. /// </summary>
  52. /// <param name="itemId">The id of the <see cref="BaseItem"/>.</param>
  53. /// <returns>True if there are any segments stored for the item, otherwise false.</returns>
  54. /// TODO: this should be async but as the only caller BaseItem.GetVersionInfo isn't async, this is also not. Venson.
  55. bool HasSegments(Guid itemId);
  56. /// <summary>
  57. /// Gets a list of all registered Segment Providers and their IDs.
  58. /// </summary>
  59. /// <param name="item">The media item that should be tested for providers.</param>
  60. /// <returns>A list of all providers for the tested item.</returns>
  61. IEnumerable<(string Name, string Id)> GetSupportedProviders(BaseItem item);
  62. }