jellyfin/MediaBrowser.Dlna/Didl/DidlBuilder.cs

1143 lines
41 KiB
C#
Raw Normal View History

2015-01-17 21:12:02 +01:00
using MediaBrowser.Model.Extensions;
2014-07-30 05:31:35 +02:00
using MediaBrowser.Controller.Channels;
2014-04-23 18:29:21 +02:00
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Entities;
2014-02-27 03:44:00 +01:00
using MediaBrowser.Controller.Entities.Audio;
2014-04-23 18:29:21 +02:00
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
2014-09-24 03:44:05 +02:00
using MediaBrowser.Controller.Localization;
2014-08-17 07:38:13 +02:00
using MediaBrowser.Controller.Playlists;
2014-10-22 06:42:26 +02:00
using MediaBrowser.Dlna.ContentDirectory;
2014-04-23 18:29:21 +02:00
using MediaBrowser.Model.Dlna;
using MediaBrowser.Model.Drawing;
2014-02-27 03:44:00 +01:00
using MediaBrowser.Model.Entities;
2015-04-04 21:35:29 +02:00
using MediaBrowser.Model.Logging;
2015-01-16 21:54:37 +01:00
using MediaBrowser.Model.Net;
2014-02-27 03:44:00 +01:00
using System;
2014-04-23 18:29:21 +02:00
using System.Globalization;
using System.IO;
2014-02-27 03:44:00 +01:00
using System.Linq;
2014-04-23 18:29:21 +02:00
using System.Xml;
using MediaBrowser.Controller.MediaEncoding;
2016-02-15 03:25:14 +01:00
using MediaBrowser.Model.Configuration;
2014-02-27 03:44:00 +01:00
2014-04-23 05:18:01 +02:00
namespace MediaBrowser.Dlna.Didl
2014-02-27 03:44:00 +01:00
{
2014-04-23 05:18:01 +02:00
public class DidlBuilder
2014-02-27 03:44:00 +01:00
{
2014-04-23 18:29:21 +02:00
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
2014-04-25 19:30:41 +02:00
2014-04-23 18:29:21 +02:00
private const string NS_DIDL = "urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/";
private const string NS_DC = "http://purl.org/dc/elements/1.1/";
private const string NS_UPNP = "urn:schemas-upnp-org:metadata-1-0/upnp/";
private const string NS_DLNA = "urn:schemas-dlna-org:metadata-1-0/";
private readonly DeviceProfile _profile;
private readonly IImageProcessor _imageProcessor;
private readonly string _serverAddress;
private readonly string _accessToken;
private readonly User _user;
private readonly IUserDataManager _userDataManager;
2014-09-24 03:44:05 +02:00
private readonly ILocalizationManager _localization;
2015-03-07 23:43:53 +01:00
private readonly IMediaSourceManager _mediaSourceManager;
2015-04-16 16:59:39 +02:00
private readonly ILogger _logger;
2015-06-21 05:35:22 +02:00
private readonly ILibraryManager _libraryManager;
private readonly IMediaEncoder _mediaEncoder;
2014-04-23 18:29:21 +02:00
public DidlBuilder(DeviceProfile profile, User user, IImageProcessor imageProcessor, string serverAddress, string accessToken, IUserDataManager userDataManager, ILocalizationManager localization, IMediaSourceManager mediaSourceManager, ILogger logger, ILibraryManager libraryManager, IMediaEncoder mediaEncoder)
2014-04-23 18:29:21 +02:00
{
_profile = profile;
_imageProcessor = imageProcessor;
_serverAddress = serverAddress;
_userDataManager = userDataManager;
2014-09-24 03:44:05 +02:00
_localization = localization;
2015-03-07 23:43:53 +01:00
_mediaSourceManager = mediaSourceManager;
2015-04-16 16:59:39 +02:00
_logger = logger;
2015-06-21 05:35:22 +02:00
_libraryManager = libraryManager;
_mediaEncoder = mediaEncoder;
_accessToken = accessToken;
_user = user;
2014-04-23 18:29:21 +02:00
}
2016-02-15 03:25:14 +01:00
public string GetItemDidl(DlnaOptions options, BaseItem item, BaseItem context, string deviceId, Filter filter, StreamInfo streamInfo)
2014-04-23 18:29:21 +02:00
{
var result = new XmlDocument();
var didl = result.CreateElement(string.Empty, "DIDL-Lite", NS_DIDL);
didl.SetAttribute("xmlns:dc", NS_DC);
didl.SetAttribute("xmlns:dlna", NS_DLNA);
didl.SetAttribute("xmlns:upnp", NS_UPNP);
//didl.SetAttribute("xmlns:sec", NS_SEC);
2014-04-24 07:08:10 +02:00
2014-04-24 16:11:05 +02:00
foreach (var att in _profile.XmlRootAttributes)
2014-04-24 07:08:10 +02:00
{
didl.SetAttribute(att.Name, att.Value);
}
2014-04-23 18:29:21 +02:00
result.AppendChild(didl);
2016-02-15 03:25:14 +01:00
result.DocumentElement.AppendChild(GetItemElement(options, result, item, context, null, deviceId, filter, streamInfo));
2014-04-23 18:29:21 +02:00
return result.DocumentElement.OuterXml;
}
2016-02-15 03:25:14 +01:00
public XmlElement GetItemElement(DlnaOptions options, XmlDocument doc, BaseItem item, BaseItem context, StubType? contextStubType, string deviceId, Filter filter, StreamInfo streamInfo = null)
2014-04-23 18:29:21 +02:00
{
2014-10-22 06:42:26 +02:00
var clientId = GetClientId(item, null);
2014-04-23 18:29:21 +02:00
var element = doc.CreateElement(string.Empty, "item", NS_DIDL);
element.SetAttribute("restricted", "1");
2014-10-22 06:42:26 +02:00
element.SetAttribute("id", clientId);
2014-04-23 18:29:21 +02:00
2014-10-22 06:42:26 +02:00
if (context != null)
{
element.SetAttribute("parentID", GetClientId(context, contextStubType));
}
2014-10-24 06:54:35 +02:00
else
2014-04-23 18:29:21 +02:00
{
2016-04-09 06:16:53 +02:00
var parent = item.DisplayParentId;
if (parent.HasValue)
2014-10-24 06:54:35 +02:00
{
2016-04-09 06:16:53 +02:00
element.SetAttribute("parentID", GetClientId(parent.Value, null));
2014-10-24 06:54:35 +02:00
}
2014-04-23 18:29:21 +02:00
}
//AddBookmarkInfo(item, user, element);
2014-10-22 06:42:26 +02:00
AddGeneralProperties(item, null, context, element, filter);
2014-04-23 18:29:21 +02:00
// refID?
// storeAttribute(itemNode, object, ClassProperties.REF_ID, false);
2014-08-14 15:24:30 +02:00
var hasMediaSources = item as IHasMediaSources;
2014-04-23 18:29:21 +02:00
2014-08-14 15:24:30 +02:00
if (hasMediaSources != null)
2014-04-23 18:29:21 +02:00
{
2014-08-14 15:24:30 +02:00
if (string.Equals(item.MediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase))
{
2016-02-15 03:25:14 +01:00
AddAudioResource(options, element, hasMediaSources, deviceId, filter, streamInfo);
2014-08-14 15:24:30 +02:00
}
else if (string.Equals(item.MediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase))
{
2016-02-15 03:25:14 +01:00
AddVideoResource(options, element, hasMediaSources, deviceId, filter, streamInfo);
2014-08-14 15:24:30 +02:00
}
2014-04-23 18:29:21 +02:00
}
2015-07-25 19:21:10 +02:00
AddCover(item, context, null, element);
2014-04-23 18:29:21 +02:00
return element;
}
2016-02-15 03:25:14 +01:00
private ILogger GetStreamBuilderLogger(DlnaOptions options)
{
if (options.EnableDebugLog)
{
return _logger;
}
return new NullLogger();
}
private void AddVideoResource(DlnaOptions options, XmlElement container, IHasMediaSources video, string deviceId, Filter filter, StreamInfo streamInfo = null)
2014-04-23 18:29:21 +02:00
{
2014-06-20 07:31:32 +02:00
if (streamInfo == null)
2014-04-23 18:29:21 +02:00
{
2015-04-01 23:56:32 +02:00
var sources = _mediaSourceManager.GetStaticMediaSources(video, true, _user).ToList();
2014-06-20 07:31:32 +02:00
streamInfo = new StreamBuilder(_mediaEncoder, GetStreamBuilderLogger(options)).BuildVideoItem(new VideoOptions
2014-10-22 06:42:26 +02:00
{
ItemId = GetClientId(video),
MediaSources = sources,
Profile = _profile,
DeviceId = deviceId,
MaxBitrate = _profile.MaxStreamingBitrate
});
2014-06-20 07:31:32 +02:00
}
2014-04-23 18:29:21 +02:00
2014-07-31 04:09:23 +02:00
var targetWidth = streamInfo.TargetWidth;
var targetHeight = streamInfo.TargetHeight;
var contentFeatureList = new ContentFeatureBuilder(_profile).BuildVideoHeader(streamInfo.Container,
streamInfo.VideoCodec,
streamInfo.AudioCodec,
targetWidth,
targetHeight,
streamInfo.TargetVideoBitDepth,
streamInfo.TargetVideoBitrate,
streamInfo.TargetTimestamp,
streamInfo.IsDirectStream,
streamInfo.RunTimeTicks,
streamInfo.TargetVideoProfile,
streamInfo.TargetVideoLevel,
streamInfo.TargetFramerate,
streamInfo.TargetPacketLength,
streamInfo.TranscodeSeekInfo,
2014-09-09 03:15:31 +02:00
streamInfo.IsTargetAnamorphic,
streamInfo.TargetRefFrames,
streamInfo.TargetVideoStreamCount,
2015-10-19 18:05:03 +02:00
streamInfo.TargetAudioStreamCount,
streamInfo.TargetVideoCodecTag);
2014-07-31 04:09:23 +02:00
foreach (var contentFeature in contentFeatureList)
{
AddVideoResource(container, video, deviceId, filter, contentFeature, streamInfo);
}
2014-08-06 04:26:12 +02:00
2015-03-30 21:57:37 +02:00
foreach (var subtitle in streamInfo.GetSubtitleProfiles(false, _serverAddress, _accessToken))
2014-08-06 04:26:12 +02:00
{
2015-03-30 21:57:37 +02:00
if (subtitle.DeliveryMethod == SubtitleDeliveryMethod.External)
{
var subtitleAdded = AddSubtitleElement(container, subtitle);
2016-03-22 05:15:12 +01:00
if (subtitleAdded && _profile.EnableSingleSubtitleLimit)
{
break;
}
2015-03-30 21:57:37 +02:00
}
2014-08-06 04:26:12 +02:00
}
}
2016-03-22 05:15:12 +01:00
private bool AddSubtitleElement(XmlElement container, SubtitleStreamInfo info)
2014-08-06 04:26:12 +02:00
{
2014-08-07 04:51:09 +02:00
var subtitleProfile = _profile.SubtitleProfiles
.FirstOrDefault(i => string.Equals(info.Format, i.Format, StringComparison.OrdinalIgnoreCase) && i.Method == SubtitleDeliveryMethod.External);
if (subtitleProfile == null)
{
return false;
2014-08-07 04:51:09 +02:00
}
var subtitleMode = subtitleProfile.DidlMode;
2014-08-06 04:26:12 +02:00
2014-08-07 04:51:09 +02:00
if (string.Equals(subtitleMode, "CaptionInfoEx", StringComparison.OrdinalIgnoreCase))
{
2015-08-19 08:12:58 +02:00
// <sec:CaptionInfoEx sec:type="srt">http://192.168.1.3:9999/video.srt</sec:CaptionInfoEx>
// <sec:CaptionInfo sec:type="srt">http://192.168.1.3:9999/video.srt</sec:CaptionInfo>
2016-03-22 05:15:12 +01:00
var res = container.OwnerDocument.CreateElement("CaptionInfoEx", "sec");
2014-08-06 04:26:12 +02:00
2016-03-22 05:15:12 +01:00
res.InnerText = info.Url;
2014-08-06 04:26:12 +02:00
2014-08-19 03:42:53 +02:00
//// TODO: attribute needs SEC:
2016-03-22 05:15:12 +01:00
res.SetAttribute("type", "sec", info.Format.ToLower());
container.AppendChild(res);
2014-08-07 04:51:09 +02:00
}
2015-08-19 08:12:58 +02:00
else if (string.Equals(subtitleMode, "smi", StringComparison.OrdinalIgnoreCase))
{
var res = container.OwnerDocument.CreateElement(string.Empty, "res", NS_DIDL);
res.InnerText = info.Url;
res.SetAttribute("protocolInfo", "http-get:*:smi/caption:*");
container.AppendChild(res);
}
2014-08-07 04:51:09 +02:00
else
{
var res = container.OwnerDocument.CreateElement(string.Empty, "res", NS_DIDL);
res.InnerText = info.Url;
var protocolInfo = string.Format("http-get:*:text/{0}:*", info.Format.ToLower());
res.SetAttribute("protocolInfo", protocolInfo);
container.AppendChild(res);
}
2016-03-22 05:15:12 +01:00
return true;
2014-07-31 04:09:23 +02:00
}
2014-08-14 15:24:30 +02:00
private void AddVideoResource(XmlElement container, IHasMediaSources video, string deviceId, Filter filter, string contentFeatures, StreamInfo streamInfo)
2014-07-31 04:09:23 +02:00
{
var res = container.OwnerDocument.CreateElement(string.Empty, "res", NS_DIDL);
var url = streamInfo.ToDlnaUrl(_serverAddress, _accessToken);
2014-04-23 18:29:21 +02:00
res.InnerText = url;
2014-06-20 07:31:32 +02:00
var mediaSource = streamInfo.MediaSource;
2014-04-23 18:29:21 +02:00
if (mediaSource.RunTimeTicks.HasValue)
{
res.SetAttribute("duration", TimeSpan.FromTicks(mediaSource.RunTimeTicks.Value).ToString("c", _usCulture));
}
if (filter.Contains("res@size"))
{
if (streamInfo.IsDirectStream || streamInfo.EstimateContentLength)
{
var size = streamInfo.TargetSize;
if (size.HasValue)
{
res.SetAttribute("size", size.Value.ToString(_usCulture));
}
}
}
2014-04-24 07:08:10 +02:00
var totalBitrate = streamInfo.TargetTotalBitrate;
2014-04-23 18:29:21 +02:00
var targetSampleRate = streamInfo.TargetAudioSampleRate;
var targetChannels = streamInfo.TargetAudioChannels;
var targetWidth = streamInfo.TargetWidth;
var targetHeight = streamInfo.TargetHeight;
if (targetChannels.HasValue)
{
res.SetAttribute("nrAudioChannels", targetChannels.Value.ToString(_usCulture));
}
if (filter.Contains("res@resolution"))
{
if (targetWidth.HasValue && targetHeight.HasValue)
{
res.SetAttribute("resolution", string.Format("{0}x{1}", targetWidth.Value, targetHeight.Value));
}
}
if (targetSampleRate.HasValue)
{
res.SetAttribute("sampleFrequency", targetSampleRate.Value.ToString(_usCulture));
}
if (totalBitrate.HasValue)
{
res.SetAttribute("bitrate", totalBitrate.Value.ToString(_usCulture));
}
var mediaProfile = _profile.GetVideoMediaProfile(streamInfo.Container,
streamInfo.AudioCodec,
2014-04-24 07:08:10 +02:00
streamInfo.VideoCodec,
streamInfo.TargetAudioBitrate,
targetWidth,
targetHeight,
streamInfo.TargetVideoBitDepth,
streamInfo.TargetVideoProfile,
streamInfo.TargetVideoLevel,
streamInfo.TargetFramerate,
streamInfo.TargetPacketLength,
2014-06-22 18:25:47 +02:00
streamInfo.TargetTimestamp,
2014-09-09 03:15:31 +02:00
streamInfo.IsTargetAnamorphic,
streamInfo.TargetRefFrames,
streamInfo.TargetVideoStreamCount,
2015-10-19 18:05:03 +02:00
streamInfo.TargetAudioStreamCount,
streamInfo.TargetVideoCodecTag);
2014-04-23 18:29:21 +02:00
var filename = url.Substring(0, url.IndexOf('?'));
var mimeType = mediaProfile == null || string.IsNullOrEmpty(mediaProfile.MimeType)
? MimeTypes.GetMimeType(filename)
: mediaProfile.MimeType;
res.SetAttribute("protocolInfo", String.Format(
"http-get:*:{0}:{1}",
mimeType,
contentFeatures
));
container.AppendChild(res);
}
2014-09-24 03:44:05 +02:00
2014-11-30 20:01:33 +01:00
private string GetDisplayName(BaseItem item, StubType? itemStubType, BaseItem context)
2014-09-24 03:44:05 +02:00
{
2014-11-30 20:01:33 +01:00
if (itemStubType.HasValue && itemStubType.Value == StubType.People)
{
if (item is Video)
{
return _localization.GetLocalizedString("HeaderCastCrew");
}
return _localization.GetLocalizedString("HeaderPeople");
}
2014-09-24 03:44:05 +02:00
var episode = item as Episode;
2014-09-25 00:47:03 +02:00
var season = context as Season;
2014-09-24 03:44:05 +02:00
2014-09-25 00:47:03 +02:00
if (episode != null && season != null)
2014-09-24 03:44:05 +02:00
{
// This is a special embedded within a season
if (item.ParentIndexNumber.HasValue && item.ParentIndexNumber.Value == 0)
{
2014-09-25 00:47:03 +02:00
if (season.IndexNumber.HasValue && season.IndexNumber.Value != 0)
2014-09-24 03:44:05 +02:00
{
return string.Format(_localization.GetLocalizedString("ValueSpecialEpisodeName"), item.Name);
}
}
if (item.IndexNumber.HasValue)
{
var number = item.IndexNumber.Value.ToString("00").ToString(CultureInfo.InvariantCulture);
if (episode.IndexNumberEnd.HasValue)
{
number += "-" + episode.IndexNumberEnd.Value.ToString("00").ToString(CultureInfo.InvariantCulture);
}
return number + " - " + item.Name;
}
}
return item.Name;
}
2014-10-22 06:42:26 +02:00
2016-02-15 03:25:14 +01:00
private void AddAudioResource(DlnaOptions options, XmlElement container, IHasMediaSources audio, string deviceId, Filter filter, StreamInfo streamInfo = null)
2014-04-23 18:29:21 +02:00
{
var res = container.OwnerDocument.CreateElement(string.Empty, "res", NS_DIDL);
2014-06-20 07:31:32 +02:00
if (streamInfo == null)
2014-04-23 18:29:21 +02:00
{
2015-04-01 23:56:32 +02:00
var sources = _mediaSourceManager.GetStaticMediaSources(audio, true, _user).ToList();
2014-06-20 07:31:32 +02:00
streamInfo = new StreamBuilder(_mediaEncoder, GetStreamBuilderLogger(options)).BuildAudioItem(new AudioOptions
2014-06-20 07:31:32 +02:00
{
2014-10-22 06:42:26 +02:00
ItemId = GetClientId(audio),
2014-06-20 07:31:32 +02:00
MediaSources = sources,
Profile = _profile,
DeviceId = deviceId
});
}
2014-04-23 18:29:21 +02:00
var url = streamInfo.ToDlnaUrl(_serverAddress, _accessToken);
2014-04-23 18:29:21 +02:00
res.InnerText = url;
2014-06-20 07:31:32 +02:00
var mediaSource = streamInfo.MediaSource;
2014-04-23 18:29:21 +02:00
if (mediaSource.RunTimeTicks.HasValue)
{
res.SetAttribute("duration", TimeSpan.FromTicks(mediaSource.RunTimeTicks.Value).ToString("c", _usCulture));
}
if (filter.Contains("res@size"))
{
if (streamInfo.IsDirectStream || streamInfo.EstimateContentLength)
{
var size = streamInfo.TargetSize;
if (size.HasValue)
{
res.SetAttribute("size", size.Value.ToString(_usCulture));
}
}
}
var targetAudioBitrate = streamInfo.TargetAudioBitrate;
var targetSampleRate = streamInfo.TargetAudioSampleRate;
var targetChannels = streamInfo.TargetAudioChannels;
if (targetChannels.HasValue)
{
res.SetAttribute("nrAudioChannels", targetChannels.Value.ToString(_usCulture));
}
if (targetSampleRate.HasValue)
{
res.SetAttribute("sampleFrequency", targetSampleRate.Value.ToString(_usCulture));
}
if (targetAudioBitrate.HasValue)
{
res.SetAttribute("bitrate", targetAudioBitrate.Value.ToString(_usCulture));
}
var mediaProfile = _profile.GetAudioMediaProfile(streamInfo.Container,
2014-04-24 07:08:10 +02:00
streamInfo.AudioCodec,
targetChannels,
targetAudioBitrate);
2014-04-23 18:29:21 +02:00
var filename = url.Substring(0, url.IndexOf('?'));
var mimeType = mediaProfile == null || string.IsNullOrEmpty(mediaProfile.MimeType)
? MimeTypes.GetMimeType(filename)
: mediaProfile.MimeType;
var contentFeatures = new ContentFeatureBuilder(_profile).BuildAudioHeader(streamInfo.Container,
streamInfo.TargetAudioCodec,
targetAudioBitrate,
targetSampleRate,
targetChannels,
streamInfo.IsDirectStream,
streamInfo.RunTimeTicks,
streamInfo.TranscodeSeekInfo);
res.SetAttribute("protocolInfo", String.Format(
"http-get:*:{0}:{1}",
mimeType,
contentFeatures
));
container.AppendChild(res);
}
2014-04-25 19:30:41 +02:00
2014-08-30 23:45:04 +02:00
public static bool IsIdRoot(string id)
{
2014-10-22 06:42:26 +02:00
if (string.IsNullOrWhiteSpace(id) ||
2014-08-30 23:45:04 +02:00
string.Equals(id, "0", StringComparison.OrdinalIgnoreCase)
// Samsung sometimes uses 1 as root
|| string.Equals(id, "1", StringComparison.OrdinalIgnoreCase))
{
return true;
}
return false;
}
2014-10-22 06:42:26 +02:00
public XmlElement GetFolderElement(XmlDocument doc, BaseItem folder, StubType? stubType, BaseItem context, int childCount, Filter filter, string requestedId = null)
2014-04-23 18:29:21 +02:00
{
var container = doc.CreateElement(string.Empty, "container", NS_DIDL);
container.SetAttribute("restricted", "0");
container.SetAttribute("searchable", "1");
container.SetAttribute("childCount", childCount.ToString(_usCulture));
2014-10-22 06:42:26 +02:00
var clientId = GetClientId(folder, stubType);
2014-08-30 23:45:04 +02:00
if (string.Equals(requestedId, "0"))
2014-04-23 18:29:21 +02:00
{
2014-08-30 23:45:04 +02:00
container.SetAttribute("id", "0");
container.SetAttribute("parentID", "-1");
2014-04-23 18:29:21 +02:00
}
else
{
2014-10-22 06:42:26 +02:00
container.SetAttribute("id", clientId);
2014-04-23 18:29:21 +02:00
2016-04-09 06:16:53 +02:00
if (context != null)
2014-08-30 23:45:04 +02:00
{
2016-04-09 06:16:53 +02:00
container.SetAttribute("parentID", GetClientId(context, null));
2014-08-30 23:45:04 +02:00
}
else
{
2016-04-09 06:16:53 +02:00
var parent = folder.DisplayParentId;
if (!parent.HasValue)
{
container.SetAttribute("parentID", "0");
}
else
{
container.SetAttribute("parentID", GetClientId(parent.Value, null));
}
2014-08-30 23:45:04 +02:00
}
}
2014-10-22 06:42:26 +02:00
AddCommonFields(folder, stubType, null, container, filter);
2014-04-23 18:29:21 +02:00
2015-07-25 19:21:10 +02:00
AddCover(folder, context, stubType, container);
2014-04-23 18:29:21 +02:00
return container;
}
//private void AddBookmarkInfo(BaseItem item, User user, XmlElement element)
//{
// var userdata = _userDataManager.GetUserData(user.Id, item.GetUserDataKey());
// if (userdata.PlaybackPositionTicks > 0)
// {
// var dcmInfo = element.OwnerDocument.CreateElement("sec", "dcmInfo", NS_SEC);
// dcmInfo.InnerText = string.Format("BM={0}", Convert.ToInt32(TimeSpan.FromTicks(userdata.PlaybackPositionTicks).TotalSeconds).ToString(_usCulture));
// element.AppendChild(dcmInfo);
// }
//}
2014-02-27 03:44:00 +01:00
/// <summary>
2014-04-23 18:29:21 +02:00
/// Adds fields used by both items and folders
2014-02-27 03:44:00 +01:00
/// </summary>
2014-04-23 18:29:21 +02:00
/// <param name="item">The item.</param>
2014-10-22 06:42:26 +02:00
/// <param name="itemStubType">Type of the item stub.</param>
2014-09-24 03:44:05 +02:00
/// <param name="context">The context.</param>
2014-04-23 18:29:21 +02:00
/// <param name="element">The element.</param>
/// <param name="filter">The filter.</param>
2014-10-22 06:42:26 +02:00
private void AddCommonFields(BaseItem item, StubType? itemStubType, BaseItem context, XmlElement element, Filter filter)
2014-04-23 18:29:21 +02:00
{
2014-05-21 02:56:24 +02:00
// Don't filter on dc:title because not all devices will include it in the filter
// MediaMonkey for example won't display content without a title
//if (filter.Contains("dc:title"))
2014-04-23 18:29:21 +02:00
{
2014-11-30 20:01:33 +01:00
AddValue(element, "dc", "title", GetDisplayName(item, itemStubType, context), NS_DC);
2014-04-23 18:29:21 +02:00
}
2014-02-27 03:44:00 +01:00
2014-10-22 06:42:26 +02:00
element.AppendChild(CreateObjectClass(element.OwnerDocument, item, itemStubType));
2014-03-25 06:25:03 +01:00
2014-04-23 18:29:21 +02:00
if (filter.Contains("dc:date"))
2014-03-25 06:25:03 +01:00
{
2014-04-23 18:29:21 +02:00
if (item.PremiereDate.HasValue)
{
AddValue(element, "dc", "date", item.PremiereDate.Value.ToString("o"), NS_DC);
}
2014-03-25 06:25:03 +01:00
}
2014-02-27 03:44:00 +01:00
2014-05-21 02:56:24 +02:00
if (filter.Contains("upnp:genre"))
2014-04-23 18:29:21 +02:00
{
2014-05-21 02:56:24 +02:00
foreach (var genre in item.Genres)
{
AddValue(element, "upnp", "genre", genre, NS_UPNP);
}
2014-04-23 18:29:21 +02:00
}
2014-02-27 03:44:00 +01:00
2014-04-23 18:29:21 +02:00
foreach (var studio in item.Studios)
2014-02-27 03:44:00 +01:00
{
2014-04-23 18:29:21 +02:00
AddValue(element, "upnp", "publisher", studio, NS_UPNP);
}
2014-03-25 06:25:03 +01:00
2014-04-23 18:29:21 +02:00
if (filter.Contains("dc:description"))
{
var desc = item.Overview;
var hasShortOverview = item as IHasShortOverview;
if (hasShortOverview != null && !string.IsNullOrEmpty(hasShortOverview.ShortOverview))
{
desc = hasShortOverview.ShortOverview;
}
if (!string.IsNullOrWhiteSpace(desc))
2014-04-23 18:29:21 +02:00
{
AddValue(element, "dc", "description", desc, NS_DC);
2014-04-23 18:29:21 +02:00
}
}
if (filter.Contains("upnp:longDescription"))
{
if (!string.IsNullOrWhiteSpace(item.Overview))
{
AddValue(element, "upnp", "longDescription", item.Overview, NS_UPNP);
}
}
if (!string.IsNullOrEmpty(item.OfficialRating))
{
if (filter.Contains("dc:rating"))
{
AddValue(element, "dc", "rating", item.OfficialRating, NS_DC);
}
if (filter.Contains("upnp:rating"))
2014-03-25 06:25:03 +01:00
{
2014-04-23 18:29:21 +02:00
AddValue(element, "upnp", "rating", item.OfficialRating, NS_UPNP);
}
}
AddPeople(item, element);
}
2014-10-22 06:42:26 +02:00
private XmlElement CreateObjectClass(XmlDocument result, BaseItem item, StubType? stubType)
2014-04-23 18:29:21 +02:00
{
// More types here
// http://oss.linn.co.uk/repos/Public/LibUpnpCil/DidlLite/UpnpAv/Test/TestDidlLite.cs
2014-04-23 18:29:21 +02:00
var objectClass = result.CreateElement("upnp", "class", NS_UPNP);
2014-10-22 06:42:26 +02:00
if (item.IsFolder || stubType.HasValue)
2014-04-23 18:29:21 +02:00
{
string classType = null;
if (!_profile.RequiresPlainFolders)
{
if (item is MusicAlbum)
{
classType = "object.container.album.musicAlbum";
}
2014-05-04 01:38:23 +02:00
else if (item is MusicArtist)
2014-04-23 18:29:21 +02:00
{
classType = "object.container.person.musicArtist";
}
2014-10-22 06:42:26 +02:00
else if (item is Series || item is Season || item is BoxSet || item is Video)
2014-05-03 23:51:56 +02:00
{
classType = "object.container.album.videoAlbum";
2014-06-15 01:13:09 +02:00
}
2014-08-17 07:38:13 +02:00
else if (item is Playlist)
{
classType = "object.container.playlistContainer";
}
else if (item is PhotoAlbum)
{
classType = "object.container.album.photoAlbum";
}
2014-04-23 18:29:21 +02:00
}
objectClass.InnerText = classType ?? "object.container.storageFolder";
}
else if (string.Equals(item.MediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase))
{
objectClass.InnerText = "object.item.audioItem.musicTrack";
}
else if (string.Equals(item.MediaType, MediaType.Photo, StringComparison.OrdinalIgnoreCase))
{
objectClass.InnerText = "object.item.imageItem.photo";
}
else if (string.Equals(item.MediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase))
{
if (!_profile.RequiresPlainVideoItems && item is Movie)
{
objectClass.InnerText = "object.item.videoItem.movie";
2014-06-15 01:13:09 +02:00
}
else if (!_profile.RequiresPlainVideoItems && item is MusicVideo)
{
objectClass.InnerText = "object.item.videoItem.musicVideoClip";
}
2014-04-23 18:29:21 +02:00
else
{
objectClass.InnerText = "object.item.videoItem";
2014-03-25 06:25:03 +01:00
}
2014-02-27 03:44:00 +01:00
}
else if (item is MusicGenre)
{
objectClass.InnerText = _profile.RequiresPlainFolders ? "object.container.storageFolder" : "object.container.genre.musicGenre";
}
else if (item is Genre || item is GameGenre)
{
objectClass.InnerText = _profile.RequiresPlainFolders ? "object.container.storageFolder" : "object.container.genre";
}
2014-02-27 03:44:00 +01:00
else
{
2014-08-07 04:51:09 +02:00
objectClass.InnerText = "object.item";
2014-04-23 18:29:21 +02:00
}
return objectClass;
}
private void AddPeople(BaseItem item, XmlElement element)
{
2014-04-25 19:30:41 +02:00
var types = new[] { PersonType.Director, PersonType.Writer, PersonType.Producer, PersonType.Composer, "Creator" };
2015-06-21 05:35:22 +02:00
var people = _libraryManager.GetPeople(item);
foreach (var actor in people)
2014-04-23 18:29:21 +02:00
{
2014-04-25 19:30:41 +02:00
var type = types.FirstOrDefault(i => string.Equals(i, actor.Type, StringComparison.OrdinalIgnoreCase) || string.Equals(i, actor.Role, StringComparison.OrdinalIgnoreCase))
?? PersonType.Actor;
AddValue(element, "upnp", type.ToLower(), actor.Name, NS_UPNP);
2014-04-23 18:29:21 +02:00
}
}
2014-10-22 06:42:26 +02:00
private void AddGeneralProperties(BaseItem item, StubType? itemStubType, BaseItem context, XmlElement element, Filter filter)
2014-04-23 18:29:21 +02:00
{
2014-10-22 06:42:26 +02:00
AddCommonFields(item, itemStubType, context, element, filter);
2014-04-23 18:29:21 +02:00
var audio = item as Audio;
if (audio != null)
{
foreach (var artist in audio.Artists)
{
AddValue(element, "upnp", "artist", artist, NS_UPNP);
}
2014-02-27 03:44:00 +01:00
2014-04-23 18:29:21 +02:00
if (!string.IsNullOrEmpty(audio.Album))
2014-02-27 03:44:00 +01:00
{
2014-04-23 18:29:21 +02:00
AddValue(element, "upnp", "album", audio.Album, NS_UPNP);
}
2014-02-27 03:44:00 +01:00
2014-06-23 18:05:19 +02:00
foreach (var artist in audio.AlbumArtists)
2014-04-23 18:29:21 +02:00
{
2014-08-17 07:38:13 +02:00
AddAlbumArtist(element, artist);
2014-02-27 03:44:00 +01:00
}
2014-04-23 18:29:21 +02:00
}
2014-02-27 03:44:00 +01:00
2014-04-23 18:29:21 +02:00
var album = item as MusicAlbum;
2014-03-25 06:25:03 +01:00
2014-04-23 18:29:21 +02:00
if (album != null)
{
2014-06-23 18:05:19 +02:00
foreach (var artist in album.AlbumArtists)
2014-08-17 07:38:13 +02:00
{
AddAlbumArtist(element, artist);
AddValue(element, "upnp", "artist", artist, NS_UPNP);
}
foreach (var artist in album.Artists)
2014-03-25 06:25:03 +01:00
{
2014-06-23 18:05:19 +02:00
AddValue(element, "upnp", "artist", artist, NS_UPNP);
2014-03-25 06:25:03 +01:00
}
2014-02-27 03:44:00 +01:00
}
2014-04-23 18:29:21 +02:00
var musicVideo = item as MusicVideo;
2014-02-27 03:44:00 +01:00
2014-04-23 18:29:21 +02:00
if (musicVideo != null)
{
2014-10-20 22:23:40 +02:00
foreach (var artist in musicVideo.Artists)
2014-04-23 18:29:21 +02:00
{
2014-10-20 22:23:40 +02:00
AddValue(element, "upnp", "artist", artist, NS_UPNP);
AddAlbumArtist(element, artist);
2014-04-23 18:29:21 +02:00
}
if (!string.IsNullOrEmpty(musicVideo.Album))
{
AddValue(element, "upnp", "album", musicVideo.Album, NS_UPNP);
}
}
if (item.IndexNumber.HasValue)
{
AddValue(element, "upnp", "originalTrackNumber", item.IndexNumber.Value.ToString(_usCulture), NS_UPNP);
2014-08-17 07:38:13 +02:00
if (item is Episode)
{
AddValue(element, "upnp", "episodeNumber", item.IndexNumber.Value.ToString(_usCulture), NS_UPNP);
}
}
}
private void AddAlbumArtist(XmlElement elem, string name)
{
try
{
var newNode = elem.OwnerDocument.CreateElement("upnp", "artist", NS_UPNP);
newNode.InnerText = name;
newNode.SetAttribute("role", "AlbumArtist");
elem.AppendChild(newNode);
}
catch (XmlException)
{
//_logger.Error("Error adding xml value: " + value);
2014-04-23 18:29:21 +02:00
}
}
private void AddValue(XmlElement elem, string prefix, string name, string value, string namespaceUri)
{
try
{
var date = elem.OwnerDocument.CreateElement(prefix, name, namespaceUri);
date.InnerText = value;
elem.AppendChild(date);
}
catch (XmlException)
{
//_logger.Error("Error adding xml value: " + value);
}
2014-02-27 03:44:00 +01:00
}
2015-07-25 19:21:10 +02:00
private void AddCover(BaseItem item, BaseItem context, StubType? stubType, XmlElement element)
2014-02-27 03:44:00 +01:00
{
if (stubType.HasValue && stubType.Value == StubType.People)
{
AddEmbeddedImageAsCover("people", element);
return;
}
2015-07-25 19:21:10 +02:00
ImageDownloadInfo imageInfo = null;
if (context is UserView)
{
var episode = item as Episode;
if (episode != null)
{
var parent = (BaseItem)episode.Series ?? episode.Season;
if (parent != null)
{
imageInfo = GetImageInfo(parent);
}
}
}
// Finally, just use the image from the item
if (imageInfo == null)
{
imageInfo = GetImageInfo(item);
}
2014-04-23 18:29:21 +02:00
if (imageInfo == null)
{
return;
}
var result = element.OwnerDocument;
var playbackPercentage = 0;
2015-04-16 16:59:39 +02:00
var unplayedCount = 0;
if (item is Video)
{
2016-06-19 08:18:29 +02:00
var userData = _userDataManager.GetUserDataDto(item, _user).Result;
playbackPercentage = Convert.ToInt32(userData.PlayedPercentage ?? 0);
2015-04-16 16:59:39 +02:00
if (playbackPercentage >= 100 || userData.Played)
{
2015-04-16 16:59:39 +02:00
playbackPercentage = 100;
}
}
else if (item is Series || item is Season || item is BoxSet)
{
2016-06-19 08:18:29 +02:00
var userData = _userDataManager.GetUserDataDto(item, _user).Result;
2015-04-16 16:59:39 +02:00
if (userData.Played)
{
playbackPercentage = 100;
}
else
{
unplayedCount = userData.UnplayedItemCount ?? 0;
}
}
2015-04-16 16:59:39 +02:00
var albumartUrlInfo = GetImageUrl(imageInfo, _profile.MaxAlbumArtWidth, _profile.MaxAlbumArtHeight, playbackPercentage, unplayedCount, "jpg");
2014-04-23 18:29:21 +02:00
var icon = result.CreateElement("upnp", "albumArtURI", NS_UPNP);
var profile = result.CreateAttribute("dlna", "profileID", NS_DLNA);
profile.InnerText = _profile.AlbumArtPn;
icon.SetAttributeNode(profile);
icon.InnerText = albumartUrlInfo.Url;
element.AppendChild(icon);
// TOOD: Remove these default values
2015-04-16 16:59:39 +02:00
var iconUrlInfo = GetImageUrl(imageInfo, _profile.MaxIconWidth ?? 48, _profile.MaxIconHeight ?? 48, playbackPercentage, unplayedCount, "jpg");
2014-04-23 18:29:21 +02:00
icon = result.CreateElement("upnp", "icon", NS_UPNP);
icon.InnerText = iconUrlInfo.Url;
element.AppendChild(icon);
2014-02-27 03:44:00 +01:00
2014-08-07 04:51:09 +02:00
if (!_profile.EnableAlbumArtInDidl)
2014-02-27 03:44:00 +01:00
{
2014-10-07 01:58:46 +02:00
if (string.Equals(item.MediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase)
|| string.Equals(item.MediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase))
2014-08-08 06:36:51 +02:00
{
2015-01-16 21:54:37 +01:00
if (!stubType.HasValue)
{
return;
}
2014-08-08 06:36:51 +02:00
}
2014-02-27 03:44:00 +01:00
}
2015-04-16 16:59:39 +02:00
AddImageResElement(item, element, 160, 160, playbackPercentage, unplayedCount, "jpg", "JPEG_TN");
2014-10-22 06:42:26 +02:00
2014-10-25 20:32:58 +02:00
if (!_profile.EnableSingleAlbumArtLimit)
2014-10-22 06:42:26 +02:00
{
2015-04-16 16:59:39 +02:00
AddImageResElement(item, element, 4096, 4096, playbackPercentage, unplayedCount, "jpg", "JPEG_LRG");
AddImageResElement(item, element, 1024, 768, playbackPercentage, unplayedCount, "jpg", "JPEG_MED");
AddImageResElement(item, element, 640, 480, playbackPercentage, unplayedCount, "jpg", "JPEG_SM");
AddImageResElement(item, element, 4096, 4096, playbackPercentage, unplayedCount, "png", "PNG_LRG");
AddImageResElement(item, element, 160, 160, playbackPercentage, unplayedCount, "png", "PNG_TN");
2014-10-22 06:42:26 +02:00
}
}
private void AddEmbeddedImageAsCover(string name, XmlElement element)
{
var result = element.OwnerDocument;
2015-07-25 19:21:10 +02:00
var icon = result.CreateElement("upnp", "albumArtURI", NS_UPNP);
var profile = result.CreateAttribute("dlna", "profileID", NS_DLNA);
profile.InnerText = _profile.AlbumArtPn;
icon.SetAttributeNode(profile);
icon.InnerText = _serverAddress + "/Dlna/icons/people480.jpg";
element.AppendChild(icon);
icon = result.CreateElement("upnp", "icon", NS_UPNP);
icon.InnerText = _serverAddress + "/Dlna/icons/people48.jpg";
element.AppendChild(icon);
}
2014-10-22 06:42:26 +02:00
private void AddImageResElement(BaseItem item,
XmlElement element,
int maxWidth,
int maxHeight,
int playbackPercentage,
2015-04-16 16:59:39 +02:00
int unplayedCount,
2014-10-22 06:42:26 +02:00
string format,
2014-08-08 06:36:51 +02:00
string org_Pn)
{
var imageInfo = GetImageInfo(item);
if (imageInfo == null)
{
return;
}
var result = element.OwnerDocument;
2015-04-16 16:59:39 +02:00
var albumartUrlInfo = GetImageUrl(imageInfo, maxWidth, maxHeight, playbackPercentage, unplayedCount, format);
2014-04-23 18:29:21 +02:00
var res = result.CreateElement(string.Empty, "res", NS_DIDL);
res.InnerText = albumartUrlInfo.Url;
var width = albumartUrlInfo.Width;
var height = albumartUrlInfo.Height;
2014-08-08 06:36:51 +02:00
var contentFeatures = new ContentFeatureBuilder(_profile)
.BuildImageHeader(format, width, height, imageInfo.IsDirectStream, org_Pn);
2014-04-23 18:29:21 +02:00
2014-04-24 07:08:10 +02:00
res.SetAttribute("protocolInfo", String.Format(
"http-get:*:{0}:{1}",
MimeTypes.GetMimeType("file." + format),
2014-04-24 07:08:10 +02:00
contentFeatures
2014-04-23 18:29:21 +02:00
));
if (width.HasValue && height.HasValue)
{
res.SetAttribute("resolution", string.Format("{0}x{1}", width.Value, height.Value));
}
element.AppendChild(res);
2014-02-27 03:44:00 +01:00
}
2014-04-23 18:29:21 +02:00
private ImageDownloadInfo GetImageInfo(BaseItem item)
2014-02-27 03:44:00 +01:00
{
2014-04-23 18:29:21 +02:00
if (item.HasImage(ImageType.Primary))
{
return GetImageInfo(item, ImageType.Primary);
}
if (item.HasImage(ImageType.Thumb))
{
return GetImageInfo(item, ImageType.Thumb);
}
2014-07-30 05:31:35 +02:00
if (item.HasImage(ImageType.Backdrop))
{
if (item is Channel)
{
return GetImageInfo(item, ImageType.Backdrop);
}
}
2014-02-27 03:44:00 +01:00
2015-11-11 15:56:31 +01:00
item = item.GetParents().FirstOrDefault(i => i.HasImage(ImageType.Primary));
2014-04-23 18:29:21 +02:00
2015-07-25 19:21:10 +02:00
if (item != null)
{
2016-04-05 21:34:09 +02:00
if (item.HasImage(ImageType.Primary))
{
return GetImageInfo(item, ImageType.Primary);
}
2014-02-27 03:44:00 +01:00
}
2014-04-23 18:29:21 +02:00
return null;
2014-02-27 03:44:00 +01:00
}
2014-04-23 18:29:21 +02:00
private ImageDownloadInfo GetImageInfo(BaseItem item, ImageType type)
2014-02-27 03:44:00 +01:00
{
2014-04-23 18:29:21 +02:00
var imageInfo = item.GetImageInfo(type, 0);
string tag = null;
try
{
2014-07-30 05:31:35 +02:00
tag = _imageProcessor.GetImageCacheTag(item, type);
2014-04-23 18:29:21 +02:00
}
catch
2014-02-27 03:44:00 +01:00
{
2014-04-23 18:29:21 +02:00
2014-02-27 03:44:00 +01:00
}
int? width = null;
int? height = null;
2014-04-23 18:29:21 +02:00
2016-06-09 18:13:25 +02:00
try
{
var size = _imageProcessor.GetImageSize(imageInfo);
2014-04-23 18:29:21 +02:00
2016-06-09 18:13:25 +02:00
width = Convert.ToInt32(size.Width);
height = Convert.ToInt32(size.Height);
}
catch
{
2014-04-23 18:29:21 +02:00
2016-06-09 18:13:25 +02:00
}
2014-04-23 18:29:21 +02:00
2015-10-15 04:55:19 +02:00
var inputFormat = (Path.GetExtension(imageInfo.Path) ?? string.Empty)
.TrimStart('.')
.Replace("jpeg", "jpg", StringComparison.OrdinalIgnoreCase);
2014-04-23 18:29:21 +02:00
return new ImageDownloadInfo
{
ItemId = item.Id.ToString("N"),
Type = type,
2014-04-23 18:29:21 +02:00
ImageTag = tag,
Width = width,
2014-08-06 06:18:13 +02:00
Height = height,
2015-10-15 04:55:19 +02:00
Format = inputFormat,
2014-08-07 04:51:09 +02:00
ItemImageInfo = imageInfo
2014-04-23 18:29:21 +02:00
};
2014-02-27 03:44:00 +01:00
}
2014-04-23 18:29:21 +02:00
class ImageDownloadInfo
2014-02-27 03:44:00 +01:00
{
2014-04-23 18:29:21 +02:00
internal string ItemId;
internal string ImageTag;
internal ImageType Type;
2014-02-27 03:44:00 +01:00
2014-04-23 18:29:21 +02:00
internal int? Width;
internal int? Height;
2014-08-06 06:18:13 +02:00
internal bool IsDirectStream;
2015-10-15 04:55:19 +02:00
internal string Format;
2014-08-07 04:51:09 +02:00
internal ItemImageInfo ItemImageInfo;
2014-02-27 03:44:00 +01:00
}
2014-04-23 18:29:21 +02:00
class ImageUrlInfo
2014-02-27 03:44:00 +01:00
{
2014-04-23 18:29:21 +02:00
internal string Url;
2014-02-27 03:44:00 +01:00
2014-04-23 18:29:21 +02:00
internal int? Width;
internal int? Height;
2014-02-27 03:44:00 +01:00
}
2014-10-22 06:42:26 +02:00
public static string GetClientId(BaseItem item, StubType? stubType)
{
2016-04-09 06:16:53 +02:00
return GetClientId(item.Id, stubType);
}
public static string GetClientId(Guid idValue, StubType? stubType)
{
var id = idValue.ToString("N");
2014-10-22 06:42:26 +02:00
if (stubType.HasValue)
{
id = stubType.Value.ToString().ToLower() + "_" + id;
}
return id;
}
public static string GetClientId(IHasMediaSources item)
{
var id = item.Id.ToString("N");
return id;
}
2015-04-16 16:59:39 +02:00
private ImageUrlInfo GetImageUrl(ImageDownloadInfo info, int maxWidth, int maxHeight, int playbackPercentage, int unplayedCount, string format)
2014-02-27 03:44:00 +01:00
{
2015-04-16 16:59:39 +02:00
var url = string.Format("{0}/Items/{1}/Images/{2}/0/{3}/{4}/{5}/{6}/{7}/{8}",
2014-04-23 18:29:21 +02:00
_serverAddress,
info.ItemId,
info.Type,
2014-05-02 16:49:28 +02:00
info.ImageTag,
format,
maxWidth.ToString(CultureInfo.InvariantCulture),
maxHeight.ToString(CultureInfo.InvariantCulture),
2015-04-16 16:59:39 +02:00
playbackPercentage.ToString(CultureInfo.InvariantCulture),
unplayedCount.ToString(CultureInfo.InvariantCulture)
);
2014-05-02 16:49:28 +02:00
2014-04-23 18:29:21 +02:00
var width = info.Width;
var height = info.Height;
2014-08-06 06:18:13 +02:00
info.IsDirectStream = false;
2014-04-23 18:29:21 +02:00
if (width.HasValue && height.HasValue)
{
var newSize = DrawingUtils.Resize(new ImageSize
2014-04-23 18:29:21 +02:00
{
Height = height.Value,
Width = width.Value
2014-04-23 18:29:21 +02:00
}, null, null, maxWidth, maxHeight);
2014-04-23 18:29:21 +02:00
width = Convert.ToInt32(newSize.Width);
height = Convert.ToInt32(newSize.Height);
2014-08-06 06:18:13 +02:00
var normalizedFormat = format
.Replace("jpeg", "jpg", StringComparison.OrdinalIgnoreCase);
2015-10-15 04:55:19 +02:00
if (string.Equals(info.Format, normalizedFormat, StringComparison.OrdinalIgnoreCase))
2014-08-06 06:18:13 +02:00
{
info.IsDirectStream = maxWidth >= width.Value && maxHeight >= height.Value;
}
2014-04-23 18:29:21 +02:00
}
return new ImageUrlInfo
{
Url = url,
Width = width,
Height = height
};
2014-02-27 03:44:00 +01:00
}
}
}