From aefb9eb11cdf00a3058c0bfc431e5cb34f473978 Mon Sep 17 00:00:00 2001 From: Ivan Drozdov Date: Thu, 15 Aug 2024 21:20:21 +0200 Subject: [PATCH] restore video transcoding The main issue is that jellyfin's StreamState doesn't consider DlnaVideoRequestDto to be a video request due to DlnaVideoRequestDto not being inherited from VideoRequestDto. As a result, all video requests are being processed as audio only. This commit updates dlna video requests to inherit from VideoRequestDto directly. --- .../DynamicHlsHelper.cs | 4 ++-- .../Model/DlnaVideoRequestDto.cs | 19 +++++------------ .../StreamingHelpers.cs | 21 ++++++++++++++----- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/Jellyfin.Plugin.Dlna.Playback/DynamicHlsHelper.cs b/src/Jellyfin.Plugin.Dlna.Playback/DynamicHlsHelper.cs index 6cc000a..2cbf6d8 100644 --- a/src/Jellyfin.Plugin.Dlna.Playback/DynamicHlsHelper.cs +++ b/src/Jellyfin.Plugin.Dlna.Playback/DynamicHlsHelper.cs @@ -106,7 +106,7 @@ public DynamicHlsHelper( /// A containing the resulting . public async Task GetMasterHlsPlaylist( TranscodingJobType transcodingJobType, - DlnaStreamingRequestDto streamingRequest, + StreamingRequestDto streamingRequest, bool enableAdaptiveBitrateStreaming) { var isHeadRequest = _httpContextAccessor.HttpContext?.Request.Method == WebRequestMethods.Http.Head; @@ -121,7 +121,7 @@ public async Task GetMasterHlsPlaylist( } private async Task GetMasterPlaylistInternal( - DlnaStreamingRequestDto streamingRequest, + StreamingRequestDto streamingRequest, bool isHeadRequest, bool enableAdaptiveBitrateStreaming, TranscodingJobType transcodingJobType, diff --git a/src/Jellyfin.Plugin.Dlna.Playback/Model/DlnaVideoRequestDto.cs b/src/Jellyfin.Plugin.Dlna.Playback/Model/DlnaVideoRequestDto.cs index 265ef15..e691b2b 100644 --- a/src/Jellyfin.Plugin.Dlna.Playback/Model/DlnaVideoRequestDto.cs +++ b/src/Jellyfin.Plugin.Dlna.Playback/Model/DlnaVideoRequestDto.cs @@ -1,23 +1,14 @@ +using MediaBrowser.Controller.Streaming; + namespace Jellyfin.Plugin.Dlna.Playback.Model; /// /// The video request dto. /// -public class DlnaVideoRequestDto : DlnaStreamingRequestDto +public class DlnaVideoRequestDto : VideoRequestDto { /// - /// Gets a value indicating whether this instance has fixed resolution. - /// - /// true if this instance has fixed resolution; otherwise, false. - public bool HasFixedResolution => Width.HasValue || Height.HasValue; - - /// - /// Gets or sets a value indicating whether to enable subtitles in the manifest. - /// - public bool EnableSubtitlesInManifest { get; set; } - - /// - /// Gets or sets a value indicating whether to enable trickplay images. + /// Gets or sets the device profile. /// - public bool EnableTrickplay { get; set; } + public string? DeviceProfileId { get; set; } } diff --git a/src/Jellyfin.Plugin.Dlna.Playback/StreamingHelpers.cs b/src/Jellyfin.Plugin.Dlna.Playback/StreamingHelpers.cs index 572b2dd..df6803e 100644 --- a/src/Jellyfin.Plugin.Dlna.Playback/StreamingHelpers.cs +++ b/src/Jellyfin.Plugin.Dlna.Playback/StreamingHelpers.cs @@ -34,7 +34,7 @@ public static class StreamingHelpers /// /// Gets the current streaming state. /// - /// The . + /// The . /// The . /// Instance of the interface. /// Instance of the interface. @@ -49,7 +49,7 @@ public static class StreamingHelpers /// The . /// A containing the current . public static async Task GetStreamingState( - DlnaStreamingRequestDto streamingRequest, + StreamingRequestDto streamingRequest, HttpContext httpContext, IMediaSourceManager mediaSourceManager, IUserManager userManager, @@ -244,7 +244,10 @@ public static async Task GetStreamingState( } } - ApplyDeviceProfileSettings(state, dlnaManager, deviceManager, httpRequest, streamingRequest.DeviceProfileId, streamingRequest.Static); + var deviceProfileId = state.IsVideoRequest + ? (streamingRequest as DlnaVideoRequestDto).DeviceProfileId + : (streamingRequest as DlnaStreamingRequestDto).DeviceProfileId; + ApplyDeviceProfileSettings(state, dlnaManager, deviceManager, httpRequest, deviceProfileId, streamingRequest.Static); var ext = string.IsNullOrWhiteSpace(state.OutputContainer) ? GetOutputFileExtension(state, mediaSource) @@ -597,7 +600,7 @@ private static void ApplyDeviceProfileSettings(DlnaStreamState state, IDlnaManag /// Parses the parameters. /// /// The request. - private static void ParseParams(DlnaStreamingRequestDto request) + private static void ParseParams(StreamingRequestDto request) { if (string.IsNullOrEmpty(request.Params)) { @@ -607,6 +610,7 @@ private static void ParseParams(DlnaStreamingRequestDto request) var vals = request.Params.Split(';'); var videoRequest = request as DlnaVideoRequestDto; + var streamingRequest = request as DlnaStreamingRequestDto; for (var i = 0; i < vals.Length; i++) { @@ -620,7 +624,14 @@ private static void ParseParams(DlnaStreamingRequestDto request) switch (i) { case 0: - request.DeviceProfileId = val; + if (videoRequest is not null) + { + videoRequest.DeviceProfileId = val; + } + else if (streamingRequest is not null) + { + streamingRequest.DeviceProfileId = val; + } break; case 1: request.DeviceId = val;