diff options
| author | JPVenson <JPVenson@users.noreply.github.com> | 2024-08-05 14:20:27 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-05 14:20:27 +0200 |
| commit | 00eb6c0d6f6aba88c66c2e9b55b9f5f4df949b59 (patch) | |
| tree | 5c013f9ff550d00bed45b5e79b687889fed45ef7 /MediaBrowser.Controller | |
| parent | 9a8298a84de89a2837e49b43b815d755995fbc1e (diff) | |
Add media segments API (#12345)
* Added Media segment manager
* Added "HasSegments" to MediaSourceInfo when requesting though baseitem
* Fixed ordering of Media Segements
* Added media segment API controller
* Added .ConfigureAwait(false) on media segments manager
* renamed MediaSegmentsController
removed empty route
* Added Model layer for Media Segments
Fixed review comments Media segments
* Updated media segment naming
refactored api and manager usage
* Added mediaSegment type filter
* Fixed codesmell
* Fixed naming and typos
* Added EF Migration
* Added Identity Generation for MediaSegments
Made mediasegment filter optional
* Fixed optional filter parameter
* refactored segment namespace
* Added SegmentProviderId to MediaSegment
* Media segment comment indentation
* Added MediaSegmentManager query notracking
Diffstat (limited to 'MediaBrowser.Controller')
| -rw-r--r-- | MediaBrowser.Controller/Entities/BaseItem.cs | 7 | ||||
| -rw-r--r-- | MediaBrowser.Controller/MediaSegements/IMediaSegmentManager.cs | 53 |
2 files changed, 59 insertions, 1 deletions
diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 7b6f364f7d..4d0e88a224 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -487,6 +487,8 @@ namespace MediaBrowser.Controller.Entities public static IMediaSourceManager MediaSourceManager { get; set; } + public static IMediaSegmentManager MediaSegmentManager { get; set; } + /// <summary> /// Gets or sets the name of the forced sort. /// </summary> @@ -1116,7 +1118,10 @@ namespace MediaBrowser.Controller.Entities RunTimeTicks = item.RunTimeTicks, Container = item.Container, Size = item.Size, - Type = type + Type = type, + HasSegments = MediaSegmentManager.IsTypeSupported(item) + && (protocol is null or MediaProtocol.File) + && MediaSegmentManager.HasSegments(item.Id) }; if (string.IsNullOrEmpty(info.Path)) diff --git a/MediaBrowser.Controller/MediaSegements/IMediaSegmentManager.cs b/MediaBrowser.Controller/MediaSegements/IMediaSegmentManager.cs new file mode 100644 index 0000000000..4fcf084e10 --- /dev/null +++ b/MediaBrowser.Controller/MediaSegements/IMediaSegmentManager.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Jellyfin.Data.Entities; +using Jellyfin.Data.Enums; +using MediaBrowser.Controller.Entities; +using MediaBrowser.Model.MediaSegments; + +namespace MediaBrowser.Controller; + +/// <summary> +/// Defines methods for interacting with media segments. +/// </summary> +public interface IMediaSegmentManager +{ + /// <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> + /// Obtains all segments accociated with the itemId. + /// </summary> + /// <param name="itemId">The id of the <see cref="BaseItem"/>.</param> + /// <param name="typeFilter">filteres all media segments of the given type to be included. If null all types are included.</param> + /// <returns>An enumerator of <see cref="MediaSegmentDto"/>'s.</returns> + Task<IEnumerable<MediaSegmentDto>> GetSegmentsAsync(Guid itemId, IEnumerable<MediaSegmentType>? typeFilter); + + /// <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); +} |
