dlna remote control fixes

This commit is contained in:
Luke Pulverenti 2014-06-20 01:31:32 -04:00
parent c2d8cb4731
commit daec8895b6
3 changed files with 41 additions and 35 deletions

View File

@ -1591,6 +1591,12 @@ namespace MediaBrowser.Api.Playback
return false; return false;
} }
// Can't stream copy if we're burning in subtitles
if (request.SubtitleStreamIndex.HasValue)
{
return false;
}
// Source and target codecs must match // Source and target codecs must match
if (!string.Equals(request.VideoCodec, videoStream.Codec, StringComparison.OrdinalIgnoreCase)) if (!string.Equals(request.VideoCodec, videoStream.Codec, StringComparison.OrdinalIgnoreCase))
{ {

View File

@ -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,13 +94,15 @@ 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);
if (streamInfo == null)
{
var sources = _user == null ? video.GetMediaSources(true).ToList() : video.GetMediaSources(true, _user).ToList(); var sources = _user == null ? video.GetMediaSources(true).ToList() : video.GetMediaSources(true, _user).ToList();
var streamInfo = new StreamBuilder().BuildVideoItem(new VideoOptions streamInfo = new StreamBuilder().BuildVideoItem(new VideoOptions
{ {
ItemId = video.Id.ToString("N"), ItemId = video.Id.ToString("N"),
MediaSources = sources, MediaSources = sources,
@ -108,12 +110,13 @@ namespace MediaBrowser.Dlna.Didl
DeviceId = deviceId, DeviceId = deviceId,
MaxBitrate = _profile.MaxBitrate 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);
if (streamInfo == null)
{
var sources = _user == null ? audio.GetMediaSources(true).ToList() : audio.GetMediaSources(true, _user).ToList(); var sources = _user == null ? audio.GetMediaSources(true).ToList() : audio.GetMediaSources(true, _user).ToList();
var streamInfo = new StreamBuilder().BuildAudioItem(new AudioOptions streamInfo = new StreamBuilder().BuildAudioItem(new AudioOptions
{ {
ItemId = audio.Id.ToString("N"), ItemId = audio.Id.ToString("N"),
MediaSources = sources, MediaSources = sources,
Profile = _profile, Profile = _profile,
DeviceId = deviceId 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)
{ {

View File

@ -81,7 +81,7 @@ namespace MediaBrowser.Dlna.PlayTo
private async void updateTimer_Elapsed(object state) private async void updateTimer_Elapsed(object state)
{ {
if (DateTime.UtcNow >= _device.DateLastActivity.AddSeconds(60)) if (DateTime.UtcNow >= _device.DateLastActivity.AddSeconds(120))
{ {
try try
{ {
@ -148,7 +148,7 @@ namespace MediaBrowser.Dlna.PlayTo
_logger.ErrorException("Error reporting progress", ex); _logger.ErrorException("Error reporting progress", ex);
} }
await SetNext().ConfigureAwait(false); //await SetNext().ConfigureAwait(false);
} }
async void _device_PlaybackStart(object sender, PlaybackStartEventArgs e) async void _device_PlaybackStart(object sender, PlaybackStartEventArgs e)
@ -305,8 +305,6 @@ namespace MediaBrowser.Dlna.PlayTo
var user = _session.UserId.HasValue ? _userManager.GetUserById(_session.UserId.Value) : null; var user = _session.UserId.HasValue ? _userManager.GetUserById(_session.UserId.Value) : null;
var newItem = CreatePlaylistItem(info.Item, user, newPosition, GetServerAddress(), info.MediaSourceId, info.AudioStreamIndex, info.SubtitleStreamIndex); var newItem = CreatePlaylistItem(info.Item, user, newPosition, GetServerAddress(), info.MediaSourceId, info.AudioStreamIndex, info.SubtitleStreamIndex);
await _device.SetStop();
await _device.SetAvTransport(newItem.StreamUrl, GetDlnaHeaders(newItem), newItem.Didl).ConfigureAwait(false); await _device.SetAvTransport(newItem.StreamUrl, GetDlnaHeaders(newItem), newItem.Didl).ConfigureAwait(false);
if (newItem.StreamInfo.IsDirectStream) if (newItem.StreamInfo.IsDirectStream)
@ -413,7 +411,7 @@ namespace MediaBrowser.Dlna.PlayTo
playlistItem.StreamUrl = playlistItem.StreamInfo.ToUrl(serverAddress); playlistItem.StreamUrl = playlistItem.StreamInfo.ToUrl(serverAddress);
var itemXml = new DidlBuilder(profile, user, _imageProcessor, serverAddress).GetItemDidl(item, _session.DeviceId, new Filter()); var itemXml = new DidlBuilder(profile, user, _imageProcessor, serverAddress).GetItemDidl(item, _session.DeviceId, new Filter(), playlistItem.StreamInfo);
playlistItem.Didl = itemXml; playlistItem.Didl = itemXml;
@ -710,8 +708,6 @@ namespace MediaBrowser.Dlna.PlayTo
var user = _session.UserId.HasValue ? _userManager.GetUserById(_session.UserId.Value) : null; var user = _session.UserId.HasValue ? _userManager.GetUserById(_session.UserId.Value) : null;
var newItem = CreatePlaylistItem(info.Item, user, newPosition, GetServerAddress(), info.MediaSourceId, newIndex, info.SubtitleStreamIndex); var newItem = CreatePlaylistItem(info.Item, user, newPosition, GetServerAddress(), info.MediaSourceId, newIndex, info.SubtitleStreamIndex);
await _device.SetStop();
await _device.SetAvTransport(newItem.StreamUrl, GetDlnaHeaders(newItem), newItem.Didl).ConfigureAwait(false); await _device.SetAvTransport(newItem.StreamUrl, GetDlnaHeaders(newItem), newItem.Didl).ConfigureAwait(false);
if (newItem.StreamInfo.IsDirectStream) if (newItem.StreamInfo.IsDirectStream)
@ -737,8 +733,6 @@ namespace MediaBrowser.Dlna.PlayTo
var user = _session.UserId.HasValue ? _userManager.GetUserById(_session.UserId.Value) : null; var user = _session.UserId.HasValue ? _userManager.GetUserById(_session.UserId.Value) : null;
var newItem = CreatePlaylistItem(info.Item, user, newPosition, GetServerAddress(), info.MediaSourceId, info.AudioStreamIndex, newIndex); var newItem = CreatePlaylistItem(info.Item, user, newPosition, GetServerAddress(), info.MediaSourceId, info.AudioStreamIndex, newIndex);
await _device.SetStop();
await _device.SetAvTransport(newItem.StreamUrl, GetDlnaHeaders(newItem), newItem.Didl).ConfigureAwait(false); await _device.SetAvTransport(newItem.StreamUrl, GetDlnaHeaders(newItem), newItem.Didl).ConfigureAwait(false);
if (newItem.StreamInfo.IsDirectStream) if (newItem.StreamInfo.IsDirectStream)