Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restore video transcoding #68

Merged
merged 1 commit into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Jellyfin.Plugin.Dlna.Playback/DynamicHlsHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public DynamicHlsHelper(
/// <returns>A <see cref="Task"/> containing the resulting <see cref="ActionResult"/>.</returns>
public async Task<ActionResult> GetMasterHlsPlaylist(
TranscodingJobType transcodingJobType,
DlnaStreamingRequestDto streamingRequest,
StreamingRequestDto streamingRequest,
bool enableAdaptiveBitrateStreaming)
{
var isHeadRequest = _httpContextAccessor.HttpContext?.Request.Method == WebRequestMethods.Http.Head;
Expand All @@ -121,7 +121,7 @@ public async Task<ActionResult> GetMasterHlsPlaylist(
}

private async Task<ActionResult> GetMasterPlaylistInternal(
DlnaStreamingRequestDto streamingRequest,
StreamingRequestDto streamingRequest,
bool isHeadRequest,
bool enableAdaptiveBitrateStreaming,
TranscodingJobType transcodingJobType,
Expand Down
19 changes: 5 additions & 14 deletions src/Jellyfin.Plugin.Dlna.Playback/Model/DlnaVideoRequestDto.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
using MediaBrowser.Controller.Streaming;

namespace Jellyfin.Plugin.Dlna.Playback.Model;

/// <summary>
/// The video request dto.
/// </summary>
public class DlnaVideoRequestDto : DlnaStreamingRequestDto
public class DlnaVideoRequestDto : VideoRequestDto
{
/// <summary>
/// Gets a value indicating whether this instance has fixed resolution.
/// </summary>
/// <value><c>true</c> if this instance has fixed resolution; otherwise, <c>false</c>.</value>
public bool HasFixedResolution => Width.HasValue || Height.HasValue;

/// <summary>
/// Gets or sets a value indicating whether to enable subtitles in the manifest.
/// </summary>
public bool EnableSubtitlesInManifest { get; set; }

/// <summary>
/// Gets or sets a value indicating whether to enable trickplay images.
/// Gets or sets the device profile.
/// </summary>
public bool EnableTrickplay { get; set; }
public string? DeviceProfileId { get; set; }
}
21 changes: 16 additions & 5 deletions src/Jellyfin.Plugin.Dlna.Playback/StreamingHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
/// <summary>
/// Gets the current streaming state.
/// </summary>
/// <param name="streamingRequest">The <see cref="DlnaStreamingRequestDto"/>.</param>
/// <param name="streamingRequest">The <see cref="StreamingRequestDto"/>.</param>
/// <param name="httpContext">The <see cref="HttpContext"/>.</param>
/// <param name="mediaSourceManager">Instance of the <see cref="IMediaSourceManager"/> interface.</param>
/// <param name="userManager">Instance of the <see cref="IUserManager"/> interface.</param>
Expand All @@ -49,7 +49,7 @@
/// <param name="cancellationToken">The <see cref="CancellationToken"/>.</param>
/// <returns>A <see cref="Task"/> containing the current <see cref="StreamState"/>.</returns>
public static async Task<DlnaStreamState> GetStreamingState(
DlnaStreamingRequestDto streamingRequest,
StreamingRequestDto streamingRequest,
HttpContext httpContext,
IMediaSourceManager mediaSourceManager,
IUserManager userManager,
Expand Down Expand Up @@ -130,7 +130,7 @@

var item = libraryManager.GetItemById(streamingRequest.Id);

state.IsInputVideo = item.MediaType == MediaType.Video;

Check warning on line 133 in src/Jellyfin.Plugin.Dlna.Playback/StreamingHelpers.cs

View workflow job for this annotation

GitHub Actions / call / test

Dereference of a possibly null reference.

Check warning on line 133 in src/Jellyfin.Plugin.Dlna.Playback/StreamingHelpers.cs

View workflow job for this annotation

GitHub Actions / call / test

Dereference of a possibly null reference.

Check warning on line 133 in src/Jellyfin.Plugin.Dlna.Playback/StreamingHelpers.cs

View workflow job for this annotation

GitHub Actions / call / Analyze (csharp)

Dereference of a possibly null reference.

Check warning on line 133 in src/Jellyfin.Plugin.Dlna.Playback/StreamingHelpers.cs

View workflow job for this annotation

GitHub Actions / call / Analyze (csharp)

Dereference of a possibly null reference.

Check warning on line 133 in src/Jellyfin.Plugin.Dlna.Playback/StreamingHelpers.cs

View workflow job for this annotation

GitHub Actions / call / build

Dereference of a possibly null reference.

MediaSourceInfo? mediaSource = null;
if (string.IsNullOrWhiteSpace(streamingRequest.LiveStreamId))
Expand Down Expand Up @@ -244,7 +244,10 @@
}
}

ApplyDeviceProfileSettings(state, dlnaManager, deviceManager, httpRequest, streamingRequest.DeviceProfileId, streamingRequest.Static);
var deviceProfileId = state.IsVideoRequest
? (streamingRequest as DlnaVideoRequestDto).DeviceProfileId

Check warning on line 248 in src/Jellyfin.Plugin.Dlna.Playback/StreamingHelpers.cs

View workflow job for this annotation

GitHub Actions / call / test

Dereference of a possibly null reference.

Check warning on line 248 in src/Jellyfin.Plugin.Dlna.Playback/StreamingHelpers.cs

View workflow job for this annotation

GitHub Actions / call / test

Dereference of a possibly null reference.

Check warning on line 248 in src/Jellyfin.Plugin.Dlna.Playback/StreamingHelpers.cs

View workflow job for this annotation

GitHub Actions / call / Analyze (csharp)

Dereference of a possibly null reference.

Check warning on line 248 in src/Jellyfin.Plugin.Dlna.Playback/StreamingHelpers.cs

View workflow job for this annotation

GitHub Actions / call / Analyze (csharp)

Dereference of a possibly null reference.

Check warning on line 248 in src/Jellyfin.Plugin.Dlna.Playback/StreamingHelpers.cs

View workflow job for this annotation

GitHub Actions / call / build

Dereference of a possibly null reference.
: (streamingRequest as DlnaStreamingRequestDto).DeviceProfileId;

Check warning on line 249 in src/Jellyfin.Plugin.Dlna.Playback/StreamingHelpers.cs

View workflow job for this annotation

GitHub Actions / call / test

Dereference of a possibly null reference.

Check warning on line 249 in src/Jellyfin.Plugin.Dlna.Playback/StreamingHelpers.cs

View workflow job for this annotation

GitHub Actions / call / test

Dereference of a possibly null reference.

Check warning on line 249 in src/Jellyfin.Plugin.Dlna.Playback/StreamingHelpers.cs

View workflow job for this annotation

GitHub Actions / call / Analyze (csharp)

Dereference of a possibly null reference.

Check warning on line 249 in src/Jellyfin.Plugin.Dlna.Playback/StreamingHelpers.cs

View workflow job for this annotation

GitHub Actions / call / Analyze (csharp)

Dereference of a possibly null reference.

Check warning on line 249 in src/Jellyfin.Plugin.Dlna.Playback/StreamingHelpers.cs

View workflow job for this annotation

GitHub Actions / call / build

Dereference of a possibly null reference.
ApplyDeviceProfileSettings(state, dlnaManager, deviceManager, httpRequest, deviceProfileId, streamingRequest.Static);

var ext = string.IsNullOrWhiteSpace(state.OutputContainer)
? GetOutputFileExtension(state, mediaSource)
Expand Down Expand Up @@ -597,7 +600,7 @@
/// Parses the parameters.
/// </summary>
/// <param name="request">The request.</param>
private static void ParseParams(DlnaStreamingRequestDto request)
private static void ParseParams(StreamingRequestDto request)
{
if (string.IsNullOrEmpty(request.Params))
{
Expand All @@ -607,6 +610,7 @@
var vals = request.Params.Split(';');

var videoRequest = request as DlnaVideoRequestDto;
var streamingRequest = request as DlnaStreamingRequestDto;

for (var i = 0; i < vals.Length; i++)
{
Expand All @@ -620,7 +624,14 @@
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;
Expand Down
Loading