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

Fixes for 10.10 #84

Merged
merged 1 commit into from
Oct 26, 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
19 changes: 10 additions & 9 deletions src/Jellyfin.Plugin.Dlna.Model/DlnaDeviceProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Jellyfin.Data.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Model.Dlna;
using MediaBrowser.Model.Extensions;
using MediaBrowser.Model.MediaInfo;

namespace Jellyfin.Plugin.Dlna.Model;
Expand Down Expand Up @@ -109,7 +110,7 @@ public class DlnaDeviceProfile : DeviceProfile
/// Gets or sets the maximum allowed height of embedded icons.
/// </summary>
public int? MaxIconHeight { get; set; }

/// <summary>
/// Gets or sets the content of the aggregationFlags element in the urn:schemas-sonycom:av namespace.
/// </summary>
Expand Down Expand Up @@ -154,19 +155,19 @@ public class DlnaDeviceProfile : DeviceProfile
/// Gets or sets the XmlRootAttributes.
/// </summary>
public XmlAttribute[] XmlRootAttributes { get; set; } = Array.Empty<XmlAttribute>();

/// <summary>
/// Gets or sets the ResponseProfiles.
/// </summary>
public ResponseProfile[] ResponseProfiles { get; set; } = Array.Empty<ResponseProfile>();

/// <summary>
/// The GetSupportedMediaTypes.
/// </summary>
/// <returns>The .</returns>
public MediaType[] GetSupportedMediaTypes()
{
return ContainerProfile.SplitValue(SupportedMediaTypes)
return ContainerHelper.Split(SupportedMediaTypes)
.Select(m => Enum.TryParse<MediaType>(m, out var parsed) ? parsed : MediaType.Unknown)
.Where(m => m != MediaType.Unknown)
.ToArray();
Expand All @@ -185,7 +186,7 @@ public MediaType[] GetSupportedMediaTypes()
return TranscodingProfiles
.Where(i => i.Type == DlnaProfileType.Audio)
.Where(i => string.Equals(container, i.Container, StringComparison.OrdinalIgnoreCase))
.FirstOrDefault(i => i.GetAudioCodecs().Contains(audioCodec ?? string.Empty, StringComparison.OrdinalIgnoreCase));
.FirstOrDefault(i => ContainerHelper.Split(i.AudioCodec).Contains(audioCodec ?? string.Empty, StringComparison.OrdinalIgnoreCase));
}

/// <summary>
Expand All @@ -202,7 +203,7 @@ public MediaType[] GetSupportedMediaTypes()
return TranscodingProfiles
.Where(i => i.Type == DlnaProfileType.Video)
.Where(i => string.Equals(container, i.Container, StringComparison.OrdinalIgnoreCase))
.Where(i => i.GetAudioCodecs().Contains(audioCodec ?? string.Empty, StringComparison.OrdinalIgnoreCase))
.Where(i => ContainerHelper.Split(i.AudioCodec).Contains(audioCodec ?? string.Empty, StringComparison.OrdinalIgnoreCase))
.FirstOrDefault(i => string.Equals(videoCodec, i.VideoCodec, StringComparison.OrdinalIgnoreCase));
}

Expand All @@ -225,7 +226,7 @@ public MediaType[] GetSupportedMediaTypes()
continue;
}

if (!ContainerProfile.ContainsContainer(i.GetContainers(), container))
if (!ContainerHelper.ContainsContainer(i.Container, container))
{
continue;
}
Expand Down Expand Up @@ -273,7 +274,7 @@ public MediaType[] GetSupportedMediaTypes()
continue;
}

if (!ContainerProfile.ContainsContainer(i.GetContainers(), container))
if (!ContainerHelper.ContainsContainer(i.Container, container))
{
continue;
}
Expand Down Expand Up @@ -352,7 +353,7 @@ public MediaType[] GetSupportedMediaTypes()
continue;
}

if (!ContainerProfile.ContainsContainer(i.GetContainers(), container))
if (!ContainerHelper.ContainsContainer(i.Container, container))
{
continue;
}
Expand Down
13 changes: 4 additions & 9 deletions src/Jellyfin.Plugin.Dlna.Model/ResponseProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System;
using System.Xml.Serialization;
using MediaBrowser.Model.Dlna;
using MediaBrowser.Model.Extensions;

namespace Jellyfin.Plugin.Dlna.Model;

Expand Down Expand Up @@ -34,17 +35,11 @@ public ResponseProfile()
public ProfileCondition[] Conditions { get; set; }

public string[] GetContainers()
{
return ContainerProfile.SplitValue(Container);
}
=> ContainerHelper.Split(Container);

public string[] GetAudioCodecs()
{
return ContainerProfile.SplitValue(AudioCodec);
}
=> ContainerHelper.Split(AudioCodec);

public string[] GetVideoCodecs()
{
return ContainerProfile.SplitValue(VideoCodec);
}
=> ContainerHelper.Split(VideoCodec);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Controller.Streaming;
using MediaBrowser.Model.Dlna;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.MediaInfo;
using MediaBrowser.Model.Net;
using Microsoft.AspNetCore.Http;
Expand Down Expand Up @@ -318,7 +319,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, "superfast");
var ffmpegCommandLineArguments = _encodingHelper.GetProgressiveVideoFullCommandLine(state, encodingOptions, EncoderPreset.superfast);
return await FileStreamResponseHelpers.GetTranscodedFile(
state,
isHeadRequest,
Expand Down
8 changes: 7 additions & 1 deletion src/Jellyfin.Plugin.Dlna.Playback/StreamingHelpers.cs
Original file line number Diff line number Diff line change
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 / build

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 / 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.

MediaSourceInfo? mediaSource = null;
if (string.IsNullOrWhiteSpace(streamingRequest.LiveStreamId))
Expand Down Expand Up @@ -232,11 +232,17 @@
}
else
{
var h264EquivalentBitrate = EncodingHelper.ScaleBitrate(
state.OutputVideoBitrate.Value,
state.ActualOutputVideoCodec,
"h264");
var resolution = ResolutionNormalizer.Normalize(
state.VideoStream?.BitRate,
state.OutputVideoBitrate.Value,
h264EquivalentBitrate,
state.VideoRequest.MaxWidth,
state.VideoRequest.MaxHeight);
state.VideoRequest.MaxHeight,
state.TargetFramerate);

state.VideoRequest.MaxWidth = resolution.MaxWidth;
state.VideoRequest.MaxHeight = resolution.MaxHeight;
Expand All @@ -245,8 +251,8 @@
}

var deviceProfileId = state.IsVideoRequest
? (streamingRequest as DlnaVideoRequestDto).DeviceProfileId

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

View workflow job for this annotation

GitHub Actions / call / build

Dereference of a possibly null reference.

Check warning on line 254 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 254 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 254 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 254 in src/Jellyfin.Plugin.Dlna.Playback/StreamingHelpers.cs

View workflow job for this annotation

GitHub Actions / call / test

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

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

View workflow job for this annotation

GitHub Actions / call / build

Dereference of a possibly null reference.

Check warning on line 255 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 255 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 255 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 255 in src/Jellyfin.Plugin.Dlna.Playback/StreamingHelpers.cs

View workflow job for this annotation

GitHub Actions / call / test

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

var ext = string.IsNullOrWhiteSpace(state.OutputContainer)
Expand Down
4 changes: 2 additions & 2 deletions src/Jellyfin.Plugin.Dlna/ContentDirectory/ControlHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,7 @@ private QueryResult<ServerItem> GetNextUp(BaseItem parent, InternalItemsQuery qu
Limit = query.Limit,
StartIndex = query.StartIndex,
// User cannot be null here as the caller has set it
UserId = query.User!.Id
User = query.User!
},
new[] { parent },
query.DtoOptions);
Expand All @@ -1027,7 +1027,7 @@ private QueryResult<ServerItem> GetLatest(BaseItem parent, InternalItemsQuery qu
new LatestItemsQuery
{
// User cannot be null here as the caller has set it
UserId = query.User!.Id,
User = query.User!,
Limit = query.Limit ?? 50,
IncludeItemTypes = new[] { itemType },
ParentId = parent?.Id ?? Guid.Empty,
Expand Down
8 changes: 6 additions & 2 deletions src/Jellyfin.Plugin.Dlna/DlnaManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.Text.Json;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Jellyfin.Extensions;
using Jellyfin.Extensions.Json;
using Jellyfin.Plugin.Dlna.Model;
using Jellyfin.Plugin.Dlna.Profiles;
Expand Down Expand Up @@ -255,7 +256,7 @@ private IEnumerable<DeviceProfile> GetProfiles(string path, DeviceProfileType ty
var tempProfile = (DlnaDeviceProfile)_xmlSerializer.DeserializeFromFile(typeof(DlnaDeviceProfile), path);
var profile = ReserializeProfile(tempProfile);

profile.Id = path.ToLowerInvariant().GetMD5().ToString("N", CultureInfo.InvariantCulture);
profile.Id = path.ToLowerInvariant().GetMD5();

_profiles[path] = new Tuple<InternalProfileInfo, DlnaDeviceProfile>(GetInternalProfileInfo(_fileSystem.GetFileInfo(path), type), profile);

Expand Down Expand Up @@ -389,7 +390,10 @@ public void UpdateProfile(string profileId, DlnaDeviceProfile profile)
{
profile = ReserializeProfile(profile);

ArgumentException.ThrowIfNullOrEmpty(profile.Id);
if (profile.Id.IsNullOrEmpty())
{
throw new ArgumentException("Profile id cannot be empty.", nameof(profile.Id));
}

ArgumentException.ThrowIfNullOrEmpty(profile.Name);

Expand Down
6 changes: 3 additions & 3 deletions src/Jellyfin.Plugin.Dlna/Extensions/StreamInfoExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ private static IEnumerable<NameValuePair> BuildParams(StreamInfo item, string? a
{
var list = new List<NameValuePair>();

string audioCodecs = item.AudioCodecs.Length == 0 ?
string audioCodecs = item.AudioCodecs.Count == 0 ?
string.Empty :
string.Join(',', item.AudioCodecs);

string videoCodecs = item.VideoCodecs.Length == 0 ?
string videoCodecs = item.VideoCodecs.Count == 0 ?
string.Empty :
string.Join(',', item.VideoCodecs);

Expand Down Expand Up @@ -164,7 +164,7 @@ private static IEnumerable<NameValuePair> BuildParams(StreamInfo item, string? a

list.Add(new NameValuePair("Tag", item.MediaSource?.ETag ?? string.Empty));

string subtitleCodecs = item.SubtitleCodecs.Length == 0 ?
string subtitleCodecs = item.SubtitleCodecs.Count == 0 ?
string.Empty :
string.Join(",", item.SubtitleCodecs);

Expand Down
2 changes: 1 addition & 1 deletion src/Jellyfin.Plugin.Dlna/Profiles/DefaultProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class DefaultProfile : DlnaDeviceProfile
{
public DefaultProfile()
{
Id = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture);
Id = Guid.NewGuid();
Name = "Generic Device";

ProtocolInfo = "http-get:*:video/mpeg:*,http-get:*:video/mp4:*,http-get:*:video/vnd.dlna.mpeg-tts:*,http-get:*:video/avi:*,http-get:*:video/x-matroska:*,http-get:*:video/x-ms-wmv:*,http-get:*:video/wtv:*,http-get:*:audio/mpeg:*,http-get:*:audio/mp3:*,http-get:*:audio/mp4:*,http-get:*:audio/x-ms-wma:*,http-get:*:audio/wav:*,http-get:*:audio/L16:*,http-get:*:image/jpeg:*,http-get:*:image/png:*,http-get:*:image/gif:*,http-get:*:image/tiff:*";
Expand Down
Loading