From 0d5bbfda321f64ad78b5b74e7bdfbbbb8b64c7af Mon Sep 17 00:00:00 2001 From: Patrick Barron Date: Wed, 6 Dec 2023 18:06:42 -0500 Subject: [PATCH] Remove unused DLNA models (#10685) * Remove unused DLNA models * Remove IDlnaManager --- MediaBrowser.Controller/Dlna/IDlnaManager.cs | 80 --- .../Dlna/ContentFeatureBuilder.cs | 259 --------- MediaBrowser.Model/Dlna/DlnaFlags.cs | 50 -- MediaBrowser.Model/Dlna/DlnaMaps.cs | 46 -- MediaBrowser.Model/Dlna/IDeviceDiscovery.cs | 14 - MediaBrowser.Model/Dlna/MediaFormatProfile.cs | 114 ---- .../Dlna/MediaFormatProfileResolver.cs | 532 ------------------ MediaBrowser.Model/Dlna/SearchCriteria.cs | 55 -- MediaBrowser.Model/Dlna/SearchType.cs | 14 - MediaBrowser.Model/Dlna/SortCriteria.cs | 24 - MediaBrowser.Model/Dlna/UpnpDeviceInfo.cs | 22 - 11 files changed, 1210 deletions(-) delete mode 100644 MediaBrowser.Controller/Dlna/IDlnaManager.cs delete mode 100644 MediaBrowser.Model/Dlna/ContentFeatureBuilder.cs delete mode 100644 MediaBrowser.Model/Dlna/DlnaFlags.cs delete mode 100644 MediaBrowser.Model/Dlna/DlnaMaps.cs delete mode 100644 MediaBrowser.Model/Dlna/IDeviceDiscovery.cs delete mode 100644 MediaBrowser.Model/Dlna/MediaFormatProfile.cs delete mode 100644 MediaBrowser.Model/Dlna/MediaFormatProfileResolver.cs delete mode 100644 MediaBrowser.Model/Dlna/SearchCriteria.cs delete mode 100644 MediaBrowser.Model/Dlna/SearchType.cs delete mode 100644 MediaBrowser.Model/Dlna/SortCriteria.cs delete mode 100644 MediaBrowser.Model/Dlna/UpnpDeviceInfo.cs diff --git a/MediaBrowser.Controller/Dlna/IDlnaManager.cs b/MediaBrowser.Controller/Dlna/IDlnaManager.cs deleted file mode 100644 index 06da5ea097..0000000000 --- a/MediaBrowser.Controller/Dlna/IDlnaManager.cs +++ /dev/null @@ -1,80 +0,0 @@ -#pragma warning disable CS1591 - -using System.Collections.Generic; -using MediaBrowser.Controller.Drawing; -using MediaBrowser.Model.Dlna; -using Microsoft.AspNetCore.Http; - -namespace MediaBrowser.Controller.Dlna -{ - public interface IDlnaManager - { - /// - /// Gets the profile infos. - /// - /// IEnumerable{DeviceProfileInfo}. - IEnumerable GetProfileInfos(); - - /// - /// Gets the profile. - /// - /// The headers. - /// DeviceProfile. - DeviceProfile? GetProfile(IHeaderDictionary headers); - - /// - /// Gets the default profile. - /// - /// DeviceProfile. - DeviceProfile GetDefaultProfile(); - - /// - /// Creates the profile. - /// - /// The profile. - void CreateProfile(DeviceProfile profile); - - /// - /// Updates the profile. - /// - /// The profile id. - /// The profile. - void UpdateProfile(string profileId, DeviceProfile profile); - - /// - /// Deletes the profile. - /// - /// The identifier. - void DeleteProfile(string id); - - /// - /// Gets the profile. - /// - /// The identifier. - /// DeviceProfile. - DeviceProfile? GetProfile(string id); - - /// - /// Gets the profile. - /// - /// The device information. - /// DeviceProfile. - DeviceProfile? GetProfile(DeviceIdentification deviceInfo); - - /// - /// Gets the server description XML. - /// - /// The headers. - /// The server uu identifier. - /// The server address. - /// System.String. - string GetServerDescriptionXml(IHeaderDictionary headers, string serverUuId, string serverAddress); - - /// - /// Gets the icon. - /// - /// The filename. - /// DlnaIconResponse. - ImageStream? GetIcon(string filename); - } -} diff --git a/MediaBrowser.Model/Dlna/ContentFeatureBuilder.cs b/MediaBrowser.Model/Dlna/ContentFeatureBuilder.cs deleted file mode 100644 index f29022b54e..0000000000 --- a/MediaBrowser.Model/Dlna/ContentFeatureBuilder.cs +++ /dev/null @@ -1,259 +0,0 @@ -#nullable disable -#pragma warning disable CS1591 - -using System; -using System.Collections.Generic; -using System.Globalization; -using Jellyfin.Data.Enums; -using MediaBrowser.Model.MediaInfo; - -namespace MediaBrowser.Model.Dlna -{ - public static class ContentFeatureBuilder - { - public static string BuildImageHeader( - DeviceProfile profile, - string container, - int? width, - int? height, - bool isDirectStream, - string orgPn = null) - { - string orgOp = ";DLNA.ORG_OP=" + DlnaMaps.GetImageOrgOpValue(); - - // 0 = native, 1 = transcoded - var orgCi = isDirectStream ? ";DLNA.ORG_CI=0" : ";DLNA.ORG_CI=1"; - - var flagValue = DlnaFlags.BackgroundTransferMode | - DlnaFlags.InteractiveTransferMode | - DlnaFlags.DlnaV15; - - string dlnaflags = string.Format( - CultureInfo.InvariantCulture, - ";DLNA.ORG_FLAGS={0}", - DlnaMaps.FlagsToString(flagValue)); - - if (string.IsNullOrEmpty(orgPn)) - { - ResponseProfile mediaProfile = profile.GetImageMediaProfile( - container, - width, - height); - - orgPn = mediaProfile?.OrgPn; - - if (string.IsNullOrEmpty(orgPn)) - { - orgPn = GetImageOrgPnValue(container, width, height); - } - } - - if (string.IsNullOrEmpty(orgPn)) - { - return orgOp.TrimStart(';') + orgCi + dlnaflags; - } - - return "DLNA.ORG_PN=" + orgPn + orgOp + orgCi + dlnaflags; - } - - public static string BuildAudioHeader( - DeviceProfile profile, - string container, - string audioCodec, - int? audioBitrate, - int? audioSampleRate, - int? audioChannels, - int? audioBitDepth, - bool isDirectStream, - long? runtimeTicks, - TranscodeSeekInfo transcodeSeekInfo) - { - // first bit means Time based seek supported, second byte range seek supported (not sure about the order now), so 01 = only byte seek, 10 = time based, 11 = both, 00 = none - string orgOp = ";DLNA.ORG_OP=" + DlnaMaps.GetOrgOpValue(runtimeTicks > 0, isDirectStream, transcodeSeekInfo); - - // 0 = native, 1 = transcoded - string orgCi = isDirectStream ? ";DLNA.ORG_CI=0" : ";DLNA.ORG_CI=1"; - - var flagValue = DlnaFlags.StreamingTransferMode | - DlnaFlags.BackgroundTransferMode | - DlnaFlags.InteractiveTransferMode | - DlnaFlags.DlnaV15; - - // if (isDirectStream) - // { - // flagValue = flagValue | DlnaFlags.ByteBasedSeek; - // } - // else if (runtimeTicks.HasValue) - // { - // flagValue = flagValue | DlnaFlags.TimeBasedSeek; - // } - - string dlnaflags = string.Format( - CultureInfo.InvariantCulture, - ";DLNA.ORG_FLAGS={0}", - DlnaMaps.FlagsToString(flagValue)); - - ResponseProfile mediaProfile = profile.GetAudioMediaProfile( - container, - audioCodec, - audioChannels, - audioBitrate, - audioSampleRate, - audioBitDepth); - - string orgPn = mediaProfile?.OrgPn; - - if (string.IsNullOrEmpty(orgPn)) - { - orgPn = GetAudioOrgPnValue(container, audioBitrate, audioSampleRate, audioChannels); - } - - if (string.IsNullOrEmpty(orgPn)) - { - return orgOp.TrimStart(';') + orgCi + dlnaflags; - } - - return "DLNA.ORG_PN=" + orgPn + orgOp + orgCi + dlnaflags; - } - - public static IEnumerable BuildVideoHeader( - DeviceProfile profile, - string container, - string videoCodec, - string audioCodec, - int? width, - int? height, - int? bitDepth, - int? videoBitrate, - TransportStreamTimestamp timestamp, - bool isDirectStream, - long? runtimeTicks, - string videoProfile, - VideoRangeType videoRangeType, - double? videoLevel, - float? videoFramerate, - int? packetLength, - TranscodeSeekInfo transcodeSeekInfo, - bool? isAnamorphic, - bool? isInterlaced, - int? refFrames, - int? numVideoStreams, - int? numAudioStreams, - string videoCodecTag, - bool? isAvc) - { - // first bit means Time based seek supported, second byte range seek supported (not sure about the order now), so 01 = only byte seek, 10 = time based, 11 = both, 00 = none - string orgOp = ";DLNA.ORG_OP=" + DlnaMaps.GetOrgOpValue(runtimeTicks > 0, isDirectStream, transcodeSeekInfo); - - // 0 = native, 1 = transcoded - string orgCi = isDirectStream ? ";DLNA.ORG_CI=0" : ";DLNA.ORG_CI=1"; - - var flagValue = DlnaFlags.StreamingTransferMode | - DlnaFlags.BackgroundTransferMode | - DlnaFlags.InteractiveTransferMode | - DlnaFlags.DlnaV15; - - if (isDirectStream) - { - flagValue |= DlnaFlags.ByteBasedSeek; - } - - // Time based seek is currently disabled when streaming. On LG CX3 adding DlnaFlags.TimeBasedSeek and orgPn causes the DLNA playback to fail (format not supported). Further investigations are needed before enabling the remaining code paths. - // else if (runtimeTicks.HasValue) - // { - // flagValue = flagValue | DlnaFlags.TimeBasedSeek; - // } - - string dlnaflags = string.Format( - CultureInfo.InvariantCulture, - ";DLNA.ORG_FLAGS={0}", - DlnaMaps.FlagsToString(flagValue)); - - ResponseProfile mediaProfile = profile.GetVideoMediaProfile( - container, - audioCodec, - videoCodec, - width, - height, - bitDepth, - videoBitrate, - videoProfile, - videoRangeType, - videoLevel, - videoFramerate, - packetLength, - timestamp, - isAnamorphic, - isInterlaced, - refFrames, - numVideoStreams, - numAudioStreams, - videoCodecTag, - isAvc); - - var orgPnValues = new List(); - - if (mediaProfile is not null && !string.IsNullOrEmpty(mediaProfile.OrgPn)) - { - orgPnValues.AddRange(mediaProfile.OrgPn.Split(',', StringSplitOptions.RemoveEmptyEntries)); - } - else - { - foreach (var s in GetVideoOrgPnValue(container, videoCodec, audioCodec, width, height, timestamp)) - { - orgPnValues.Add(s.ToString()); - break; - } - } - - var contentFeatureList = new List(); - - foreach (string orgPn in orgPnValues) - { - if (string.IsNullOrEmpty(orgPn)) - { - contentFeatureList.Add(orgOp.TrimStart(';') + orgCi + dlnaflags); - } - else if (isDirectStream) - { - // orgOp should be added all the time once the time based seek is resolved for transcoded streams - contentFeatureList.Add("DLNA.ORG_PN=" + orgPn + orgOp + orgCi + dlnaflags); - } - else - { - contentFeatureList.Add("DLNA.ORG_PN=" + orgPn + orgCi + dlnaflags); - } - } - - if (orgPnValues.Count == 0) - { - contentFeatureList.Add(orgOp.TrimStart(';') + orgCi + dlnaflags); - } - - return contentFeatureList; - } - - private static string GetImageOrgPnValue(string container, int? width, int? height) - { - MediaFormatProfile? format = MediaFormatProfileResolver.ResolveImageFormat(container, width, height); - - return format.HasValue ? format.Value.ToString() : null; - } - - private static string GetAudioOrgPnValue(string container, int? audioBitrate, int? audioSampleRate, int? audioChannels) - { - MediaFormatProfile? format = MediaFormatProfileResolver.ResolveAudioFormat( - container, - audioBitrate, - audioSampleRate, - audioChannels); - - return format.HasValue ? format.Value.ToString() : null; - } - - private static MediaFormatProfile[] GetVideoOrgPnValue(string container, string videoCodec, string audioCodec, int? width, int? height, TransportStreamTimestamp timestamp) - { - return MediaFormatProfileResolver.ResolveVideoFormat(container, videoCodec, audioCodec, width, height, timestamp); - } - } -} diff --git a/MediaBrowser.Model/Dlna/DlnaFlags.cs b/MediaBrowser.Model/Dlna/DlnaFlags.cs deleted file mode 100644 index 02d9ea9c58..0000000000 --- a/MediaBrowser.Model/Dlna/DlnaFlags.cs +++ /dev/null @@ -1,50 +0,0 @@ -#pragma warning disable CS1591 - -using System; - -namespace MediaBrowser.Model.Dlna -{ - [Flags] - public enum DlnaFlags : ulong - { - /*! Background transfer mode. - For use with upload and download transfers to and from the server. - The primary difference between \ref DH_TransferMode_Interactive and - \ref DH_TransferMode_Bulk is that the latter assumes that the user - is not relying on the transfer for immediately rendering the content - and there are no issues with causing a buffer overflow if the - receiver uses TCP flow control to reduce total throughput. - */ - BackgroundTransferMode = 1 << 22, - - ByteBasedSeek = 1 << 29, - ConnectionStall = 1 << 21, - - DlnaV15 = 1 << 20, - - /*! Interactive transfer mode. - For best effort transfer of images and non-real-time transfers. - URIs with image content usually support \ref DH_TransferMode_Bulk too. - The primary difference between \ref DH_TransferMode_Interactive and - \ref DH_TransferMode_Bulk is that the former assumes that the - transfer is intended for immediate rendering. - */ - InteractiveTransferMode = 1 << 23, - - PlayContainer = 1 << 28, - RtspPause = 1 << 25, - S0Increase = 1 << 27, - SenderPaced = 1L << 31, - SnIncrease = 1 << 26, - - /*! Streaming transfer mode. - The server transmits at a throughput sufficient for real-time playback of - audio or video. URIs with audio or video often support the - \ref DH_TransferMode_Interactive and \ref DH_TransferMode_Bulk transfer modes. - The most well-known exception to this general claim is for live streams. - */ - StreamingTransferMode = 1 << 24, - - TimeBasedSeek = 1 << 30 - } -} diff --git a/MediaBrowser.Model/Dlna/DlnaMaps.cs b/MediaBrowser.Model/Dlna/DlnaMaps.cs deleted file mode 100644 index 4613bc5427..0000000000 --- a/MediaBrowser.Model/Dlna/DlnaMaps.cs +++ /dev/null @@ -1,46 +0,0 @@ -#pragma warning disable CS1591 - -using System.Globalization; - -namespace MediaBrowser.Model.Dlna -{ - public static class DlnaMaps - { - public static string FlagsToString(DlnaFlags flags) - { - return string.Format(CultureInfo.InvariantCulture, "{0:X8}{1:D24}", (ulong)flags, 0); - } - - public static string GetOrgOpValue(bool hasKnownRuntime, bool isDirectStream, TranscodeSeekInfo profileTranscodeSeekInfo) - { - if (hasKnownRuntime) - { - string orgOp = string.Empty; - - // Time-based seeking currently only possible when transcoding - orgOp += isDirectStream ? "0" : "1"; - - // Byte-based seeking only possible when not transcoding - orgOp += isDirectStream || profileTranscodeSeekInfo == TranscodeSeekInfo.Bytes ? "1" : "0"; - - return orgOp; - } - - // No seeking is available if we don't know the content runtime - return "00"; - } - - public static string GetImageOrgOpValue() - { - string orgOp = string.Empty; - - // Time-based seeking currently only possible when transcoding - orgOp += "0"; - - // Byte-based seeking only possible when not transcoding - orgOp += "0"; - - return orgOp; - } - } -} diff --git a/MediaBrowser.Model/Dlna/IDeviceDiscovery.cs b/MediaBrowser.Model/Dlna/IDeviceDiscovery.cs deleted file mode 100644 index 086088deae..0000000000 --- a/MediaBrowser.Model/Dlna/IDeviceDiscovery.cs +++ /dev/null @@ -1,14 +0,0 @@ -#pragma warning disable CS1591 - -using System; -using Jellyfin.Data.Events; - -namespace MediaBrowser.Model.Dlna -{ - public interface IDeviceDiscovery - { - event EventHandler> DeviceDiscovered; - - event EventHandler> DeviceLeft; - } -} diff --git a/MediaBrowser.Model/Dlna/MediaFormatProfile.cs b/MediaBrowser.Model/Dlna/MediaFormatProfile.cs deleted file mode 100644 index 06f6660f4b..0000000000 --- a/MediaBrowser.Model/Dlna/MediaFormatProfile.cs +++ /dev/null @@ -1,114 +0,0 @@ -#pragma warning disable CS1591, CA1707 - -namespace MediaBrowser.Model.Dlna -{ - public enum MediaFormatProfile - { - MP3, - WMA_BASE, - WMA_FULL, - LPCM16_44_MONO, - LPCM16_44_STEREO, - LPCM16_48_MONO, - LPCM16_48_STEREO, - AAC_ISO, - AAC_ISO_320, - AAC_ADTS, - AAC_ADTS_320, - FLAC, - OGG, - - JPEG_SM, - JPEG_MED, - JPEG_LRG, - JPEG_TN, - PNG_LRG, - PNG_TN, - GIF_LRG, - RAW, - - MPEG1, - MPEG_PS_PAL, - MPEG_PS_NTSC, - MPEG_TS_SD_EU, - MPEG_TS_SD_EU_ISO, - MPEG_TS_SD_EU_T, - MPEG_TS_SD_NA, - MPEG_TS_SD_NA_ISO, - MPEG_TS_SD_NA_T, - MPEG_TS_SD_KO, - MPEG_TS_SD_KO_ISO, - MPEG_TS_SD_KO_T, - MPEG_TS_JP_T, - AVI, - MATROSKA, - FLV, - DVR_MS, - WTV, - OGV, - AVC_MP4_MP_SD_AAC_MULT5, - AVC_MP4_MP_SD_MPEG1_L3, - AVC_MP4_MP_SD_AC3, - AVC_MP4_MP_HD_720p_AAC, - AVC_MP4_MP_HD_1080i_AAC, - AVC_MP4_HP_HD_AAC, - AVC_TS_MP_HD_AAC_MULT5, - AVC_TS_MP_HD_AAC_MULT5_T, - AVC_TS_MP_HD_AAC_MULT5_ISO, - AVC_TS_MP_HD_MPEG1_L3, - AVC_TS_MP_HD_MPEG1_L3_T, - AVC_TS_MP_HD_MPEG1_L3_ISO, - AVC_TS_MP_HD_AC3, - AVC_TS_MP_HD_AC3_T, - AVC_TS_MP_HD_AC3_ISO, - AVC_TS_HP_HD_MPEG1_L2_T, - AVC_TS_HP_HD_MPEG1_L2_ISO, - AVC_TS_MP_SD_AAC_MULT5, - AVC_TS_MP_SD_AAC_MULT5_T, - AVC_TS_MP_SD_AAC_MULT5_ISO, - AVC_TS_MP_SD_MPEG1_L3, - AVC_TS_MP_SD_MPEG1_L3_T, - AVC_TS_MP_SD_MPEG1_L3_ISO, - AVC_TS_HP_SD_MPEG1_L2_T, - AVC_TS_HP_SD_MPEG1_L2_ISO, - AVC_TS_MP_SD_AC3, - AVC_TS_MP_SD_AC3_T, - AVC_TS_MP_SD_AC3_ISO, - AVC_TS_HD_DTS_T, - AVC_TS_HD_DTS_ISO, - WMVMED_BASE, - WMVMED_FULL, - WMVMED_PRO, - WMVHIGH_FULL, - WMVHIGH_PRO, - VC1_ASF_AP_L1_WMA, - VC1_ASF_AP_L2_WMA, - VC1_ASF_AP_L3_WMA, - VC1_TS_AP_L1_AC3_ISO, - VC1_TS_AP_L2_AC3_ISO, - VC1_TS_HD_DTS_ISO, - VC1_TS_HD_DTS_T, - MPEG4_P2_MP4_ASP_AAC, - MPEG4_P2_MP4_SP_L6_AAC, - MPEG4_P2_MP4_NDSD, - MPEG4_P2_TS_ASP_AAC, - MPEG4_P2_TS_ASP_AAC_T, - MPEG4_P2_TS_ASP_AAC_ISO, - MPEG4_P2_TS_ASP_MPEG1_L3, - MPEG4_P2_TS_ASP_MPEG1_L3_T, - MPEG4_P2_TS_ASP_MPEG1_L3_ISO, - MPEG4_P2_TS_ASP_MPEG2_L2, - MPEG4_P2_TS_ASP_MPEG2_L2_T, - MPEG4_P2_TS_ASP_MPEG2_L2_ISO, - MPEG4_P2_TS_ASP_AC3, - MPEG4_P2_TS_ASP_AC3_T, - MPEG4_P2_TS_ASP_AC3_ISO, - AVC_TS_HD_50_LPCM_T, - AVC_MP4_LPCM, - MPEG4_P2_3GPP_SP_L0B_AAC, - MPEG4_P2_3GPP_SP_L0B_AMR, - AVC_3GPP_BL_QCIF15_AAC, - MPEG4_H263_3GPP_P0_L10_AMR, - MPEG4_H263_MP4_P0_L10_AAC - } -} diff --git a/MediaBrowser.Model/Dlna/MediaFormatProfileResolver.cs b/MediaBrowser.Model/Dlna/MediaFormatProfileResolver.cs deleted file mode 100644 index 93a9ae6159..0000000000 --- a/MediaBrowser.Model/Dlna/MediaFormatProfileResolver.cs +++ /dev/null @@ -1,532 +0,0 @@ -#nullable disable -#pragma warning disable CS1591 - -using System; -using System.Collections.Generic; -using System.Globalization; -using MediaBrowser.Model.MediaInfo; - -namespace MediaBrowser.Model.Dlna -{ - public static class MediaFormatProfileResolver - { - public static MediaFormatProfile[] ResolveVideoFormat(string container, string videoCodec, string audioCodec, int? width, int? height, TransportStreamTimestamp timestampType) - { - if (string.Equals(container, "asf", StringComparison.OrdinalIgnoreCase)) - { - MediaFormatProfile? val = ResolveVideoASFFormat(videoCodec, audioCodec, width, height); - return val.HasValue ? new MediaFormatProfile[] { val.Value } : Array.Empty(); - } - - if (string.Equals(container, "mp4", StringComparison.OrdinalIgnoreCase)) - { - MediaFormatProfile? val = ResolveVideoMP4Format(videoCodec, audioCodec, width, height); - return val.HasValue ? new MediaFormatProfile[] { val.Value } : Array.Empty(); - } - - if (string.Equals(container, "avi", StringComparison.OrdinalIgnoreCase)) - { - return new MediaFormatProfile[] { MediaFormatProfile.AVI }; - } - - if (string.Equals(container, "mkv", StringComparison.OrdinalIgnoreCase)) - { - return new MediaFormatProfile[] { MediaFormatProfile.MATROSKA }; - } - - if (string.Equals(container, "mpeg2ps", StringComparison.OrdinalIgnoreCase) || - string.Equals(container, "ts", StringComparison.OrdinalIgnoreCase)) - { - return new MediaFormatProfile[] { MediaFormatProfile.MPEG_PS_NTSC, MediaFormatProfile.MPEG_PS_PAL }; - } - - if (string.Equals(container, "mpeg1video", StringComparison.OrdinalIgnoreCase)) - { - return new MediaFormatProfile[] { MediaFormatProfile.MPEG1 }; - } - - if (string.Equals(container, "mpeg2ts", StringComparison.OrdinalIgnoreCase) || - string.Equals(container, "mpegts", StringComparison.OrdinalIgnoreCase) || - string.Equals(container, "m2ts", StringComparison.OrdinalIgnoreCase)) - { - return ResolveVideoMPEG2TSFormat(videoCodec, audioCodec, width, height, timestampType); - } - - if (string.Equals(container, "flv", StringComparison.OrdinalIgnoreCase)) - { - return new MediaFormatProfile[] { MediaFormatProfile.FLV }; - } - - if (string.Equals(container, "wtv", StringComparison.OrdinalIgnoreCase)) - { - return new MediaFormatProfile[] { MediaFormatProfile.WTV }; - } - - if (string.Equals(container, "3gp", StringComparison.OrdinalIgnoreCase)) - { - MediaFormatProfile? val = ResolveVideo3GPFormat(videoCodec, audioCodec); - return val.HasValue ? new MediaFormatProfile[] { val.Value } : Array.Empty(); - } - - if (string.Equals(container, "ogv", StringComparison.OrdinalIgnoreCase) || string.Equals(container, "ogg", StringComparison.OrdinalIgnoreCase)) - { - return new MediaFormatProfile[] { MediaFormatProfile.OGV }; - } - - return Array.Empty(); - } - - private static MediaFormatProfile[] ResolveVideoMPEG2TSFormat(string videoCodec, string audioCodec, int? width, int? height, TransportStreamTimestamp timestampType) - { - string suffix = string.Empty; - - switch (timestampType) - { - case TransportStreamTimestamp.None: - suffix = "_ISO"; - break; - case TransportStreamTimestamp.Valid: - suffix = "_T"; - break; - } - - string resolution = "S"; - if ((width.HasValue && width.Value > 720) || (height.HasValue && height.Value > 576)) - { - resolution = "H"; - } - - if (string.Equals(videoCodec, "mpeg2video", StringComparison.OrdinalIgnoreCase)) - { - var list = new List - { - ValueOf("MPEG_TS_SD_NA" + suffix), - ValueOf("MPEG_TS_SD_EU" + suffix), - ValueOf("MPEG_TS_SD_KO" + suffix) - }; - - if ((timestampType == TransportStreamTimestamp.Valid) && string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase)) - { - list.Add(MediaFormatProfile.MPEG_TS_JP_T); - } - - return list.ToArray(); - } - - if (string.Equals(videoCodec, "h264", StringComparison.OrdinalIgnoreCase)) - { - if (string.Equals(audioCodec, "lpcm", StringComparison.OrdinalIgnoreCase)) - { - return new MediaFormatProfile[] { MediaFormatProfile.AVC_TS_HD_50_LPCM_T }; - } - - if (string.Equals(audioCodec, "dts", StringComparison.OrdinalIgnoreCase)) - { - if (timestampType == TransportStreamTimestamp.None) - { - return new MediaFormatProfile[] { MediaFormatProfile.AVC_TS_HD_DTS_ISO }; - } - - return new MediaFormatProfile[] { MediaFormatProfile.AVC_TS_HD_DTS_T }; - } - - if (string.Equals(audioCodec, "mp2", StringComparison.OrdinalIgnoreCase)) - { - if (timestampType == TransportStreamTimestamp.None) - { - return new MediaFormatProfile[] { ValueOf(string.Format(CultureInfo.InvariantCulture, "AVC_TS_HP_{0}D_MPEG1_L2_ISO", resolution)) }; - } - - return new MediaFormatProfile[] { ValueOf(string.Format(CultureInfo.InvariantCulture, "AVC_TS_HP_{0}D_MPEG1_L2_T", resolution)) }; - } - - if (string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase)) - { - return new MediaFormatProfile[] { ValueOf(string.Format(CultureInfo.InvariantCulture, "AVC_TS_MP_{0}D_AAC_MULT5{1}", resolution, suffix)) }; - } - - if (string.Equals(audioCodec, "mp3", StringComparison.OrdinalIgnoreCase)) - { - return new MediaFormatProfile[] { ValueOf(string.Format(CultureInfo.InvariantCulture, "AVC_TS_MP_{0}D_MPEG1_L3{1}", resolution, suffix)) }; - } - - if (string.IsNullOrEmpty(audioCodec) || - string.Equals(audioCodec, "ac3", StringComparison.OrdinalIgnoreCase)) - { - return new MediaFormatProfile[] { ValueOf(string.Format(CultureInfo.InvariantCulture, "AVC_TS_MP_{0}D_AC3{1}", resolution, suffix)) }; - } - } - else if (string.Equals(videoCodec, "vc1", StringComparison.OrdinalIgnoreCase)) - { - if (string.IsNullOrEmpty(audioCodec) || string.Equals(audioCodec, "ac3", StringComparison.OrdinalIgnoreCase)) - { - if ((width.HasValue && width.Value > 720) || (height.HasValue && height.Value > 576)) - { - return new MediaFormatProfile[] { MediaFormatProfile.VC1_TS_AP_L2_AC3_ISO }; - } - - return new MediaFormatProfile[] { MediaFormatProfile.VC1_TS_AP_L1_AC3_ISO }; - } - - if (string.Equals(audioCodec, "dts", StringComparison.OrdinalIgnoreCase)) - { - suffix = string.Equals(suffix, "_ISO", StringComparison.OrdinalIgnoreCase) ? suffix : "_T"; - - return new MediaFormatProfile[] { ValueOf(string.Format(CultureInfo.InvariantCulture, "VC1_TS_HD_DTS{0}", suffix)) }; - } - } - else if (string.Equals(videoCodec, "mpeg4", StringComparison.OrdinalIgnoreCase) || string.Equals(videoCodec, "msmpeg4", StringComparison.OrdinalIgnoreCase)) - { - if (string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase)) - { - return new MediaFormatProfile[] { ValueOf(string.Format(CultureInfo.InvariantCulture, "MPEG4_P2_TS_ASP_AAC{0}", suffix)) }; - } - - if (string.Equals(audioCodec, "mp3", StringComparison.OrdinalIgnoreCase)) - { - return new MediaFormatProfile[] { ValueOf(string.Format(CultureInfo.InvariantCulture, "MPEG4_P2_TS_ASP_MPEG1_L3{0}", suffix)) }; - } - - if (string.Equals(audioCodec, "mp2", StringComparison.OrdinalIgnoreCase)) - { - return new MediaFormatProfile[] { ValueOf(string.Format(CultureInfo.InvariantCulture, "MPEG4_P2_TS_ASP_MPEG2_L2{0}", suffix)) }; - } - - if (string.Equals(audioCodec, "ac3", StringComparison.OrdinalIgnoreCase)) - { - return new MediaFormatProfile[] { ValueOf(string.Format(CultureInfo.InvariantCulture, "MPEG4_P2_TS_ASP_AC3{0}", suffix)) }; - } - } - - return Array.Empty(); - } - - private static MediaFormatProfile ValueOf(string value) - { - return (MediaFormatProfile)Enum.Parse(typeof(MediaFormatProfile), value, true); - } - - private static MediaFormatProfile? ResolveVideoMP4Format(string videoCodec, string audioCodec, int? width, int? height) - { - if (string.Equals(videoCodec, "h264", StringComparison.OrdinalIgnoreCase)) - { - if (string.Equals(audioCodec, "lpcm", StringComparison.OrdinalIgnoreCase)) - { - return MediaFormatProfile.AVC_MP4_LPCM; - } - - if (string.IsNullOrEmpty(audioCodec) || - string.Equals(audioCodec, "ac3", StringComparison.OrdinalIgnoreCase)) - { - return MediaFormatProfile.AVC_MP4_MP_SD_AC3; - } - - if (string.Equals(audioCodec, "mp3", StringComparison.OrdinalIgnoreCase)) - { - return MediaFormatProfile.AVC_MP4_MP_SD_MPEG1_L3; - } - - if (width.HasValue && height.HasValue) - { - if ((width.Value <= 720) && (height.Value <= 576)) - { - if (string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase)) - { - return MediaFormatProfile.AVC_MP4_MP_SD_AAC_MULT5; - } - } - else if ((width.Value <= 1280) && (height.Value <= 720)) - { - if (string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase)) - { - return MediaFormatProfile.AVC_MP4_MP_HD_720p_AAC; - } - } - else if ((width.Value <= 1920) && (height.Value <= 1080)) - { - if (string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase)) - { - return MediaFormatProfile.AVC_MP4_MP_HD_1080i_AAC; - } - } - } - } - else if (string.Equals(videoCodec, "mpeg4", StringComparison.OrdinalIgnoreCase) || - string.Equals(videoCodec, "msmpeg4", StringComparison.OrdinalIgnoreCase)) - { - if (width.HasValue && height.HasValue && width.Value <= 720 && height.Value <= 576) - { - if (string.IsNullOrEmpty(audioCodec) || string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase)) - { - return MediaFormatProfile.MPEG4_P2_MP4_ASP_AAC; - } - - if (string.Equals(audioCodec, "ac3", StringComparison.OrdinalIgnoreCase) || string.Equals(audioCodec, "mp3", StringComparison.OrdinalIgnoreCase)) - { - return MediaFormatProfile.MPEG4_P2_MP4_NDSD; - } - } - else if (string.IsNullOrEmpty(audioCodec) || string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase)) - { - return MediaFormatProfile.MPEG4_P2_MP4_SP_L6_AAC; - } - } - else if (string.Equals(videoCodec, "h263", StringComparison.OrdinalIgnoreCase) && string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase)) - { - return MediaFormatProfile.MPEG4_H263_MP4_P0_L10_AAC; - } - - return null; - } - - private static MediaFormatProfile? ResolveVideo3GPFormat(string videoCodec, string audioCodec) - { - if (string.Equals(videoCodec, "h264", StringComparison.OrdinalIgnoreCase)) - { - if (string.IsNullOrEmpty(audioCodec) || string.Equals(audioCodec, "aac", StringComparison.OrdinalIgnoreCase)) - { - return MediaFormatProfile.AVC_3GPP_BL_QCIF15_AAC; - } - } - else if (string.Equals(videoCodec, "mpeg4", StringComparison.OrdinalIgnoreCase) || - string.Equals(videoCodec, "msmpeg4", StringComparison.OrdinalIgnoreCase)) - { - if (string.IsNullOrEmpty(audioCodec) || string.Equals(audioCodec, "wma", StringComparison.OrdinalIgnoreCase)) - { - return MediaFormatProfile.MPEG4_P2_3GPP_SP_L0B_AAC; - } - - if (string.Equals(audioCodec, "amrnb", StringComparison.OrdinalIgnoreCase)) - { - return MediaFormatProfile.MPEG4_P2_3GPP_SP_L0B_AMR; - } - } - else if (string.Equals(videoCodec, "h263", StringComparison.OrdinalIgnoreCase) && string.Equals(audioCodec, "amrnb", StringComparison.OrdinalIgnoreCase)) - { - return MediaFormatProfile.MPEG4_H263_3GPP_P0_L10_AMR; - } - - return null; - } - - private static MediaFormatProfile? ResolveVideoASFFormat(string videoCodec, string audioCodec, int? width, int? height) - { - if (string.Equals(videoCodec, "wmv", StringComparison.OrdinalIgnoreCase) && - (string.IsNullOrEmpty(audioCodec) || string.Equals(audioCodec, "wma", StringComparison.OrdinalIgnoreCase) || string.Equals(videoCodec, "wmapro", StringComparison.OrdinalIgnoreCase))) - { - if (width.HasValue && height.HasValue) - { - if ((width.Value <= 720) && (height.Value <= 576)) - { - if (string.IsNullOrEmpty(audioCodec) || string.Equals(audioCodec, "wma", StringComparison.OrdinalIgnoreCase)) - { - return MediaFormatProfile.WMVMED_FULL; - } - - return MediaFormatProfile.WMVMED_PRO; - } - } - - if (string.IsNullOrEmpty(audioCodec) || string.Equals(audioCodec, "wma", StringComparison.OrdinalIgnoreCase)) - { - return MediaFormatProfile.WMVHIGH_FULL; - } - - return MediaFormatProfile.WMVHIGH_PRO; - } - - if (string.Equals(videoCodec, "vc1", StringComparison.OrdinalIgnoreCase)) - { - if (width.HasValue && height.HasValue) - { - if ((width.Value <= 720) && (height.Value <= 576)) - { - return MediaFormatProfile.VC1_ASF_AP_L1_WMA; - } - - if ((width.Value <= 1280) && (height.Value <= 720)) - { - return MediaFormatProfile.VC1_ASF_AP_L2_WMA; - } - - if ((width.Value <= 1920) && (height.Value <= 1080)) - { - return MediaFormatProfile.VC1_ASF_AP_L3_WMA; - } - } - } - else if (string.Equals(videoCodec, "mpeg2video", StringComparison.OrdinalIgnoreCase)) - { - return MediaFormatProfile.DVR_MS; - } - - return null; - } - - public static MediaFormatProfile? ResolveAudioFormat(string container, int? bitrate, int? frequency, int? channels) - { - if (string.Equals(container, "asf", StringComparison.OrdinalIgnoreCase)) - { - return ResolveAudioASFFormat(bitrate); - } - - if (string.Equals(container, "mp3", StringComparison.OrdinalIgnoreCase)) - { - return MediaFormatProfile.MP3; - } - - if (string.Equals(container, "lpcm", StringComparison.OrdinalIgnoreCase)) - { - return ResolveAudioLPCMFormat(frequency, channels); - } - - if (string.Equals(container, "mp4", StringComparison.OrdinalIgnoreCase) || - string.Equals(container, "aac", StringComparison.OrdinalIgnoreCase)) - { - return ResolveAudioMP4Format(bitrate); - } - - if (string.Equals(container, "adts", StringComparison.OrdinalIgnoreCase)) - { - return ResolveAudioADTSFormat(bitrate); - } - - if (string.Equals(container, "flac", StringComparison.OrdinalIgnoreCase)) - { - return MediaFormatProfile.FLAC; - } - - if (string.Equals(container, "oga", StringComparison.OrdinalIgnoreCase) || - string.Equals(container, "ogg", StringComparison.OrdinalIgnoreCase)) - { - return MediaFormatProfile.OGG; - } - - return null; - } - - private static MediaFormatProfile ResolveAudioASFFormat(int? bitrate) - { - if (bitrate.HasValue && bitrate.Value <= 193) - { - return MediaFormatProfile.WMA_BASE; - } - - return MediaFormatProfile.WMA_FULL; - } - - private static MediaFormatProfile? ResolveAudioLPCMFormat(int? frequency, int? channels) - { - if (frequency.HasValue && channels.HasValue) - { - if (frequency.Value == 44100 && channels.Value == 1) - { - return MediaFormatProfile.LPCM16_44_MONO; - } - - if (frequency.Value == 44100 && channels.Value == 2) - { - return MediaFormatProfile.LPCM16_44_STEREO; - } - - if (frequency.Value == 48000 && channels.Value == 1) - { - return MediaFormatProfile.LPCM16_48_MONO; - } - - if (frequency.Value == 48000 && channels.Value == 2) - { - return MediaFormatProfile.LPCM16_48_STEREO; - } - - return null; - } - - return MediaFormatProfile.LPCM16_48_STEREO; - } - - private static MediaFormatProfile ResolveAudioMP4Format(int? bitrate) - { - if (bitrate.HasValue && bitrate.Value <= 320) - { - return MediaFormatProfile.AAC_ISO_320; - } - - return MediaFormatProfile.AAC_ISO; - } - - private static MediaFormatProfile ResolveAudioADTSFormat(int? bitrate) - { - if (bitrate.HasValue && bitrate.Value <= 320) - { - return MediaFormatProfile.AAC_ADTS_320; - } - - return MediaFormatProfile.AAC_ADTS; - } - - public static MediaFormatProfile? ResolveImageFormat(string container, int? width, int? height) - { - if (string.Equals(container, "jpeg", StringComparison.OrdinalIgnoreCase) || - string.Equals(container, "jpg", StringComparison.OrdinalIgnoreCase)) - { - return ResolveImageJPGFormat(width, height); - } - - if (string.Equals(container, "png", StringComparison.OrdinalIgnoreCase)) - { - return ResolveImagePNGFormat(width, height); - } - - if (string.Equals(container, "gif", StringComparison.OrdinalIgnoreCase)) - { - return MediaFormatProfile.GIF_LRG; - } - - if (string.Equals(container, "raw", StringComparison.OrdinalIgnoreCase)) - { - return MediaFormatProfile.RAW; - } - - return null; - } - - private static MediaFormatProfile ResolveImageJPGFormat(int? width, int? height) - { - if (width.HasValue && height.HasValue) - { - if ((width.Value <= 160) && (height.Value <= 160)) - { - return MediaFormatProfile.JPEG_TN; - } - - if ((width.Value <= 640) && (height.Value <= 480)) - { - return MediaFormatProfile.JPEG_SM; - } - - if ((width.Value <= 1024) && (height.Value <= 768)) - { - return MediaFormatProfile.JPEG_MED; - } - - return MediaFormatProfile.JPEG_LRG; - } - - return MediaFormatProfile.JPEG_SM; - } - - private static MediaFormatProfile ResolveImagePNGFormat(int? width, int? height) - { - if (width.HasValue && height.HasValue) - { - if ((width.Value <= 160) && (height.Value <= 160)) - { - return MediaFormatProfile.PNG_TN; - } - } - - return MediaFormatProfile.PNG_LRG; - } - } -} diff --git a/MediaBrowser.Model/Dlna/SearchCriteria.cs b/MediaBrowser.Model/Dlna/SearchCriteria.cs deleted file mode 100644 index 6f4a692c8c..0000000000 --- a/MediaBrowser.Model/Dlna/SearchCriteria.cs +++ /dev/null @@ -1,55 +0,0 @@ -#pragma warning disable CS1591 - -using System; -using System.Text.RegularExpressions; - -namespace MediaBrowser.Model.Dlna -{ - public partial class SearchCriteria - { - public SearchCriteria(string search) - { - ArgumentException.ThrowIfNullOrEmpty(search); - - SearchType = SearchType.Unknown; - - string[] factors = AndOrRegex().Split(search); - foreach (string factor in factors) - { - string[] subFactors = WhiteSpaceRegex().Split(factor.Trim().Trim('(').Trim(')').Trim(), 3); - - if (subFactors.Length == 3) - { - if (string.Equals("upnp:class", subFactors[0], StringComparison.OrdinalIgnoreCase) - && (string.Equals("=", subFactors[1], StringComparison.Ordinal) || string.Equals("derivedfrom", subFactors[1], StringComparison.OrdinalIgnoreCase))) - { - if (string.Equals("\"object.item.imageItem\"", subFactors[2], StringComparison.Ordinal) || string.Equals("\"object.item.imageItem.photo\"", subFactors[2], StringComparison.OrdinalIgnoreCase)) - { - SearchType = SearchType.Image; - } - else if (string.Equals("\"object.item.videoItem\"", subFactors[2], StringComparison.OrdinalIgnoreCase)) - { - SearchType = SearchType.Video; - } - else if (string.Equals("\"object.container.playlistContainer\"", subFactors[2], StringComparison.OrdinalIgnoreCase)) - { - SearchType = SearchType.Playlist; - } - else if (string.Equals("\"object.container.album.musicAlbum\"", subFactors[2], StringComparison.OrdinalIgnoreCase)) - { - SearchType = SearchType.MusicAlbum; - } - } - } - } - } - - public SearchType SearchType { get; set; } - - [GeneratedRegex("\\s")] - private static partial Regex WhiteSpaceRegex(); - - [GeneratedRegex("(and|or)", RegexOptions.IgnoreCase)] - private static partial Regex AndOrRegex(); - } -} diff --git a/MediaBrowser.Model/Dlna/SearchType.cs b/MediaBrowser.Model/Dlna/SearchType.cs deleted file mode 100644 index 8bc7c52493..0000000000 --- a/MediaBrowser.Model/Dlna/SearchType.cs +++ /dev/null @@ -1,14 +0,0 @@ -#pragma warning disable CS1591 - -namespace MediaBrowser.Model.Dlna -{ - public enum SearchType - { - Unknown = 0, - Audio = 1, - Image = 2, - Video = 3, - Playlist = 4, - MusicAlbum = 5 - } -} diff --git a/MediaBrowser.Model/Dlna/SortCriteria.cs b/MediaBrowser.Model/Dlna/SortCriteria.cs deleted file mode 100644 index 7df53c6d19..0000000000 --- a/MediaBrowser.Model/Dlna/SortCriteria.cs +++ /dev/null @@ -1,24 +0,0 @@ -#pragma warning disable CS1591 - -using System; -using Jellyfin.Data.Enums; - -namespace MediaBrowser.Model.Dlna -{ - public class SortCriteria - { - public SortCriteria(string sortOrder) - { - if (Enum.TryParse(sortOrder, true, out var sortOrderValue)) - { - SortOrder = sortOrderValue; - } - else - { - SortOrder = SortOrder.Ascending; - } - } - - public SortOrder SortOrder { get; } - } -} diff --git a/MediaBrowser.Model/Dlna/UpnpDeviceInfo.cs b/MediaBrowser.Model/Dlna/UpnpDeviceInfo.cs deleted file mode 100644 index c7489d57ae..0000000000 --- a/MediaBrowser.Model/Dlna/UpnpDeviceInfo.cs +++ /dev/null @@ -1,22 +0,0 @@ -#nullable disable -#pragma warning disable CS1591 - -using System; -using System.Collections.Generic; -using System.Net; - -namespace MediaBrowser.Model.Dlna -{ - public class UpnpDeviceInfo - { - public Uri Location { get; set; } - - public Dictionary Headers { get; set; } - - public IPAddress LocalIPAddress { get; set; } - - public int LocalPort { get; set; } - - public IPAddress RemoteIPAddress { get; set; } - } -}