Skip to content

Commit

Permalink
10.9 (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
crobibero authored May 11, 2024
1 parent ec1faf9 commit 9cdf87e
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 60 deletions.
3 changes: 2 additions & 1 deletion src/Jellyfin.Plugin.Dlna.Model/IDlnaManager.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma warning disable CS1591

using System.Collections.Generic;
using System.IO;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Model.Dlna;
using Microsoft.AspNetCore.Http;
Expand Down Expand Up @@ -75,5 +76,5 @@ public interface IDlnaManager
/// </summary>
/// <param name="filename">The filename.</param>
/// <returns>DlnaIconResponse.</returns>
ImageStream? GetIcon(string filename);
Stream? GetIcon(string filename);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Jellyfin.Controller" Version="10.9.0-20240112.4" />
<PackageReference Include="Jellyfin.Extensions" Version="10.9.0-20240112.4" />
<PackageReference Include="Jellyfin.Model" Version="10.9.0-20240112.4" />
<PackageReference Include="Jellyfin.Controller" Version="10.*-*" />
<PackageReference Include="Jellyfin.Extensions" Version="10.*-*" />
<PackageReference Include="Jellyfin.Model" Version="10.*-*" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ public async Task<ActionResult> GetVideoStream(

// Need to start ffmpeg (because media can't be returned directly)
var encodingOptions = _serverConfigurationManager.GetEncodingOptions();
var ffmpegCommandLineArguments = _encodingHelper.GetProgressiveVideoFullCommandLine(state, encodingOptions, outputPath, "superfast");
var ffmpegCommandLineArguments = _encodingHelper.GetProgressiveVideoFullCommandLine(state, encodingOptions, "superfast");
return await FileStreamResponseHelpers.GetTranscodedFile(
state,
isHeadRequest,
Expand Down
41 changes: 17 additions & 24 deletions src/Jellyfin.Plugin.Dlna.Playback/FileStreamResponseHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,33 +93,26 @@ public static async Task<ActionResult> GetTranscodedFile(
return new OkResult();
}

var transcodingLock = transcodeManager.GetTranscodingLock(outputPath);
await transcodingLock.WaitAsync(cancellationTokenSource.Token).ConfigureAwait(false);
try
{
TranscodingJob? job;
if (!File.Exists(outputPath))
{
job = await transcodeManager.StartFfMpeg(
state,
outputPath,
ffmpegCommandLineArguments,
httpContext.User.GetUserId(),
transcodingJobType,
cancellationTokenSource).ConfigureAwait(false);
}
else
{
job = transcodeManager.OnTranscodeBeginRequest(outputPath, TranscodingJobType.Progressive);
state.Dispose();
}
using var transcodingLock = await transcodeManager.LockAsync(outputPath, cancellationTokenSource.Token);

var stream = new ProgressiveFileStream(outputPath, job, transcodeManager);
return new FileStreamResult(stream, contentType);
TranscodingJob? job;
if (!File.Exists(outputPath))
{
job = await transcodeManager.StartFfMpeg(
state,
outputPath,
ffmpegCommandLineArguments,
httpContext.User.GetUserId(),
transcodingJobType,
cancellationTokenSource).ConfigureAwait(false);
}
finally
else
{
transcodingLock.Release();
job = transcodeManager.OnTranscodeBeginRequest(outputPath, TranscodingJobType.Progressive);
state.Dispose();
}

var stream = new ProgressiveFileStream(outputPath, job, transcodeManager);
return new FileStreamResult(stream, contentType);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Jellyfin.Controller" Version="10.9.0-20240112.4" />
<PackageReference Include="Jellyfin.Model" Version="10.9.0-20240112.4" />
<PackageReference Include="Jellyfin.Controller" Version="10.*-*" />
<PackageReference Include="Jellyfin.Model" Version="10.*-*" />
<PackageReference Include="Microsoft.AspNetCore.Authorization" Version="8.0.0" />
</ItemGroup>

Expand Down
6 changes: 3 additions & 3 deletions src/Jellyfin.Plugin.Dlna/Api/DlnaServerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,13 +265,13 @@ public ActionResult GetIcon([FromRoute, Required] string fileName)

private ActionResult GetIconInternal(string fileName)
{
var icon = _dlnaManager.GetIcon(fileName);
if (icon is null)
var iconStream = _dlnaManager.GetIcon(fileName);
if (iconStream is null)
{
return NotFound();
}

return File(icon.Stream, MimeTypes.GetMimeType(fileName));
return File(iconStream, MimeTypes.GetMimeType(fileName));
}

private string GetAbsoluteUri()
Expand Down
17 changes: 2 additions & 15 deletions src/Jellyfin.Plugin.Dlna/DlnaManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -458,23 +458,10 @@ public string GetServerDescriptionXml(IHeaderDictionary headers, string serverUu
}

/// <inheritdoc />
public ImageStream? GetIcon(string filename)
public Stream? GetIcon(string filename)
{
var format = filename.EndsWith(".png", StringComparison.OrdinalIgnoreCase)
? ImageFormat.Png
: ImageFormat.Jpg;

var resource = GetType().Namespace + ".Images." + filename.ToLowerInvariant();
var stream = _assembly.GetManifestResourceStream(resource);
if (stream is null)
{
return null;
}

return new ImageStream(stream)
{
Format = format
};
return _assembly.GetManifestResourceStream(resource);
}

private class InternalProfileInfo
Expand Down
11 changes: 6 additions & 5 deletions src/Jellyfin.Plugin.Dlna/Extensions/StreamInfoExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using Jellyfin.Data.Enums;
using MediaBrowser.Model.Dlna;
using MediaBrowser.Model.Dto;

Expand Down Expand Up @@ -60,22 +61,22 @@ private static string GetUrl(StreamInfo streamInfo, string baseUrl, string query
var itemId = streamInfo.ItemId;
if (streamInfo.MediaType == DlnaProfileType.Audio)
{
if (string.Equals(streamInfo.SubProtocol, "hls", StringComparison.OrdinalIgnoreCase))
if (streamInfo.SubProtocol == MediaStreamProtocol.hls)
{
return string.Format(CultureInfo.InvariantCulture, "{0}/dlna/audio/{1}/master.m3u8?{2}", baseUrl, itemId, queryString);
}

return string.Format(CultureInfo.InvariantCulture, "{0}/dlna/audio/{1}/stream{2}?{3}", baseUrl, itemId, extension, queryString);
}

if (string.Equals(streamInfo.SubProtocol, "hls", StringComparison.OrdinalIgnoreCase))
if (streamInfo.SubProtocol == MediaStreamProtocol.hls)
{
return string.Format(CultureInfo.InvariantCulture, "{0}/dlna/videos/{1}/master.m3u8?{2}", baseUrl, itemId, queryString);
}

return string.Format(CultureInfo.InvariantCulture, "{0}/dlna/videos/{1}/stream{2}?{3}", baseUrl, itemId, extension, queryString);
}

private static IEnumerable<NameValuePair> BuildParams(StreamInfo item, string? accessToken)
{
var list = new List<NameValuePair>();
Expand Down Expand Up @@ -105,7 +106,7 @@ private static IEnumerable<NameValuePair> BuildParams(StreamInfo item, string? a
list.Add(new NameValuePair("MaxHeight", item.MaxHeight.HasValue ? item.MaxHeight.Value.ToString(CultureInfo.InvariantCulture) : string.Empty));

long startPositionTicks = item.StartPositionTicks;
var isHls = string.Equals(item.SubProtocol, "hls", StringComparison.OrdinalIgnoreCase);
var isHls = item.SubProtocol == MediaStreamProtocol.hls;

if (isHls)
{
Expand Down Expand Up @@ -204,4 +205,4 @@ private static IEnumerable<NameValuePair> BuildParams(StreamInfo item, string? a

return list;
}
}
}
4 changes: 2 additions & 2 deletions src/Jellyfin.Plugin.Dlna/Jellyfin.Plugin.Dlna.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Jellyfin.Controller" Version="10.9.0-20240112.4" />
<PackageReference Include="Jellyfin.Model" Version="10.9.0-20240112.4" />
<PackageReference Include="Jellyfin.Controller" Version="10.*-*" />
<PackageReference Include="Jellyfin.Model" Version="10.*-*" />
</ItemGroup>

<ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions src/Rssdp/Rssdp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Jellyfin.Common" Version="10.9.0-20240112.4" />
<PackageReference Include="Jellyfin.Controller" Version="10.9.0-20240112.4" />
<PackageReference Include="Jellyfin.Extensions" Version="10.9.0-20240112.4" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageReference Include="Jellyfin.Common" Version="10.*-*" />
<PackageReference Include="Jellyfin.Controller" Version="10.*-*" />
<PackageReference Include="Jellyfin.Extensions" Version="10.*-*" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
</ItemGroup>
</Project>

0 comments on commit 9cdf87e

Please sign in to comment.