From 68fd9c469f013acef3e661d15adb61c4eb965ec7 Mon Sep 17 00:00:00 2001 From: Patrick Barron Date: Fri, 12 Jan 2024 11:24:32 -0500 Subject: [PATCH] Remove DLNA-specific DeviceProfile code (#10850) * Remove DLNA-specific methods from DeviceProfile * Remove DLNA-specific fields from DeviceProfile * Remove unused DLNA models --- .../Dlna/DeviceIdentification.cs | 63 --- MediaBrowser.Model/Dlna/DeviceProfile.cs | 439 +----------------- MediaBrowser.Model/Dlna/DeviceProfileInfo.cs | 26 -- MediaBrowser.Model/Dlna/DeviceProfileType.cs | 10 - MediaBrowser.Model/Dlna/HeaderMatchType.cs | 11 - MediaBrowser.Model/Dlna/HttpHeaderInfo.cs | 19 - MediaBrowser.Model/Dlna/ResponseProfile.cs | 51 -- MediaBrowser.Model/Dlna/XmlAttribute.cs | 25 - 8 files changed, 1 insertion(+), 643 deletions(-) delete mode 100644 MediaBrowser.Model/Dlna/DeviceIdentification.cs delete mode 100644 MediaBrowser.Model/Dlna/DeviceProfileInfo.cs delete mode 100644 MediaBrowser.Model/Dlna/DeviceProfileType.cs delete mode 100644 MediaBrowser.Model/Dlna/HeaderMatchType.cs delete mode 100644 MediaBrowser.Model/Dlna/HttpHeaderInfo.cs delete mode 100644 MediaBrowser.Model/Dlna/ResponseProfile.cs delete mode 100644 MediaBrowser.Model/Dlna/XmlAttribute.cs diff --git a/MediaBrowser.Model/Dlna/DeviceIdentification.cs b/MediaBrowser.Model/Dlna/DeviceIdentification.cs deleted file mode 100644 index 6625b79814..0000000000 --- a/MediaBrowser.Model/Dlna/DeviceIdentification.cs +++ /dev/null @@ -1,63 +0,0 @@ -#pragma warning disable CS1591 - -using System; - -namespace MediaBrowser.Model.Dlna -{ - public class DeviceIdentification - { - /// - /// Gets or sets the name of the friendly. - /// - /// The name of the friendly. - public string FriendlyName { get; set; } = string.Empty; - - /// - /// Gets or sets the model number. - /// - /// The model number. - public string ModelNumber { get; set; } = string.Empty; - - /// - /// Gets or sets the serial number. - /// - /// The serial number. - public string SerialNumber { get; set; } = string.Empty; - - /// - /// Gets or sets the name of the model. - /// - /// The name of the model. - public string ModelName { get; set; } = string.Empty; - - /// - /// Gets or sets the model description. - /// - /// The model description. - public string ModelDescription { get; set; } = string.Empty; - - /// - /// Gets or sets the model URL. - /// - /// The model URL. - public string ModelUrl { get; set; } = string.Empty; - - /// - /// Gets or sets the manufacturer. - /// - /// The manufacturer. - public string Manufacturer { get; set; } = string.Empty; - - /// - /// Gets or sets the manufacturer URL. - /// - /// The manufacturer URL. - public string ManufacturerUrl { get; set; } = string.Empty; - - /// - /// Gets or sets the headers. - /// - /// The headers. - public HttpHeaderInfo[] Headers { get; set; } = Array.Empty(); - } -} diff --git a/MediaBrowser.Model/Dlna/DeviceProfile.cs b/MediaBrowser.Model/Dlna/DeviceProfile.cs index 71d0896a70..2addebbfca 100644 --- a/MediaBrowser.Model/Dlna/DeviceProfile.cs +++ b/MediaBrowser.Model/Dlna/DeviceProfile.cs @@ -1,11 +1,7 @@ #pragma warning disable CA1819 // Properties should not return arrays + using System; -using System.ComponentModel; -using System.Linq; using System.Xml.Serialization; -using Jellyfin.Data.Enums; -using Jellyfin.Extensions; -using MediaBrowser.Model.MediaInfo; namespace MediaBrowser.Model.Dlna { @@ -17,7 +13,6 @@ namespace MediaBrowser.Model.Dlna /// the device is able to direct play (without transcoding or remuxing), /// as well as which containers/codecs to transcode to in case it isn't. /// - [XmlRoot("Profile")] public class DeviceProfile { /// @@ -31,104 +26,6 @@ namespace MediaBrowser.Model.Dlna [XmlIgnore] public string? Id { get; set; } - /// - /// Gets or sets the Identification. - /// - public DeviceIdentification? Identification { get; set; } - - /// - /// Gets or sets the friendly name of the device profile, which can be shown to users. - /// - public string? FriendlyName { get; set; } - - /// - /// Gets or sets the manufacturer of the device which this profile represents. - /// - public string? Manufacturer { get; set; } - - /// - /// Gets or sets an url for the manufacturer of the device which this profile represents. - /// - public string? ManufacturerUrl { get; set; } - - /// - /// Gets or sets the model name of the device which this profile represents. - /// - public string? ModelName { get; set; } - - /// - /// Gets or sets the model description of the device which this profile represents. - /// - public string? ModelDescription { get; set; } - - /// - /// Gets or sets the model number of the device which this profile represents. - /// - public string? ModelNumber { get; set; } - - /// - /// Gets or sets the ModelUrl. - /// - public string? ModelUrl { get; set; } - - /// - /// Gets or sets the serial number of the device which this profile represents. - /// - public string? SerialNumber { get; set; } - - /// - /// Gets or sets a value indicating whether EnableAlbumArtInDidl. - /// - [DefaultValue(false)] - public bool EnableAlbumArtInDidl { get; set; } - - /// - /// Gets or sets a value indicating whether EnableSingleAlbumArtLimit. - /// - [DefaultValue(false)] - public bool EnableSingleAlbumArtLimit { get; set; } - - /// - /// Gets or sets a value indicating whether EnableSingleSubtitleLimit. - /// - [DefaultValue(false)] - public bool EnableSingleSubtitleLimit { get; set; } - - /// - /// Gets or sets the SupportedMediaTypes. - /// - public string SupportedMediaTypes { get; set; } = "Audio,Photo,Video"; - - /// - /// Gets or sets the UserId. - /// - public string? UserId { get; set; } - - /// - /// Gets or sets the AlbumArtPn. - /// - public string? AlbumArtPn { get; set; } - - /// - /// Gets or sets the MaxAlbumArtWidth. - /// - public int? MaxAlbumArtWidth { get; set; } - - /// - /// Gets or sets the MaxAlbumArtHeight. - /// - public int? MaxAlbumArtHeight { get; set; } - - /// - /// Gets or sets the maximum allowed width of embedded icons. - /// - public int? MaxIconWidth { get; set; } - - /// - /// Gets or sets the maximum allowed height of embedded icons. - /// - public int? MaxIconHeight { get; set; } - /// /// Gets or sets the maximum allowed bitrate for all streamed content. /// @@ -149,51 +46,6 @@ namespace MediaBrowser.Model.Dlna /// public int? MaxStaticMusicBitrate { get; set; } = 8000000; - /// - /// Gets or sets the content of the aggregationFlags element in the urn:schemas-sonycom:av namespace. - /// - public string? SonyAggregationFlags { get; set; } - - /// - /// Gets or sets the ProtocolInfo. - /// - public string? ProtocolInfo { get; set; } - - /// - /// Gets or sets the TimelineOffsetSeconds. - /// - [DefaultValue(0)] - public int TimelineOffsetSeconds { get; set; } - - /// - /// Gets or sets a value indicating whether RequiresPlainVideoItems. - /// - [DefaultValue(false)] - public bool RequiresPlainVideoItems { get; set; } - - /// - /// Gets or sets a value indicating whether RequiresPlainFolders. - /// - [DefaultValue(false)] - public bool RequiresPlainFolders { get; set; } - - /// - /// Gets or sets a value indicating whether EnableMSMediaReceiverRegistrar. - /// - [DefaultValue(false)] - public bool EnableMSMediaReceiverRegistrar { get; set; } - - /// - /// Gets or sets a value indicating whether IgnoreTranscodeByteRangeRequests. - /// - [DefaultValue(false)] - public bool IgnoreTranscodeByteRangeRequests { get; set; } - - /// - /// Gets or sets the XmlRootAttributes. - /// - public XmlAttribute[] XmlRootAttributes { get; set; } = Array.Empty(); - /// /// Gets or sets the direct play profiles. /// @@ -214,298 +66,9 @@ namespace MediaBrowser.Model.Dlna /// public CodecProfile[] CodecProfiles { get; set; } = Array.Empty(); - /// - /// Gets or sets the ResponseProfiles. - /// - public ResponseProfile[] ResponseProfiles { get; set; } = Array.Empty(); - /// /// Gets or sets the subtitle profiles. /// public SubtitleProfile[] SubtitleProfiles { get; set; } = Array.Empty(); - - /// - /// The GetSupportedMediaTypes. - /// - /// The . - public MediaType[] GetSupportedMediaTypes() - { - return ContainerProfile.SplitValue(SupportedMediaTypes) - .Select(m => Enum.TryParse(m, out var parsed) ? parsed : MediaType.Unknown) - .Where(m => m != MediaType.Unknown) - .ToArray(); - } - - /// - /// Gets the audio transcoding profile. - /// - /// The container. - /// The audio Codec. - /// A . - public TranscodingProfile? GetAudioTranscodingProfile(string? container, string? audioCodec) - { - container = (container ?? string.Empty).TrimStart('.'); - - foreach (var i in TranscodingProfiles) - { - if (i.Type != DlnaProfileType.Audio) - { - continue; - } - - if (!string.Equals(container, i.Container, StringComparison.OrdinalIgnoreCase)) - { - continue; - } - - if (!i.GetAudioCodecs().Contains(audioCodec ?? string.Empty, StringComparison.OrdinalIgnoreCase)) - { - continue; - } - - return i; - } - - return null; - } - - /// - /// Gets the video transcoding profile. - /// - /// The container. - /// The audio Codec. - /// The video Codec. - /// The . - public TranscodingProfile? GetVideoTranscodingProfile(string? container, string? audioCodec, string? videoCodec) - { - container = (container ?? string.Empty).TrimStart('.'); - - foreach (var i in TranscodingProfiles) - { - if (i.Type != DlnaProfileType.Video) - { - continue; - } - - if (!string.Equals(container, i.Container, StringComparison.OrdinalIgnoreCase)) - { - continue; - } - - if (!i.GetAudioCodecs().Contains(audioCodec ?? string.Empty, StringComparison.OrdinalIgnoreCase)) - { - continue; - } - - if (!string.Equals(videoCodec, i.VideoCodec, StringComparison.OrdinalIgnoreCase)) - { - continue; - } - - return i; - } - - return null; - } - - /// - /// Gets the audio media profile. - /// - /// The container. - /// The audio codec. - /// The audio channels. - /// The audio bitrate. - /// The audio sample rate. - /// The audio bit depth. - /// The . - public ResponseProfile? GetAudioMediaProfile(string? container, string? audioCodec, int? audioChannels, int? audioBitrate, int? audioSampleRate, int? audioBitDepth) - { - foreach (var i in ResponseProfiles) - { - if (i.Type != DlnaProfileType.Audio) - { - continue; - } - - if (!ContainerProfile.ContainsContainer(i.GetContainers(), container)) - { - continue; - } - - var audioCodecs = i.GetAudioCodecs(); - if (audioCodecs.Length > 0 && !audioCodecs.Contains(audioCodec ?? string.Empty, StringComparison.OrdinalIgnoreCase)) - { - continue; - } - - var anyOff = false; - foreach (ProfileCondition c in i.Conditions) - { - if (!ConditionProcessor.IsAudioConditionSatisfied(GetModelProfileCondition(c), audioChannels, audioBitrate, audioSampleRate, audioBitDepth)) - { - anyOff = true; - break; - } - } - - if (anyOff) - { - continue; - } - - return i; - } - - return null; - } - - /// - /// Gets the model profile condition. - /// - /// The c. - /// The . - private ProfileCondition GetModelProfileCondition(ProfileCondition c) - { - return new ProfileCondition - { - Condition = c.Condition, - IsRequired = c.IsRequired, - Property = c.Property, - Value = c.Value - }; - } - - /// - /// Gets the image media profile. - /// - /// The container. - /// The width. - /// The height. - /// The . - public ResponseProfile? GetImageMediaProfile(string container, int? width, int? height) - { - foreach (var i in ResponseProfiles) - { - if (i.Type != DlnaProfileType.Photo) - { - continue; - } - - if (!ContainerProfile.ContainsContainer(i.GetContainers(), container)) - { - continue; - } - - var anyOff = false; - foreach (var c in i.Conditions) - { - if (!ConditionProcessor.IsImageConditionSatisfied(GetModelProfileCondition(c), width, height)) - { - anyOff = true; - break; - } - } - - if (anyOff) - { - continue; - } - - return i; - } - - return null; - } - - /// - /// Gets the video media profile. - /// - /// The container. - /// The audio codec. - /// The video codec. - /// The width. - /// The height. - /// The bit depth. - /// The video bitrate. - /// The video profile. - /// The video range type. - /// The video level. - /// The video framerate. - /// The packet length. - /// The timestamp. - /// True if anamorphic. - /// True if interlaced. - /// The ref frames. - /// The number of video streams. - /// The number of audio streams. - /// The video Codec tag. - /// True if Avc. - /// The . - public ResponseProfile? GetVideoMediaProfile( - string? container, - string? audioCodec, - string? videoCodec, - int? width, - int? height, - int? bitDepth, - int? videoBitrate, - string? videoProfile, - VideoRangeType videoRangeType, - double? videoLevel, - float? videoFramerate, - int? packetLength, - TransportStreamTimestamp timestamp, - bool? isAnamorphic, - bool? isInterlaced, - int? refFrames, - int? numVideoStreams, - int? numAudioStreams, - string? videoCodecTag, - bool? isAvc) - { - foreach (var i in ResponseProfiles) - { - if (i.Type != DlnaProfileType.Video) - { - continue; - } - - if (!ContainerProfile.ContainsContainer(i.GetContainers(), container)) - { - continue; - } - - var audioCodecs = i.GetAudioCodecs(); - if (audioCodecs.Length > 0 && !audioCodecs.Contains(audioCodec ?? string.Empty, StringComparison.OrdinalIgnoreCase)) - { - continue; - } - - var videoCodecs = i.GetVideoCodecs(); - if (videoCodecs.Length > 0 && !videoCodecs.Contains(videoCodec ?? string.Empty, StringComparison.OrdinalIgnoreCase)) - { - continue; - } - - var anyOff = false; - foreach (ProfileCondition c in i.Conditions) - { - if (!ConditionProcessor.IsVideoConditionSatisfied(GetModelProfileCondition(c), width, height, bitDepth, videoBitrate, videoProfile, videoRangeType, videoLevel, videoFramerate, packetLength, timestamp, isAnamorphic, isInterlaced, refFrames, numVideoStreams, numAudioStreams, videoCodecTag, isAvc)) - { - anyOff = true; - break; - } - } - - if (anyOff) - { - continue; - } - - return i; - } - - return null; - } } } diff --git a/MediaBrowser.Model/Dlna/DeviceProfileInfo.cs b/MediaBrowser.Model/Dlna/DeviceProfileInfo.cs deleted file mode 100644 index 74c32c523e..0000000000 --- a/MediaBrowser.Model/Dlna/DeviceProfileInfo.cs +++ /dev/null @@ -1,26 +0,0 @@ -#nullable disable -#pragma warning disable CS1591 - -namespace MediaBrowser.Model.Dlna -{ - public class DeviceProfileInfo - { - /// - /// Gets or sets the identifier. - /// - /// The identifier. - public string Id { get; set; } - - /// - /// Gets or sets the name. - /// - /// The name. - public string Name { get; set; } - - /// - /// Gets or sets the type. - /// - /// The type. - public DeviceProfileType Type { get; set; } - } -} diff --git a/MediaBrowser.Model/Dlna/DeviceProfileType.cs b/MediaBrowser.Model/Dlna/DeviceProfileType.cs deleted file mode 100644 index 46062abd09..0000000000 --- a/MediaBrowser.Model/Dlna/DeviceProfileType.cs +++ /dev/null @@ -1,10 +0,0 @@ -#pragma warning disable CS1591 - -namespace MediaBrowser.Model.Dlna -{ - public enum DeviceProfileType - { - System = 0, - User = 1 - } -} diff --git a/MediaBrowser.Model/Dlna/HeaderMatchType.cs b/MediaBrowser.Model/Dlna/HeaderMatchType.cs deleted file mode 100644 index 2a9abb20eb..0000000000 --- a/MediaBrowser.Model/Dlna/HeaderMatchType.cs +++ /dev/null @@ -1,11 +0,0 @@ -#pragma warning disable CS1591 - -namespace MediaBrowser.Model.Dlna -{ - public enum HeaderMatchType - { - Equals = 0, - Regex = 1, - Substring = 2 - } -} diff --git a/MediaBrowser.Model/Dlna/HttpHeaderInfo.cs b/MediaBrowser.Model/Dlna/HttpHeaderInfo.cs deleted file mode 100644 index 17c4dffcc0..0000000000 --- a/MediaBrowser.Model/Dlna/HttpHeaderInfo.cs +++ /dev/null @@ -1,19 +0,0 @@ -#nullable disable -#pragma warning disable CS1591 - -using System.Xml.Serialization; - -namespace MediaBrowser.Model.Dlna -{ - public class HttpHeaderInfo - { - [XmlAttribute("name")] - public string Name { get; set; } - - [XmlAttribute("value")] - public string Value { get; set; } - - [XmlAttribute("match")] - public HeaderMatchType Match { get; set; } - } -} diff --git a/MediaBrowser.Model/Dlna/ResponseProfile.cs b/MediaBrowser.Model/Dlna/ResponseProfile.cs deleted file mode 100644 index bf9661f7f3..0000000000 --- a/MediaBrowser.Model/Dlna/ResponseProfile.cs +++ /dev/null @@ -1,51 +0,0 @@ -#nullable disable -#pragma warning disable CS1591 - -using System; -using System.Xml.Serialization; - -namespace MediaBrowser.Model.Dlna -{ - public class ResponseProfile - { - public ResponseProfile() - { - Conditions = Array.Empty(); - } - - [XmlAttribute("container")] - public string Container { get; set; } - - [XmlAttribute("audioCodec")] - public string AudioCodec { get; set; } - - [XmlAttribute("videoCodec")] - public string VideoCodec { get; set; } - - [XmlAttribute("type")] - public DlnaProfileType Type { get; set; } - - [XmlAttribute("orgPn")] - public string OrgPn { get; set; } - - [XmlAttribute("mimeType")] - public string MimeType { get; set; } - - public ProfileCondition[] Conditions { get; set; } - - public string[] GetContainers() - { - return ContainerProfile.SplitValue(Container); - } - - public string[] GetAudioCodecs() - { - return ContainerProfile.SplitValue(AudioCodec); - } - - public string[] GetVideoCodecs() - { - return ContainerProfile.SplitValue(VideoCodec); - } - } -} diff --git a/MediaBrowser.Model/Dlna/XmlAttribute.cs b/MediaBrowser.Model/Dlna/XmlAttribute.cs deleted file mode 100644 index 03bb2e4b11..0000000000 --- a/MediaBrowser.Model/Dlna/XmlAttribute.cs +++ /dev/null @@ -1,25 +0,0 @@ -#nullable disable -#pragma warning disable CS1591 - -using System.Xml.Serialization; - -namespace MediaBrowser.Model.Dlna -{ - /// - /// Defines the . - /// - public class XmlAttribute - { - /// - /// Gets or sets the name of the attribute. - /// - [XmlAttribute("name")] - public string Name { get; set; } - - /// - /// Gets or sets the value of the attribute. - /// - [XmlAttribute("value")] - public string Value { get; set; } - } -}