2014-06-01 06:11:04 +02:00
|
|
|
|
using MediaBrowser.Model.Extensions;
|
|
|
|
|
using MediaBrowser.Model.MediaInfo;
|
2014-03-26 17:10:46 +01:00
|
|
|
|
using System.Collections.Generic;
|
2014-03-26 16:06:48 +01:00
|
|
|
|
using System.Xml.Serialization;
|
2014-03-25 06:25:03 +01:00
|
|
|
|
|
2014-04-02 00:23:07 +02:00
|
|
|
|
namespace MediaBrowser.Model.Dlna
|
2014-03-13 20:08:02 +01:00
|
|
|
|
{
|
2014-03-26 16:06:48 +01:00
|
|
|
|
[XmlRoot("Profile")]
|
2014-03-15 05:14:07 +01:00
|
|
|
|
public class DeviceProfile
|
2014-03-13 20:08:02 +01:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the name.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The name.</value>
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
|
2014-03-26 16:06:48 +01:00
|
|
|
|
[XmlIgnore]
|
|
|
|
|
public string Id { get; set; }
|
2014-03-23 17:42:02 +01:00
|
|
|
|
|
2014-03-26 21:14:47 +01:00
|
|
|
|
[XmlIgnore]
|
|
|
|
|
public DeviceProfileType ProfileType { get; set; }
|
|
|
|
|
|
2014-03-17 15:48:16 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the identification.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The identification.</value>
|
|
|
|
|
public DeviceIdentification Identification { get; set; }
|
|
|
|
|
|
2014-03-18 02:45:41 +01: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; }
|
2014-04-10 17:06:54 +02:00
|
|
|
|
public string SerialNumber { get; set; }
|
2014-03-23 17:42:02 +01:00
|
|
|
|
public bool IgnoreTranscodeByteRangeRequests { get; set; }
|
2014-03-26 17:10:46 +01:00
|
|
|
|
public bool EnableAlbumArtInDidl { get; set; }
|
|
|
|
|
|
|
|
|
|
public string SupportedMediaTypes { get; set; }
|
2014-03-23 17:42:02 +01:00
|
|
|
|
|
2014-04-20 07:21:08 +02:00
|
|
|
|
public string UserId { get; set; }
|
2014-04-21 03:36:12 +02:00
|
|
|
|
|
|
|
|
|
public string AlbumArtPn { get; set; }
|
|
|
|
|
|
2014-08-01 02:37:06 +02:00
|
|
|
|
public int MaxAlbumArtWidth { get; set; }
|
|
|
|
|
public int MaxAlbumArtHeight { get; set; }
|
2014-04-21 03:36:12 +02:00
|
|
|
|
|
|
|
|
|
public int? MaxIconWidth { get; set; }
|
|
|
|
|
public int? MaxIconHeight { get; set; }
|
|
|
|
|
|
2014-07-28 00:01:29 +02:00
|
|
|
|
public int? MaxStreamingBitrate { get; set; }
|
|
|
|
|
public int? MaxStaticBitrate { get; set; }
|
|
|
|
|
|
2014-08-14 15:24:30 +02:00
|
|
|
|
public int? MusicStreamingTranscodingBitrate { get; set; }
|
|
|
|
|
public int? MusicSyncBitrate { get; set; }
|
|
|
|
|
|
2014-03-18 02:45:41 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Controls the content of the X_DLNADOC element in the urn:schemas-dlna-org:device-1-0 namespace.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string XDlnaDoc { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Controls the content of the X_DLNACAP element in the urn:schemas-dlna-org:device-1-0 namespace.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string XDlnaCap { get; set; }
|
|
|
|
|
/// <summary>
|
2014-04-22 19:25:54 +02:00
|
|
|
|
/// Controls the content of the aggregationFlags element in the urn:schemas-sonycom:av namespace.
|
2014-03-18 02:45:41 +01:00
|
|
|
|
/// </summary>
|
|
|
|
|
public string SonyAggregationFlags { get; set; }
|
|
|
|
|
|
|
|
|
|
public string ProtocolInfo { get; set; }
|
|
|
|
|
|
2014-03-22 21:50:28 +01:00
|
|
|
|
public int TimelineOffsetSeconds { get; set; }
|
2014-03-23 01:48:34 +01:00
|
|
|
|
public bool RequiresPlainVideoItems { get; set; }
|
|
|
|
|
public bool RequiresPlainFolders { get; set; }
|
2014-03-23 17:42:02 +01:00
|
|
|
|
|
2014-10-12 03:46:02 +02:00
|
|
|
|
public bool SupportsDirectRemoteContent { get; set; }
|
|
|
|
|
public bool SupportsCustomHttpHeaders { get; set; }
|
|
|
|
|
|
2014-04-24 16:11:05 +02:00
|
|
|
|
public XmlAttribute[] XmlRootAttributes { get; set; }
|
2014-04-24 07:08:10 +02:00
|
|
|
|
|
2014-03-26 16:06:48 +01:00
|
|
|
|
/// <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; }
|
2014-04-01 06:16:25 +02:00
|
|
|
|
public ResponseProfile[] ResponseProfiles { get; set; }
|
2014-03-26 16:06:48 +01:00
|
|
|
|
|
2014-08-06 03:09:03 +02:00
|
|
|
|
public SubtitleProfile[] SubtitleProfiles { get; set; }
|
2014-07-17 05:17:14 +02:00
|
|
|
|
|
2014-03-15 05:14:07 +01:00
|
|
|
|
public DeviceProfile()
|
2014-03-13 20:08:02 +01:00
|
|
|
|
{
|
|
|
|
|
DirectPlayProfiles = new DirectPlayProfile[] { };
|
|
|
|
|
TranscodingProfiles = new TranscodingProfile[] { };
|
2014-04-01 06:16:25 +02:00
|
|
|
|
ResponseProfiles = new ResponseProfile[] { };
|
2014-03-22 21:02:10 +01:00
|
|
|
|
CodecProfiles = new CodecProfile[] { };
|
2014-03-23 17:42:02 +01:00
|
|
|
|
ContainerProfiles = new ContainerProfile[] { };
|
2014-08-07 04:51:09 +02:00
|
|
|
|
SubtitleProfiles = new SubtitleProfile[] { };
|
|
|
|
|
|
2014-04-24 16:11:05 +02:00
|
|
|
|
XmlRootAttributes = new XmlAttribute[] { };
|
2014-04-24 07:08:10 +02:00
|
|
|
|
|
2014-03-26 17:10:46 +01:00
|
|
|
|
SupportedMediaTypes = "Audio,Photo,Video";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<string> GetSupportedMediaTypes()
|
|
|
|
|
{
|
2014-05-08 23:23:24 +02:00
|
|
|
|
List<string> list = new List<string>();
|
|
|
|
|
foreach (string i in (SupportedMediaTypes ?? string.Empty).Split(','))
|
|
|
|
|
{
|
2014-05-09 21:43:06 +02:00
|
|
|
|
if (!string.IsNullOrEmpty(i))
|
|
|
|
|
list.Add(i);
|
2014-05-08 23:23:24 +02:00
|
|
|
|
}
|
|
|
|
|
return list;
|
2014-03-13 20:08:02 +01:00
|
|
|
|
}
|
2014-03-25 06:25:03 +01:00
|
|
|
|
|
|
|
|
|
public TranscodingProfile GetAudioTranscodingProfile(string container, string audioCodec)
|
|
|
|
|
{
|
2014-07-01 06:06:28 +02:00
|
|
|
|
container = StringHelper.TrimStart((container ?? string.Empty), '.');
|
2014-03-25 06:25:03 +01:00
|
|
|
|
|
2014-05-09 21:43:06 +02:00
|
|
|
|
foreach (var i in TranscodingProfiles)
|
2014-03-25 06:25:03 +01:00
|
|
|
|
{
|
|
|
|
|
if (i.Type != DlnaProfileType.Audio)
|
|
|
|
|
{
|
2014-05-09 21:43:06 +02:00
|
|
|
|
continue;
|
2014-03-25 06:25:03 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-01 06:11:04 +02:00
|
|
|
|
if (!StringHelper.EqualsIgnoreCase(container, i.Container))
|
2014-03-25 06:25:03 +01:00
|
|
|
|
{
|
2014-05-09 21:43:06 +02:00
|
|
|
|
continue;
|
2014-03-25 06:25:03 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-05 04:32:40 +02:00
|
|
|
|
if (!ListHelper.ContainsIgnoreCase(i.GetAudioCodecs(), audioCodec ?? string.Empty))
|
2014-03-25 06:25:03 +01:00
|
|
|
|
{
|
2014-05-09 21:43:06 +02:00
|
|
|
|
continue;
|
2014-03-25 06:25:03 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-09 21:43:06 +02:00
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
2014-03-25 06:25:03 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TranscodingProfile GetVideoTranscodingProfile(string container, string audioCodec, string videoCodec)
|
|
|
|
|
{
|
2014-07-01 06:06:28 +02:00
|
|
|
|
container = StringHelper.TrimStart((container ?? string.Empty), '.');
|
2014-03-25 06:25:03 +01:00
|
|
|
|
|
2014-05-09 21:43:06 +02:00
|
|
|
|
foreach (var i in TranscodingProfiles)
|
2014-03-25 06:25:03 +01:00
|
|
|
|
{
|
|
|
|
|
if (i.Type != DlnaProfileType.Video)
|
|
|
|
|
{
|
2014-05-09 21:43:06 +02:00
|
|
|
|
continue;
|
2014-03-25 06:25:03 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-01 06:11:04 +02:00
|
|
|
|
if (!StringHelper.EqualsIgnoreCase(container, i.Container))
|
2014-03-25 06:25:03 +01:00
|
|
|
|
{
|
2014-05-09 21:43:06 +02:00
|
|
|
|
continue;
|
2014-03-25 06:25:03 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-23 18:05:19 +02:00
|
|
|
|
if (!ListHelper.ContainsIgnoreCase(i.GetAudioCodecs(), audioCodec ?? string.Empty))
|
2014-03-25 06:25:03 +01:00
|
|
|
|
{
|
2014-05-09 21:43:06 +02:00
|
|
|
|
continue;
|
2014-03-25 06:25:03 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-23 18:05:19 +02:00
|
|
|
|
if (!StringHelper.EqualsIgnoreCase(videoCodec, i.VideoCodec ?? string.Empty))
|
2014-03-25 06:25:03 +01:00
|
|
|
|
{
|
2014-05-09 21:43:06 +02:00
|
|
|
|
continue;
|
2014-03-25 06:25:03 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-09 21:43:06 +02:00
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
2014-03-25 06:25:03 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-04-24 07:08:10 +02:00
|
|
|
|
public ResponseProfile GetAudioMediaProfile(string container, string audioCodec, int? audioChannels, int? audioBitrate)
|
2014-03-25 06:25:03 +01:00
|
|
|
|
{
|
2014-07-01 06:06:28 +02:00
|
|
|
|
container = StringHelper.TrimStart((container ?? string.Empty), '.');
|
2014-03-25 06:25:03 +01:00
|
|
|
|
|
2014-05-09 21:43:06 +02:00
|
|
|
|
foreach (var i in ResponseProfiles)
|
2014-03-25 06:25:03 +01:00
|
|
|
|
{
|
|
|
|
|
if (i.Type != DlnaProfileType.Audio)
|
|
|
|
|
{
|
2014-05-09 21:43:06 +02:00
|
|
|
|
continue;
|
2014-03-25 06:25:03 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-09 21:43:06 +02:00
|
|
|
|
List<string> containers = i.GetContainers();
|
2014-06-05 04:32:40 +02:00
|
|
|
|
if (containers.Count > 0 && !ListHelper.ContainsIgnoreCase(containers, container))
|
2014-03-25 06:25:03 +01:00
|
|
|
|
{
|
2014-05-09 21:43:06 +02:00
|
|
|
|
continue;
|
2014-03-25 06:25:03 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-09 21:43:06 +02:00
|
|
|
|
List<string> audioCodecs = i.GetAudioCodecs();
|
2014-06-23 18:05:19 +02:00
|
|
|
|
if (audioCodecs.Count > 0 && !ListHelper.ContainsIgnoreCase(audioCodecs, audioCodec ?? string.Empty))
|
2014-03-25 06:25:03 +01:00
|
|
|
|
{
|
2014-05-09 21:43:06 +02:00
|
|
|
|
continue;
|
2014-03-25 06:25:03 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-08 22:44:17 +02:00
|
|
|
|
ConditionProcessor conditionProcessor = new ConditionProcessor();
|
2014-05-09 21:43:06 +02:00
|
|
|
|
|
|
|
|
|
var anyOff = false;
|
|
|
|
|
foreach (ProfileCondition c in i.Conditions)
|
|
|
|
|
{
|
|
|
|
|
if (!conditionProcessor.IsAudioConditionSatisfied(c, audioChannels, audioBitrate))
|
|
|
|
|
{
|
|
|
|
|
anyOff = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (anyOff)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
2014-03-25 06:25:03 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-04-24 07:08:10 +02:00
|
|
|
|
public ResponseProfile GetImageMediaProfile(string container, int? width, int? height)
|
|
|
|
|
{
|
2014-07-01 06:06:28 +02:00
|
|
|
|
container = StringHelper.TrimStart((container ?? string.Empty), '.');
|
2014-04-24 07:08:10 +02:00
|
|
|
|
|
2014-05-10 01:08:08 +02:00
|
|
|
|
foreach (var i in ResponseProfiles)
|
2014-04-24 07:08:10 +02:00
|
|
|
|
{
|
|
|
|
|
if (i.Type != DlnaProfileType.Photo)
|
|
|
|
|
{
|
2014-05-10 01:08:08 +02:00
|
|
|
|
continue;
|
2014-04-24 07:08:10 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-09 21:43:06 +02:00
|
|
|
|
List<string> containers = i.GetContainers();
|
2014-06-05 04:32:40 +02:00
|
|
|
|
if (containers.Count > 0 && !ListHelper.ContainsIgnoreCase(containers, container))
|
2014-04-24 07:08:10 +02:00
|
|
|
|
{
|
2014-05-10 01:08:08 +02:00
|
|
|
|
continue;
|
2014-04-24 07:08:10 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-08 22:44:17 +02:00
|
|
|
|
ConditionProcessor conditionProcessor = new ConditionProcessor();
|
2014-05-10 01:08:08 +02:00
|
|
|
|
|
|
|
|
|
var anyOff = false;
|
2014-05-09 21:43:06 +02:00
|
|
|
|
foreach (ProfileCondition c in i.Conditions)
|
|
|
|
|
{
|
2014-05-10 01:08:08 +02:00
|
|
|
|
if (!conditionProcessor.IsImageConditionSatisfied(c, width, height))
|
|
|
|
|
{
|
|
|
|
|
anyOff = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (anyOff)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
2014-05-09 21:43:06 +02:00
|
|
|
|
}
|
2014-05-10 01:08:08 +02:00
|
|
|
|
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
2014-04-24 07:08:10 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ResponseProfile GetVideoMediaProfile(string container,
|
|
|
|
|
string audioCodec,
|
|
|
|
|
string videoCodec,
|
|
|
|
|
int? audioBitrate,
|
|
|
|
|
int? audioChannels,
|
|
|
|
|
int? width,
|
|
|
|
|
int? height,
|
|
|
|
|
int? bitDepth,
|
|
|
|
|
int? videoBitrate,
|
|
|
|
|
string videoProfile,
|
|
|
|
|
double? videoLevel,
|
2014-06-23 18:05:19 +02:00
|
|
|
|
float? videoFramerate,
|
2014-04-24 07:08:10 +02:00
|
|
|
|
int? packetLength,
|
2014-06-22 18:25:47 +02:00
|
|
|
|
TransportStreamTimestamp timestamp,
|
2014-09-09 03:15:31 +02:00
|
|
|
|
bool? isAnamorphic,
|
|
|
|
|
int? refFrames)
|
2014-03-25 06:25:03 +01:00
|
|
|
|
{
|
2014-07-01 06:06:28 +02:00
|
|
|
|
container = StringHelper.TrimStart((container ?? string.Empty), '.');
|
2014-03-25 06:25:03 +01:00
|
|
|
|
|
2014-05-10 01:08:08 +02:00
|
|
|
|
foreach (var i in ResponseProfiles)
|
2014-03-25 06:25:03 +01:00
|
|
|
|
{
|
|
|
|
|
if (i.Type != DlnaProfileType.Video)
|
|
|
|
|
{
|
2014-05-10 01:08:08 +02:00
|
|
|
|
continue;
|
2014-03-25 06:25:03 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-09 21:43:06 +02:00
|
|
|
|
List<string> containers = i.GetContainers();
|
2014-06-23 18:05:19 +02:00
|
|
|
|
if (containers.Count > 0 && !ListHelper.ContainsIgnoreCase(containers, container ?? string.Empty))
|
2014-03-25 06:25:03 +01:00
|
|
|
|
{
|
2014-05-10 01:08:08 +02:00
|
|
|
|
continue;
|
2014-03-25 06:25:03 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-09 21:43:06 +02:00
|
|
|
|
List<string> audioCodecs = i.GetAudioCodecs();
|
2014-06-23 18:05:19 +02:00
|
|
|
|
if (audioCodecs.Count > 0 && !ListHelper.ContainsIgnoreCase(audioCodecs, audioCodec ?? string.Empty))
|
2014-03-25 06:25:03 +01:00
|
|
|
|
{
|
2014-05-10 01:08:08 +02:00
|
|
|
|
continue;
|
2014-03-25 06:25:03 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-09 21:43:06 +02:00
|
|
|
|
List<string> videoCodecs = i.GetVideoCodecs();
|
2014-06-23 18:05:19 +02:00
|
|
|
|
if (videoCodecs.Count > 0 && !ListHelper.ContainsIgnoreCase(videoCodecs, videoCodec ?? string.Empty))
|
2014-03-25 06:25:03 +01:00
|
|
|
|
{
|
2014-05-10 01:08:08 +02:00
|
|
|
|
continue;
|
2014-03-25 06:25:03 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-08 22:44:17 +02:00
|
|
|
|
ConditionProcessor conditionProcessor = new ConditionProcessor();
|
2014-05-10 01:08:08 +02:00
|
|
|
|
|
|
|
|
|
var anyOff = false;
|
2014-05-09 21:43:06 +02:00
|
|
|
|
foreach (ProfileCondition c in i.Conditions)
|
|
|
|
|
{
|
2014-09-09 03:15:31 +02:00
|
|
|
|
if (!conditionProcessor.IsVideoConditionSatisfied(c, audioBitrate, audioChannels, width, height, bitDepth, videoBitrate, videoProfile, videoLevel, videoFramerate, packetLength, timestamp, isAnamorphic, refFrames))
|
2014-05-10 01:08:08 +02:00
|
|
|
|
{
|
|
|
|
|
anyOff = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (anyOff)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
2014-05-09 21:43:06 +02:00
|
|
|
|
}
|
2014-05-10 01:08:08 +02:00
|
|
|
|
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
2014-03-25 06:25:03 +01:00
|
|
|
|
}
|
2014-03-13 20:08:02 +01:00
|
|
|
|
}
|
|
|
|
|
}
|