Feature/media segments plugin api (#12359)

This commit is contained in:
JPVenson
2024-09-07 22:56:51 +02:00
committed by GitHub
parent fc247dab92
commit 5ceedced1c
11 changed files with 312 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
@@ -13,6 +14,15 @@ namespace MediaBrowser.Controller;
/// </summary>
public interface IMediaSegmentManager
{
/// <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);
/// <summary>
/// Returns if this item supports media segments.
/// </summary>
@@ -50,4 +60,11 @@ public interface IMediaSegmentManager
/// <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);
/// <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);
}

View File

@@ -0,0 +1,36 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model;
using MediaBrowser.Model.MediaSegments;
namespace MediaBrowser.Controller;
/// <summary>
/// Provides methods for Obtaining the Media Segments from an Item.
/// </summary>
public interface IMediaSegmentProvider
{
/// <summary>
/// Gets the provider name.
/// </summary>
string Name { get; }
/// <summary>
/// Enumerates all Media Segments from an Media Item.
/// </summary>
/// <param name="request">Arguments to enumerate MediaSegments.</param>
/// <param name="cancellationToken">Abort token.</param>
/// <returns>A list of all MediaSegments found from this provider.</returns>
Task<IReadOnlyList<MediaSegmentDto>> GetMediaSegments(MediaSegmentGenerationRequest request, CancellationToken cancellationToken);
/// <summary>
/// Should return support state for the given item.
/// </summary>
/// <param name="item">The base item to extract segments from.</param>
/// <returns>True if item is supported, otherwise false.</returns>
ValueTask<bool> Supports(BaseItem item);
}