From afa2103d424e92631ef02d00b0f8bc950a2f7054 Mon Sep 17 00:00:00 2001 From: Cody Robibero Date: Mon, 16 Jun 2025 18:55:21 -0600 Subject: [PATCH] Use dto instead of db object when returning trickplay --- Emby.Server.Implementations/Dto/DtoService.cs | 7 ++- MediaBrowser.Model/Dto/BaseItemDto.cs | 2 +- MediaBrowser.Model/Dto/TrickplayInfoDto.cs | 62 +++++++++++++++++++ 3 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 MediaBrowser.Model/Dto/TrickplayInfoDto.cs diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs index 9e0a6080d3..cf886ae826 100644 --- a/Emby.Server.Implementations/Dto/DtoService.cs +++ b/Emby.Server.Implementations/Dto/DtoService.cs @@ -1065,7 +1065,12 @@ namespace Emby.Server.Implementations.Dto if (options.ContainsField(ItemFields.Trickplay)) { - dto.Trickplay = _trickplayManager.GetTrickplayManifest(item).GetAwaiter().GetResult(); + var trickplay = _trickplayManager.GetTrickplayManifest(item).GetAwaiter().GetResult(); + dto.Trickplay = trickplay.ToDictionary( + mediaStream => mediaStream.Key, + mediaStream => mediaStream.Value.ToDictionary( + width => width.Key, + width => new TrickplayInfoDto(width.Value))); } dto.ExtraType = video.ExtraType; diff --git a/MediaBrowser.Model/Dto/BaseItemDto.cs b/MediaBrowser.Model/Dto/BaseItemDto.cs index 937409111a..8f223c12a5 100644 --- a/MediaBrowser.Model/Dto/BaseItemDto.cs +++ b/MediaBrowser.Model/Dto/BaseItemDto.cs @@ -569,7 +569,7 @@ namespace MediaBrowser.Model.Dto /// Gets or sets the trickplay manifest. /// /// The trickplay manifest. - public Dictionary> Trickplay { get; set; } + public Dictionary> Trickplay { get; set; } /// /// Gets or sets the type of the location. diff --git a/MediaBrowser.Model/Dto/TrickplayInfoDto.cs b/MediaBrowser.Model/Dto/TrickplayInfoDto.cs new file mode 100644 index 0000000000..0c5f6e8171 --- /dev/null +++ b/MediaBrowser.Model/Dto/TrickplayInfoDto.cs @@ -0,0 +1,62 @@ +using System; +using Jellyfin.Database.Implementations.Entities; + +namespace MediaBrowser.Model.Dto; + +/// +/// The trickplay api model. +/// +public record TrickplayInfoDto +{ + /// + /// Initializes a new instance of the class. + /// + /// The trickplay info. + public TrickplayInfoDto(TrickplayInfo info) + { + ArgumentNullException.ThrowIfNull(info); + + Width = info.Width; + Height = info.Height; + TileWidth = info.TileWidth; + TileHeight = info.TileHeight; + ThumbnailCount = info.ThumbnailCount; + Interval = info.Interval; + Bandwidth = info.Bandwidth; + } + + /// + /// Gets the width of an individual thumbnail. + /// + public int Width { get; init; } + + /// + /// Gets the height of an individual thumbnail. + /// + public int Height { get; init; } + + /// + /// Gets the amount of thumbnails per row. + /// + public int TileWidth { get; init; } + + /// + /// Gets the amount of thumbnails per column. + /// + public int TileHeight { get; init; } + + /// + /// Gets the total amount of non-black thumbnails. + /// + public int ThumbnailCount { get; init; } + + /// + /// Gets the interval in milliseconds between each trickplay thumbnail. + /// + public int Interval { get; init; } + + /// + /// Gets the peak bandwidth usage in bits per second. + /// + public int Bandwidth { get; init; } +}