Remove unused DLNA models (#10685)

* Remove unused DLNA models

* Remove IDlnaManager
pull/10694/head
Patrick Barron 5 months ago committed by GitHub
parent fca345db4a
commit 0d5bbfda32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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
{
/// <summary>
/// Gets the profile infos.
/// </summary>
/// <returns>IEnumerable{DeviceProfileInfo}.</returns>
IEnumerable<DeviceProfileInfo> GetProfileInfos();
/// <summary>
/// Gets the profile.
/// </summary>
/// <param name="headers">The headers.</param>
/// <returns>DeviceProfile.</returns>
DeviceProfile? GetProfile(IHeaderDictionary headers);
/// <summary>
/// Gets the default profile.
/// </summary>
/// <returns>DeviceProfile.</returns>
DeviceProfile GetDefaultProfile();
/// <summary>
/// Creates the profile.
/// </summary>
/// <param name="profile">The profile.</param>
void CreateProfile(DeviceProfile profile);
/// <summary>
/// Updates the profile.
/// </summary>
/// <param name="profileId">The profile id.</param>
/// <param name="profile">The profile.</param>
void UpdateProfile(string profileId, DeviceProfile profile);
/// <summary>
/// Deletes the profile.
/// </summary>
/// <param name="id">The identifier.</param>
void DeleteProfile(string id);
/// <summary>
/// Gets the profile.
/// </summary>
/// <param name="id">The identifier.</param>
/// <returns>DeviceProfile.</returns>
DeviceProfile? GetProfile(string id);
/// <summary>
/// Gets the profile.
/// </summary>
/// <param name="deviceInfo">The device information.</param>
/// <returns>DeviceProfile.</returns>
DeviceProfile? GetProfile(DeviceIdentification deviceInfo);
/// <summary>
/// Gets the server description XML.
/// </summary>
/// <param name="headers">The headers.</param>
/// <param name="serverUuId">The server uu identifier.</param>
/// <param name="serverAddress">The server address.</param>
/// <returns>System.String.</returns>
string GetServerDescriptionXml(IHeaderDictionary headers, string serverUuId, string serverAddress);
/// <summary>
/// Gets the icon.
/// </summary>
/// <param name="filename">The filename.</param>
/// <returns>DlnaIconResponse.</returns>
ImageStream? GetIcon(string filename);
}
}

@ -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<string> 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<string>();
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<string>();
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);
}
}
}

@ -1,50 +0,0 @@
#pragma warning disable CS1591
using System;
namespace MediaBrowser.Model.Dlna
{
[Flags]
public enum DlnaFlags : ulong
{
/*! <i>Background</i> 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,
/*! <i>Interactive</i> 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,
/*! <i>Streaming</i> 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
}
}

@ -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;
}
}
}

@ -1,14 +0,0 @@
#pragma warning disable CS1591
using System;
using Jellyfin.Data.Events;
namespace MediaBrowser.Model.Dlna
{
public interface IDeviceDiscovery
{
event EventHandler<GenericEventArgs<UpnpDeviceInfo>> DeviceDiscovered;
event EventHandler<GenericEventArgs<UpnpDeviceInfo>> DeviceLeft;
}
}

@ -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
}
}

@ -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<MediaFormatProfile>();
}
if (string.Equals(container, "mp4", StringComparison.OrdinalIgnoreCase))
{
MediaFormatProfile? val = ResolveVideoMP4Format(videoCodec, audioCodec, width, height);
return val.HasValue ? new MediaFormatProfile[] { val.Value } : Array.Empty<MediaFormatProfile>();
}
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<MediaFormatProfile>();
}
if (string.Equals(container, "ogv", StringComparison.OrdinalIgnoreCase) || string.Equals(container, "ogg", StringComparison.OrdinalIgnoreCase))
{
return new MediaFormatProfile[] { MediaFormatProfile.OGV };
}
return Array.Empty<MediaFormatProfile>();
}
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<MediaFormatProfile>
{
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<MediaFormatProfile>();
}
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;
}
}
}

@ -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();
}
}

@ -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
}
}

@ -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>(sortOrder, true, out var sortOrderValue))
{
SortOrder = sortOrderValue;
}
else
{
SortOrder = SortOrder.Ascending;
}
}
public SortOrder SortOrder { get; }
}
}

@ -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<string, string> Headers { get; set; }
public IPAddress LocalIPAddress { get; set; }
public int LocalPort { get; set; }
public IPAddress RemoteIPAddress { get; set; }
}
}
Loading…
Cancel
Save