2014-04-27 03:42:05 +00:00
|
|
|
|
using MediaBrowser.Model.MediaInfo;
|
|
|
|
|
using System;
|
2014-03-26 16:10:46 +00:00
|
|
|
|
using System.Collections.Generic;
|
2014-03-25 05:25:03 +00:00
|
|
|
|
using System.Linq;
|
2014-03-26 15:06:48 +00:00
|
|
|
|
using System.Xml.Serialization;
|
2014-03-25 05:25:03 +00:00
|
|
|
|
|
2014-04-01 22:23:07 +00:00
|
|
|
|
namespace MediaBrowser.Model.Dlna
|
2014-03-13 19:08:02 +00:00
|
|
|
|
{
|
2014-03-26 15:06:48 +00:00
|
|
|
|
[XmlRoot("Profile")]
|
2014-03-15 04:14:07 +00:00
|
|
|
|
public class DeviceProfile
|
2014-03-13 19:08:02 +00:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the name.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The name.</value>
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
|
2014-03-26 15:06:48 +00:00
|
|
|
|
[XmlIgnore]
|
|
|
|
|
public string Id { get; set; }
|
2014-03-23 16:42:02 +00:00
|
|
|
|
|
2014-03-26 20:14:47 +00:00
|
|
|
|
[XmlIgnore]
|
|
|
|
|
public DeviceProfileType ProfileType { get; set; }
|
|
|
|
|
|
2014-03-17 14:48:16 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the identification.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The identification.</value>
|
|
|
|
|
public DeviceIdentification Identification { get; set; }
|
|
|
|
|
|
2014-03-18 01:45:41 +00: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 15:06:54 +00:00
|
|
|
|
public string SerialNumber { get; set; }
|
2014-03-23 16:42:02 +00:00
|
|
|
|
public bool IgnoreTranscodeByteRangeRequests { get; set; }
|
2014-03-26 16:10:46 +00:00
|
|
|
|
public bool EnableAlbumArtInDidl { get; set; }
|
|
|
|
|
|
|
|
|
|
public string SupportedMediaTypes { get; set; }
|
2014-03-23 16:42:02 +00:00
|
|
|
|
|
2014-04-20 05:21:08 +00:00
|
|
|
|
public string UserId { get; set; }
|
2014-04-21 01:36:12 +00:00
|
|
|
|
|
|
|
|
|
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 int? MaxBitrate { get; set; }
|
2014-04-20 05:21:08 +00:00
|
|
|
|
|
2014-03-18 01:45:41 +00: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 17:25:54 +00:00
|
|
|
|
/// Controls the content of the aggregationFlags element in the urn:schemas-sonycom:av namespace.
|
2014-03-18 01:45:41 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
public string SonyAggregationFlags { get; set; }
|
|
|
|
|
|
|
|
|
|
public string ProtocolInfo { get; set; }
|
|
|
|
|
|
2014-03-22 20:50:28 +00:00
|
|
|
|
public int TimelineOffsetSeconds { get; set; }
|
2014-03-23 00:48:34 +00:00
|
|
|
|
public bool RequiresPlainVideoItems { get; set; }
|
|
|
|
|
public bool RequiresPlainFolders { get; set; }
|
2014-03-23 16:42:02 +00:00
|
|
|
|
|
2014-04-24 14:11:05 +00:00
|
|
|
|
public XmlAttribute[] XmlRootAttributes { get; set; }
|
2014-04-24 05:08:10 +00:00
|
|
|
|
|
2014-03-26 15:06:48 +00: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 04:16:25 +00:00
|
|
|
|
public ResponseProfile[] ResponseProfiles { get; set; }
|
2014-03-26 15:06:48 +00:00
|
|
|
|
|
2014-03-15 04:14:07 +00:00
|
|
|
|
public DeviceProfile()
|
2014-03-13 19:08:02 +00:00
|
|
|
|
{
|
|
|
|
|
DirectPlayProfiles = new DirectPlayProfile[] { };
|
|
|
|
|
TranscodingProfiles = new TranscodingProfile[] { };
|
2014-04-01 04:16:25 +00:00
|
|
|
|
ResponseProfiles = new ResponseProfile[] { };
|
2014-03-22 20:02:10 +00:00
|
|
|
|
CodecProfiles = new CodecProfile[] { };
|
2014-03-23 16:42:02 +00:00
|
|
|
|
ContainerProfiles = new ContainerProfile[] { };
|
2014-03-26 16:10:46 +00:00
|
|
|
|
|
2014-04-24 14:11:05 +00:00
|
|
|
|
XmlRootAttributes = new XmlAttribute[] { };
|
2014-04-24 05:08:10 +00:00
|
|
|
|
|
2014-03-26 16:10:46 +00:00
|
|
|
|
SupportedMediaTypes = "Audio,Photo,Video";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<string> GetSupportedMediaTypes()
|
|
|
|
|
{
|
2014-05-08 21:23:24 +00:00
|
|
|
|
List<string> list = new List<string>();
|
|
|
|
|
foreach (string i in (SupportedMediaTypes ?? string.Empty).Split(','))
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(i)) list.Add(i);
|
|
|
|
|
}
|
|
|
|
|
return list;
|
2014-03-13 19:08:02 +00:00
|
|
|
|
}
|
2014-03-25 05:25:03 +00:00
|
|
|
|
|
|
|
|
|
public TranscodingProfile GetAudioTranscodingProfile(string container, string audioCodec)
|
|
|
|
|
{
|
|
|
|
|
container = (container ?? string.Empty).TrimStart('.');
|
|
|
|
|
|
|
|
|
|
return TranscodingProfiles.FirstOrDefault(i =>
|
|
|
|
|
{
|
|
|
|
|
if (i.Type != DlnaProfileType.Audio)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.Equals(container, i.Container, StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!i.GetAudioCodecs().Contains(audioCodec ?? string.Empty))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TranscodingProfile GetVideoTranscodingProfile(string container, string audioCodec, string videoCodec)
|
|
|
|
|
{
|
|
|
|
|
container = (container ?? string.Empty).TrimStart('.');
|
|
|
|
|
|
|
|
|
|
return TranscodingProfiles.FirstOrDefault(i =>
|
|
|
|
|
{
|
|
|
|
|
if (i.Type != DlnaProfileType.Video)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.Equals(container, i.Container, StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!i.GetAudioCodecs().Contains(audioCodec ?? string.Empty))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.Equals(videoCodec, i.VideoCodec, StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-24 05:08:10 +00:00
|
|
|
|
public ResponseProfile GetAudioMediaProfile(string container, string audioCodec, int? audioChannels, int? audioBitrate)
|
2014-03-25 05:25:03 +00:00
|
|
|
|
{
|
|
|
|
|
container = (container ?? string.Empty).TrimStart('.');
|
|
|
|
|
|
2014-04-01 04:16:25 +00:00
|
|
|
|
return ResponseProfiles.FirstOrDefault(i =>
|
2014-03-25 05:25:03 +00:00
|
|
|
|
{
|
|
|
|
|
if (i.Type != DlnaProfileType.Audio)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-08 20:44:17 +00:00
|
|
|
|
List<string> containers = i.GetContainers().ToList();
|
2014-03-25 05:25:03 +00:00
|
|
|
|
if (containers.Count > 0 && !containers.Contains(container))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-08 20:44:17 +00:00
|
|
|
|
List<string> audioCodecs = i.GetAudioCodecs().ToList();
|
2014-03-25 05:25:03 +00:00
|
|
|
|
if (audioCodecs.Count > 0 && !audioCodecs.Contains(audioCodec ?? string.Empty))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-08 20:44:17 +00:00
|
|
|
|
ConditionProcessor conditionProcessor = new ConditionProcessor();
|
2014-04-24 05:08:10 +00:00
|
|
|
|
return i.Conditions.All(c => conditionProcessor.IsAudioConditionSatisfied(c,
|
|
|
|
|
audioChannels,
|
|
|
|
|
audioBitrate));
|
2014-03-25 05:25:03 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-24 05:08:10 +00:00
|
|
|
|
public ResponseProfile GetImageMediaProfile(string container, int? width, int? height)
|
|
|
|
|
{
|
|
|
|
|
container = (container ?? string.Empty).TrimStart('.');
|
|
|
|
|
|
|
|
|
|
return ResponseProfiles.FirstOrDefault(i =>
|
|
|
|
|
{
|
|
|
|
|
if (i.Type != DlnaProfileType.Photo)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-08 20:44:17 +00:00
|
|
|
|
List<string> containers = i.GetContainers().ToList();
|
2014-04-24 05:08:10 +00:00
|
|
|
|
if (containers.Count > 0 && !containers.Contains(container))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-08 20:44:17 +00:00
|
|
|
|
ConditionProcessor conditionProcessor = new ConditionProcessor();
|
2014-04-24 05:08:10 +00:00
|
|
|
|
return i.Conditions.All(c => conditionProcessor.IsImageConditionSatisfied(c,
|
|
|
|
|
width,
|
|
|
|
|
height));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
double? videoFramerate,
|
|
|
|
|
int? packetLength,
|
|
|
|
|
TransportStreamTimestamp timestamp)
|
2014-03-25 05:25:03 +00:00
|
|
|
|
{
|
|
|
|
|
container = (container ?? string.Empty).TrimStart('.');
|
|
|
|
|
|
2014-04-01 04:16:25 +00:00
|
|
|
|
return ResponseProfiles.FirstOrDefault(i =>
|
2014-03-25 05:25:03 +00:00
|
|
|
|
{
|
|
|
|
|
if (i.Type != DlnaProfileType.Video)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-08 20:44:17 +00:00
|
|
|
|
List<string> containers = i.GetContainers().ToList();
|
2014-03-25 05:25:03 +00:00
|
|
|
|
if (containers.Count > 0 && !containers.Contains(container))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-08 20:44:17 +00:00
|
|
|
|
List<string> audioCodecs = i.GetAudioCodecs().ToList();
|
2014-03-25 05:25:03 +00:00
|
|
|
|
if (audioCodecs.Count > 0 && !audioCodecs.Contains(audioCodec ?? string.Empty))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-08 20:44:17 +00:00
|
|
|
|
List<string> videoCodecs = i.GetVideoCodecs().ToList();
|
2014-03-25 05:25:03 +00:00
|
|
|
|
if (videoCodecs.Count > 0 && !videoCodecs.Contains(videoCodec ?? string.Empty))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-08 20:44:17 +00:00
|
|
|
|
ConditionProcessor conditionProcessor = new ConditionProcessor();
|
2014-04-24 05:08:10 +00:00
|
|
|
|
return i.Conditions.All(c => conditionProcessor.IsVideoConditionSatisfied(c,
|
|
|
|
|
audioBitrate,
|
|
|
|
|
audioChannels,
|
|
|
|
|
width,
|
|
|
|
|
height,
|
|
|
|
|
bitDepth,
|
|
|
|
|
videoBitrate,
|
|
|
|
|
videoProfile,
|
|
|
|
|
videoLevel,
|
|
|
|
|
videoFramerate,
|
|
|
|
|
packetLength,
|
|
|
|
|
timestamp));
|
2014-03-25 05:25:03 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-24 05:08:10 +00:00
|
|
|
|
public ResponseProfile GetPhotoMediaProfile(string container, int? width, int? height)
|
2014-03-25 05:25:03 +00:00
|
|
|
|
{
|
|
|
|
|
container = (container ?? string.Empty).TrimStart('.');
|
|
|
|
|
|
2014-04-01 04:16:25 +00:00
|
|
|
|
return ResponseProfiles.FirstOrDefault(i =>
|
2014-03-25 05:25:03 +00:00
|
|
|
|
{
|
|
|
|
|
if (i.Type != DlnaProfileType.Photo)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-08 20:44:17 +00:00
|
|
|
|
List<string> containers = i.GetContainers().ToList();
|
2014-03-25 05:25:03 +00:00
|
|
|
|
if (containers.Count > 0 && !containers.Contains(container))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-08 20:44:17 +00:00
|
|
|
|
ConditionProcessor conditionProcessor = new ConditionProcessor();
|
2014-04-24 05:08:10 +00:00
|
|
|
|
return i.Conditions.All(c => conditionProcessor.IsImageConditionSatisfied(c,
|
|
|
|
|
width,
|
|
|
|
|
height));
|
2014-03-25 05:25:03 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
2014-03-13 19:08:02 +00:00
|
|
|
|
}
|
|
|
|
|
}
|