2020-02-03 17:49:27 -07:00
|
|
|
#pragma warning disable CS1591
|
|
|
|
#pragma warning disable SA1600
|
|
|
|
|
2019-01-13 13:02:23 -07:00
|
|
|
using System;
|
2018-12-27 16:27:57 -07:00
|
|
|
using System.Xml.Serialization;
|
2019-01-13 12:26:15 -07:00
|
|
|
using MediaBrowser.Model.Extensions;
|
|
|
|
using MediaBrowser.Model.MediaInfo;
|
2018-12-27 16:27:57 -07:00
|
|
|
|
|
|
|
namespace MediaBrowser.Model.Dlna
|
|
|
|
{
|
|
|
|
[XmlRoot("Profile")]
|
|
|
|
public class DeviceProfile
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets the name.
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The name.</value>
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
|
|
|
[XmlIgnore]
|
|
|
|
public string Id { get; set; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets the identification.
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The identification.</value>
|
2019-01-13 13:37:13 -07:00
|
|
|
public DeviceIdentification Identification { get; set; }
|
2018-12-27 16:27:57 -07:00
|
|
|
|
|
|
|
public string FriendlyName { get; set; }
|
|
|
|
public string Manufacturer { get; set; }
|
|
|
|
public string ManufacturerUrl { get; set; }
|
|
|
|
public string ModelName { get; set; }
|
|
|
|
public string ModelDescription { get; set; }
|
|
|
|
public string ModelNumber { get; set; }
|
|
|
|
public string ModelUrl { get; set; }
|
|
|
|
public string SerialNumber { get; set; }
|
|
|
|
|
|
|
|
public bool EnableAlbumArtInDidl { get; set; }
|
|
|
|
public bool EnableSingleAlbumArtLimit { get; set; }
|
|
|
|
public bool EnableSingleSubtitleLimit { get; set; }
|
|
|
|
|
|
|
|
public string SupportedMediaTypes { get; set; }
|
|
|
|
|
|
|
|
public string UserId { get; set; }
|
|
|
|
|
|
|
|
public string AlbumArtPn { get; set; }
|
|
|
|
|
|
|
|
public int MaxAlbumArtWidth { get; set; }
|
|
|
|
public int MaxAlbumArtHeight { get; set; }
|
|
|
|
|
|
|
|
public int? MaxIconWidth { get; set; }
|
|
|
|
public int? MaxIconHeight { get; set; }
|
|
|
|
|
|
|
|
public long? MaxStreamingBitrate { get; set; }
|
|
|
|
public long? MaxStaticBitrate { get; set; }
|
|
|
|
|
|
|
|
public int? MusicStreamingTranscodingBitrate { get; set; }
|
|
|
|
public int? MaxStaticMusicBitrate { get; set; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Controls the content of the aggregationFlags element in the urn:schemas-sonycom:av namespace.
|
|
|
|
/// </summary>
|
|
|
|
public string SonyAggregationFlags { get; set; }
|
|
|
|
|
|
|
|
public string ProtocolInfo { get; set; }
|
|
|
|
|
|
|
|
public int TimelineOffsetSeconds { get; set; }
|
|
|
|
public bool RequiresPlainVideoItems { get; set; }
|
|
|
|
public bool RequiresPlainFolders { get; set; }
|
|
|
|
|
|
|
|
public bool EnableMSMediaReceiverRegistrar { get; set; }
|
|
|
|
public bool IgnoreTranscodeByteRangeRequests { get; set; }
|
|
|
|
|
|
|
|
public XmlAttribute[] XmlRootAttributes { get; set; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets the direct play profiles.
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The direct play profiles.</value>
|
|
|
|
public DirectPlayProfile[] DirectPlayProfiles { get; set; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets the transcoding profiles.
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The transcoding profiles.</value>
|
|
|
|
public TranscodingProfile[] TranscodingProfiles { get; set; }
|
|
|
|
|
|
|
|
public ContainerProfile[] ContainerProfiles { get; set; }
|
|
|
|
|
|
|
|
public CodecProfile[] CodecProfiles { get; set; }
|
|
|
|
public ResponseProfile[] ResponseProfiles { get; set; }
|
|
|
|
|
|
|
|
public SubtitleProfile[] SubtitleProfiles { get; set; }
|
|
|
|
|
|
|
|
public DeviceProfile()
|
|
|
|
{
|
|
|
|
DirectPlayProfiles = new DirectPlayProfile[] { };
|
|
|
|
TranscodingProfiles = new TranscodingProfile[] { };
|
|
|
|
ResponseProfiles = new ResponseProfile[] { };
|
|
|
|
CodecProfiles = new CodecProfile[] { };
|
|
|
|
ContainerProfiles = new ContainerProfile[] { };
|
|
|
|
SubtitleProfiles = Array.Empty<SubtitleProfile>();
|
|
|
|
|
|
|
|
XmlRootAttributes = new XmlAttribute[] { };
|
|
|
|
|
|
|
|
SupportedMediaTypes = "Audio,Photo,Video";
|
|
|
|
MaxStreamingBitrate = 8000000;
|
|
|
|
MaxStaticBitrate = 8000000;
|
|
|
|
MusicStreamingTranscodingBitrate = 128000;
|
|
|
|
}
|
|
|
|
|
|
|
|
public string[] GetSupportedMediaTypes()
|
|
|
|
{
|
|
|
|
return ContainerProfile.SplitValue(SupportedMediaTypes);
|
|
|
|
}
|
|
|
|
|
|
|
|
public TranscodingProfile GetAudioTranscodingProfile(string container, string audioCodec)
|
|
|
|
{
|
|
|
|
container = (container ?? string.Empty).TrimStart('.');
|
|
|
|
|
|
|
|
foreach (var i in TranscodingProfiles)
|
|
|
|
{
|
|
|
|
if (i.Type != MediaBrowser.Model.Dlna.DlnaProfileType.Audio)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2020-01-09 09:07:13 -07:00
|
|
|
if (!string.Equals(container, i.Container, StringComparison.OrdinalIgnoreCase))
|
2018-12-27 16:27:57 -07:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ListHelper.ContainsIgnoreCase(i.GetAudioCodecs(), audioCodec ?? string.Empty))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public TranscodingProfile GetVideoTranscodingProfile(string container, string audioCodec, string videoCodec)
|
|
|
|
{
|
|
|
|
container = (container ?? string.Empty).TrimStart('.');
|
|
|
|
|
|
|
|
foreach (var i in TranscodingProfiles)
|
|
|
|
{
|
|
|
|
if (i.Type != MediaBrowser.Model.Dlna.DlnaProfileType.Video)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2020-01-09 09:07:13 -07:00
|
|
|
if (!string.Equals(container, i.Container, StringComparison.OrdinalIgnoreCase))
|
2018-12-27 16:27:57 -07:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ListHelper.ContainsIgnoreCase(i.GetAudioCodecs(), audioCodec ?? string.Empty))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2020-01-09 09:07:13 -07:00
|
|
|
if (!string.Equals(videoCodec, i.VideoCodec ?? string.Empty, StringComparison.OrdinalIgnoreCase))
|
2018-12-27 16:27:57 -07:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
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 && !ListHelper.ContainsIgnoreCase(audioCodecs, audioCodec ?? string.Empty))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
var anyOff = false;
|
2019-01-17 12:24:39 -07:00
|
|
|
foreach (ProfileCondition c in i.Conditions)
|
2018-12-27 16:27:57 -07:00
|
|
|
{
|
2019-01-20 03:34:33 -07:00
|
|
|
if (!ConditionProcessor.IsAudioConditionSatisfied(GetModelProfileCondition(c), audioChannels, audioBitrate, audioSampleRate, audioBitDepth))
|
2018-12-27 16:27:57 -07:00
|
|
|
{
|
|
|
|
anyOff = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (anyOff)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
private ProfileCondition GetModelProfileCondition(ProfileCondition c)
|
|
|
|
{
|
|
|
|
return new ProfileCondition
|
|
|
|
{
|
|
|
|
Condition = c.Condition,
|
|
|
|
IsRequired = c.IsRequired,
|
|
|
|
Property = c.Property,
|
|
|
|
Value = c.Value
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2019-01-13 13:37:13 -07:00
|
|
|
foreach (var c in i.Conditions)
|
2018-12-27 16:27:57 -07:00
|
|
|
{
|
2019-01-20 03:34:33 -07:00
|
|
|
if (!ConditionProcessor.IsImageConditionSatisfied(GetModelProfileCondition(c), width, height))
|
2018-12-27 16:27:57 -07:00
|
|
|
{
|
|
|
|
anyOff = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (anyOff)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ResponseProfile GetVideoMediaProfile(string container,
|
|
|
|
string audioCodec,
|
|
|
|
string videoCodec,
|
|
|
|
int? width,
|
|
|
|
int? height,
|
|
|
|
int? bitDepth,
|
|
|
|
int? videoBitrate,
|
|
|
|
string videoProfile,
|
|
|
|
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 && !ListHelper.ContainsIgnoreCase(audioCodecs, audioCodec ?? string.Empty))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
var videoCodecs = i.GetVideoCodecs();
|
|
|
|
if (videoCodecs.Length > 0 && !ListHelper.ContainsIgnoreCase(videoCodecs, videoCodec ?? string.Empty))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
var anyOff = false;
|
2019-01-17 12:24:39 -07:00
|
|
|
foreach (ProfileCondition c in i.Conditions)
|
2018-12-27 16:27:57 -07:00
|
|
|
{
|
2019-01-20 03:34:33 -07:00
|
|
|
if (!ConditionProcessor.IsVideoConditionSatisfied(GetModelProfileCondition(c), width, height, bitDepth, videoBitrate, videoProfile, videoLevel, videoFramerate, packetLength, timestamp, isAnamorphic, isInterlaced, refFrames, numVideoStreams, numAudioStreams, videoCodecTag, isAvc))
|
2018-12-27 16:27:57 -07:00
|
|
|
{
|
|
|
|
anyOff = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (anyOff)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|