Skip to content

Commit 9cdf87e

Browse files
authored
10.9 (#44)
1 parent ec1faf9 commit 9cdf87e

10 files changed

Lines changed: 42 additions & 60 deletions

File tree

src/Jellyfin.Plugin.Dlna.Model/IDlnaManager.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma warning disable CS1591
22

33
using System.Collections.Generic;
4+
using System.IO;
45
using MediaBrowser.Controller.Drawing;
56
using MediaBrowser.Model.Dlna;
67
using Microsoft.AspNetCore.Http;
@@ -75,5 +76,5 @@ public interface IDlnaManager
7576
/// </summary>
7677
/// <param name="filename">The filename.</param>
7778
/// <returns>DlnaIconResponse.</returns>
78-
ImageStream? GetIcon(string filename);
79+
Stream? GetIcon(string filename);
7980
}

src/Jellyfin.Plugin.Dlna.Model/Jellyfin.Plugin.Dlna.Model.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="Jellyfin.Controller" Version="10.9.0-20240112.4" />
9-
<PackageReference Include="Jellyfin.Extensions" Version="10.9.0-20240112.4" />
10-
<PackageReference Include="Jellyfin.Model" Version="10.9.0-20240112.4" />
8+
<PackageReference Include="Jellyfin.Controller" Version="10.*-*" />
9+
<PackageReference Include="Jellyfin.Extensions" Version="10.*-*" />
10+
<PackageReference Include="Jellyfin.Model" Version="10.*-*" />
1111
</ItemGroup>
1212
</Project>

src/Jellyfin.Plugin.Dlna.Playback/Api/DlnaVideosController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ public async Task<ActionResult> GetVideoStream(
318318

319319
// Need to start ffmpeg (because media can't be returned directly)
320320
var encodingOptions = _serverConfigurationManager.GetEncodingOptions();
321-
var ffmpegCommandLineArguments = _encodingHelper.GetProgressiveVideoFullCommandLine(state, encodingOptions, outputPath, "superfast");
321+
var ffmpegCommandLineArguments = _encodingHelper.GetProgressiveVideoFullCommandLine(state, encodingOptions, "superfast");
322322
return await FileStreamResponseHelpers.GetTranscodedFile(
323323
state,
324324
isHeadRequest,

src/Jellyfin.Plugin.Dlna.Playback/FileStreamResponseHelpers.cs

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -93,33 +93,26 @@ public static async Task<ActionResult> GetTranscodedFile(
9393
return new OkResult();
9494
}
9595

96-
var transcodingLock = transcodeManager.GetTranscodingLock(outputPath);
97-
await transcodingLock.WaitAsync(cancellationTokenSource.Token).ConfigureAwait(false);
98-
try
99-
{
100-
TranscodingJob? job;
101-
if (!File.Exists(outputPath))
102-
{
103-
job = await transcodeManager.StartFfMpeg(
104-
state,
105-
outputPath,
106-
ffmpegCommandLineArguments,
107-
httpContext.User.GetUserId(),
108-
transcodingJobType,
109-
cancellationTokenSource).ConfigureAwait(false);
110-
}
111-
else
112-
{
113-
job = transcodeManager.OnTranscodeBeginRequest(outputPath, TranscodingJobType.Progressive);
114-
state.Dispose();
115-
}
96+
using var transcodingLock = await transcodeManager.LockAsync(outputPath, cancellationTokenSource.Token);
11697

117-
var stream = new ProgressiveFileStream(outputPath, job, transcodeManager);
118-
return new FileStreamResult(stream, contentType);
98+
TranscodingJob? job;
99+
if (!File.Exists(outputPath))
100+
{
101+
job = await transcodeManager.StartFfMpeg(
102+
state,
103+
outputPath,
104+
ffmpegCommandLineArguments,
105+
httpContext.User.GetUserId(),
106+
transcodingJobType,
107+
cancellationTokenSource).ConfigureAwait(false);
119108
}
120-
finally
109+
else
121110
{
122-
transcodingLock.Release();
111+
job = transcodeManager.OnTranscodeBeginRequest(outputPath, TranscodingJobType.Progressive);
112+
state.Dispose();
123113
}
114+
115+
var stream = new ProgressiveFileStream(outputPath, job, transcodeManager);
116+
return new FileStreamResult(stream, contentType);
124117
}
125118
}

src/Jellyfin.Plugin.Dlna.Playback/Jellyfin.Plugin.Dlna.Playback.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="Jellyfin.Controller" Version="10.9.0-20240112.4" />
9-
<PackageReference Include="Jellyfin.Model" Version="10.9.0-20240112.4" />
8+
<PackageReference Include="Jellyfin.Controller" Version="10.*-*" />
9+
<PackageReference Include="Jellyfin.Model" Version="10.*-*" />
1010
<PackageReference Include="Microsoft.AspNetCore.Authorization" Version="8.0.0" />
1111
</ItemGroup>
1212

src/Jellyfin.Plugin.Dlna/Api/DlnaServerController.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,13 +265,13 @@ public ActionResult GetIcon([FromRoute, Required] string fileName)
265265

266266
private ActionResult GetIconInternal(string fileName)
267267
{
268-
var icon = _dlnaManager.GetIcon(fileName);
269-
if (icon is null)
268+
var iconStream = _dlnaManager.GetIcon(fileName);
269+
if (iconStream is null)
270270
{
271271
return NotFound();
272272
}
273273

274-
return File(icon.Stream, MimeTypes.GetMimeType(fileName));
274+
return File(iconStream, MimeTypes.GetMimeType(fileName));
275275
}
276276

277277
private string GetAbsoluteUri()

src/Jellyfin.Plugin.Dlna/DlnaManager.cs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -458,23 +458,10 @@ public string GetServerDescriptionXml(IHeaderDictionary headers, string serverUu
458458
}
459459

460460
/// <inheritdoc />
461-
public ImageStream? GetIcon(string filename)
461+
public Stream? GetIcon(string filename)
462462
{
463-
var format = filename.EndsWith(".png", StringComparison.OrdinalIgnoreCase)
464-
? ImageFormat.Png
465-
: ImageFormat.Jpg;
466-
467463
var resource = GetType().Namespace + ".Images." + filename.ToLowerInvariant();
468-
var stream = _assembly.GetManifestResourceStream(resource);
469-
if (stream is null)
470-
{
471-
return null;
472-
}
473-
474-
return new ImageStream(stream)
475-
{
476-
Format = format
477-
};
464+
return _assembly.GetManifestResourceStream(resource);
478465
}
479466

480467
private class InternalProfileInfo

src/Jellyfin.Plugin.Dlna/Extensions/StreamInfoExtensions.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Globalization;
4+
using Jellyfin.Data.Enums;
45
using MediaBrowser.Model.Dlna;
56
using MediaBrowser.Model.Dto;
67

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

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

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

7677
return string.Format(CultureInfo.InvariantCulture, "{0}/dlna/videos/{1}/stream{2}?{3}", baseUrl, itemId, extension, queryString);
7778
}
78-
79+
7980
private static IEnumerable<NameValuePair> BuildParams(StreamInfo item, string? accessToken)
8081
{
8182
var list = new List<NameValuePair>();
@@ -105,7 +106,7 @@ private static IEnumerable<NameValuePair> BuildParams(StreamInfo item, string? a
105106
list.Add(new NameValuePair("MaxHeight", item.MaxHeight.HasValue ? item.MaxHeight.Value.ToString(CultureInfo.InvariantCulture) : string.Empty));
106107

107108
long startPositionTicks = item.StartPositionTicks;
108-
var isHls = string.Equals(item.SubProtocol, "hls", StringComparison.OrdinalIgnoreCase);
109+
var isHls = item.SubProtocol == MediaStreamProtocol.hls;
109110

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

205206
return list;
206207
}
207-
}
208+
}

src/Jellyfin.Plugin.Dlna/Jellyfin.Plugin.Dlna.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="Jellyfin.Controller" Version="10.9.0-20240112.4" />
9-
<PackageReference Include="Jellyfin.Model" Version="10.9.0-20240112.4" />
8+
<PackageReference Include="Jellyfin.Controller" Version="10.*-*" />
9+
<PackageReference Include="Jellyfin.Model" Version="10.*-*" />
1010
</ItemGroup>
1111

1212
<ItemGroup>

src/Rssdp/Rssdp.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="Jellyfin.Common" Version="10.9.0-20240112.4" />
9-
<PackageReference Include="Jellyfin.Controller" Version="10.9.0-20240112.4" />
10-
<PackageReference Include="Jellyfin.Extensions" Version="10.9.0-20240112.4" />
11-
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
8+
<PackageReference Include="Jellyfin.Common" Version="10.*-*" />
9+
<PackageReference Include="Jellyfin.Controller" Version="10.*-*" />
10+
<PackageReference Include="Jellyfin.Extensions" Version="10.*-*" />
11+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
1212
</ItemGroup>
1313
</Project>

0 commit comments

Comments
 (0)