2024-08-30 15:29:48 +02:00
using System ;
2024-08-05 14:20:27 +02:00
using System.Collections.Generic ;
2024-09-07 22:56:51 +02:00
using System.Threading ;
2024-08-05 14:20:27 +02:00
using System.Threading.Tasks ;
using Jellyfin.Data.Entities ;
2025-03-25 15:30:22 +00:00
using Jellyfin.Database.Implementations.Enums ;
2024-08-05 14:20:27 +02:00
using MediaBrowser.Controller.Entities ;
using MediaBrowser.Model.MediaSegments ;
namespace MediaBrowser.Controller ;
/// <summary>
/// Defines methods for interacting with media segments.
/// </summary>
public interface IMediaSegmentManager
{
2024-09-07 22:56:51 +02:00
/// <summary>
/// Uses all segment providers enabled for the <see cref="BaseItem"/>'s library to get the Media Segments.
/// </summary>
/// <param name="baseItem">The Item to evaluate.</param>
/// <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>
/// <param name="cancellationToken">stop request token.</param>
/// <returns>A task that indicates the Operation is finished.</returns>
Task RunSegmentPluginProviders ( BaseItem baseItem , bool overwrite , CancellationToken cancellationToken ) ;
2024-08-05 14:20:27 +02:00
/// <summary>
/// Returns if this item supports media segments.
/// </summary>
/// <param name="baseItem">The base Item to check.</param>
/// <returns>True if supported otherwise false.</returns>
bool IsTypeSupported ( BaseItem baseItem ) ;
/// <summary>
/// Creates a new Media Segment associated with an Item.
/// </summary>
/// <param name="mediaSegment">The segment to create.</param>
/// <param name="segmentProviderId">The id of the Provider who created this segment.</param>
/// <returns>The created Segment entity.</returns>
Task < MediaSegmentDto > CreateSegmentAsync ( MediaSegmentDto mediaSegment , string segmentProviderId ) ;
/// <summary>
/// Deletes a single media segment.
/// </summary>
/// <param name="segmentId">The <see cref="MediaSegment.Id"/> to delete.</param>
/// <returns>a task.</returns>
Task DeleteSegmentAsync ( Guid segmentId ) ;
/// <summary>
2024-12-07 21:52:54 -10:00
/// Obtains all segments associated with the itemId.
2024-08-05 14:20:27 +02:00
/// </summary>
/// <param name="itemId">The id of the <see cref="BaseItem"/>.</param>
2024-12-07 21:52:54 -10:00
/// <param name="typeFilter">filters all media segments of the given type to be included. If null all types are included.</param>
/// <param name="filterByProvider">When set filters the segments to only return those that which providers are currently enabled on their library.</param>
2024-08-05 14:20:27 +02:00
/// <returns>An enumerator of <see cref="MediaSegmentDto"/>'s.</returns>
2024-11-19 15:43:17 -05:00
Task < IEnumerable < MediaSegmentDto > > GetSegmentsAsync ( Guid itemId , IEnumerable < MediaSegmentType > ? typeFilter , bool filterByProvider = true ) ;
/// <summary>
2024-12-07 21:52:54 -10:00
/// Obtains all segments associated with the itemId.
2024-11-19 15:43:17 -05:00
/// </summary>
/// <param name="item">The <see cref="BaseItem"/>.</param>
2024-12-07 21:52:54 -10:00
/// <param name="typeFilter">filters all media segments of the given type to be included. If null all types are included.</param>
/// <param name="filterByProvider">When set filters the segments to only return those that which providers are currently enabled on their library.</param>
2024-11-19 15:43:17 -05:00
/// <returns>An enumerator of <see cref="MediaSegmentDto"/>'s.</returns>
Task < IEnumerable < MediaSegmentDto > > GetSegmentsAsync ( BaseItem item , IEnumerable < MediaSegmentType > ? typeFilter , bool filterByProvider = true ) ;
2024-08-05 14:20:27 +02:00
/// <summary>
/// Gets information about any media segments stored for the given itemId.
/// </summary>
/// <param name="itemId">The id of the <see cref="BaseItem"/>.</param>
/// <returns>True if there are any segments stored for the item, otherwise false.</returns>
/// TODO: this should be async but as the only caller BaseItem.GetVersionInfo isn't async, this is also not. Venson.
bool HasSegments ( Guid itemId ) ;
2024-09-07 22:56:51 +02:00
/// <summary>
/// Gets a list of all registered Segment Providers and their IDs.
/// </summary>
/// <param name="item">The media item that should be tested for providers.</param>
/// <returns>A list of all providers for the tested item.</returns>
IEnumerable < ( string Name , string Id ) > GetSupportedProviders ( BaseItem item ) ;
2024-08-05 14:20:27 +02:00
}