diff options
44 files changed, 1368 insertions, 364 deletions
diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index af5264279..a3847dcdf 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "dotnet-ef": { - "version": "8.0.7", + "version": "8.0.8", "commands": [ "dotnet-ef" ] diff --git a/.github/ISSUE_TEMPLATE/issue report.yml b/.github/ISSUE_TEMPLATE/issue report.yml index 85590c0b0..b71b365f7 100644 --- a/.github/ISSUE_TEMPLATE/issue report.yml +++ b/.github/ISSUE_TEMPLATE/issue report.yml @@ -86,7 +86,7 @@ body: label: Jellyfin Server version description: What version of Jellyfin are you using? options: - - 10.9.8+ + - 10.9.9+ - Master - Unstable - Older* diff --git a/.github/workflows/ci-codeql-analysis.yml b/.github/workflows/ci-codeql-analysis.yml index ba66526e0..9eb907126 100644 --- a/.github/workflows/ci-codeql-analysis.yml +++ b/.github/workflows/ci-codeql-analysis.yml @@ -27,11 +27,11 @@ jobs: dotnet-version: '8.0.x' - name: Initialize CodeQL - uses: github/codeql-action/init@afb54ba388a7dca6ecae48f608c4ff05ff4cc77a # v3.25.15 + uses: github/codeql-action/init@29d86d22a34ea372b1bbf3b2dced2e25ca6b3384 # v3.26.1 with: languages: ${{ matrix.language }} queries: +security-extended - name: Autobuild - uses: github/codeql-action/autobuild@afb54ba388a7dca6ecae48f608c4ff05ff4cc77a # v3.25.15 + uses: github/codeql-action/autobuild@29d86d22a34ea372b1bbf3b2dced2e25ca6b3384 # v3.26.1 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@afb54ba388a7dca6ecae48f608c4ff05ff4cc77a # v3.25.15 + uses: github/codeql-action/analyze@29d86d22a34ea372b1bbf3b2dced2e25ca6b3384 # v3.26.1 diff --git a/.github/workflows/ci-openapi.yml b/.github/workflows/ci-openapi.yml index 54a061556..93bfc83a2 100644 --- a/.github/workflows/ci-openapi.yml +++ b/.github/workflows/ci-openapi.yml @@ -27,7 +27,7 @@ jobs: - name: Generate openapi.json run: dotnet test tests/Jellyfin.Server.Integration.Tests/Jellyfin.Server.Integration.Tests.csproj -c Release --filter "Jellyfin.Server.Integration.Tests.OpenApiSpecTests" - name: Upload openapi.json - uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4 + uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 with: name: openapi-head retention-days: 14 @@ -61,7 +61,7 @@ jobs: - name: Generate openapi.json run: dotnet test tests/Jellyfin.Server.Integration.Tests/Jellyfin.Server.Integration.Tests.csproj -c Release --filter "Jellyfin.Server.Integration.Tests.OpenApiSpecTests" - name: Upload openapi.json - uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4 + uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 with: name: openapi-base retention-days: 14 diff --git a/Directory.Packages.props b/Directory.Packages.props index 683f2eee3..8ff5bc366 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -16,7 +16,6 @@ <PackageVersion Include="Diacritics" Version="3.3.29" /> <PackageVersion Include="DiscUtils.Udf" Version="0.16.13" /> <PackageVersion Include="DotNet.Glob" Version="3.1.3" /> - <PackageVersion Include="EFCoreSecondLevelCacheInterceptor" Version="4.5.0" /> <PackageVersion Include="FsCheck.Xunit" Version="2.16.6" /> <PackageVersion Include="HarfBuzzSharp.NativeAssets.Linux" Version="7.3.0.2" /> <PackageVersion Include="ICU4N.Transliterator" Version="60.1.0-alpha.356" /> @@ -25,14 +24,14 @@ <PackageVersion Include="libse" Version="4.0.7" /> <PackageVersion Include="LrcParser" Version="2023.524.0" /> <PackageVersion Include="MetaBrainz.MusicBrainz" Version="6.1.0" /> - <PackageVersion Include="Microsoft.AspNetCore.Authorization" Version="8.0.7" /> - <PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.7" /> + <PackageVersion Include="Microsoft.AspNetCore.Authorization" Version="8.0.8" /> + <PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.8" /> <PackageVersion Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="3.3.4" /> - <PackageVersion Include="Microsoft.Data.Sqlite" Version="8.0.7" /> - <PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.7" /> - <PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.7" /> - <PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.7" /> - <PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.7" /> + <PackageVersion Include="Microsoft.Data.Sqlite" Version="8.0.8" /> + <PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.8" /> + <PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.8" /> + <PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.8" /> + <PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.8" /> <PackageVersion Include="Microsoft.Extensions.Caching.Abstractions" Version="8.0.0" /> <PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="8.0.0" /> <PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" /> @@ -41,8 +40,8 @@ <PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" /> <PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" /> <PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" /> - <PackageVersion Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="8.0.7" /> - <PackageVersion Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="8.0.7" /> + <PackageVersion Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="8.0.8" /> + <PackageVersion Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="8.0.8" /> <PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" /> <PackageVersion Include="Microsoft.Extensions.Http" Version="8.0.0" /> <PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" /> @@ -81,7 +80,7 @@ <PackageVersion Include="System.Text.Json" Version="8.0.4" /> <PackageVersion Include="System.Threading.Tasks.Dataflow" Version="8.0.1" /> <PackageVersion Include="TagLibSharp" Version="2.3.0" /> - <PackageVersion Include="z440.atl.core" Version="5.25.0" /> + <PackageVersion Include="z440.atl.core" Version="5.26.0" /> <PackageVersion Include="TMDbLib" Version="2.2.0" /> <PackageVersion Include="UTF.Unknown" Version="2.5.1" /> <PackageVersion Include="Xunit.Priority" Version="1.1.6" /> diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index 5bf9c4fc2..ceda0bd64 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -40,6 +40,7 @@ using Jellyfin.MediaEncoding.Hls.Playlist; using Jellyfin.Networking.Manager; using Jellyfin.Networking.Udp; using Jellyfin.Server.Implementations; +using Jellyfin.Server.Implementations.MediaSegments; using MediaBrowser.Common; using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Events; @@ -552,6 +553,8 @@ namespace Emby.Server.Implementations serviceCollection.AddScoped<DynamicHlsHelper>(); serviceCollection.AddScoped<IClientEventLogger, ClientEventLogger>(); serviceCollection.AddSingleton<IDirectoryService, DirectoryService>(); + + serviceCollection.AddSingleton<IMediaSegmentManager, MediaSegmentManager>(); } /// <summary> @@ -635,6 +638,7 @@ namespace Emby.Server.Implementations UserView.TVSeriesManager = Resolve<ITVSeriesManager>(); UserView.CollectionManager = Resolve<ICollectionManager>(); BaseItem.MediaSourceManager = Resolve<IMediaSourceManager>(); + BaseItem.MediaSegmentManager = Resolve<IMediaSegmentManager>(); CollectionFolder.XmlSerializer = _xmlSerializer; CollectionFolder.ApplicationHost = this; } diff --git a/Emby.Server.Implementations/ConfigurationOptions.cs b/Emby.Server.Implementations/ConfigurationOptions.cs index c06cd8510..f0c267627 100644 --- a/Emby.Server.Implementations/ConfigurationOptions.cs +++ b/Emby.Server.Implementations/ConfigurationOptions.cs @@ -19,8 +19,7 @@ namespace Emby.Server.Implementations { FfmpegAnalyzeDurationKey, "200M" }, { PlaylistsAllowDuplicatesKey, bool.FalseString }, { BindToUnixSocketKey, bool.FalseString }, - { SqliteCacheSizeKey, "20000" }, - { SqliteDisableSecondLevelCacheKey, bool.FalseString } + { SqliteCacheSizeKey, "20000" } }; } } diff --git a/Emby.Server.Implementations/Localization/Core/enm.json b/Emby.Server.Implementations/Localization/Core/enm.json new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/Emby.Server.Implementations/Localization/Core/enm.json @@ -0,0 +1 @@ +{} diff --git a/Emby.Server.Implementations/Localization/Core/es-AR.json b/Emby.Server.Implementations/Localization/Core/es-AR.json index 8bd3c5def..9433da28b 100644 --- a/Emby.Server.Implementations/Localization/Core/es-AR.json +++ b/Emby.Server.Implementations/Localization/Core/es-AR.json @@ -124,5 +124,11 @@ "External": "Externo", "TaskKeyframeExtractorDescription": "Extrae Fotogramas Clave de los archivos de vídeo para crear Listas de Reprodución HLS más precisas. Esta tarea puede durar mucho tiempo.", "TaskKeyframeExtractor": "Extractor de Fotogramas Clave", - "HearingImpaired": "Discapacidad Auditiva" + "HearingImpaired": "Discapacidad Auditiva", + "TaskRefreshTrickplayImages": "Generar imágenes de Trickplay", + "TaskRefreshTrickplayImagesDescription": "Crea vistas previas de reproducción engañosa para videos en bibliotecas habilitadas.", + "TaskAudioNormalization": "Normalización de audio", + "TaskAudioNormalizationDescription": "Escanea archivos en busca de datos de normalización de audio.", + "TaskCleanCollectionsAndPlaylists": "Limpiar colecciones y listas de reproducción", + "TaskCleanCollectionsAndPlaylistsDescription": "Elimina elementos de colecciones y listas de reproducción que ya no existen." } diff --git a/Emby.Server.Implementations/Localization/Core/fr.json b/Emby.Server.Implementations/Localization/Core/fr.json index a13ee48d5..e8c0f7fc3 100644 --- a/Emby.Server.Implementations/Localization/Core/fr.json +++ b/Emby.Server.Implementations/Localization/Core/fr.json @@ -15,7 +15,7 @@ "Favorites": "Favoris", "Folders": "Dossiers", "Genres": "Genres", - "HeaderAlbumArtists": "Artistes de l'album", + "HeaderAlbumArtists": "Artistes d'albums", "HeaderContinueWatching": "Continuer de regarder", "HeaderFavoriteAlbums": "Albums favoris", "HeaderFavoriteArtists": "Artistes préférés", diff --git a/Emby.Server.Implementations/Session/SessionManager.cs b/Emby.Server.Implementations/Session/SessionManager.cs index 3dda5fdee..681c252b6 100644 --- a/Emby.Server.Implementations/Session/SessionManager.cs +++ b/Emby.Server.Implementations/Session/SessionManager.cs @@ -237,7 +237,7 @@ namespace Emby.Server.Implementations.Session ArgumentException.ThrowIfNullOrEmpty(deviceId); var activityDate = DateTime.UtcNow; - var session = await GetSessionInfo(appName, appVersion, deviceId, deviceName, remoteEndPoint, user).ConfigureAwait(false); + var session = GetSessionInfo(appName, appVersion, deviceId, deviceName, remoteEndPoint, user); var lastActivityDate = session.LastActivityDate; session.LastActivityDate = activityDate; @@ -435,7 +435,7 @@ namespace Emby.Server.Implementations.Session /// <param name="remoteEndPoint">The remote end point.</param> /// <param name="user">The user.</param> /// <returns>SessionInfo.</returns> - private async Task<SessionInfo> GetSessionInfo( + private SessionInfo GetSessionInfo( string appName, string appVersion, string deviceId, @@ -453,7 +453,7 @@ namespace Emby.Server.Implementations.Session if (!_activeConnections.TryGetValue(key, out var sessionInfo)) { - sessionInfo = await CreateSession(key, appName, appVersion, deviceId, deviceName, remoteEndPoint, user).ConfigureAwait(false); + sessionInfo = CreateSession(key, appName, appVersion, deviceId, deviceName, remoteEndPoint, user); _activeConnections[key] = sessionInfo; } @@ -478,7 +478,7 @@ namespace Emby.Server.Implementations.Session return sessionInfo; } - private async Task<SessionInfo> CreateSession( + private SessionInfo CreateSession( string key, string appName, string appVersion, @@ -508,7 +508,7 @@ namespace Emby.Server.Implementations.Session deviceName = "Network Device"; } - var deviceOptions = await _deviceManager.GetDeviceOptions(deviceId).ConfigureAwait(false); + var deviceOptions = _deviceManager.GetDeviceOptions(deviceId); if (string.IsNullOrEmpty(deviceOptions.CustomName)) { sessionInfo.DeviceName = deviceName; @@ -1297,7 +1297,7 @@ namespace Emby.Server.Implementations.Session return new[] { item }; } - private IEnumerable<BaseItem> TranslateItemForInstantMix(Guid id, User user) + private List<BaseItem> TranslateItemForInstantMix(Guid id, User user) { var item = _libraryManager.GetItemById(id); @@ -1307,7 +1307,7 @@ namespace Emby.Server.Implementations.Session return new List<BaseItem>(); } - return _musicManager.GetInstantMixFromItem(item, user, new DtoOptions(false) { EnableImages = false }); + return _musicManager.GetInstantMixFromItem(item, user, new DtoOptions(false) { EnableImages = false }).ToList(); } /// <inheritdoc /> @@ -1520,12 +1520,12 @@ namespace Emby.Server.Implementations.Session // This should be validated above, but if it isn't don't delete all tokens. ArgumentException.ThrowIfNullOrEmpty(deviceId); - var existing = (await _deviceManager.GetDevices( + var existing = _deviceManager.GetDevices( new DeviceQuery { DeviceId = deviceId, UserId = user.Id - }).ConfigureAwait(false)).Items; + }).Items; foreach (var auth in existing) { @@ -1553,12 +1553,12 @@ namespace Emby.Server.Implementations.Session ArgumentException.ThrowIfNullOrEmpty(accessToken); - var existing = (await _deviceManager.GetDevices( + var existing = _deviceManager.GetDevices( new DeviceQuery { Limit = 1, AccessToken = accessToken - }).ConfigureAwait(false)).Items; + }).Items; if (existing.Count > 0) { @@ -1597,10 +1597,10 @@ namespace Emby.Server.Implementations.Session { CheckDisposed(); - var existing = await _deviceManager.GetDevices(new DeviceQuery + var existing = _deviceManager.GetDevices(new DeviceQuery { UserId = userId - }).ConfigureAwait(false); + }); foreach (var info in existing.Items) { @@ -1787,11 +1787,11 @@ namespace Emby.Server.Implementations.Session /// <inheritdoc /> public async Task<SessionInfo> GetSessionByAuthenticationToken(string token, string deviceId, string remoteEndpoint) { - var items = (await _deviceManager.GetDevices(new DeviceQuery + var items = _deviceManager.GetDevices(new DeviceQuery { AccessToken = token, Limit = 1 - }).ConfigureAwait(false)).Items; + }).Items; if (items.Count == 0) { diff --git a/Jellyfin.Api/Controllers/AudioController.cs b/Jellyfin.Api/Controllers/AudioController.cs index 8954c8ef5..a47c60473 100644 --- a/Jellyfin.Api/Controllers/AudioController.cs +++ b/Jellyfin.Api/Controllers/AudioController.cs @@ -46,7 +46,7 @@ public class AudioController : BaseJellyfinApiController /// <param name="minSegments">The minimum number of segments.</param> /// <param name="mediaSourceId">The media version id, if playing an alternate version.</param> /// <param name="deviceId">The device id of the client requesting. Used to stop encoding processes when needed.</param> - /// <param name="audioCodec">Optional. Specify a audio codec to encode to, e.g. mp3. If omitted the server will auto-select using the url's extension. Options: aac, mp3, vorbis, wma.</param> + /// <param name="audioCodec">Optional. Specify an audio codec to encode to, e.g. mp3. If omitted the server will auto-select using the url's extension.</param> /// <param name="enableAutoStreamCopy">Whether or not to allow automatic stream copy if requested values match the original source. Defaults to true.</param> /// <param name="allowVideoStreamCopy">Whether or not to allow copying of the video stream url.</param> /// <param name="allowAudioStreamCopy">Whether or not to allow copying of the audio stream url.</param> @@ -76,7 +76,7 @@ public class AudioController : BaseJellyfinApiController /// <param name="cpuCoreLimit">Optional. The limit of how many cpu cores to use.</param> /// <param name="liveStreamId">The live stream id.</param> /// <param name="enableMpegtsM2TsMode">Optional. Whether to enable the MpegtsM2Ts mode.</param> - /// <param name="videoCodec">Optional. Specify a video codec to encode to, e.g. h264. If omitted the server will auto-select using the url's extension. Options: h265, h264, mpeg4, theora, vp8, vp9, vpx (deprecated), wmv.</param> + /// <param name="videoCodec">Optional. Specify a video codec to encode to, e.g. h264. If omitted the server will auto-select using the url's extension.</param> /// <param name="subtitleCodec">Optional. Specify a subtitle codec to encode to.</param> /// <param name="transcodeReasons">Optional. The transcoding reason.</param> /// <param name="audioStreamIndex">Optional. The index of the audio stream to use. If omitted the first audio stream will be used.</param> @@ -213,7 +213,7 @@ public class AudioController : BaseJellyfinApiController /// <param name="minSegments">The minimum number of segments.</param> /// <param name="mediaSourceId">The media version id, if playing an alternate version.</param> /// <param name="deviceId">The device id of the client requesting. Used to stop encoding processes when needed.</param> - /// <param name="audioCodec">Optional. Specify a audio codec to encode to, e.g. mp3. If omitted the server will auto-select using the url's extension. Options: aac, mp3, vorbis, wma.</param> + /// <param name="audioCodec">Optional. Specify an audio codec to encode to, e.g. mp3. If omitted the server will auto-select using the url's extension.</param> /// <param name="enableAutoStreamCopy">Whether or not to allow automatic stream copy if requested values match the original source. Defaults to true.</param> /// <param name="allowVideoStreamCopy">Whether or not to allow copying of the video stream url.</param> /// <param name="allowAudioStreamCopy">Whether or not to allow copying of the audio stream url.</param> @@ -243,7 +243,7 @@ public class AudioController : BaseJellyfinApiController /// <param name="cpuCoreLimit">Optional. The limit of how many cpu cores to use.</param> /// <param name="liveStreamId">The live stream id.</param> /// <param name="enableMpegtsM2TsMode">Optional. Whether to enable the MpegtsM2Ts mode.</param> - /// <param name="videoCodec">Optional. Specify a video codec to encode to, e.g. h264. If omitted the server will auto-select using the url's extension. Options: h265, h264, mpeg4, theora, vp8, vp9, vpx (deprecated), wmv.</param> + /// <param name="videoCodec">Optional. Specify a video codec to encode to, e.g. h264. If omitted the server will auto-select using the url's extension.</param> /// <param name="subtitleCodec">Optional. Specify a subtitle codec to encode to.</param> /// <param name="transcodeReasons">Optional. The transcoding reason.</param> /// <param name="audioStreamIndex">Optional. The index of the audio stream to use. If omitted the first audio stream will be used.</param> diff --git a/Jellyfin.Api/Controllers/DevicesController.cs b/Jellyfin.Api/Controllers/DevicesController.cs index 6d9ec343e..2a2ab4ad1 100644 --- a/Jellyfin.Api/Controllers/DevicesController.cs +++ b/Jellyfin.Api/Controllers/DevicesController.cs @@ -47,10 +47,10 @@ public class DevicesController : BaseJellyfinApiController /// <returns>An <see cref="OkResult"/> containing the list of devices.</returns> [HttpGet] [ProducesResponseType(StatusCodes.Status200OK)] - public async Task<ActionResult<QueryResult<DeviceInfo>>> GetDevices([FromQuery] Guid? userId) + public ActionResult<QueryResult<DeviceInfo>> GetDevices([FromQuery] Guid? userId) { userId = RequestHelpers.GetUserId(User, userId); - return await _deviceManager.GetDevicesForUser(userId).ConfigureAwait(false); + return _deviceManager.GetDevicesForUser(userId); } /// <summary> @@ -63,9 +63,9 @@ public class DevicesController : BaseJellyfinApiController [HttpGet("Info")] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status404NotFound)] - public async Task<ActionResult<DeviceInfo>> GetDeviceInfo([FromQuery, Required] string id) + public ActionResult<DeviceInfo> GetDeviceInfo([FromQuery, Required] string id) { - var deviceInfo = await _deviceManager.GetDevice(id).ConfigureAwait(false); + var deviceInfo = _deviceManager.GetDevice(id); if (deviceInfo is null) { return NotFound(); @@ -84,9 +84,9 @@ public class DevicesController : BaseJellyfinApiController [HttpGet("Options")] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status404NotFound)] - public async Task<ActionResult<DeviceOptions>> GetDeviceOptions([FromQuery, Required] string id) + public ActionResult<DeviceOptions> GetDeviceOptions([FromQuery, Required] string id) { - var deviceInfo = await _deviceManager.GetDeviceOptions(id).ConfigureAwait(false); + var deviceInfo = _deviceManager.GetDeviceOptions(id); if (deviceInfo is null) { return NotFound(); @@ -124,13 +124,13 @@ public class DevicesController : BaseJellyfinApiController [ProducesResponseType(StatusCodes.Status404NotFound)] public async Task<ActionResult> DeleteDevice([FromQuery, Required] string id) { - var existingDevice = await _deviceManager.GetDevice(id).ConfigureAwait(false); + var existingDevice = _deviceManager.GetDevice(id); if (existingDevice is null) { return NotFound(); } - var sessions = await _deviceManager.GetDevices(new DeviceQuery { DeviceId = id }).ConfigureAwait(false); + var sessions = _deviceManager.GetDevices(new DeviceQuery { DeviceId = id }); foreach (var session in sessions.Items) { diff --git a/Jellyfin.Api/Controllers/DynamicHlsController.cs b/Jellyfin.Api/Controllers/DynamicHlsController.cs index 130c1192f..016c5b163 100644 --- a/Jellyfin.Api/Controllers/DynamicHlsController.cs +++ b/Jellyfin.Api/Controllers/DynamicHlsController.cs @@ -116,7 +116,7 @@ public class DynamicHlsController : BaseJellyfinApiController /// <param name="minSegments">The minimum number of segments.</param> /// <param name="mediaSourceId">The media version id, if playing an alternate version.</param> /// <param name="deviceId">The device id of the client requesting. Used to stop encoding processes when needed.</param> - /// <param name="audioCodec">Optional. Specify a audio codec to encode to, e.g. mp3. If omitted the server will auto-select using the url's extension. Options: aac, mp3, vorbis, wma.</param> + /// <param name="audioCodec">Optional. Specify an audio codec to encode to, e.g. mp3.</param> /// <param name="enableAutoStreamCopy">Whether or not to allow automatic stream copy if requested values match the original source. Defaults to true.</param> /// <param name="allowVideoStreamCopy">Whether or not to allow copying of the video stream url.</param> /// <param name="allowAudioStreamCopy">Whether or not to allow copying of the audio stream url.</param> @@ -146,7 +146,7 @@ public class DynamicHlsController : BaseJellyfinApiController /// <param name="cpuCoreLimit">Optional. The limit of how many cpu cores to use.</param> /// <param name="liveStreamId">The live stream id.</param> /// <param name="enableMpegtsM2TsMode">Optional. Whether to enable the MpegtsM2Ts mode.</param> - /// <param name="videoCodec">Optional. Specify a video codec to encode to, e.g. h264. If omitted the server will auto-select using the url's extension. Options: h265, h264, mpeg4, theora, vp8, vp9, vpx (deprecated), wmv.</param> + /// <param name="videoCodec">Optional. Specify a video codec to encode to, e.g. h264.</param> /// <param name="subtitleCodec">Optional. Specify a subtitle codec to encode to.</param> /// <param name="transcodeReasons">Optional. The transcoding reason.</param> /// <param name="audioStreamIndex">Optional. The index of the audio stream to use. If omitted the first audio stream will be used.</param> @@ -355,7 +355,7 @@ public class DynamicHlsController : BaseJellyfinApiController /// <param name="minSegments">The minimum number of segments.</param> /// <param name="mediaSourceId">The media version id, if playing an alternate version.</param> /// <param name="deviceId">The device id of the client requesting. Used to stop encoding processes when needed.</param> - /// <param name="audioCodec">Optional. Specify a audio codec to encode to, e.g. mp3. If omitted the server will auto-select using the url's extension. Options: aac, mp3, vorbis, wma.</param> + /// <param name="audioCodec">Optional. Specify an audio codec to encode to, e.g. mp3.</param> /// <param name="enableAutoStreamCopy">Whether or not to allow automatic stream copy if requested values match the original source. Defaults to true.</param> /// <param name="allowVideoStreamCopy">Whether or not to allow copying of the video stream url.</param> /// <param name="allowAudioStreamCopy">Whether or not to allow copying of the audio stream url.</param> @@ -387,7 +387,7 @@ public class DynamicHlsController : BaseJellyfinApiController /// <param name="cpuCoreLimit">Optional. The limit of how many cpu cores to use.</param> /// <param name="liveStreamId">The live stream id.</param> /// <param name="enableMpegtsM2TsMode">Optional. Whether to enable the MpegtsM2Ts mode.</param> - /// <param name="videoCodec">Optional. Specify a video codec to encode to, e.g. h264. If omitted the server will auto-select using the url's extension. Options: h265, h264, mpeg4, theora, vp8, vp9, vpx (deprecated), wmv.</param> + /// <param name="videoCodec">Optional. Specify a video codec to encode to, e.g. h264.</param> /// <param name="subtitleCodec">Optional. Specify a subtitle codec to encode to.</param> /// <param name="transcodeReasons">Optional. The transcoding reason.</param> /// <param name="audioStreamIndex">Optional. The index of the audio stream to use. If omitted the first audio stream will be used.</param> @@ -531,7 +531,7 @@ public class DynamicHlsController : BaseJellyfinApiController /// <param name="minSegments">The minimum number of segments.</param> /// <param name="mediaSourceId">The media version id, if playing an alternate version.</param> /// <param name="deviceId">The device id of the client requesting. Used to stop encoding processes when needed.</param> - /// <param name="audioCodec">Optional. Specify a audio codec to encode to, e.g. mp3. If omitted the server will auto-select using the url's extension. Options: aac, mp3, vorbis, wma.</param> + /// <param name="audioCodec">Optional. Specify an audio codec to encode to, e.g. mp3.</param> /// <param name="enableAutoStreamCopy">Whether or not to allow automatic stream copy if requested values match the original source. Defaults to true.</param> /// <param name="allowVideoStreamCopy">Whether or not to allow copying of the video stream url.</param> /// <param name="allowAudioStreamCopy">Whether or not to allow copying of the audio stream url.</param> @@ -562,7 +562,7 @@ public class DynamicHlsController : BaseJellyfinApiController /// <param name="cpuCoreLimit">Optional. The limit of how many cpu cores to use.</param> /// <param name="liveStreamId">The live stream id.</param> /// <param name="enableMpegtsM2TsMode">Optional. Whether to enable the MpegtsM2Ts mode.</param> - /// <param name="videoCodec">Optional. Specify a video codec to encode to, e.g. h264. If omitted the server will auto-select using the url's extension. Options: h265, h264, mpeg4, theora, vp8, vp9, vpx (deprecated), wmv.</param> + /// <param name="videoCodec">Optional. Specify a video codec to encode to, e.g. h264.</param> /// <param name="subtitleCodec">Optional. Specify a subtitle codec to encode to.</param> /// <param name="transcodeReasons">Optional. The transcoding reason.</param> /// <param name="audioStreamIndex">Optional. The index of the audio stream to use. If omitted the first audio stream will be used.</param> @@ -700,7 +700,7 @@ public class DynamicHlsController : BaseJellyfinApiController /// <param name="minSegments">The minimum number of segments.</param> /// <param name="mediaSourceId">The media version id, if playing an alternate version.</param> /// <param name="deviceId">The device id of the client requesting. Used to stop encoding processes when needed.</param> - /// <param name="audioCodec">Optional. Specify a audio codec to encode to, e.g. mp3. If omitted the server will auto-select using the url's extension. Options: aac, mp3, vorbis, wma.</param> + /// <param name="audioCodec">Optional. Specify an audio codec to encode to, e.g. mp3.</param> /// <param name="enableAutoStreamCopy">Whether or not to allow automatic stream copy if requested values match the original source. Defaults to true.</param> /// <param name="allowVideoStreamCopy">Whether or not to allow copying of the video stream url.</param> /// <param name="allowAudioStreamCopy">Whether or not to allow copying of the audio stream url.</param> @@ -732,7 +732,7 @@ public class DynamicHlsController : BaseJellyfinApiController /// <param name="cpuCoreLimit">Optional. The limit of how many cpu cores to use.</param> /// <param name="liveStreamId">The live stream id.</param> /// <param name="enableMpegtsM2TsMode">Optional. Whether to enable the MpegtsM2Ts mode.</param> - /// <param name="videoCodec">Optional. Specify a video codec to encode to, e.g. h264. If omitted the server will auto-select using the url's extension. Options: h265, h264, mpeg4, theora, vp8, vp9, vpx (deprecated), wmv.</param> + /// <param name="videoCodec">Optional. Specify a video codec to encode to, e.g. h264.</param> /// <param name="subtitleCodec">Optional. Specify a subtitle codec to encode to.</param> /// <param name="transcodeReasons">Optional. The transcoding reason.</param> /// <param name="audioStreamIndex">Optional. The index of the audio stream to use. If omitted the first audio stream will be used.</param> @@ -871,7 +871,7 @@ public class DynamicHlsController : BaseJellyfinApiController /// <param name="minSegments">The minimum number of segments.</param> /// <param name="mediaSourceId">The media version id, if playing an alternate version.</param> /// <param name="deviceId">The device id of the client requesting. Used to stop encoding processes when needed.</param> - /// <param name="audioCodec">Optional. Specify a audio codec to encode to, e.g. mp3. If omitted the server will auto-select using the url's extension. Options: aac, mp3, vorbis, wma.</param> + /// <param name="audioCodec">Optional. Specify an audio codec to encode to, e.g. mp3.</param> /// <param name="enableAutoStreamCopy">Whether or not to allow automatic stream copy if requested values match the original source. Defaults to true.</param> /// <param name="allowVideoStreamCopy">Whether or not to allow copying of the video stream url.</param> /// <param name="allowAudioStreamCopy">Whether or not to allow copying of the audio stream url.</param> @@ -902,7 +902,7 @@ public class DynamicHlsController : BaseJellyfinApiController /// <param name="cpuCoreLimit">Optional. The limit of how many cpu cores to use.</param> /// <param name="liveStreamId">The live stream id.</param> /// <param name="enableMpegtsM2TsMode">Optional. Whether to enable the MpegtsM2Ts mode.</param> - /// <param name="videoCodec">Optional. Specify a video codec to encode to, e.g. h264. If omitted the server will auto-select using the url's extension. Options: h265, h264, mpeg4, theora, vpx, wmv.</param> + /// <param name="videoCodec">Optional. Specify a video codec to encode to, e.g. h264.</param> /// <param name="subtitleCodec">Optional. Specify a subtitle codec to encode to.</param> /// <param name="transcodeReasons">Optional. The transcoding reason.</param> /// <param name="audioStreamIndex">Optional. The index of the audio stream to use. If omitted the first audio stream will be used.</param> @@ -1043,7 +1043,7 @@ public class DynamicHlsController : BaseJellyfinApiController /// <param name="minSegments">The minimum number of segments.</param> /// <param name="mediaSourceId">The media version id, if playing an alternate version.</param> /// <param name="deviceId">The device id of the client requesting. Used to stop encoding processes when needed.</param> - /// <param name="audioCodec">Optional. Specify a audio codec to encode to, e.g. mp3. If omitted the server will auto-select using the url's extension. Options: aac, mp3, vorbis, wma.</param> + /// <param name="audioCodec">Optional. Specify an audio codec to encode to, e.g. mp3.</param> /// <param name="enableAutoStreamCopy">Whether or not to allow automatic stream copy if requested values match the original source. Defaults to true.</param> /// <param name="allowVideoStreamCopy">Whether or not to allow copying of the video stream url.</param> /// <param name="allowAudioStreamCopy">Whether or not to allow copying of the audio stream url.</param> @@ -1075,7 +1075,7 @@ public class DynamicHlsController : BaseJellyfinApiController /// <param name="cpuCoreLimit">Optional. The limit of how many cpu cores to use.</param> /// <param name="liveStreamId">The live stream id.</param> /// <param name="enableMpegtsM2TsMode">Optional. Whether to enable the MpegtsM2Ts mode.</param> - /// <param name="videoCodec">Optional. Specify a video codec to encode to, e.g. h264. If omitted the server will auto-select using the url's extension. Options: h265, h264, mpeg4, theora, vp8, vp9, vpx (deprecated), wmv.</param> + /// <param name="videoCodec">Optional. Specify a video codec to encode to, e.g. h264.</param> /// <param name="subtitleCodec">Optional. Specify a subtitle codec to encode to.</param> /// <param name="transcodeReasons">Optional. The transcoding reason.</param> /// <param name="audioStreamIndex">Optional. The index of the audio stream to use. If omitted the first audio stream will be used.</param> @@ -1227,7 +1227,7 @@ public class DynamicHlsController : BaseJellyfinApiController /// <param name="minSegments">The minimum number of segments.</param> /// <param name="mediaSourceId">The media version id, if playing an alternate version.</param> /// <param name="deviceId">The device id of the client requesting. Used to stop encoding processes when needed.</param> - /// <param name="audioCodec">Optional. Specify a audio codec to encode to, e.g. mp3. If omitted the server will auto-select using the url's extension. Options: aac, mp3, vorbis, wma.</param> + /// <param name="audioCodec">Optional. Specify an audio codec to encode to, e.g. mp3.</param> /// <param name="enableAutoStreamCopy">Whether or not to allow automatic stream copy if requested values match the original source. Defaults to true.</param> /// <param name="allowVideoStreamCopy">Whether or not to allow copying of the video stream url.</param> /// <param name="allowAudioStreamCopy">Whether or not to allow copying of the audio stream url.</param> @@ -1258,7 +1258,7 @@ public class DynamicHlsController : BaseJellyfinApiController /// <param name="cpuCoreLimit">Optional. The limit of how many cpu cores to use.</param> /// <param name="liveStreamId">The live stream id.</param> /// <param name="enableMpegtsM2TsMode">Optional. Whether to enable the MpegtsM2Ts mode.</param> - /// <param name="videoCodec">Optional. Specify a video codec to encode to, e.g. h264. If omitted the server will auto-select using the url's extension. Options: h265, h264, mpeg4, theora, vpx, wmv.</param> + /// <param name="videoCodec">Optional. Specify a video codec to encode to, e.g. h264.</param> /// <param name="subtitleCodec">Optional. Specify a subtitle codec to encode to.</param> /// <param name="transcodeReasons">Optional. The transcoding reason.</param> /// <param name="audioStreamIndex">Optional. The index of the audio stream to use. If omitted the first audio stream will be used.</param> diff --git a/Jellyfin.Api/Controllers/MediaSegmentsController.cs b/Jellyfin.Api/Controllers/MediaSegmentsController.cs new file mode 100644 index 000000000..e97704d48 --- /dev/null +++ b/Jellyfin.Api/Controllers/MediaSegmentsController.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Threading.Tasks; +using Jellyfin.Api.Extensions; +using Jellyfin.Data.Enums; +using MediaBrowser.Controller; +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Library; +using MediaBrowser.Model.MediaSegments; +using MediaBrowser.Model.Querying; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace Jellyfin.Api.Controllers; + +/// <summary> +/// Media Segments api. +/// </summary> +[Authorize] +public class MediaSegmentsController : BaseJellyfinApiController +{ + private readonly IMediaSegmentManager _mediaSegmentManager; + private readonly ILibraryManager _libraryManager; + + /// <summary> + /// Initializes a new instance of the <see cref="MediaSegmentsController"/> class. + /// </summary> + /// <param name="mediaSegmentManager">MediaSegments Manager.</param> + /// <param name="libraryManager">The Library manager.</param> + public MediaSegmentsController(IMediaSegmentManager mediaSegmentManager, ILibraryManager libraryManager) + { + _mediaSegmentManager = mediaSegmentManager; + _libraryManager = libraryManager; + } + + /// <summary> + /// Gets all media segments based on an itemId. + /// </summary> + /// <param name="itemId">The ItemId.</param> + /// <param name="includeSegmentTypes">Optional filter of requested segment types.</param> + /// <returns>A list of media segment objects related to the requested itemId.</returns> + [HttpGet("{itemId}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task<ActionResult<QueryResult<MediaSegmentDto>>> GetSegmentsAsync( + [FromRoute, Required] Guid itemId, + [FromQuery] IEnumerable<MediaSegmentType>? includeSegmentTypes = null) + { + var item = _libraryManager.GetItemById<BaseItem>(itemId, User.GetUserId()); + if (item is null) + { + return NotFound(); + } + + var items = await _mediaSegmentManager.GetSegmentsAsync(item.Id, includeSegmentTypes).ConfigureAwait(false); + return Ok(new QueryResult<MediaSegmentDto>(items.ToArray())); + } +} diff --git a/Jellyfin.Api/Controllers/VideosController.cs b/Jellyfin.Api/Controllers/VideosController.cs index 7f9608378..effe7b021 100644 --- a/Jellyfin.Api/Controllers/VideosController.cs +++ b/Jellyfin.Api/Controllers/VideosController.cs @@ -267,7 +267,7 @@ public class VideosController : BaseJellyfinApiController /// <param name="minSegments">The minimum number of segments.</param> /// <param name="mediaSourceId">The media version id, if playing an alternate version.</param> /// <param name="deviceId">The device id of the client requesting. Used to stop encoding processes when needed.</param> - /// <param name="audioCodec">Optional. Specify a audio codec to encode to, e.g. mp3. If omitted the server will auto-select using the url's extension. Options: aac, mp3, vorbis, wma.</param> + /// <param name="audioCodec">Optional. Specify an audio codec to encode to, e.g. mp3. If omitted the server will auto-select using the url's extension.</param> /// <param name="enableAutoStreamCopy">Whether or not to allow automatic stream copy if requested values match the original source. Defaults to true.</param> /// <param name="allowVideoStreamCopy">Whether or not to allow copying of the video stream url.</param> /// <param name="allowAudioStreamCopy">Whether or not to allow copying of the audio stream url.</param> @@ -299,7 +299,7 @@ public class VideosController : BaseJellyfinApiController /// <param name="cpuCoreLimit">Optional. The limit of how many cpu cores to use.</param> /// <param name="liveStreamId">The live stream id.</param> /// <param name="enableMpegtsM2TsMode">Optional. Whether to enable the MpegtsM2Ts mode.</param> - /// <param name="videoCodec">Optional. Specify a video codec to encode to, e.g. h264. If omitted the server will auto-select using the url's extension. Options: h265, h264, mpeg4, theora, vp8, vp9, vpx (deprecated), wmv.</param> + /// <param name="videoCodec">Optional. Specify a video codec to encode to, e.g. h264. If omitted the server will auto-select using the url's extension.</param> /// <param name="subtitleCodec">Optional. Specify a subtitle codec to encode to.</param> /// <param name="transcodeReasons">Optional. The transcoding reason.</param> /// <param name="audioStreamIndex">Optional. The index of the audio stream to use. If omitted the first audio stream will be used.</param> @@ -508,7 +508,7 @@ public class VideosController : BaseJellyfinApiController /// <param name="minSegments">The minimum number of segments.</param> /// <param name="mediaSourceId">The media version id, if playing an alternate version.</param> /// <param name="deviceId">The device id of the client requesting. Used to stop encoding processes when needed.</param> - /// <param name="audioCodec">Optional. Specify a audio codec to encode to, e.g. mp3. If omitted the server will auto-select using the url's extension. Options: aac, mp3, vorbis, wma.</param> + /// <param name="audioCodec">Optional. Specify an audio codec to encode to, e.g. mp3. If omitted the server will auto-select using the url's extension.</param> /// <param name="enableAutoStreamCopy">Whether or not to allow automatic stream copy if requested values match the original source. Defaults to true.</param> /// <param name="allowVideoStreamCopy">Whether or not to allow copying of the video stream url.</param> /// <param name="allowAudioStreamCopy">Whether or not to allow copying of the audio stream url.</param> @@ -540,7 +540,7 @@ public class VideosController : BaseJellyfinApiController /// <param name="cpuCoreLimit">Optional. The limit of how many cpu cores to use.</param> /// <param name="liveStreamId">The live stream id.</param> /// <param name="enableMpegtsM2TsMode">Optional. Whether to enable the MpegtsM2Ts mode.</param> - /// <param name="videoCodec">Optional. Specify a video codec to encode to, e.g. h264. If omitted the server will auto-select using the url's extension. Options: h265, h264, mpeg4, theora, vp8, vp9, vpx (deprecated), wmv.</param> + /// <param name="videoCodec">Optional. Specify a video codec to encode to, e.g. h264. If omitted the server will auto-select using the url's extension.</param> /// <param name="subtitleCodec">Optional. Specify a subtitle codec to encode to.</param> /// <param name="transcodeReasons">Optional. The transcoding reason.</param> /// <param name="audioStreamIndex">Optional. The index of the audio stream to use. If omitted the first audio stream will be used.</param> diff --git a/Jellyfin.Data/Entities/MediaSegment.cs b/Jellyfin.Data/Entities/MediaSegment.cs new file mode 100644 index 000000000..90120d772 --- /dev/null +++ b/Jellyfin.Data/Entities/MediaSegment.cs @@ -0,0 +1,42 @@ +using System; +using System.ComponentModel.DataAnnotations.Schema; +using Jellyfin.Data.Enums; + +namespace Jellyfin.Data.Entities; + +/// <summary> +/// An entity representing the metadata for a group of trickplay tiles. +/// </summary> +public class MediaSegment +{ + /// <summary> + /// Gets or sets the id of the media segment. + /// </summary> + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public Guid Id { get; set; } + + /// <summary> + /// Gets or sets the id of the associated item. + /// </summary> + public Guid ItemId { get; set; } + + /// <summary> + /// Gets or sets the Type of content this segment defines. + /// </summary> + public MediaSegmentType Type { get; set; } + + /// <summary> + /// Gets or sets the end of the segment. + /// </summary> + public long EndTicks { get; set; } + + /// <summary> + /// Gets or sets the start of the segment. + /// </summary> + public long StartTicks { get; set; } + + /// <summary> + /// Gets or sets Id of the media segment provider this entry originates from. + /// </summary> + public required string SegmentProviderId { get; set; } +} diff --git a/Jellyfin.Data/Enums/MediaSegmentType.cs b/Jellyfin.Data/Enums/MediaSegmentType.cs new file mode 100644 index 000000000..458635450 --- /dev/null +++ b/Jellyfin.Data/Enums/MediaSegmentType.cs @@ -0,0 +1,39 @@ +using Jellyfin.Data.Entities; + +namespace Jellyfin.Data.Enums; + +/// <summary> +/// Defines the types of content an individual <see cref="MediaSegment"/> represents. +/// </summary> +public enum MediaSegmentType +{ + /// <summary> + /// Default media type or custom one. + /// </summary> + Unknown = 0, + + /// <summary> + /// Commercial. + /// </summary> + Commercial = 1, + + /// <summary> + /// Preview. + /// </summary> + Preview = 2, + + /// <summary> + /// Recap. + /// </summary> + Recap = 3, + + /// <summary> + /// Outro. + /// </summary> + Outro = 4, + + /// <summary> + /// Intro. + /// </summary> + Intro = 5 +} diff --git a/Jellyfin.Server.Implementations/Devices/DeviceManager.cs b/Jellyfin.Server.Implementations/Devices/DeviceManager.cs index d8d1b6fa8..d7a46e2d5 100644 --- a/Jellyfin.Server.Implementations/Devices/DeviceManager.cs +++ b/Jellyfin.Server.Implementations/Devices/DeviceManager.cs @@ -27,6 +27,8 @@ namespace Jellyfin.Server.Implementations.Devices private readonly IDbContextFactory<JellyfinDbContext> _dbProvider; private readonly IUserManager _userManager; private readonly ConcurrentDictionary<string, ClientCapabilities> _capabilitiesMap = new(); + private readonly ConcurrentDictionary<int, Device> _devices; + private readonly ConcurrentDictionary<string, DeviceOptions> _deviceOptions; /// <summary> /// Initializes a new instance of the <see cref="DeviceManager"/> class. @@ -37,6 +39,23 @@ namespace Jellyfin.Server.Implementations.Devices { _dbProvider = dbProvider; _userManager = userManager; + _devices = new ConcurrentDictionary<int, Device>(); + _deviceOptions = new ConcurrentDictionary<string, DeviceOptions>(); + + using var dbContext = _dbProvider.CreateDbContext(); + foreach (var device in dbContext.Devices + .OrderBy(d => d.Id) + .AsEnumerable()) + { + _devices.TryAdd(device.Id, device); + } + + foreach (var deviceOption in dbContext.DeviceOptions + .OrderBy(d => d.Id) + .AsEnumerable()) + { + _deviceOptions.TryAdd(deviceOption.DeviceId, deviceOption); + } } /// <inheritdoc /> @@ -66,6 +85,8 @@ namespace Jellyfin.Server.Implementations.Devices await dbContext.SaveChangesAsync().ConfigureAwait(false); } + _deviceOptions[deviceId] = deviceOptions; + DeviceOptionsUpdated?.Invoke(this, new GenericEventArgs<Tuple<string, DeviceOptions>>(new Tuple<string, DeviceOptions>(deviceId, deviceOptions))); } @@ -76,25 +97,17 @@ namespace Jellyfin.Server.Implementations.Devices await using (dbContext.ConfigureAwait(false)) { dbContext.Devices.Add(device); - await dbContext.SaveChangesAsync().ConfigureAwait(false); + _devices.TryAdd(device.Id, device); } return device; } /// <inheritdoc /> - public async Task<DeviceOptions> GetDeviceOptions(string deviceId) + public DeviceOptions GetDeviceOptions(string deviceId) { - var dbContext = await _dbProvider.CreateDbContextAsync().ConfigureAwait(false); - DeviceOptions? deviceOptions; - await using (dbContext.ConfigureAwait(false)) - { - deviceOptions = await dbContext.DeviceOptions - .AsNoTracking() - .FirstOrDefaultAsync(d => d.DeviceId == deviceId) - .ConfigureAwait(false); - } + _deviceOptions.TryGetValue(deviceId, out var deviceOptions); return deviceOptions ?? new DeviceOptions(deviceId); } @@ -108,57 +121,43 @@ namespace Jellyfin.Server.Implementations.Devices } /// <inheritdoc /> - public async Task<DeviceInfo?> GetDevice(string id) + public DeviceInfo? GetDevice(string id) { - var dbContext = await _dbProvider.CreateDbContextAsync().ConfigureAwait(false); - await using (dbContext.ConfigureAwait(false)) - { - var device = await dbContext.Devices - .Where(d => d.DeviceId == id) - .OrderByDescending(d => d.DateLastActivity) - .Include(d => d.User) - .SelectMany(d => dbContext.DeviceOptions.Where(o => o.DeviceId == d.DeviceId).DefaultIfEmpty(), (d, o) => new { Device = d, Options = o }) - .FirstOrDefaultAsync() - .ConfigureAwait(false); + var device = _devices.Values.Where(d => d.DeviceId == id).OrderByDescending(d => d.DateLastActivity).FirstOrDefault(); + _deviceOptions.TryGetValue(id, out var deviceOption); - var deviceInfo = device is null ? null : ToDeviceInfo(device.Device, device.Options); - - return deviceInfo; - } + var deviceInfo = device is null ? null : ToDeviceInfo(device, deviceOption); + return deviceInfo; } /// <inheritdoc /> - public async Task<QueryResult<Device>> GetDevices(DeviceQuery query) + public QueryResult<Device> GetDevices(DeviceQuery query) { - var dbContext = await _dbProvider.CreateDbContextAsync().ConfigureAwait(false); - await using (dbContext.ConfigureAwait(false)) + IEnumerable<Device> devices = _devices.Values + .Where(device => !query.UserId.HasValue || device.UserId.Equals(query.UserId.Value)) + .Where(device => query.DeviceId == null || device.DeviceId == query.DeviceId) + .Where(device => query.AccessToken == null || device.AccessToken == query.AccessToken) + .OrderBy(d => d.Id) + .ToList(); + var count = devices.Count(); + + if (query.Skip.HasValue) { - var devices = dbContext.Devices - .OrderBy(d => d.Id) - .Where(device => !query.UserId.HasValue || device.UserId.Equals(query.UserId.Value)) - .Where(device => query.DeviceId == null || device.DeviceId == query.DeviceId) - .Where(device => query.AccessToken == null || device.AccessToken == query.AccessToken); - - var count = await devices.CountAsync().ConfigureAwait(false); - - if (query.Skip.HasValue) - { - devices = devices.Skip(query.Skip.Value); - } - - if (query.Limit.HasValue) - { - devices = devices.Take(query.Limit.Value); - } + devices = devices.Skip(query.Skip.Value); + } - return new QueryResult<Device>(query.Skip, count, await devices.ToListAsync().ConfigureAwait(false)); + if (query.Limit.HasValue) + { + devices = devices.Take(query.Limit.Value); } + + return new QueryResult<Device>(query.Skip, count, devices.ToList()); } /// <inheritdoc /> - public async Task<QueryResult<DeviceInfo>> GetDeviceInfos(DeviceQuery query) + public QueryResult<DeviceInfo> GetDeviceInfos(DeviceQuery query) { - var devices = await GetDevices(query).ConfigureAwait(false); + var devices = GetDevices(query); return new QueryResult<DeviceInfo>( devices.StartIndex, @@ -167,38 +166,36 @@ namespace Jellyfin.Server.Implementations.Devices } /// <inheritdoc /> - public async Task<QueryResult<DeviceInfo>> GetDevicesForUser(Guid? userId) + public QueryResult<DeviceInfo> GetDevicesForUser(Guid? userId) { - var dbContext = await _dbProvider.CreateDbContextAsync().ConfigureAwait(false); - await using (dbContext.ConfigureAwait(false)) + IEnumerable<Device> devices = _devices.Values + .OrderByDescending(d => d.DateLastActivity) + .ThenBy(d => d.DeviceId); + + if (!userId.IsNullOrEmpty()) { - var sessions = dbContext.Devices - .Include(d => d.User) - .OrderByDescending(d => d.DateLastActivity) - .ThenBy(d => d.DeviceId) - .SelectMany(d => dbContext.DeviceOptions.Where(o => o.DeviceId == d.DeviceId).DefaultIfEmpty(), (d, o) => new { Device = d, Options = o }) - .AsAsyncEnumerable(); - - if (!userId.IsNullOrEmpty()) + var user = _userManager.GetUserById(userId.Value); + if (user is null) { - var user = _userManager.GetUserById(userId.Value); - if (user is null) - { - throw new ResourceNotFoundException(); - } - - sessions = sessions.Where(i => CanAccessDevice(user, i.Device.DeviceId)); + throw new ResourceNotFoundException(); } - var array = await sessions.Select(device => ToDeviceInfo(device.Device, device.Options)).ToArrayAsync().ConfigureAwait(false); - - return new QueryResult<DeviceInfo>(array); + devices = devices.Where(i => CanAccessDevice(user, i.DeviceId)); } + + var array = devices.Select(device => + { + _deviceOptions.TryGetValue(device.DeviceId, out var option); + return ToDeviceInfo(device, option); + }).ToArray(); + + return new QueryResult<DeviceInfo>(array); } /// <inheritdoc /> public async Task DeleteDevice(Device device) { + _devices.TryRemove(device.Id, out _); var dbContext = await _dbProvider.CreateDbContextAsync().ConfigureAwait(false); await using (dbContext.ConfigureAwait(false)) { @@ -208,6 +205,19 @@ namespace Jellyfin.Server.Implementations.Devices } /// <inheritdoc /> + public async Task UpdateDevice(Device device) + { + var dbContext = await _dbProvider.CreateDbContextAsync().ConfigureAwait(false); + await using (dbContext.ConfigureAwait(false)) + { + dbContext.Devices.Update(device); + await dbContext.SaveChangesAsync().ConfigureAwait(false); + } + + _devices[device.Id] = device; + } + + /// <inheritdoc /> public bool CanAccessDevice(User user, string deviceId) { ArgumentNullException.ThrowIfNull(user); @@ -225,6 +235,11 @@ namespace Jellyfin.Server.Implementations.Devices private DeviceInfo ToDeviceInfo(Device authInfo, DeviceOptions? options = null) { var caps = GetCapabilities(authInfo.DeviceId); + var user = _userManager.GetUserById(authInfo.UserId); + if (user is null) + { + throw new ResourceNotFoundException("User with UserId " + authInfo.UserId + " not found"); + } return new DeviceInfo { @@ -232,7 +247,7 @@ namespace Jellyfin.Server.Implementations.Devices AppVersion = authInfo.AppVersion, Id = authInfo.DeviceId, LastUserId = authInfo.UserId, - LastUserName = authInfo.User.Username, + LastUserName = user.Username, Name = authInfo.DeviceName, DateLastActivity = authInfo.DateLastActivity, IconUrl = caps.IconUrl, diff --git a/Jellyfin.Server.Implementations/Extensions/ServiceCollectionExtensions.cs b/Jellyfin.Server.Implementations/Extensions/ServiceCollectionExtensions.cs index a88989840..ff29d69b4 100644 --- a/Jellyfin.Server.Implementations/Extensions/ServiceCollectionExtensions.cs +++ b/Jellyfin.Server.Implementations/Extensions/ServiceCollectionExtensions.cs @@ -1,6 +1,5 @@ using System; using System.IO; -using EFCoreSecondLevelCacheInterceptor; using MediaBrowser.Common.Configuration; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; @@ -16,28 +15,13 @@ public static class ServiceCollectionExtensions /// Adds the <see cref="IDbContextFactory{TContext}"/> interface to the service collection with second level caching enabled. /// </summary> /// <param name="serviceCollection">An instance of the <see cref="IServiceCollection"/> interface.</param> - /// <param name="disableSecondLevelCache">Whether second level cache disabled..</param> /// <returns>The updated service collection.</returns> - public static IServiceCollection AddJellyfinDbContext(this IServiceCollection serviceCollection, bool disableSecondLevelCache) + public static IServiceCollection AddJellyfinDbContext(this IServiceCollection serviceCollection) { - if (!disableSecondLevelCache) - { - serviceCollection.AddEFSecondLevelCache(options => - options.UseMemoryCacheProvider() - .CacheAllQueries(CacheExpirationMode.Sliding, TimeSpan.FromMinutes(10)) - .UseCacheKeyPrefix("EF_") - // Don't cache null values. Remove this optional setting if it's not necessary. - .SkipCachingResults(result => result.Value is null or EFTableRows { RowsCount: 0 })); - } - serviceCollection.AddPooledDbContextFactory<JellyfinDbContext>((serviceProvider, opt) => { var applicationPaths = serviceProvider.GetRequiredService<IApplicationPaths>(); - var dbOpt = opt.UseSqlite($"Filename={Path.Combine(applicationPaths.DataPath, "jellyfin.db")}"); - if (!disableSecondLevelCache) - { - dbOpt.AddInterceptors(serviceProvider.GetRequiredService<SecondLevelCacheInterceptor>()); - } + opt.UseSqlite($"Filename={Path.Combine(applicationPaths.DataPath, "jellyfin.db")}"); }); return serviceCollection; diff --git a/Jellyfin.Server.Implementations/Jellyfin.Server.Implementations.csproj b/Jellyfin.Server.Implementations/Jellyfin.Server.Implementations.csproj index 7c4155bfc..20944ee4b 100644 --- a/Jellyfin.Server.Implementations/Jellyfin.Server.Implementations.csproj +++ b/Jellyfin.Server.Implementations/Jellyfin.Server.Implementations.csproj @@ -27,7 +27,6 @@ <ItemGroup> <PackageReference Include="AsyncKeyedLock" /> - <PackageReference Include="EFCoreSecondLevelCacheInterceptor" /> <PackageReference Include="System.Linq.Async" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Relational" /> diff --git a/Jellyfin.Server.Implementations/JellyfinDbContext.cs b/Jellyfin.Server.Implementations/JellyfinDbContext.cs index ea99af004..150bc8bb4 100644 --- a/Jellyfin.Server.Implementations/JellyfinDbContext.cs +++ b/Jellyfin.Server.Implementations/JellyfinDbContext.cs @@ -83,6 +83,11 @@ public class JellyfinDbContext : DbContext /// </summary> public DbSet<TrickplayInfo> TrickplayInfos => Set<TrickplayInfo>(); + /// <summary> + /// Gets the <see cref="DbSet{TEntity}"/> containing the media segments. + /// </summary> + public DbSet<MediaSegment> MediaSegments => Set<MediaSegment>(); + /*public DbSet<Artwork> Artwork => Set<Artwork>(); public DbSet<Book> Books => Set<Book>(); diff --git a/Jellyfin.Server.Implementations/MediaSegments/MediaSegmentManager.cs b/Jellyfin.Server.Implementations/MediaSegments/MediaSegmentManager.cs new file mode 100644 index 000000000..7916d15c9 --- /dev/null +++ b/Jellyfin.Server.Implementations/MediaSegments/MediaSegmentManager.cs @@ -0,0 +1,106 @@ +using System; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Linq; +using System.Threading.Tasks; +using Jellyfin.Data.Entities; +using Jellyfin.Data.Enums; +using MediaBrowser.Controller; +using MediaBrowser.Controller.Entities; +using MediaBrowser.Model.MediaSegments; +using Microsoft.EntityFrameworkCore; + +namespace Jellyfin.Server.Implementations.MediaSegments; + +/// <summary> +/// Manages media segments retrival and storage. +/// </summary> +public class MediaSegmentManager : IMediaSegmentManager +{ + private readonly IDbContextFactory<JellyfinDbContext> _dbProvider; + + /// <summary> + /// Initializes a new instance of the <see cref="MediaSegmentManager"/> class. + /// </summary> + /// <param name="dbProvider">EFCore Database factory.</param> + public MediaSegmentManager(IDbContextFactory<JellyfinDbContext> dbProvider) + { + _dbProvider = dbProvider; + } + + /// <inheritdoc /> + public async Task<MediaSegmentDto> CreateSegmentAsync(MediaSegmentDto mediaSegment, string segmentProviderId) + { + ArgumentOutOfRangeException.ThrowIfLessThan(mediaSegment.EndTicks, mediaSegment.StartTicks); + + using var db = await _dbProvider.CreateDbContextAsync().ConfigureAwait(false); + db.MediaSegments.Add(Map(mediaSegment, segmentProviderId)); + await db.SaveChangesAsync().ConfigureAwait(false); + return mediaSegment; + } + + /// <inheritdoc /> + public async Task DeleteSegmentAsync(Guid segmentId) + { + using var db = await _dbProvider.CreateDbContextAsync().ConfigureAwait(false); + await db.MediaSegments.Where(e => e.Id.Equals(segmentId)).ExecuteDeleteAsync().ConfigureAwait(false); + } + + /// <inheritdoc /> + public async Task<IEnumerable<MediaSegmentDto>> GetSegmentsAsync(Guid itemId, IEnumerable<MediaSegmentType>? typeFilter) + { + using var db = await _dbProvider.CreateDbContextAsync().ConfigureAwait(false); + + var query = db.MediaSegments + .Where(e => e.ItemId.Equals(itemId)); + + if (typeFilter is not null) + { + query = query.Where(e => typeFilter.Contains(e.Type)); + } + + return query + .OrderBy(e => e.StartTicks) + .AsNoTracking() + .ToImmutableList() + .Select(Map); + } + + private static MediaSegmentDto Map(MediaSegment segment) + { + return new MediaSegmentDto() + { + Id = segment.Id, + EndTicks = segment.EndTicks, + ItemId = segment.ItemId, + StartTicks = segment.StartTicks, + Type = segment.Type + }; + } + + private static MediaSegment Map(MediaSegmentDto segment, string segmentProviderId) + { + return new MediaSegment() + { + Id = segment.Id, + EndTicks = segment.EndTicks, + ItemId = segment.ItemId, + StartTicks = segment.StartTicks, + Type = segment.Type, + SegmentProviderId = segmentProviderId + }; + } + + /// <inheritdoc /> + public bool HasSegments(Guid itemId) + { + using var db = _dbProvider.CreateDbContext(); + return db.MediaSegments.Any(e => e.ItemId.Equals(itemId)); + } + + /// <inheritdoc/> + public bool IsTypeSupported(BaseItem baseItem) + { + return baseItem.MediaType is Data.Enums.MediaType.Video or Data.Enums.MediaType.Audio; + } +} diff --git a/Jellyfin.Server.Implementations/Migrations/20240729140605_AddMediaSegments.Designer.cs b/Jellyfin.Server.Implementations/Migrations/20240729140605_AddMediaSegments.Designer.cs new file mode 100644 index 000000000..c03cb4760 --- /dev/null +++ b/Jellyfin.Server.Implementations/Migrations/20240729140605_AddMediaSegments.Designer.cs @@ -0,0 +1,708 @@ +// <auto-generated /> +using System; +using Jellyfin.Server.Implementations; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Jellyfin.Server.Implementations.Migrations +{ + [DbContext(typeof(JellyfinDbContext))] + [Migration("20240729140605_AddMediaSegments")] + partial class AddMediaSegments + { + /// <inheritdoc /> + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "8.0.7"); + + modelBuilder.Entity("Jellyfin.Data.Entities.AccessSchedule", b => + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property<int>("DayOfWeek") + .HasColumnType("INTEGER"); + + b.Property<double>("EndHour") + .HasColumnType("REAL"); + + b.Property<double>("StartHour") + .HasColumnType("REAL"); + + b.Property<Guid>("UserId") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AccessSchedules"); + }); + + modelBuilder.Entity("Jellyfin.Data.Entities.ActivityLog", b => + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property<DateTime>("DateCreated") + .HasColumnType("TEXT"); + + b.Property<string>("ItemId") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property<int>("LogSeverity") + .HasColumnType("INTEGER"); + + b.Property<string>("Name") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("TEXT"); + + b.Property<string>("Overview") + .HasMaxLength(512) + .HasColumnType("TEXT"); + + b.Property<uint>("RowVersion") + .IsConcurrencyToken() + .HasColumnType("INTEGER"); + + b.Property<string>("ShortOverview") + .HasMaxLength(512) + .HasColumnType("TEXT"); + + b.Property<string>("Type") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property<Guid>("UserId") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("DateCreated"); + + b.ToTable("ActivityLogs"); + }); + + modelBuilder.Entity("Jellyfin.Data.Entities.CustomItemDisplayPreferences", b => + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property<string>("Client") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.Property<Guid>("ItemId") + .HasColumnType("TEXT"); + + b.Property<string>("Key") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property<Guid>("UserId") + .HasColumnType("TEXT"); + + b.Property<string>("Value") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("UserId", "ItemId", "Client", "Key") + .IsUnique(); + + b.ToTable("CustomItemDisplayPreferences"); + }); + + modelBuilder.Entity("Jellyfin.Data.Entities.DisplayPreferences", b => + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property<int>("ChromecastVersion") + .HasColumnType("INTEGER"); + + b.Property<string>("Client") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.Property<string>("DashboardTheme") + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.Property<bool>("EnableNextVideoInfoOverlay") + .HasColumnType("INTEGER"); + + b.Property<int?>("IndexBy") + .HasColumnType("INTEGER"); + + b.Property<Guid>("ItemId") + .HasColumnType("TEXT"); + + b.Property<int>("ScrollDirection") + .HasColumnType("INTEGER"); + + b.Property<bool>("ShowBackdrop") + .HasColumnType("INTEGER"); + + b.Property<bool>("ShowSidebar") + .HasColumnType("INTEGER"); + + b.Property<int>("SkipBackwardLength") + .HasColumnType("INTEGER"); + + b.Property<int>("SkipForwardLength") + .HasColumnType("INTEGER"); + + b.Property<string>("TvHome") + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.Property<Guid>("UserId") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("UserId", "ItemId", "Client") + .IsUnique(); + + b.ToTable("DisplayPreferences"); + }); + + modelBuilder.Entity("Jellyfin.Data.Entities.HomeSection", b => + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property<int>("DisplayPreferencesId") + .HasColumnType("INTEGER"); + + b.Property<int>("Order") + .HasColumnType("INTEGER"); + + b.Property<int>("Type") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("DisplayPreferencesId"); + + b.ToTable("HomeSection"); + }); + + modelBuilder.Entity("Jellyfin.Data.Entities.ImageInfo", b => + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property<DateTime>("LastModified") + .HasColumnType("TEXT"); + + b.Property<string>("Path") + .IsRequired() + .HasMaxLength(512) + .HasColumnType("TEXT"); + + b.Property<Guid?>("UserId") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("ImageInfos"); + }); + + modelBuilder.Entity("Jellyfin.Data.Entities.ItemDisplayPreferences", b => + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property<string>("Client") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.Property<int?>("IndexBy") + .HasColumnType("INTEGER"); + + b.Property<Guid>("ItemId") + .HasColumnType("TEXT"); + + b.Property<bool>("RememberIndexing") + .HasColumnType("INTEGER"); + + b.Property<bool>("RememberSorting") + .HasColumnType("INTEGER"); + + b.Property<string>("SortBy") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("TEXT"); + + b.Property<int>("SortOrder") + .HasColumnType("INTEGER"); + + b.Property<Guid>("UserId") + .HasColumnType("TEXT"); + + b.Property<int>("ViewType") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("ItemDisplayPreferences"); + }); + + modelBuilder.Entity("Jellyfin.Data.Entities.MediaSegment", b => + { + b.Property<Guid>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property<long>("EndTicks") + .HasColumnType("INTEGER"); + + b.Property<Guid>("ItemId") + .HasColumnType("TEXT"); + + b.Property<long>("StartTicks") + .HasColumnType("INTEGER"); + + b.Property<int>("Type") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.ToTable("MediaSegments"); + }); + + modelBuilder.Entity("Jellyfin.Data.Entities.Permission", b => + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property<int>("Kind") + .HasColumnType("INTEGER"); + + b.Property<Guid?>("Permission_Permissions_Guid") + .HasColumnType("TEXT"); + + b.Property<uint>("RowVersion") + .IsConcurrencyToken() + .HasColumnType("INTEGER"); + + b.Property<Guid?>("UserId") + .HasColumnType("TEXT"); + + b.Property<bool>("Value") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("UserId", "Kind") + .IsUnique() + .HasFilter("[UserId] IS NOT NULL"); + + b.ToTable("Permissions"); + }); + + modelBuilder.Entity("Jellyfin.Data.Entities.Preference", b => + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property<int>("Kind") + .HasColumnType("INTEGER"); + + b.Property<Guid?>("Preference_Preferences_Guid") + .HasColumnType("TEXT"); + + b.Property<uint>("RowVersion") + .IsConcurrencyToken() + .HasColumnType("INTEGER"); + + b.Property<Guid?>("UserId") + .HasColumnType("TEXT"); + + b.Property<string>("Value") + .IsRequired() + .HasMaxLength(65535) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("UserId", "Kind") + .IsUnique() + .HasFilter("[UserId] IS NOT NULL"); + + b.ToTable("Preferences"); + }); + + modelBuilder.Entity("Jellyfin.Data.Entities.Security.ApiKey", b => + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property<string>("AccessToken") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property<DateTime>("DateCreated") + .HasColumnType("TEXT"); + + b.Property<DateTime>("DateLastActivity") + .HasColumnType("TEXT"); + + b.Property<string>("Name") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("AccessToken") + .IsUnique(); + + b.ToTable("ApiKeys"); + }); + + modelBuilder.Entity("Jellyfin.Data.Entities.Security.Device", b => + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property<string>("AccessToken") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property<string>("AppName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("TEXT"); + + b.Property<string>("AppVersion") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.Property<DateTime>("DateCreated") + .HasColumnType("TEXT"); + + b.Property<DateTime>("DateLastActivity") + .HasColumnType("TEXT"); + + b.Property<DateTime>("DateModified") + .HasColumnType("TEXT"); + + b.Property<string>("DeviceId") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property<string>("DeviceName") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("TEXT"); + + b.Property<bool>("IsActive") + .HasColumnType("INTEGER"); + + b.Property<Guid>("UserId") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("DeviceId"); + + b.HasIndex("AccessToken", "DateLastActivity"); + + b.HasIndex("DeviceId", "DateLastActivity"); + + b.HasIndex("UserId", "DeviceId"); + + b.ToTable("Devices"); + }); + + modelBuilder.Entity("Jellyfin.Data.Entities.Security.DeviceOptions", b => + { + b.Property<int>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property<string>("CustomName") + .HasColumnType("TEXT"); + + b.Property<string>("DeviceId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("DeviceId") + .IsUnique(); + + b.ToTable("DeviceOptions"); + }); + + modelBuilder.Entity("Jellyfin.Data.Entities.TrickplayInfo", b => + { + b.Property<Guid>("ItemId") + .HasColumnType("TEXT"); + + b.Property<int>("Width") + .HasColumnType("INTEGER"); + + b.Property<int>("Bandwidth") + .HasColumnType("INTEGER"); + + b.Property<int>("Height") + .HasColumnType("INTEGER"); + + b.Property<int>("Interval") + .HasColumnType("INTEGER"); + + b.Property<int>("ThumbnailCount") + .HasColumnType("INTEGER"); + + b.Property<int>("TileHeight") + .HasColumnType("INTEGER"); + + b.Property<int>("TileWidth") + .HasColumnType("INTEGER"); + + b.HasKey("ItemId", "Width"); + + b.ToTable("TrickplayInfos"); + }); + + modelBuilder.Entity("Jellyfin.Data.Entities.User", b => + { + b.Property<Guid>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property<string>("AudioLanguagePreference") + .HasMaxLength(255) + .HasColumnType("TEXT"); + + b.Property<string>("AuthenticationProviderId") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("TEXT"); + + b.Property<string>("CastReceiverId") + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.Property<bool>("DisplayCollectionsView") + .HasColumnType("INTEGER"); + + b.Property<bool>("DisplayMissingEpisodes") + .HasColumnType("INTEGER"); + + b.Property<bool>("EnableAutoLogin") + .HasColumnType("INTEGER"); + + b.Property<bool>("EnableLocalPassword") + .HasColumnType("INTEGER"); + + b.Property<bool>("EnableNextEpisodeAutoPlay") + .HasColumnType("INTEGER"); + + b.Property<bool>("EnableUserPreferenceAccess") + .HasColumnType("INTEGER"); + + b.Property<bool>("HidePlayedInLatest") + .HasColumnType("INTEGER"); + + b.Property<long>("InternalId") + .HasColumnType("INTEGER"); + + b.Property<int>("InvalidLoginAttemptCount") + .HasColumnType("INTEGER"); + + b.Property<DateTime?>("LastActivityDate") + .HasColumnType("TEXT"); + + b.Property<DateTime?>("LastLoginDate") + .HasColumnType("TEXT"); + + b.Property<int?>("LoginAttemptsBeforeLockout") + .HasColumnType("INTEGER"); + + b.Property<int>("MaxActiveSessions") + .HasColumnType("INTEGER"); + + b.Property<int?>("MaxParentalAgeRating") + .HasColumnType("INTEGER"); + + b.Property<bool>("MustUpdatePassword") + .HasColumnType("INTEGER"); + + b.Property<string>("Password") + .HasMaxLength(65535) + .HasColumnType("TEXT"); + + b.Property<string>("PasswordResetProviderId") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("TEXT"); + + b.Property<bool>("PlayDefaultAudioTrack") + .HasColumnType("INTEGER"); + + b.Property<bool>("RememberAudioSelections") + .HasColumnType("INTEGER"); + + b.Property<bool>("RememberSubtitleSelections") + .HasColumnType("INTEGER"); + + b.Property<int?>("RemoteClientBitrateLimit") + .HasColumnType("INTEGER"); + + b.Property<uint>("RowVersion") + .IsConcurrencyToken() + .HasColumnType("INTEGER"); + + b.Property<string>("SubtitleLanguagePreference") + .HasMaxLength(255) + .HasColumnType("TEXT"); + + b.Property<int>("SubtitleMode") + .HasColumnType("INTEGER"); + + b.Property<int>("SyncPlayAccess") + .HasColumnType("INTEGER"); + + b.Property<string>("Username") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("TEXT") + .UseCollation("NOCASE"); + + b.HasKey("Id"); + + b.HasIndex("Username") + .IsUnique(); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("Jellyfin.Data.Entities.AccessSchedule", b => + { + b.HasOne("Jellyfin.Data.Entities.User", null) + .WithMany("AccessSchedules") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Jellyfin.Data.Entities.DisplayPreferences", b => + { + b.HasOne("Jellyfin.Data.Entities.User", null) + .WithMany("DisplayPreferences") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Jellyfin.Data.Entities.HomeSection", b => + { + b.HasOne("Jellyfin.Data.Entities.DisplayPreferences", null) + .WithMany("HomeSections") + .HasForeignKey("DisplayPreferencesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Jellyfin.Data.Entities.ImageInfo", b => + { + b.HasOne("Jellyfin.Data.Entities.User", null) + .WithOne("ProfileImage") + .HasForeignKey("Jellyfin.Data.Entities.ImageInfo", "UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Jellyfin.Data.Entities.ItemDisplayPreferences", b => + { + b.HasOne("Jellyfin.Data.Entities.User", null) + .WithMany("ItemDisplayPreferences") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Jellyfin.Data.Entities.Permission", b => + { + b.HasOne("Jellyfin.Data.Entities.User", null) + .WithMany("Permissions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Jellyfin.Data.Entities.Preference", b => + { + b.HasOne("Jellyfin.Data.Entities.User", null) + .WithMany("Preferences") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Jellyfin.Data.Entities.Security.Device", b => + { + b.HasOne("Jellyfin.Data.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Jellyfin.Data.Entities.DisplayPreferences", b => + { + b.Navigation("HomeSections"); + }); + + modelBuilder.Entity("Jellyfin.Data.Entities.User", b => + { + b.Navigation("AccessSchedules"); + + b.Navigation("DisplayPreferences"); + + b.Navigation("ItemDisplayPreferences"); + + b.Navigation("Permissions"); + + b.Navigation("Preferences"); + + b.Navigation("ProfileImage"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Jellyfin.Server.Implementations/Migrations/20240729140605_AddMediaSegments.cs b/Jellyfin.Server.Implementations/Migrations/20240729140605_AddMediaSegments.cs new file mode 100644 index 000000000..24a8ffc42 --- /dev/null +++ b/Jellyfin.Server.Implementations/Migrations/20240729140605_AddMediaSegments.cs @@ -0,0 +1,38 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Jellyfin.Server.Implementations.Migrations +{ + /// <inheritdoc /> + public partial class AddMediaSegments : Migration + { + /// <inheritdoc /> + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "MediaSegments", + columns: table => new + { + Id = table.Column<Guid>(type: "TEXT", nullable: false), + ItemId = table.Column<Guid>(type: "TEXT", nullable: false), + Type = table.Column<int>(type: "INTEGER", nullable: false), + EndTicks = table.Column<long>(type: "INTEGER", nullable: false), + StartTicks = table.Column<long>(type: "INTEGER", nullable: false), + SegmentProviderId = table.Column<string>(type: "TEXT", nullable: false), + }, + constraints: table => + { + table.PrimaryKey("PK_MediaSegments", x => x.Id); + }); + } + + /// <inheritdoc /> + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "MediaSegments"); + } + } +} diff --git a/Jellyfin.Server.Implementations/Migrations/JellyfinDbModelSnapshot.cs b/Jellyfin.Server.Implementations/Migrations/JellyfinDbModelSnapshot.cs index f725ababe..cdeeb6d87 100644 --- a/Jellyfin.Server.Implementations/Migrations/JellyfinDbModelSnapshot.cs +++ b/Jellyfin.Server.Implementations/Migrations/JellyfinDbModelSnapshot.cs @@ -1,4 +1,4 @@ -// <auto-generated /> +// <auto-generated /> using System; using Jellyfin.Server.Implementations; using Microsoft.EntityFrameworkCore; @@ -15,7 +15,7 @@ namespace Jellyfin.Server.Implementations.Migrations protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.11"); + modelBuilder.HasAnnotation("ProductVersion", "8.0.7"); modelBuilder.Entity("Jellyfin.Data.Entities.AccessSchedule", b => { @@ -270,6 +270,32 @@ namespace Jellyfin.Server.Implementations.Migrations b.ToTable("ItemDisplayPreferences"); }); + modelBuilder.Entity("Jellyfin.Data.Entities.MediaSegment", b => + { + b.Property<Guid>("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property<long>("EndTicks") + .HasColumnType("INTEGER"); + + b.Property<Guid>("ItemId") + .HasColumnType("TEXT"); + + b.Property<long>("StartTicks") + .HasColumnType("INTEGER"); + + b.Property<int>("Type") + .HasColumnType("INTEGER"); + + b.Property<string>("SegmentProviderId") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("MediaSegments"); + }); + modelBuilder.Entity("Jellyfin.Data.Entities.Permission", b => { b.Property<int>("Id") diff --git a/Jellyfin.Server.Implementations/Security/AuthorizationContext.cs b/Jellyfin.Server.Implementations/Security/AuthorizationContext.cs index 6bda12c5b..2ae722982 100644 --- a/Jellyfin.Server.Implementations/Security/AuthorizationContext.cs +++ b/Jellyfin.Server.Implementations/Security/AuthorizationContext.cs @@ -4,7 +4,10 @@ using System; using System.Collections.Generic; using System.Net; using System.Threading.Tasks; +using Jellyfin.Data.Queries; +using Jellyfin.Extensions; using MediaBrowser.Controller; +using MediaBrowser.Controller.Devices; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Net; using Microsoft.AspNetCore.Http; @@ -17,15 +20,18 @@ namespace Jellyfin.Server.Implementations.Security { private readonly IDbContextFactory<JellyfinDbContext> _jellyfinDbProvider; private readonly IUserManager _userManager; + private readonly IDeviceManager _deviceManager; private readonly IServerApplicationHost _serverApplicationHost; public AuthorizationContext( IDbContextFactory<JellyfinDbContext> jellyfinDb, IUserManager userManager, + IDeviceManager deviceManager, IServerApplicationHost serverApplicationHost) { _jellyfinDbProvider = jellyfinDb; _userManager = userManager; + _deviceManager = deviceManager; _serverApplicationHost = serverApplicationHost; } @@ -121,7 +127,11 @@ namespace Jellyfin.Server.Implementations.Security var dbContext = await _jellyfinDbProvider.CreateDbContextAsync().ConfigureAwait(false); await using (dbContext.ConfigureAwait(false)) { - var device = await dbContext.Devices.FirstOrDefaultAsync(d => d.AccessToken == token).ConfigureAwait(false); + var device = _deviceManager.GetDevices( + new DeviceQuery + { + AccessToken = token + }).Items.FirstOrDefault(); if (device is not null) { @@ -178,8 +188,7 @@ namespace Jellyfin.Server.Implementations.Security if (updateToken) { - dbContext.Devices.Update(device); - await dbContext.SaveChangesAsync().ConfigureAwait(false); + await _deviceManager.UpdateDevice(device).ConfigureAwait(false); } } else diff --git a/Jellyfin.Server.Implementations/Users/DeviceAccessHost.cs b/Jellyfin.Server.Implementations/Users/DeviceAccessHost.cs index e40b541a3..634aea9f0 100644 --- a/Jellyfin.Server.Implementations/Users/DeviceAccessHost.cs +++ b/Jellyfin.Server.Implementations/Users/DeviceAccessHost.cs @@ -60,10 +60,10 @@ public sealed class DeviceAccessHost : IHostedService private async Task UpdateDeviceAccess(User user) { - var existing = (await _deviceManager.GetDevices(new DeviceQuery + var existing = _deviceManager.GetDevices(new DeviceQuery { UserId = user.Id - }).ConfigureAwait(false)).Items; + }).Items; foreach (var device in existing) { diff --git a/Jellyfin.Server/Extensions/WebHostBuilderExtensions.cs b/Jellyfin.Server/Extensions/WebHostBuilderExtensions.cs index 858df6728..6b95770ed 100644 --- a/Jellyfin.Server/Extensions/WebHostBuilderExtensions.cs +++ b/Jellyfin.Server/Extensions/WebHostBuilderExtensions.cs @@ -85,6 +85,6 @@ public static class WebHostBuilderExtensions logger.LogInformation("Kestrel listening to unix socket {SocketPath}", socketPath); } }) - .UseStartup(_ => new Startup(appHost, startupConfig)); + .UseStartup(_ => new Startup(appHost)); } } diff --git a/Jellyfin.Server/Startup.cs b/Jellyfin.Server/Startup.cs index 2ff377403..e9fb3e4c2 100644 --- a/Jellyfin.Server/Startup.cs +++ b/Jellyfin.Server/Startup.cs @@ -40,18 +40,15 @@ namespace Jellyfin.Server { private readonly CoreAppHost _serverApplicationHost; private readonly IServerConfigurationManager _serverConfigurationManager; - private readonly IConfiguration _startupConfig; /// <summary> /// Initializes a new instance of the <see cref="Startup" /> class. /// </summary> /// <param name="appHost">The server application host.</param> - /// <param name="startupConfig">The server startupConfig.</param> - public Startup(CoreAppHost appHost, IConfiguration startupConfig) + public Startup(CoreAppHost appHost) { _serverApplicationHost = appHost; _serverConfigurationManager = appHost.ConfigurationManager; - _startupConfig = startupConfig; } /// <summary> @@ -70,7 +67,7 @@ namespace Jellyfin.Server // TODO remove once this is fixed upstream https://github.com/dotnet/aspnetcore/issues/34371 services.AddSingleton<IActionResultExecutor<PhysicalFileResult>, SymlinkFollowingPhysicalFileResultExecutor>(); services.AddJellyfinApi(_serverApplicationHost.GetApiPluginAssemblies(), _serverConfigurationManager.GetNetworkConfiguration()); - services.AddJellyfinDbContext(_startupConfig.GetSqliteSecondLevelCacheDisabled()); + services.AddJellyfinDbContext(); services.AddJellyfinApiSwagger(); // configure custom legacy authentication diff --git a/MediaBrowser.Controller/Devices/IDeviceManager.cs b/MediaBrowser.Controller/Devices/IDeviceManager.cs index eb181dcc4..5566421cb 100644 --- a/MediaBrowser.Controller/Devices/IDeviceManager.cs +++ b/MediaBrowser.Controller/Devices/IDeviceManager.cs @@ -44,26 +44,28 @@ namespace MediaBrowser.Controller.Devices /// </summary> /// <param name="id">The identifier.</param> /// <returns>DeviceInfo.</returns> - Task<DeviceInfo> GetDevice(string id); + DeviceInfo GetDevice(string id); /// <summary> /// Gets devices based on the provided query. /// </summary> /// <param name="query">The device query.</param> /// <returns>A <see cref="Task{QueryResult}"/> representing the retrieval of the devices.</returns> - Task<QueryResult<Device>> GetDevices(DeviceQuery query); + QueryResult<Device> GetDevices(DeviceQuery query); - Task<QueryResult<DeviceInfo>> GetDeviceInfos(DeviceQuery query); + QueryResult<DeviceInfo> GetDeviceInfos(DeviceQuery query); /// <summary> /// Gets the devices. /// </summary> /// <param name="userId">The user's id, or <c>null</c>.</param> /// <returns>IEnumerable<DeviceInfo>.</returns> - Task<QueryResult<DeviceInfo>> GetDevicesForUser(Guid? userId); + QueryResult<DeviceInfo> GetDevicesForUser(Guid? userId); Task DeleteDevice(Device device); + Task UpdateDevice(Device device); + /// <summary> /// Determines whether this instance [can access device] the specified user identifier. /// </summary> @@ -74,6 +76,6 @@ namespace MediaBrowser.Controller.Devices Task UpdateDeviceOptions(string deviceId, string deviceName); - Task<DeviceOptions> GetDeviceOptions(string deviceId); + DeviceOptions GetDeviceOptions(string deviceId); } } diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 7b6f364f7..4d0e88a22 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/Extensions/ConfigurationExtensions.cs b/MediaBrowser.Controller/Extensions/ConfigurationExtensions.cs index 7dfda73bf..6c58064ce 100644 --- a/MediaBrowser.Controller/Extensions/ConfigurationExtensions.cs +++ b/MediaBrowser.Controller/Extensions/ConfigurationExtensions.cs @@ -65,11 +65,6 @@ namespace MediaBrowser.Controller.Extensions public const string SqliteCacheSizeKey = "sqlite:cacheSize"; /// <summary> - /// Disable second level cache of sqlite. - /// </summary> - public const string SqliteDisableSecondLevelCacheKey = "sqlite:disableSecondLevelCache"; - - /// <summary> /// Gets a value indicating whether the application should host static web content from the <see cref="IConfiguration"/>. /// </summary> /// <param name="configuration">The configuration to retrieve the value from.</param> @@ -133,15 +128,5 @@ namespace MediaBrowser.Controller.Extensions /// <returns>The sqlite cache size.</returns> public static int? GetSqliteCacheSize(this IConfiguration configuration) => configuration.GetValue<int?>(SqliteCacheSizeKey); - - /// <summary> - /// Gets whether second level cache disabled from the <see cref="IConfiguration" />. - /// </summary> - /// <param name="configuration">The configuration to read the setting from.</param> - /// <returns>Whether second level cache disabled.</returns> - public static bool GetSqliteSecondLevelCacheDisabled(this IConfiguration configuration) - { - return configuration.GetValue<bool>(SqliteDisableSecondLevelCacheKey); - } } } diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index 2c3d44bf8..12d15d9fd 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -64,6 +64,7 @@ namespace MediaBrowser.Controller.MediaEncoding private readonly Version _minFFmpegSvtAv1Params = new Version(5, 1); private readonly Version _minFFmpegVaapiH26xEncA53CcSei = new Version(6, 0); private readonly Version _minFFmpegReadrateOption = new Version(5, 0); + private readonly Version _minFFmpegWorkingVtHwSurface = new Version(7, 0, 1); private static readonly Regex _validationRegex = new(ValidationRegex, RegexOptions.Compiled); @@ -106,7 +107,6 @@ namespace MediaBrowser.Controller.MediaEncoding // AAC, FLAC, ALAC, libopus, libvorbis encoders all support at least 8 channels private static readonly Dictionary<string, int> _audioTranscodeChannelLookup = new(StringComparer.OrdinalIgnoreCase) { - { "wmav2", 2 }, { "libmp3lame", 2 }, { "libfdk_aac", 6 }, { "ac3", 6 }, @@ -399,27 +399,6 @@ namespace MediaBrowser.Controller.MediaEncoding return GetMjpegEncoder(state, encodingOptions); } - if (string.Equals(codec, "vp8", StringComparison.OrdinalIgnoreCase) - || string.Equals(codec, "vpx", StringComparison.OrdinalIgnoreCase)) - { - return "libvpx"; - } - - if (string.Equals(codec, "vp9", StringComparison.OrdinalIgnoreCase)) - { - return "libvpx-vp9"; - } - - if (string.Equals(codec, "wmv", StringComparison.OrdinalIgnoreCase)) - { - return "wmv2"; - } - - if (string.Equals(codec, "theora", StringComparison.OrdinalIgnoreCase)) - { - return "libtheora"; - } - if (_validationRegex.IsMatch(codec)) { return codec.ToLowerInvariant(); @@ -739,11 +718,6 @@ namespace MediaBrowser.Controller.MediaEncoding return "libvorbis"; } - if (string.Equals(codec, "wma", StringComparison.OrdinalIgnoreCase)) - { - return "wmav2"; - } - if (string.Equals(codec, "opus", StringComparison.OrdinalIgnoreCase)) { return "libopus"; @@ -1373,20 +1347,6 @@ namespace MediaBrowser.Controller.MediaEncoding // Currently use the same buffer size for all encoders int bufsize = bitrate * 2; - if (string.Equals(videoCodec, "libvpx", StringComparison.OrdinalIgnoreCase) - || string.Equals(videoCodec, "libvpx-vp9", StringComparison.OrdinalIgnoreCase)) - { - // When crf is used with vpx, b:v becomes a max rate - // https://trac.ffmpeg.org/wiki/Encode/VP8 - // https://trac.ffmpeg.org/wiki/Encode/VP9 - return FormattableString.Invariant($" -maxrate:v {bitrate} -bufsize:v {bufsize} -b:v {bitrate}"); - } - - if (string.Equals(videoCodec, "msmpeg4", StringComparison.OrdinalIgnoreCase)) - { - return FormattableString.Invariant($" -b:v {bitrate}"); - } - if (string.Equals(videoCodec, "libsvtav1", StringComparison.OrdinalIgnoreCase)) { return FormattableString.Invariant($" -b:v {bitrate} -bufsize {bufsize}"); @@ -1922,93 +1882,6 @@ namespace MediaBrowser.Controller.MediaEncoding break; } } - else if (string.Equals(videoEncoder, "libvpx", StringComparison.OrdinalIgnoreCase)) // vp8 - { - // Values 0-3, 0 being highest quality but slower - var profileScore = 0; - - var qmin = "0"; - var qmax = "50"; - var crf = "10"; - - if (isVc1) - { - profileScore++; - } - - // Max of 2 - profileScore = Math.Min(profileScore, 2); - - // http://www.webmproject.org/docs/encoder-parameters/ - param += string.Format( - CultureInfo.InvariantCulture, - " -speed 16 -quality good -profile:v {0} -slices 8 -crf {1} -qmin {2} -qmax {3}", - profileScore.ToString(CultureInfo.InvariantCulture), - crf, - qmin, - qmax); - } - else if (string.Equals(videoEncoder, "libvpx-vp9", StringComparison.OrdinalIgnoreCase)) // vp9 - { - // When `-deadline` is set to `good` or `best`, `-cpu-used` ranges from 0-5. - // When `-deadline` is set to `realtime`, `-cpu-used` ranges from 0-15. - // Resources: - // * https://trac.ffmpeg.org/wiki/Encode/VP9 - // * https://superuser.com/questions/1586934 - // * https://developers.google.com/media/vp9 - param += encodingOptions.EncoderPreset switch - { - "veryslow" => " -deadline best -cpu-used 0", - "slower" => " -deadline best -cpu-used 2", - "slow" => " -deadline best -cpu-used 3", - "medium" => " -deadline good -cpu-used 0", - "fast" => " -deadline good -cpu-used 1", - "faster" => " -deadline good -cpu-used 2", - "veryfast" => " -deadline good -cpu-used 3", - "superfast" => " -deadline good -cpu-used 4", - "ultrafast" => " -deadline good -cpu-used 5", - _ => " -deadline good -cpu-used 1" - }; - - // TODO: until VP9 gets its own CRF setting, base CRF on H.265. - int h265Crf = encodingOptions.H265Crf; - int defaultVp9Crf = 31; - if (h265Crf >= 0 && h265Crf <= 51) - { - // This conversion factor is chosen to match the default CRF for H.265 to the - // recommended 1080p CRF from Google. The factor also maps the logarithmic CRF - // scale of x265 [0, 51] to that of VP9 [0, 63] relatively well. - - // Resources: - // * https://developers.google.com/media/vp9/settings/vod - const float H265ToVp9CrfConversionFactor = 1.12F; - - var vp9Crf = Convert.ToInt32(h265Crf * H265ToVp9CrfConversionFactor); - - // Encoder allows for CRF values in the range [0, 63]. - vp9Crf = Math.Clamp(vp9Crf, 0, 63); - - param += FormattableString.Invariant($" -crf {vp9Crf}"); - } - else - { - param += FormattableString.Invariant($" -crf {defaultVp9Crf}"); - } - - param += " -row-mt 1 -profile 1"; - } - else if (string.Equals(videoEncoder, "mpeg4", StringComparison.OrdinalIgnoreCase)) - { - param += " -mbd rd -flags +mv4+aic -trellis 2 -cmp 2 -subcmp 2 -bf 2"; - } - else if (string.Equals(videoEncoder, "wmv2", StringComparison.OrdinalIgnoreCase)) // asf/wmv - { - param += " -qmin 2"; - } - else if (string.Equals(videoEncoder, "msmpeg4", StringComparison.OrdinalIgnoreCase)) - { - param += " -mbd 2"; - } param += GetVideoBitrateParam(state, videoEncoder); @@ -5166,12 +5039,14 @@ namespace MediaBrowser.Controller.MediaEncoding var threeDFormat = state.MediaSource.Video3DFormat; var isVtEncoder = vidEncoder.Contains("videotoolbox", StringComparison.OrdinalIgnoreCase); + var isVtDecoder = vidDecoder.Contains("videotoolbox", StringComparison.OrdinalIgnoreCase); var doDeintH264 = state.DeInterlace("h264", true) || state.DeInterlace("avc", true); var doDeintHevc = state.DeInterlace("h265", true) || state.DeInterlace("hevc", true); var doDeintH2645 = doDeintH264 || doDeintHevc; var doVtTonemap = IsVideoToolboxTonemapAvailable(state, options); var doMetalTonemap = !doVtTonemap && IsHwTonemapAvailable(state, options); + var usingHwSurface = isVtDecoder && (_mediaEncoder.EncoderVersion >= _minFFmpegWorkingVtHwSurface); var scaleFormat = string.Empty; // Use P010 for Metal tone mapping, otherwise force an 8bit output. @@ -5259,23 +5134,25 @@ namespace MediaBrowser.Controller.MediaEncoding subFilters.Add(subTextSubtitlesFilter); } - subFilters.Add("hwupload=derive_device=videotoolbox"); + subFilters.Add("hwupload"); overlayFilters.Add("overlay_videotoolbox=eof_action=pass:repeatlast=0"); } + if (usingHwSurface) + { + return (mainFilters, subFilters, overlayFilters); + } + + // For old jellyfin-ffmpeg that has broken hwsurface, add a hwupload var needFiltering = mainFilters.Any(f => !string.IsNullOrEmpty(f)) || subFilters.Any(f => !string.IsNullOrEmpty(f)) || overlayFilters.Any(f => !string.IsNullOrEmpty(f)); - - // This is a workaround for ffmpeg's hwupload implementation - // For VideoToolbox encoders, a hwupload without a valid filter actually consuming its frame - // will cause the encoder to produce incorrect frames. if (needFiltering) { // INPUT videotoolbox/memory surface(vram/uma) // this will pass-through automatically if in/out format matches. + mainFilters.Insert(0, "hwupload"); mainFilters.Insert(0, "format=nv12|p010le|videotoolbox_vld"); - mainFilters.Insert(0, "hwupload=derive_device=videotoolbox"); } return (mainFilters, subFilters, overlayFilters); @@ -6283,36 +6160,34 @@ namespace MediaBrowser.Controller.MediaEncoding || string.Equals("yuvj420p", videoStream.PixelFormat, StringComparison.OrdinalIgnoreCase); var is8_10bitSwFormatsVt = is8bitSwFormatsVt || string.Equals("yuv420p10le", videoStream.PixelFormat, StringComparison.OrdinalIgnoreCase); - // VideoToolbox's Hardware surface in ffmpeg is not only slower than hwupload, but also breaks HDR in many cases. - // For example: https://trac.ffmpeg.org/ticket/10884 - // Disable it for now. - const bool UseHwSurface = false; + // The related patches make videotoolbox hardware surface working is only available in jellyfin-ffmpeg 7.0.1 at the moment. + bool useHwSurface = (_mediaEncoder.EncoderVersion >= _minFFmpegWorkingVtHwSurface) && IsVideoToolboxFullSupported(); if (is8bitSwFormatsVt) { - if (string.Equals("avc", videoStream.Codec, StringComparison.OrdinalIgnoreCase) - || string.Equals("h264", videoStream.Codec, StringComparison.OrdinalIgnoreCase)) - { - return GetHwaccelType(state, options, "h264", bitDepth, UseHwSurface); - } - if (string.Equals("vp8", videoStream.Codec, StringComparison.OrdinalIgnoreCase)) { - return GetHwaccelType(state, options, "vp8", bitDepth, UseHwSurface); + return GetHwaccelType(state, options, "vp8", bitDepth, useHwSurface); } } if (is8_10bitSwFormatsVt) { + if (string.Equals("avc", videoStream.Codec, StringComparison.OrdinalIgnoreCase) + || string.Equals("h264", videoStream.Codec, StringComparison.OrdinalIgnoreCase)) + { + return GetHwaccelType(state, options, "h264", bitDepth, useHwSurface); + } + if (string.Equals("hevc", videoStream.Codec, StringComparison.OrdinalIgnoreCase) || string.Equals("h265", videoStream.Codec, StringComparison.OrdinalIgnoreCase)) { - return GetHwaccelType(state, options, "hevc", bitDepth, UseHwSurface); + return GetHwaccelType(state, options, "hevc", bitDepth, useHwSurface); } if (string.Equals("vp9", videoStream.Codec, StringComparison.OrdinalIgnoreCase)) { - return GetHwaccelType(state, options, "vp9", bitDepth, UseHwSurface); + return GetHwaccelType(state, options, "vp9", bitDepth, useHwSurface); } } @@ -6425,24 +6300,15 @@ namespace MediaBrowser.Controller.MediaEncoding #nullable enable public static int GetNumberOfThreads(EncodingJobInfo? state, EncodingOptions encodingOptions, string? outputVideoCodec) { - // VP8 and VP9 encoders must have their thread counts set. - bool mustSetThreadCount = string.Equals(outputVideoCodec, "libvpx", StringComparison.OrdinalIgnoreCase) - || string.Equals(outputVideoCodec, "libvpx-vp9", StringComparison.OrdinalIgnoreCase); - var threads = state?.BaseRequest.CpuCoreLimit ?? encodingOptions.EncodingThreadCount; if (threads <= 0) { // Automatically set thread count - return mustSetThreadCount ? Math.Max(Environment.ProcessorCount - 1, 1) : 0; - } - - if (threads >= Environment.ProcessorCount) - { - return Environment.ProcessorCount; + return 0; } - return threads; + return Math.Min(threads, Environment.ProcessorCount); } #nullable disable diff --git a/MediaBrowser.Controller/MediaSegements/IMediaSegmentManager.cs b/MediaBrowser.Controller/MediaSegements/IMediaSegmentManager.cs new file mode 100644 index 000000000..4fcf084e1 --- /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); +} diff --git a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs index a865b0e4c..20a47da10 100644 --- a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs +++ b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs @@ -62,10 +62,6 @@ namespace MediaBrowser.MediaEncoding.Encoder "libx264", "libx265", "libsvtav1", - "mpeg4", - "msmpeg4", - "libvpx", - "libvpx-vp9", "aac", "aac_at", "libfdk_aac", @@ -171,6 +167,8 @@ namespace MediaBrowser.MediaEncoding.Encoder private readonly string _encoderPath; + private readonly Version _minFFmpegMultiThreadedCli = new Version(7, 0); + public EncoderValidator(ILogger logger, string encoderPath) { _logger = logger; @@ -480,7 +478,7 @@ namespace MediaBrowser.MediaEncoding.Encoder return false; } - public bool CheckSupportedRuntimeKey(string keyDesc) + public bool CheckSupportedRuntimeKey(string keyDesc, Version? ffmpegVersion) { if (string.IsNullOrEmpty(keyDesc)) { @@ -490,7 +488,9 @@ namespace MediaBrowser.MediaEncoding.Encoder string output; try { - output = GetProcessOutput(_encoderPath, "-hide_banner -f lavfi -i nullsrc=s=1x1:d=500 -f null -", true, "?"); + // With multi-threaded cli support, FFmpeg 7 is less sensitive to keyboard input + var duration = ffmpegVersion >= _minFFmpegMultiThreadedCli ? 10000 : 1000; + output = GetProcessOutput(_encoderPath, $"-hide_banner -f lavfi -i nullsrc=s=1x1:d={duration} -f null -", true, "?"); } catch (Exception ex) { diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs index 5cfead502..e8461e77f 100644 --- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs @@ -194,7 +194,7 @@ namespace MediaBrowser.MediaEncoding.Encoder _threads = EncodingHelper.GetNumberOfThreads(null, options, null); - _isPkeyPauseSupported = validator.CheckSupportedRuntimeKey("p pause transcoding"); + _isPkeyPauseSupported = validator.CheckSupportedRuntimeKey("p pause transcoding", _ffmpegVersion); _isLowPriorityHwDecodeSupported = validator.CheckSupportedHwaccelFlag("low_priority"); // Check the Vaapi device vendor diff --git a/MediaBrowser.MediaEncoding/Transcoding/TranscodeManager.cs b/MediaBrowser.MediaEncoding/Transcoding/TranscodeManager.cs index 67a2dddb8..42f355b05 100644 --- a/MediaBrowser.MediaEncoding/Transcoding/TranscodeManager.cs +++ b/MediaBrowser.MediaEncoding/Transcoding/TranscodeManager.cs @@ -51,6 +51,8 @@ public sealed class TranscodeManager : ITranscodeManager, IDisposable o.PoolInitialFill = 1; }); + private readonly Version _maxFFmpegCkeyPauseSupported = new Version(6, 1); + /// <summary> /// Initializes a new instance of the <see cref="TranscodeManager"/> class. /// </summary> @@ -555,7 +557,9 @@ public sealed class TranscodeManager : ITranscodeManager, IDisposable private void StartThrottler(StreamState state, TranscodingJob transcodingJob) { - if (EnableThrottling(state)) + if (EnableThrottling(state) + && (_mediaEncoder.IsPkeyPauseSupported + || _mediaEncoder.EncoderVersion <= _maxFFmpegCkeyPauseSupported)) { transcodingJob.TranscodingThrottler = new TranscodingThrottler(transcodingJob, _loggerFactory.CreateLogger<TranscodingThrottler>(), _serverConfigurationManager, _fileSystem, _mediaEncoder); transcodingJob.TranscodingThrottler.Start(); diff --git a/MediaBrowser.Model/Dto/MediaSourceInfo.cs b/MediaBrowser.Model/Dto/MediaSourceInfo.cs index b7236b1e8..1c6037325 100644 --- a/MediaBrowser.Model/Dto/MediaSourceInfo.cs +++ b/MediaBrowser.Model/Dto/MediaSourceInfo.cs @@ -117,6 +117,8 @@ namespace MediaBrowser.Model.Dto public int? DefaultSubtitleStreamIndex { get; set; } + public bool HasSegments { get; set; } + [JsonIgnore] public MediaStream VideoStream { diff --git a/MediaBrowser.Model/MediaSegments/MediaSegmentDto.cs b/MediaBrowser.Model/MediaSegments/MediaSegmentDto.cs new file mode 100644 index 000000000..a0433fee1 --- /dev/null +++ b/MediaBrowser.Model/MediaSegments/MediaSegmentDto.cs @@ -0,0 +1,35 @@ +using System; +using Jellyfin.Data.Enums; + +namespace MediaBrowser.Model.MediaSegments; + +/// <summary> +/// Api model for MediaSegment's. +/// </summary> +public class MediaSegmentDto +{ + /// <summary> + /// Gets or sets the id of the media segment. + /// </summary> + public Guid Id { get; set; } + + /// <summary> + /// Gets or sets the id of the associated item. + /// </summary> + public Guid ItemId { get; set; } + + /// <summary> + /// Gets or sets the type of content this segment defines. + /// </summary> + public MediaSegmentType Type { get; set; } + + /// <summary> + /// Gets or sets the start of the segment. + /// </summary> + public long StartTicks { get; set; } + + /// <summary> + /// Gets or sets the end of the segment. + /// </summary> + public long EndTicks { get; set; } +} diff --git a/MediaBrowser.Providers/TV/SeriesMetadataService.cs b/MediaBrowser.Providers/TV/SeriesMetadataService.cs index b03d6ffb5..5ede023f1 100644 --- a/MediaBrowser.Providers/TV/SeriesMetadataService.cs +++ b/MediaBrowser.Providers/TV/SeriesMetadataService.cs @@ -61,8 +61,8 @@ namespace MediaBrowser.Providers.TV await base.AfterMetadataRefresh(item, refreshOptions, cancellationToken).ConfigureAwait(false); RemoveObsoleteEpisodes(item); - await CreateSeasonsAsync(item, cancellationToken).ConfigureAwait(false); RemoveObsoleteSeasons(item); + await CreateSeasonsAsync(item, cancellationToken).ConfigureAwait(false); } /// <inheritdoc /> @@ -82,7 +82,7 @@ Instructions to run this project from the command line are included here, but yo ### Cloning the Repository -After dependencies are installed you will need to clone a local copy of this repository. If you just want to run the server from source you can clone this repository directly, but if you are intending to contribute code changes to the project, you should [set up your own fork](https://jellyfin.org/docs/general/contributing/development.html#set-up-your-copy-of-the-repo) of the repository. The following example shows how you can clone the repository directly over HTTPS. +After dependencies have been installed you will need to clone a local copy of this repository. If you just want to run the server from source you can clone this repository directly, but if you are intending to contribute code changes to the project, you should [set up your own fork](https://jellyfin.org/docs/general/contributing/development.html#set-up-your-copy-of-the-repo) of the repository. The following example shows how you can clone the repository directly over HTTPS. ```bash git clone https://github.com/jellyfin/jellyfin.git @@ -116,7 +116,7 @@ Second, you need to [install the recommended extensions for the workspace](https After the required extensions are installed, you can run the server by pressing `F5`. -#### Running From The Command Line +#### Running From the Command Line To run the server from the command line you can use the `dotnet run` command. The example below shows how to do this if you have cloned the repository into a directory named `jellyfin` (the default directory name) and should work on all operating systems. @@ -143,9 +143,9 @@ If the Server is configured to host the Web Client, and the Server is running, t API documentation can be viewed at `http://localhost:8096/api-docs/swagger/index.html` -### Running from GH-Codespaces +### Running from GitHub Codespaces -As Jellyfin will run on a container on a github hosted server, JF needs to handle some things differently. +As Jellyfin will run on a container on a GitHub hosted server, JF needs to handle some things differently. **NOTE:** Depending on the selected configuration (if you just click 'create codespace' it will create a default configuration one) it might take 20-30 seconds to load all extensions and prepare the environment while VS Code is already open. Just give it some time and wait until you see `Downloading .NET version(s) 7.0.15~x64 ...... Done!` in the output tab. @@ -182,12 +182,12 @@ The following sections describe some more advanced scenarios for running the ser It is not necessary to host the frontend web client as part of the backend server. Hosting these two components separately may be useful for frontend developers who would prefer to host the client in a separate webpack development server for a tighter development loop. See the [jellyfin-web](https://github.com/jellyfin/jellyfin-web#getting-started) repo for instructions on how to do this. -To instruct the server not to host the web content, there is a `nowebclient` configuration flag that must be set. This can specified using the command line +To instruct the server not to host the web content, there is a `nowebclient` configuration flag that must be set. This can be specified using the command line switch `--nowebclient` or the environment variable `JELLYFIN_NOWEBCONTENT=true`. Since this is a common scenario, there is also a separate launch profile defined for Visual Studio called `Jellyfin.Server (nowebcontent)` that can be selected from the 'Start Debugging' dropdown in the main toolbar. -**NOTE:** The setup wizard can not be run if the web client is hosted separately. +**NOTE:** The setup wizard cannot be run if the web client is hosted separately. --- <p align="center"> diff --git a/tests/Jellyfin.MediaEncoding.Tests/EncoderValidatorTests.cs b/tests/Jellyfin.MediaEncoding.Tests/EncoderValidatorTests.cs index e0a7fa3aa..988073074 100644 --- a/tests/Jellyfin.MediaEncoding.Tests/EncoderValidatorTests.cs +++ b/tests/Jellyfin.MediaEncoding.Tests/EncoderValidatorTests.cs @@ -17,6 +17,7 @@ namespace Jellyfin.MediaEncoding.Tests } [Theory] + [InlineData(EncoderValidatorTestsData.FFmpegV701Output, true)] [InlineData(EncoderValidatorTestsData.FFmpegV611Output, true)] [InlineData(EncoderValidatorTestsData.FFmpegV60Output, true)] [InlineData(EncoderValidatorTestsData.FFmpegV512Output, true)] @@ -33,6 +34,7 @@ namespace Jellyfin.MediaEncoding.Tests { public GetFFmpegVersionTestData() { + Add(EncoderValidatorTestsData.FFmpegV701Output, new Version(7, 0, 1)); Add(EncoderValidatorTestsData.FFmpegV611Output, new Version(6, 1, 1)); Add(EncoderValidatorTestsData.FFmpegV60Output, new Version(6, 0)); Add(EncoderValidatorTestsData.FFmpegV512Output, new Version(5, 1, 2)); diff --git a/tests/Jellyfin.MediaEncoding.Tests/EncoderValidatorTestsData.cs b/tests/Jellyfin.MediaEncoding.Tests/EncoderValidatorTestsData.cs index 30df94950..1f2d618aa 100644 --- a/tests/Jellyfin.MediaEncoding.Tests/EncoderValidatorTestsData.cs +++ b/tests/Jellyfin.MediaEncoding.Tests/EncoderValidatorTestsData.cs @@ -2,6 +2,18 @@ namespace Jellyfin.MediaEncoding.Tests { internal static class EncoderValidatorTestsData { + public const string FFmpegV701Output = @"ffmpeg version 7.0.1-Jellyfin Copyright (c) 2000-2024 the FFmpeg developers +built with clang version 18.1.8 +configuration: --cc=clang --pkg-config-flags=--static --extra-cflags=-I/clang64/ffbuild/include --extra-ldflags=-L/clang64/ffbuild/lib --prefix=/clang64/ffbuild/jellyfin-ffmpeg --extra-version=Jellyfin --disable-ffplay --disable-debug --disable-doc --disable-sdl2 --disable-ptx-compression --enable-lto=thin --enable-gpl --enable-version3 --enable-schannel --enable-iconv --enable-libxml2 --enable-zlib --enable-lzma --enable-gmp --enable-chromaprint --enable-libfreetype --enable-libfribidi --enable-libfontconfig --enable-libharfbuzz --enable-libass --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libopenmpt --enable-libwebp --enable-libvpx --enable-libzimg --enable-libx264 --enable-libx265 --enable-libsvtav1 --enable-libdav1d --enable-libfdk-aac --enable-opencl --enable-dxva2 --enable-d3d11va --enable-amf --enable-libvpl --enable-ffnvcodec --enable-cuda --enable-cuda-llvm --enable-cuvid --enable-nvdec --enable-nvenc +libavutil 59. 8.100 / 59. 8.100 +libavcodec 61. 3.100 / 61. 3.100 +libavformat 61. 1.100 / 61. 1.100 +libavdevice 61. 1.100 / 61. 1.100 +libavfilter 10. 1.100 / 10. 1.100 +libswscale 8. 1.100 / 8. 1.100 +libswresample 5. 1.100 / 5. 1.100 +libpostproc 58. 1.100 / 58. 1.100"; + public const string FFmpegV611Output = @"ffmpeg version n6.1.1-16-g33efa50fa4-20240317 Copyright (c) 2000-2023 the FFmpeg developers built with gcc 13.2.0 (crosstool-NG 1.26.0.65_ecc5e41) configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --enable-shared --disable-static --disable-w32threads --enable-pthreads --enable-iconv --enable-libxml2 --enable-zlib --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-libharfbuzz --enable-libvorbis --enable-opencl --disable-libpulse --enable-libvmaf --disable-libxcb --disable-xlib --enable-amf --enable-libaom --enable-libaribb24 --enable-avisynth --enable-chromaprint --enable-libdav1d --enable-libdavs2 --disable-libfdk-aac --enable-ffnvcodec --enable-cuda-llvm --enable-frei0r --enable-libgme --enable-libkvazaar --enable-libaribcaption --enable-libass --enable-libbluray --enable-libjxl --enable-libmp3lame --enable-libopus --enable-librist --enable-libssh --enable-libtheora --enable-libvpx --enable-libwebp --enable-lv2 --enable-libvpl --enable-openal --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --disable-libdrm --enable-vaapi --enable-libvidstab --enable-vulkan --enable-libshaderc --enable-libplacebo --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --enable-libzvbi --extra-cflags='$FF_CFLAGS' --extra-cxxflags='$FF_CXXFLAGS' --extra-ldflags='$FF_LDFLAGS' --extra-ldexeflags='$FF_LDEXEFLAGS' --extra-libs='$FF_LIBS' --extra-version=20240317 |
