|
|
@ -37,7 +37,7 @@ namespace MediaBrowser.Dlna.Didl
|
|
|
|
_user = user;
|
|
|
|
_user = user;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string GetItemDidl(BaseItem item, string deviceId, Filter filter)
|
|
|
|
public string GetItemDidl(BaseItem item, string deviceId, Filter filter, StreamInfo streamInfo)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var result = new XmlDocument();
|
|
|
|
var result = new XmlDocument();
|
|
|
|
|
|
|
|
|
|
|
@ -54,12 +54,12 @@ namespace MediaBrowser.Dlna.Didl
|
|
|
|
|
|
|
|
|
|
|
|
result.AppendChild(didl);
|
|
|
|
result.AppendChild(didl);
|
|
|
|
|
|
|
|
|
|
|
|
result.DocumentElement.AppendChild(GetItemElement(result, item, deviceId, filter));
|
|
|
|
result.DocumentElement.AppendChild(GetItemElement(result, item, deviceId, filter, streamInfo));
|
|
|
|
|
|
|
|
|
|
|
|
return result.DocumentElement.OuterXml;
|
|
|
|
return result.DocumentElement.OuterXml;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public XmlElement GetItemElement(XmlDocument doc, BaseItem item, string deviceId, Filter filter)
|
|
|
|
public XmlElement GetItemElement(XmlDocument doc, BaseItem item, string deviceId, Filter filter, StreamInfo streamInfo = null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var element = doc.CreateElement(string.Empty, "item", NS_DIDL);
|
|
|
|
var element = doc.CreateElement(string.Empty, "item", NS_DIDL);
|
|
|
|
element.SetAttribute("restricted", "1");
|
|
|
|
element.SetAttribute("restricted", "1");
|
|
|
@ -80,13 +80,13 @@ namespace MediaBrowser.Dlna.Didl
|
|
|
|
var audio = item as Audio;
|
|
|
|
var audio = item as Audio;
|
|
|
|
if (audio != null)
|
|
|
|
if (audio != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
AddAudioResource(element, audio, deviceId, filter);
|
|
|
|
AddAudioResource(element, audio, deviceId, filter, streamInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var video = item as Video;
|
|
|
|
var video = item as Video;
|
|
|
|
if (video != null)
|
|
|
|
if (video != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
AddVideoResource(element, video, deviceId, filter);
|
|
|
|
AddVideoResource(element, video, deviceId, filter, streamInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AddCover(item, element);
|
|
|
|
AddCover(item, element);
|
|
|
@ -94,26 +94,29 @@ namespace MediaBrowser.Dlna.Didl
|
|
|
|
return element;
|
|
|
|
return element;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void AddVideoResource(XmlElement container, Video video, string deviceId, Filter filter)
|
|
|
|
private void AddVideoResource(XmlElement container, Video video, string deviceId, Filter filter, StreamInfo streamInfo = null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var res = container.OwnerDocument.CreateElement(string.Empty, "res", NS_DIDL);
|
|
|
|
var res = container.OwnerDocument.CreateElement(string.Empty, "res", NS_DIDL);
|
|
|
|
|
|
|
|
|
|
|
|
var sources = _user == null ? video.GetMediaSources(true).ToList() : video.GetMediaSources(true, _user).ToList();
|
|
|
|
if (streamInfo == null)
|
|
|
|
|
|
|
|
|
|
|
|
var streamInfo = new StreamBuilder().BuildVideoItem(new VideoOptions
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ItemId = video.Id.ToString("N"),
|
|
|
|
var sources = _user == null ? video.GetMediaSources(true).ToList() : video.GetMediaSources(true, _user).ToList();
|
|
|
|
MediaSources = sources,
|
|
|
|
|
|
|
|
Profile = _profile,
|
|
|
|
streamInfo = new StreamBuilder().BuildVideoItem(new VideoOptions
|
|
|
|
DeviceId = deviceId,
|
|
|
|
{
|
|
|
|
MaxBitrate = _profile.MaxBitrate
|
|
|
|
ItemId = video.Id.ToString("N"),
|
|
|
|
});
|
|
|
|
MediaSources = sources,
|
|
|
|
|
|
|
|
Profile = _profile,
|
|
|
|
|
|
|
|
DeviceId = deviceId,
|
|
|
|
|
|
|
|
MaxBitrate = _profile.MaxBitrate
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var url = streamInfo.ToDlnaUrl(_serverAddress);
|
|
|
|
var url = streamInfo.ToDlnaUrl(_serverAddress);
|
|
|
|
|
|
|
|
|
|
|
|
res.InnerText = url;
|
|
|
|
res.InnerText = url;
|
|
|
|
|
|
|
|
|
|
|
|
var mediaSource = sources.First(i => string.Equals(i.Id, streamInfo.MediaSourceId));
|
|
|
|
var mediaSource = streamInfo.MediaSource;
|
|
|
|
|
|
|
|
|
|
|
|
if (mediaSource.RunTimeTicks.HasValue)
|
|
|
|
if (mediaSource.RunTimeTicks.HasValue)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -211,25 +214,28 @@ namespace MediaBrowser.Dlna.Didl
|
|
|
|
container.AppendChild(res);
|
|
|
|
container.AppendChild(res);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void AddAudioResource(XmlElement container, Audio audio, string deviceId, Filter filter)
|
|
|
|
private void AddAudioResource(XmlElement container, Audio audio, string deviceId, Filter filter, StreamInfo streamInfo = null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var res = container.OwnerDocument.CreateElement(string.Empty, "res", NS_DIDL);
|
|
|
|
var res = container.OwnerDocument.CreateElement(string.Empty, "res", NS_DIDL);
|
|
|
|
|
|
|
|
|
|
|
|
var sources = _user == null ? audio.GetMediaSources(true).ToList() : audio.GetMediaSources(true, _user).ToList();
|
|
|
|
if (streamInfo == null)
|
|
|
|
|
|
|
|
|
|
|
|
var streamInfo = new StreamBuilder().BuildAudioItem(new AudioOptions
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ItemId = audio.Id.ToString("N"),
|
|
|
|
var sources = _user == null ? audio.GetMediaSources(true).ToList() : audio.GetMediaSources(true, _user).ToList();
|
|
|
|
MediaSources = sources,
|
|
|
|
|
|
|
|
Profile = _profile,
|
|
|
|
streamInfo = new StreamBuilder().BuildAudioItem(new AudioOptions
|
|
|
|
DeviceId = deviceId
|
|
|
|
{
|
|
|
|
});
|
|
|
|
ItemId = audio.Id.ToString("N"),
|
|
|
|
|
|
|
|
MediaSources = sources,
|
|
|
|
|
|
|
|
Profile = _profile,
|
|
|
|
|
|
|
|
DeviceId = deviceId
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var url = streamInfo.ToDlnaUrl(_serverAddress);
|
|
|
|
var url = streamInfo.ToDlnaUrl(_serverAddress);
|
|
|
|
|
|
|
|
|
|
|
|
res.InnerText = url;
|
|
|
|
res.InnerText = url;
|
|
|
|
|
|
|
|
|
|
|
|
var mediaSource = sources.First(i => string.Equals(i.Id, streamInfo.MediaSourceId));
|
|
|
|
var mediaSource = streamInfo.MediaSource;
|
|
|
|
|
|
|
|
|
|
|
|
if (mediaSource.RunTimeTicks.HasValue)
|
|
|
|
if (mediaSource.RunTimeTicks.HasValue)
|
|
|
|
{
|
|
|
|
{
|
|
|
|