mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-05-01 14:26:40 +01:00
Migrate to trickplay table to EF. Rename vars/methods/members to have consistent use of tile and thumbnail
This commit is contained in:
@@ -78,7 +78,6 @@ using MediaBrowser.Controller.Session;
|
||||
using MediaBrowser.Controller.Sorting;
|
||||
using MediaBrowser.Controller.Subtitles;
|
||||
using MediaBrowser.Controller.SyncPlay;
|
||||
using MediaBrowser.Controller.Trickplay;
|
||||
using MediaBrowser.Controller.TV;
|
||||
using MediaBrowser.LocalMetadata.Savers;
|
||||
using MediaBrowser.MediaEncoding.BdInfo;
|
||||
@@ -97,7 +96,6 @@ using MediaBrowser.Providers.Lyric;
|
||||
using MediaBrowser.Providers.Manager;
|
||||
using MediaBrowser.Providers.Plugins.Tmdb;
|
||||
using MediaBrowser.Providers.Subtitles;
|
||||
using MediaBrowser.Providers.Trickplay;
|
||||
using MediaBrowser.XbmcMetadata.Providers;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -593,7 +591,6 @@ namespace Emby.Server.Implementations
|
||||
serviceCollection.AddSingleton<IDeviceDiscovery, DeviceDiscovery>();
|
||||
|
||||
serviceCollection.AddSingleton<IChapterManager, ChapterManager>();
|
||||
serviceCollection.AddSingleton<ITrickplayManager, TrickplayManager>();
|
||||
|
||||
serviceCollection.AddSingleton<IEncodingManager, MediaEncoder.EncodingManager>();
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Extensions;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.LiveTv;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Controller.Playlists;
|
||||
@@ -48,7 +47,6 @@ namespace Emby.Server.Implementations.Data
|
||||
{
|
||||
private const string FromText = " from TypedBaseItems A";
|
||||
private const string ChaptersTableName = "Chapters2";
|
||||
private const string TrickplayTableName = "Trickplay";
|
||||
|
||||
private const string SaveItemCommandText =
|
||||
@"replace into TypedBaseItems
|
||||
@@ -384,8 +382,6 @@ namespace Emby.Server.Implementations.Data
|
||||
|
||||
"create table if not exists " + ChaptersTableName + " (ItemId GUID, ChapterIndex INT NOT NULL, StartPositionTicks BIGINT NOT NULL, Name TEXT, ImagePath TEXT, PRIMARY KEY (ItemId, ChapterIndex))",
|
||||
|
||||
"create table if not exists " + TrickplayTableName + " (ItemId GUID, Width INT NOT NULL, Height INT NOT NULL, TileWidth INT NOT NULL, TileHeight INT NOT NULL, TileCount INT NOT NULL, Interval INT NOT NULL, Bandwidth INT NOT NULL, PRIMARY KEY (ItemId, Width))",
|
||||
|
||||
CreateMediaStreamsTableCommand,
|
||||
CreateMediaAttachmentsTableCommand,
|
||||
|
||||
@@ -2138,126 +2134,6 @@ namespace Emby.Server.Implementations.Data
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Dictionary<int, TrickplayTilesInfo> GetTilesResolutions(Guid itemId)
|
||||
{
|
||||
CheckDisposed();
|
||||
|
||||
var tilesResolutions = new Dictionary<int, TrickplayTilesInfo>();
|
||||
using (var connection = GetConnection(true))
|
||||
{
|
||||
using (var statement = PrepareStatement(connection, "select Width,Height,TileWidth,TileHeight,TileCount,Interval,Bandwidth from " + TrickplayTableName + " where ItemId = @ItemId order by Width asc"))
|
||||
{
|
||||
statement.TryBind("@ItemId", itemId);
|
||||
|
||||
foreach (var row in statement.ExecuteQuery())
|
||||
{
|
||||
TrickplayTilesInfo tilesInfo = GetTrickplayTilesInfo(row);
|
||||
tilesResolutions[tilesInfo.Width] = tilesInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return tilesResolutions;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void SaveTilesInfo(Guid itemId, TrickplayTilesInfo tilesInfo)
|
||||
{
|
||||
CheckDisposed();
|
||||
|
||||
ArgumentNullException.ThrowIfNull(tilesInfo);
|
||||
|
||||
var idBlob = itemId.ToByteArray();
|
||||
using (var connection = GetConnection(false))
|
||||
{
|
||||
connection.RunInTransaction(
|
||||
db =>
|
||||
{
|
||||
// Delete old tiles info
|
||||
db.Execute("delete from " + TrickplayTableName + " where ItemId=@ItemId and Width=@Width", idBlob, tilesInfo.Width);
|
||||
db.Execute(
|
||||
"insert into " + TrickplayTableName + " values (@ItemId, @Width, @Height, @TileWidth, @TileHeight, @TileCount, @Interval, @Bandwidth)",
|
||||
idBlob,
|
||||
tilesInfo.Width,
|
||||
tilesInfo.Height,
|
||||
tilesInfo.TileWidth,
|
||||
tilesInfo.TileHeight,
|
||||
tilesInfo.TileCount,
|
||||
tilesInfo.Interval,
|
||||
tilesInfo.Bandwidth);
|
||||
},
|
||||
TransactionMode);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Dictionary<Guid, Dictionary<int, TrickplayTilesInfo>> GetTrickplayManifest(BaseItem item)
|
||||
{
|
||||
CheckDisposed();
|
||||
|
||||
var trickplayManifest = new Dictionary<Guid, Dictionary<int, TrickplayTilesInfo>>();
|
||||
foreach (var mediaSource in item.GetMediaSources(false))
|
||||
{
|
||||
var mediaSourceId = Guid.Parse(mediaSource.Id);
|
||||
var tilesResolutions = GetTilesResolutions(mediaSourceId);
|
||||
|
||||
if (tilesResolutions.Count > 0)
|
||||
{
|
||||
trickplayManifest[mediaSourceId] = tilesResolutions;
|
||||
}
|
||||
}
|
||||
|
||||
return trickplayManifest;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the trickplay tiles info.
|
||||
/// </summary>
|
||||
/// <param name="reader">The reader.</param>
|
||||
/// <returns>TrickplayTilesInfo.</returns>
|
||||
private TrickplayTilesInfo GetTrickplayTilesInfo(IReadOnlyList<ResultSetValue> reader)
|
||||
{
|
||||
var tilesInfo = new TrickplayTilesInfo();
|
||||
|
||||
if (reader.TryGetInt32(0, out var width))
|
||||
{
|
||||
tilesInfo.Width = width;
|
||||
}
|
||||
|
||||
if (reader.TryGetInt32(1, out var height))
|
||||
{
|
||||
tilesInfo.Height = height;
|
||||
}
|
||||
|
||||
if (reader.TryGetInt32(2, out var tileWidth))
|
||||
{
|
||||
tilesInfo.TileWidth = tileWidth;
|
||||
}
|
||||
|
||||
if (reader.TryGetInt32(3, out var tileHeight))
|
||||
{
|
||||
tilesInfo.TileHeight = tileHeight;
|
||||
}
|
||||
|
||||
if (reader.TryGetInt32(4, out var tileCount))
|
||||
{
|
||||
tilesInfo.TileCount = tileCount;
|
||||
}
|
||||
|
||||
if (reader.TryGetInt32(5, out var interval))
|
||||
{
|
||||
tilesInfo.Interval = interval;
|
||||
}
|
||||
|
||||
if (reader.TryGetInt32(6, out var bandwidth))
|
||||
{
|
||||
tilesInfo.Bandwidth = bandwidth;
|
||||
}
|
||||
|
||||
return tilesInfo;
|
||||
}
|
||||
|
||||
private static bool EnableJoinUserData(InternalItemsQuery query)
|
||||
{
|
||||
if (query.User is null)
|
||||
|
||||
@@ -22,6 +22,7 @@ using MediaBrowser.Controller.Lyrics;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Controller.Playlists;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Controller.Trickplay;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Querying;
|
||||
@@ -52,6 +53,7 @@ namespace Emby.Server.Implementations.Dto
|
||||
private readonly Lazy<ILiveTvManager> _livetvManagerFactory;
|
||||
|
||||
private readonly ILyricManager _lyricManager;
|
||||
private readonly ITrickplayManager _trickplayManager;
|
||||
|
||||
public DtoService(
|
||||
ILogger<DtoService> logger,
|
||||
@@ -63,7 +65,8 @@ namespace Emby.Server.Implementations.Dto
|
||||
IApplicationHost appHost,
|
||||
IMediaSourceManager mediaSourceManager,
|
||||
Lazy<ILiveTvManager> livetvManagerFactory,
|
||||
ILyricManager lyricManager)
|
||||
ILyricManager lyricManager,
|
||||
ITrickplayManager trickplayManager)
|
||||
{
|
||||
_logger = logger;
|
||||
_libraryManager = libraryManager;
|
||||
@@ -75,6 +78,7 @@ namespace Emby.Server.Implementations.Dto
|
||||
_mediaSourceManager = mediaSourceManager;
|
||||
_livetvManagerFactory = livetvManagerFactory;
|
||||
_lyricManager = lyricManager;
|
||||
_trickplayManager = trickplayManager;
|
||||
}
|
||||
|
||||
private ILiveTvManager LivetvManager => _livetvManagerFactory.Value;
|
||||
@@ -1060,9 +1064,11 @@ namespace Emby.Server.Implementations.Dto
|
||||
|
||||
if (options.ContainsField(ItemFields.Trickplay))
|
||||
{
|
||||
var manifest = _trickplayManager.GetTrickplayManifest(item).ConfigureAwait(false).GetAwaiter().GetResult();
|
||||
|
||||
// To stay consistent with other fields, this must go from a Guid to a non-dashed string.
|
||||
// This does not seem to occur automatically to dictionaries like it does with other Guid fields.
|
||||
dto.Trickplay = _itemRepo.GetTrickplayManifest(item).ToDictionary(x => x.Key.ToString("N", CultureInfo.InvariantCulture), y => y.Value);
|
||||
dto.Trickplay = manifest.ToDictionary(x => x.Key.ToString("N", CultureInfo.InvariantCulture), y => y.Value);
|
||||
}
|
||||
|
||||
if (video.ExtraType.HasValue)
|
||||
|
||||
Reference in New Issue
Block a user